refactor: make some constant things that are List immutable by using List.of()
This commit is contained in:
@@ -1 +1 @@
|
||||
2928
|
||||
2929
|
||||
@@ -10,22 +10,19 @@ import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.TranslationArgument;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MinecraftChatParser implements ChatParser {
|
||||
private final Bot bot;
|
||||
|
||||
private static final List<String> keys = new ArrayList<>();
|
||||
|
||||
static {
|
||||
keys.add("chat.type.text");
|
||||
keys.add("chat.type.announcement");
|
||||
keys.add("commands.message.display.incoming");
|
||||
keys.add("chat.type.team.text");
|
||||
keys.add("chat.type.emote");
|
||||
}
|
||||
private static final List<String> keys = List.of(
|
||||
"chat.type.text",
|
||||
"chat.type.announcement",
|
||||
"commands.message.display.incoming",
|
||||
"chat.type.team.text",
|
||||
"chat.type.emote"
|
||||
);
|
||||
|
||||
public MinecraftChatParser (final Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ChatPlugin implements Listener {
|
||||
|
||||
public final Pattern CHAT_SPLIT_PATTERN = Pattern.compile("\\G\\s*([^\\r\\n]{1,254}(?=\\s|$)|[^\\r\\n]{254})");
|
||||
|
||||
private final List<ChatParser> chatParsers = Collections.synchronizedList(new ArrayList<>());
|
||||
private final List<ChatParser> chatParsers = new ArrayList<>();
|
||||
|
||||
public final List<Component> chatTypes = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -37,13 +37,11 @@ public class ChomeNSModIntegrationPlugin implements Listener {
|
||||
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
public static final List<Class<? extends Packet>> SERVERBOUND_PACKETS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
SERVERBOUND_PACKETS.add(ServerboundSuccessfulHandshakePacket.class);
|
||||
SERVERBOUND_PACKETS.add(ServerboundRunCoreCommandPacket.class);
|
||||
SERVERBOUND_PACKETS.add(ServerboundRunCommandPacket.class);
|
||||
}
|
||||
public static final List<Class<? extends Packet>> SERVERBOUND_PACKETS = List.of(
|
||||
ServerboundSuccessfulHandshakePacket.class,
|
||||
ServerboundRunCoreCommandPacket.class,
|
||||
ServerboundRunCommandPacket.class
|
||||
);
|
||||
|
||||
private final Bot bot;
|
||||
|
||||
|
||||
@@ -16,59 +16,52 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandHandlerPlugin implements Listener {
|
||||
public static final List<Command> COMMANDS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
registerCommand(new CommandBlockCommand());
|
||||
registerCommand(new CowsayCommand());
|
||||
registerCommand(new EchoCommand());
|
||||
registerCommand(new HelpCommand());
|
||||
registerCommand(new TestCommand());
|
||||
registerCommand(new ValidateCommand());
|
||||
registerCommand(new MusicCommand());
|
||||
registerCommand(new RandomTeleportCommand());
|
||||
registerCommand(new BotVisibilityCommand());
|
||||
registerCommand(new TPSBarCommand());
|
||||
registerCommand(new NetMessageCommand());
|
||||
registerCommand(new RefillCoreCommand());
|
||||
registerCommand(new WikipediaCommand());
|
||||
registerCommand(new UrbanCommand());
|
||||
registerCommand(new ClearChatCommand());
|
||||
registerCommand(new ListCommand());
|
||||
registerCommand(new ServerEvalCommand());
|
||||
registerCommand(new UUIDCommand());
|
||||
registerCommand(new TimeCommand());
|
||||
registerCommand(new BruhifyCommand());
|
||||
registerCommand(new EndCommand());
|
||||
registerCommand(new CloopCommand());
|
||||
registerCommand(new WeatherCommand());
|
||||
registerCommand(new TranslateCommand());
|
||||
registerCommand(new KickCommand());
|
||||
registerCommand(new ClearChatQueueCommand());
|
||||
registerCommand(new FilterCommand());
|
||||
registerCommand(new MailCommand());
|
||||
registerCommand(new EvalCommand());
|
||||
registerCommand(new InfoCommand());
|
||||
registerCommand(new ConsoleCommand());
|
||||
// registerCommand(new ScreenshareCommand());
|
||||
registerCommand(new WhitelistCommand());
|
||||
registerCommand(new SeenCommand());
|
||||
registerCommand(new IPFilterCommand());
|
||||
registerCommand(new StopCommand());
|
||||
registerCommand(new GrepLogCommand());
|
||||
registerCommand(new FindAltsCommand());
|
||||
registerCommand(new RestartCommand());
|
||||
registerCommand(new NetCommandCommand());
|
||||
}
|
||||
|
||||
public static void registerCommand (final Command command) {
|
||||
COMMANDS.add(command);
|
||||
}
|
||||
public static final List<Command> COMMANDS = List.of(
|
||||
new CommandBlockCommand(),
|
||||
new CowsayCommand(),
|
||||
new EchoCommand(),
|
||||
new HelpCommand(),
|
||||
new TestCommand(),
|
||||
new ValidateCommand(),
|
||||
new MusicCommand(),
|
||||
new RandomTeleportCommand(),
|
||||
new BotVisibilityCommand(),
|
||||
new TPSBarCommand(),
|
||||
new NetMessageCommand(),
|
||||
new RefillCoreCommand(),
|
||||
new WikipediaCommand(),
|
||||
new UrbanCommand(),
|
||||
new ClearChatCommand(),
|
||||
new ListCommand(),
|
||||
new ServerEvalCommand(),
|
||||
new UUIDCommand(),
|
||||
new TimeCommand(),
|
||||
new BruhifyCommand(),
|
||||
new EndCommand(),
|
||||
new CloopCommand(),
|
||||
new WeatherCommand(),
|
||||
new TranslateCommand(),
|
||||
new KickCommand(),
|
||||
new ClearChatQueueCommand(),
|
||||
new FilterCommand(),
|
||||
new MailCommand(),
|
||||
new EvalCommand(),
|
||||
new InfoCommand(),
|
||||
new ConsoleCommand(),
|
||||
// new ScreenshareCommand(),
|
||||
new WhitelistCommand(),
|
||||
new SeenCommand(),
|
||||
new IPFilterCommand(),
|
||||
new StopCommand(),
|
||||
new GrepLogCommand(),
|
||||
new FindAltsCommand(),
|
||||
new RestartCommand(),
|
||||
new NetCommandCommand()
|
||||
);
|
||||
|
||||
public static Command findCommand (final String searchTerm) {
|
||||
if (searchTerm.isBlank()) return null;
|
||||
|
||||
@@ -14,10 +14,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
// Author: hhhzzzsss
|
||||
public class NBSConverter implements Converter {
|
||||
@@ -303,6 +300,6 @@ public class NBSConverter implements Converter {
|
||||
list.add(entry.getAsString());
|
||||
}
|
||||
|
||||
return list;
|
||||
return Collections.unmodifiableList(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,21 +10,18 @@ import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
// Author: _ChipMC_ & hhhzzzsss but modified
|
||||
public class SongLoaderThread extends Thread {
|
||||
// should the converters be here?
|
||||
public static final List<Converter> converters = new ArrayList<>();
|
||||
|
||||
static {
|
||||
converters.add(new MidiConverter());
|
||||
converters.add(new NBSConverter());
|
||||
converters.add(new TextFileConverter());
|
||||
converters.add(new SongPlayerConverter());
|
||||
}
|
||||
public static final List<Converter> converters = List.of(
|
||||
new MidiConverter(),
|
||||
new NBSConverter(),
|
||||
new TextFileConverter(),
|
||||
new SongPlayerConverter()
|
||||
);
|
||||
|
||||
public final String fileName;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user