micro optimizations

This commit is contained in:
xGinko 2023-09-10 23:52:22 +02:00
parent 2299ca675b
commit b3002c15fd
2 changed files with 7 additions and 14 deletions

View File

@ -26,10 +26,10 @@ public interface VillagerOptimizerCommand extends CommandExecutor {
VillagerOptimizer plugin = VillagerOptimizer.getInstance(); VillagerOptimizer plugin = VillagerOptimizer.getInstance();
CommandMap commandMap = plugin.getServer().getCommandMap(); CommandMap commandMap = plugin.getServer().getCommandMap();
for (VillagerOptimizerCommand command : commands) { commands.forEach(command -> {
plugin.getCommand(command.label()).unregister(commandMap); plugin.getCommand(command.label()).unregister(commandMap);
plugin.getCommand(command.label()).setExecutor(command); plugin.getCommand(command.label()).setExecutor(command);
} });
} }
@Override @Override

View File

@ -17,15 +17,13 @@ import java.util.List;
public class VillagerOptimizerCmd implements TabCompleter, VillagerOptimizerCommand { public class VillagerOptimizerCmd implements TabCompleter, VillagerOptimizerCommand {
private final List<SubCommand> subCommands = new ArrayList<>(7); private final List<SubCommand> subCommands = new ArrayList<>(2);
private final List<String> tabCompleter = new ArrayList<>(7); private final List<String> tabCompleter = new ArrayList<>(2);
public VillagerOptimizerCmd() { public VillagerOptimizerCmd() {
subCommands.add(new ReloadSubCmd()); subCommands.add(new ReloadSubCmd());
subCommands.add(new VersionSubCmd()); subCommands.add(new VersionSubCmd());
for (SubCommand subcommand : subCommands) { subCommands.forEach(subCommand -> tabCompleter.add(subCommand.getLabel()));
tabCompleter.add(subcommand.getLabel());
}
} }
@Override @Override
@ -61,13 +59,8 @@ public class VillagerOptimizerCmd implements TabCompleter, VillagerOptimizerComm
sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY)); sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY));
sender.sendMessage(Component.text("VillagerOptimizer Commands").color(NamedTextColor.BLUE)); sender.sendMessage(Component.text("VillagerOptimizer Commands").color(NamedTextColor.BLUE));
sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY)); sender.sendMessage(Component.text("-----------------------------------------------------").color(NamedTextColor.GRAY));
for (SubCommand subCommand : subCommands) { subCommands.forEach(subCommand -> sender.sendMessage(
sender.sendMessage( subCommand.getSyntax().append(Component.text(" - ").color(NamedTextColor.DARK_GRAY)).append(subCommand.getDescription())));
subCommand.getSyntax()
.append(Component.text(" - ").color(NamedTextColor.DARK_GRAY))
.append(subCommand.getDescription())
);
}
sender.sendMessage( sender.sendMessage(
Component.text("/optimizevillagers <message>").color(NamedTextColor.BLUE) Component.text("/optimizevillagers <message>").color(NamedTextColor.BLUE)
.append(Component.text(" - ").color(NamedTextColor.DARK_GRAY)) .append(Component.text(" - ").color(NamedTextColor.DARK_GRAY))