refactor: run Code Inspection and fix most of the warnings
This commit is contained in:
@@ -6,9 +6,9 @@ import java.util.Arrays;
|
||||
|
||||
public abstract class Command {
|
||||
public final String name;
|
||||
public String description;
|
||||
public final String description;
|
||||
public String[] usages;
|
||||
public String[] aliases;
|
||||
public final String[] aliases;
|
||||
public final TrustLevel trustLevel;
|
||||
public final boolean consoleOnly;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class MailCommand extends Command {
|
||||
|
||||
int senderMailSize = 0;
|
||||
for (Mail mail : mails) {
|
||||
if (!mail.sentTo.equals(sender.profile.getName())) continue;
|
||||
if (!mail.sentTo().equals(sender.profile.getName())) continue;
|
||||
senderMailSize++;
|
||||
}
|
||||
|
||||
@@ -130,9 +130,9 @@ public class MailCommand extends Command {
|
||||
|
||||
int count = 1;
|
||||
for (Mail mail : mails) {
|
||||
if (!mail.sentTo.equals(sender.profile.getName())) continue;
|
||||
if (!mail.sentTo().equals(sender.profile.getName())) continue;
|
||||
|
||||
final Instant instant = Instant.ofEpochMilli(mail.timeSent);
|
||||
final Instant instant = Instant.ofEpochMilli(mail.timeSent());
|
||||
final ZoneId zoneId = ZoneId.systemDefault();
|
||||
final OffsetDateTime localDateTime = OffsetDateTime.ofInstant(instant, zoneId);
|
||||
|
||||
@@ -148,7 +148,7 @@ public class MailCommand extends Command {
|
||||
Component.text(count).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)),
|
||||
Component.text("-").color(NamedTextColor.DARK_GRAY),
|
||||
|
||||
Component.text(mail.sentBy).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
|
||||
Component.text(mail.sentBy()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
|
||||
Component
|
||||
.text("[Hover here for more info]")
|
||||
.color(NamedTextColor.GREEN)
|
||||
@@ -159,11 +159,11 @@ public class MailCommand extends Command {
|
||||
Time sent: %s
|
||||
Server: %s""",
|
||||
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
|
||||
Component.text(mail.server).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))
|
||||
Component.text(mail.server()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))
|
||||
).color(NamedTextColor.GREEN)
|
||||
)
|
||||
),
|
||||
Component.text(mail.contents).color(NamedTextColor.WHITE)
|
||||
Component.text(mail.contents()).color(NamedTextColor.WHITE)
|
||||
).color(NamedTextColor.GREEN)
|
||||
);
|
||||
|
||||
|
||||
@@ -84,9 +84,7 @@ public class ScreenshareCommand extends Command {
|
||||
.append(Component.text(fps).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
default -> {
|
||||
throw new CommandException(Component.text("Invalid action"));
|
||||
}
|
||||
default -> throw new CommandException(Component.text("Invalid action"));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new CommandException(Component.text("Invalid integer"));
|
||||
|
||||
@@ -44,9 +44,7 @@ public class TPSBarCommand extends Command {
|
||||
.append(Component.text("disabled").color(NamedTextColor.RED))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
default -> {
|
||||
throw new CommandException(Component.text("Invalid action"));
|
||||
}
|
||||
default -> throw new CommandException(Component.text("Invalid action"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.chayapak1.chomens_bot.commands;
|
||||
|
||||
import me.chayapak1.chomens_bot.command.Command;
|
||||
import me.chayapak1.chomens_bot.command.CommandContext;
|
||||
import me.chayapak1.chomens_bot.command.CommandException;
|
||||
import me.chayapak1.chomens_bot.command.TrustLevel;
|
||||
import me.chayapak1.chomens_bot.command.contexts.ConsoleCommandContext;
|
||||
import me.chayapak1.chomens_bot.command.contexts.DiscordCommandContext;
|
||||
@@ -22,7 +21,7 @@ public class ValidateCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandException {
|
||||
public Component execute (CommandContext context) {
|
||||
// <red>Trusted - 1
|
||||
// <dark_red>Admin - 2
|
||||
// .......
|
||||
|
||||
@@ -17,13 +17,6 @@ public class EvalFunction {
|
||||
|
||||
public Output execute (Object... args) throws Exception { return null; }
|
||||
|
||||
public static class Output {
|
||||
public final String message;
|
||||
public final boolean parseJSON;
|
||||
|
||||
public Output (String message, boolean parseJSON) {
|
||||
this.message = message;
|
||||
this.parseJSON = parseJSON;
|
||||
}
|
||||
public record Output(String message, boolean parseJSON) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,7 @@ package me.chayapak1.chomens_bot.data.mail;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class Mail {
|
||||
public final String sentBy;
|
||||
public final String sentTo;
|
||||
public final long timeSent;
|
||||
public final String server;
|
||||
public final String contents;
|
||||
|
||||
public record Mail(String sentBy, String sentTo, long timeSent, String server, String contents) {
|
||||
@JsonCreator
|
||||
public Mail (
|
||||
@JsonProperty("sentBy") String sentBy,
|
||||
|
||||
@@ -14,7 +14,7 @@ public class PlayerEntry {
|
||||
public GameMode gamemode;
|
||||
public int latency;
|
||||
public Component displayName;
|
||||
public List<String> usernames = new ArrayList<>();
|
||||
public final List<String> usernames = new ArrayList<>();
|
||||
public final long expiresAt;
|
||||
public PublicKey publicKey;
|
||||
public final byte[] keySignature;
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
|
||||
public class Team {
|
||||
public String teamName;
|
||||
public List<String> players;
|
||||
public final List<String> players;
|
||||
public Component displayName;
|
||||
public boolean friendlyFire;
|
||||
public boolean seeFriendlyInvisibles;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DiscordPlugin extends ListenerAdapter {
|
||||
|
||||
public final String prefix;
|
||||
|
||||
public Component messagePrefix;
|
||||
public final Component messagePrefix;
|
||||
|
||||
public final String discordUrl;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class EvalPlugin {
|
||||
|
||||
if (output == null) return;
|
||||
|
||||
socket.emit("functionOutput:" + function.name, output.message, output.parseJSON);
|
||||
socket.emit("functionOutput:" + function.name, output.message(), output.parseJSON());
|
||||
} catch (Exception ignored) { }
|
||||
}).start());
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MailPlugin implements PlayersPlugin.Listener {
|
||||
final List<Mail> mails = list();
|
||||
|
||||
for (Mail mail : mails) {
|
||||
if (!mail.sentTo.equals(name)) continue;
|
||||
if (!mail.sentTo().equals(name)) continue;
|
||||
|
||||
sendToTargetSize++;
|
||||
}
|
||||
@@ -77,11 +77,11 @@ public class MailPlugin implements PlayersPlugin.Listener {
|
||||
try {
|
||||
final PreparedStatement statement = bot.database.connection.prepareStatement(INSERT_MAIL);
|
||||
|
||||
statement.setString(1, mail.sentBy);
|
||||
statement.setString(2, mail.sentTo);
|
||||
statement.setLong(3, mail.timeSent);
|
||||
statement.setString(4, mail.server);
|
||||
statement.setString(5, mail.contents);
|
||||
statement.setString(1, mail.sentBy());
|
||||
statement.setString(2, mail.sentTo());
|
||||
statement.setLong(3, mail.timeSent());
|
||||
statement.setString(4, mail.server());
|
||||
statement.setString(5, mail.contents());
|
||||
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -108,11 +108,11 @@ public class ScreensharePlugin {
|
||||
private final Bot bot;
|
||||
|
||||
public String[][] screen;
|
||||
public int width;
|
||||
public int height;
|
||||
public Vector3i pos;
|
||||
public final int width;
|
||||
public final int height;
|
||||
public final Vector3i pos;
|
||||
|
||||
public ArrayList<String> tags = new ArrayList<>();
|
||||
public final ArrayList<String> tags = new ArrayList<>();
|
||||
|
||||
public Screen (Bot bot, int width, int height, Vector3i pos) {
|
||||
screen = new String[width][height];
|
||||
|
||||
@@ -317,6 +317,7 @@ public class NBSConverter implements Converter {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(name);
|
||||
assert is != null;
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
JsonArray json = JsonParser.parseReader(reader).getAsJsonArray();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Song {
|
||||
public String songOriginalAuthor;
|
||||
public String songDescription;
|
||||
|
||||
public String tracks;
|
||||
public final String tracks;
|
||||
|
||||
public final boolean nbs;
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ public class ComponentUtilities {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream(name);
|
||||
assert is != null;
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
JsonObject json = JsonParser.parseReader(reader).getAsJsonObject();
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import org.concentus.OpusException;
|
||||
|
||||
public class JavaOpusDecoder {
|
||||
protected OpusDecoder opusDecoder;
|
||||
protected short[] buffer;
|
||||
protected int sampleRate;
|
||||
protected int frameSize;
|
||||
protected int maxPayloadSize;
|
||||
protected final short[] buffer;
|
||||
protected final int sampleRate;
|
||||
protected final int frameSize;
|
||||
protected final int maxPayloadSize;
|
||||
|
||||
public JavaOpusDecoder (int sampleRate, int frameSize, int maxPayloadSize) {
|
||||
this.sampleRate = sampleRate;
|
||||
|
||||
@@ -5,10 +5,10 @@ import org.concentus.OpusEncoder;
|
||||
|
||||
public class JavaOpusEncoder {
|
||||
public OpusEncoder opusEncoder;
|
||||
public byte[] buffer;
|
||||
public int sampleRate;
|
||||
public int frameSize;
|
||||
public de.maxhenkel.opus4j.OpusEncoder.Application application;
|
||||
public final byte[] buffer;
|
||||
public final int sampleRate;
|
||||
public final int frameSize;
|
||||
public final de.maxhenkel.opus4j.OpusEncoder.Application application;
|
||||
|
||||
public JavaOpusEncoder (int sampleRate, int frameSize, int maxPayloadSize, de.maxhenkel.opus4j.OpusEncoder.Application application) {
|
||||
this.sampleRate = sampleRate;
|
||||
|
||||
@@ -5,11 +5,11 @@ import org.concentus.OpusEncoder;
|
||||
|
||||
public class JavaOpusEncoder2 {
|
||||
public OpusEncoder opusEncoder;
|
||||
public byte[] buffer;
|
||||
public int sampleRate;
|
||||
public int frameSize;
|
||||
public int maxPayloadSize;
|
||||
public OpusApplication application;
|
||||
public final byte[] buffer;
|
||||
public final int sampleRate;
|
||||
public final int frameSize;
|
||||
public final int maxPayloadSize;
|
||||
public final OpusApplication application;
|
||||
|
||||
public JavaOpusEncoder2 (int sampleRate, int frameSize, int maxPayloadSize, OpusApplication application) {
|
||||
this.sampleRate = sampleRate;
|
||||
|
||||
Reference in New Issue
Block a user