Fix some low-hanging code smells using SonarLint.
This commit is contained in:
@@ -43,20 +43,20 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
private static final GenericResult ALLOWED = new GenericResult(true);
|
||||
private static final GenericResult DENIED = new GenericResult(false);
|
||||
|
||||
private final boolean allowed;
|
||||
private final boolean status;
|
||||
|
||||
private GenericResult(boolean b) {
|
||||
this.allowed = b;
|
||||
this.status = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowed() {
|
||||
return allowed;
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allowed ? "allowed" : "denied";
|
||||
return status ? "allowed" : "denied";
|
||||
}
|
||||
|
||||
public static GenericResult allowed() {
|
||||
@@ -74,17 +74,17 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
final class ComponentResult implements Result {
|
||||
private static final ComponentResult ALLOWED = new ComponentResult(true, null);
|
||||
|
||||
private final boolean allowed;
|
||||
private final boolean status;
|
||||
private final @Nullable Component reason;
|
||||
|
||||
protected ComponentResult(boolean allowed, @Nullable Component reason) {
|
||||
this.allowed = allowed;
|
||||
protected ComponentResult(boolean status, @Nullable Component reason) {
|
||||
this.status = status;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowed() {
|
||||
return allowed;
|
||||
return status;
|
||||
}
|
||||
|
||||
public Optional<Component> getReason() {
|
||||
@@ -93,7 +93,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (allowed) {
|
||||
if (status) {
|
||||
return "allowed";
|
||||
}
|
||||
if (reason != null) {
|
||||
|
@@ -78,20 +78,20 @@ public final class PluginMessageEvent implements ResultedEvent<PluginMessageEven
|
||||
private static final ForwardResult ALLOWED = new ForwardResult(true);
|
||||
private static final ForwardResult DENIED = new ForwardResult(false);
|
||||
|
||||
private final boolean allowed;
|
||||
private final boolean status;
|
||||
|
||||
private ForwardResult(boolean b) {
|
||||
this.allowed = b;
|
||||
this.status = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowed() {
|
||||
return allowed;
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allowed ? "forward to sink" : "handled message at proxy";
|
||||
return status ? "forward to sink" : "handled message at proxy";
|
||||
}
|
||||
|
||||
public static ForwardResult forward() {
|
||||
|
@@ -58,21 +58,21 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
|
||||
|
||||
// The server can not accept formatted text from clients!
|
||||
private @Nullable String message;
|
||||
private final boolean allowed;
|
||||
private final boolean status;
|
||||
|
||||
protected ChatResult(boolean allowed, @Nullable String message) {
|
||||
this.allowed = allowed;
|
||||
protected ChatResult(boolean status, @Nullable String message) {
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowed() {
|
||||
return allowed;
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allowed ? "allowed" : "denied";
|
||||
return status ? "allowed" : "denied";
|
||||
}
|
||||
|
||||
public static ChatResult allowed() {
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.velocitypowered.api.permission;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@@ -52,7 +51,10 @@ public enum Tristate {
|
||||
* is <code>null</code>, <code>true</code> or <code>false</code>, respectively.
|
||||
*/
|
||||
public static Tristate fromNullableBoolean(@Nullable Boolean val) {
|
||||
return val == null ? UNDEFINED : val ? TRUE : FALSE;
|
||||
if (val == null) {
|
||||
return UNDEFINED;
|
||||
}
|
||||
return val ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
private final boolean booleanValue;
|
||||
|
@@ -18,8 +18,6 @@ public @interface Dependency {
|
||||
*/
|
||||
String id();
|
||||
|
||||
// TODO Add required version field
|
||||
|
||||
/**
|
||||
* If this dependency is optional for the plugin to work. By default
|
||||
* this is {@code false}.
|
||||
|
@@ -42,6 +42,6 @@ public final class LegacyChannelIdentifier implements ChannelIdentifier {
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name;
|
||||
return this.getName();
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ public final class SkinParts {
|
||||
}
|
||||
|
||||
public boolean hasCape() {
|
||||
return ((bitmask >> 0) & 1) == 1;
|
||||
return (bitmask & 1) == 1;
|
||||
}
|
||||
|
||||
public boolean hasJacket() {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.velocitypowered.api.scheduler;
|
||||
|
||||
import org.checkerframework.common.value.qual.IntRange;
|
||||
import org.checkerframework.common.value.qual.IntRangeFromNonNegative;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@@ -56,7 +56,7 @@ public final class GameProfile {
|
||||
'}';
|
||||
}
|
||||
|
||||
public final static class Property {
|
||||
public static final class Property {
|
||||
private final String name;
|
||||
private final String value;
|
||||
private final String signature;
|
||||
|
Reference in New Issue
Block a user