From 81b2f352debd80cf058899e00c70928d495407b8 Mon Sep 17 00:00:00 2001 From: dfsek Date: Sun, 19 Dec 2021 19:52:19 -0700 Subject: [PATCH] remove old main commands --- .../com/dfsek/terra/AbstractPlatform.java | 8 - .../dfsek/terra/commands/AddonsCommand.java | 39 --- .../dfsek/terra/commands/ExecutionState.java | 56 ---- .../dfsek/terra/commands/GetBlockCommand.java | 46 --- .../dfsek/terra/commands/PacksCommand.java | 46 --- .../dfsek/terra/commands/ReloadCommand.java | 50 --- .../terra/commands/TerraCommandManager.java | 311 ------------------ .../dfsek/terra/commands/VersionCommand.java | 39 --- .../commands/profiler/ProfileCommand.java | 51 --- .../profiler/ProfileQueryCommand.java | 46 --- .../profiler/ProfileResetCommand.java | 39 --- .../profiler/ProfileStartCommand.java | 39 --- .../commands/profiler/ProfileStopCommand.java | 39 --- 13 files changed, 809 deletions(-) delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/AddonsCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/ExecutionState.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/GetBlockCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/PacksCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/ReloadCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/TerraCommandManager.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/VersionCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileQueryCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileResetCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStartCommand.java delete mode 100644 common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStopCommand.java diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/AbstractPlatform.java b/common/implementation/base/src/main/java/com/dfsek/terra/AbstractPlatform.java index 7508422ee..4a72e0a21 100644 --- a/common/implementation/base/src/main/java/com/dfsek/terra/AbstractPlatform.java +++ b/common/implementation/base/src/main/java/com/dfsek/terra/AbstractPlatform.java @@ -48,7 +48,6 @@ import com.dfsek.terra.addon.EphemeralAddon; import com.dfsek.terra.addon.InternalAddon; import com.dfsek.terra.api.Platform; import com.dfsek.terra.api.addon.BaseAddon; -import com.dfsek.terra.api.command.CommandManager; import com.dfsek.terra.api.config.ConfigPack; import com.dfsek.terra.api.config.PluginConfig; import com.dfsek.terra.api.event.EventManager; @@ -61,7 +60,6 @@ import com.dfsek.terra.api.registry.CheckedRegistry; import com.dfsek.terra.api.registry.Registry; import com.dfsek.terra.api.util.StringIdentifiable; import com.dfsek.terra.api.util.mutable.MutableBoolean; -import com.dfsek.terra.commands.TerraCommandManager; import com.dfsek.terra.config.GenericLoaders; import com.dfsek.terra.config.PluginConfigImpl; import com.dfsek.terra.event.EventManagerImpl; @@ -92,8 +90,6 @@ public abstract class AbstractPlatform implements Platform { private final PluginConfigImpl config = new PluginConfigImpl(); - private final CommandManager manager = new TerraCommandManager(this); - private final CheckedRegistry addonRegistry = new CheckedRegistryImpl<>(new OpenRegistryImpl<>(TypeKey.of(BaseAddon.class))); private final Registry lockedAddonRegistry = new LockedRegistryImpl<>(addonRegistry); @@ -102,10 +98,6 @@ public abstract class AbstractPlatform implements Platform { return configRegistry; } - public CommandManager getManager() { - return manager; - } - protected Iterable platformAddon() { return Collections.emptySet(); } diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/AddonsCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/AddonsCommand.java deleted file mode 100644 index 6355fa304..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/AddonsCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Command( - usage = "/terra addons" -) -public class AddonsCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - sender.sendMessage("Installed Addons:"); - platform.getAddons().forEach(addon -> sender.sendMessage(" - " + addon.getID())); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/ExecutionState.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/ExecutionState.java deleted file mode 100644 index 52a2393c1..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/ExecutionState.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.dfsek.terra.api.entity.CommandSender; - - -public final class ExecutionState { - private final Set switches = new HashSet<>(); - private final Map args = new HashMap<>(); - private final CommandSender sender; - - public ExecutionState(CommandSender sender) { - this.sender = sender; - } - - public void addSwitch(String flag) { - switches.add(flag); - } - - public void addArgument(String arg, String value) { - args.put(arg, value); - } - - public String getArgument(String argument) { - return args.get(argument); - } - - public boolean hasSwitch(String flag) { - return switches.contains(flag); - } - - public CommandSender getSender() { - return sender; - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/GetBlockCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/GetBlockCommand.java deleted file mode 100644 index a01312ec1..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/GetBlockCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.type.DebugCommand; -import com.dfsek.terra.api.command.annotation.type.PlayerCommand; -import com.dfsek.terra.api.command.annotation.type.WorldCommand; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.entity.Player; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@WorldCommand -@DebugCommand -@PlayerCommand -@Command( - usage = "/terra getblock" -) -public class GetBlockCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - Player player = (Player) sender; - sender.sendMessage("Block: " + player.world().getGenerator().getBlock(player.world(), player.position()).getAsString()); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/PacksCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/PacksCommand.java deleted file mode 100644 index d6bff7484..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/PacksCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.config.ConfigPack; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; -import com.dfsek.terra.api.registry.CheckedRegistry; - - -@Command( - usage = "/terra packs" -) -public class PacksCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - CheckedRegistry registry = platform.getConfigRegistry(); - - if(registry.entries().isEmpty()) { - sender.sendMessage("No packs installed"); - return; - } - registry.entries().forEach(configPack -> sender.sendMessage(" - " + configPack.getID() + "@" + configPack.getVersion().getFormatted())); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/ReloadCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/ReloadCommand.java deleted file mode 100644 index 1ebeaf7e6..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/ReloadCommand.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Command( - usage = "/terra reload" -) -public class ReloadCommand implements CommandTemplate { - private static final Logger logger = LoggerFactory.getLogger(ReloadCommand.class); - - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - logger.info("Reloading Terra..."); - if(platform.reload()) { - logger.info("Terra reloaded successfully."); - sender.sendMessage("Terra reloaded successfully."); - } else { - logger.error("Terra failed to reload."); - sender.sendMessage("Terra failed to reload. See logs for more information."); - } - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/TerraCommandManager.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/TerraCommandManager.java deleted file mode 100644 index 009db7a6c..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/TerraCommandManager.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands; - -import net.jafama.FastMath; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandManager; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Argument; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.Subcommand; -import com.dfsek.terra.api.command.annotation.Switch; -import com.dfsek.terra.api.command.annotation.inject.ArgumentTarget; -import com.dfsek.terra.api.command.annotation.inject.SwitchTarget; -import com.dfsek.terra.api.command.annotation.type.DebugCommand; -import com.dfsek.terra.api.command.annotation.type.PlayerCommand; -import com.dfsek.terra.api.command.annotation.type.WorldCommand; -import com.dfsek.terra.api.command.arg.ArgumentParser; -import com.dfsek.terra.api.command.exception.CommandException; -import com.dfsek.terra.api.command.exception.ExecutionException; -import com.dfsek.terra.api.command.exception.InvalidArgumentsException; -import com.dfsek.terra.api.command.exception.MalformedCommandException; -import com.dfsek.terra.api.command.exception.SwitchFormatException; -import com.dfsek.terra.api.command.tab.TabCompleter; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.entity.Player; -import com.dfsek.terra.api.inject.exception.InjectionException; -import com.dfsek.terra.api.inject.impl.InjectorImpl; -import com.dfsek.terra.api.util.reflection.ReflectionUtil; - - -public class TerraCommandManager implements CommandManager { - private final Map commands = new HashMap<>(); - private final InjectorImpl pluginInjector; - private final Platform platform; - - public TerraCommandManager(Platform platform) { - this.platform = platform; - this.pluginInjector = new InjectorImpl<>(platform); - pluginInjector.addExplicitTarget(Platform.class); - } - - @Override - public void execute(String commandName, CommandSender sender, List argsIn) throws CommandException { - if(!commands.containsKey(commandName)) throw new InvalidArgumentsException("No such command \"" + commandName + "\""); - execute(commands.get(commandName), sender, new ArrayList<>(argsIn)); - } - - @Override - public void register(String name, Class clazz) throws MalformedCommandException { - commands.put(name, new CommandHolder(clazz)); - } - - @Override - public List tabComplete(String command, CommandSender sender, List args) throws CommandException { - if(args.isEmpty()) return new ArrayList<>(commands.keySet()).stream().sorted(String::compareTo).collect(Collectors.toList()); - if(!commands.containsKey(command)) return Collections.emptyList(); - return tabComplete(commands.get(command), sender, new ArrayList<>(args)).stream().filter( - s -> s.toLowerCase().startsWith(args.get(args.size() - 1).toLowerCase())).sorted(String::compareTo).collect( - Collectors.toList()); - } - - @Override - public int getMaxArgumentDepth() { - int max = 0; - for(CommandHolder value : commands.values()) { - max = FastMath.max(getMaxArgumentDepth(value), max); - } - return max; - } - - private void execute(CommandHolder commandHolder, CommandSender sender, List args) throws CommandException { - Class commandClass = commandHolder.clazz; - - if(commandClass.isAnnotationPresent(DebugCommand.class) && !platform.getTerraConfig().isDebugCommands()) { - sender.sendMessage("Command must be executed with debug commands enabled."); - return; - } - - if(commandClass.isAnnotationPresent(PlayerCommand.class) && !(sender instanceof Player)) { - sender.sendMessage("Command must be executed by player."); - return; - } - - if(commandClass.isAnnotationPresent(WorldCommand.class) && (!(sender instanceof Player))) { - sender.sendMessage("Command must be executed in a Terra world."); - return; - } - - List ogArgs = new ArrayList<>(args); - - ExecutionState state = new ExecutionState(sender); - - if(!commandClass.isAnnotationPresent(Command.class)) { - invoke(commandClass, state, commandHolder); - return; - } - - Command command = commandClass.getAnnotation(Command.class); - - if(command.arguments().length == 0 && command.subcommands().length == 0) { - if(args.isEmpty()) { - invoke(commandClass, state, commandHolder); - return; - } else throw new InvalidArgumentsException("Expected 0 arguments, found " + args.size()); - } - - if(!args.isEmpty() && commandHolder.subcommands.containsKey(args.get(0))) { - String c = args.get(0); - args.remove(0); - execute(commandHolder.subcommands.get(c), sender, args); - return; - } - - boolean req = true; - for(Argument argument : command.arguments()) { - if(!req && argument.required()) { - throw new MalformedCommandException( - "Required arguments must come first! Arguments: " + Arrays.toString(command.arguments())); - } - req = argument.required(); - - if(args.isEmpty()) { - if(req) throw new InvalidArgumentsException("Invalid arguments: " + ogArgs + ", usage: " + command.usage()); - break; - } - - String arg = args.get(0); - - if(arg.startsWith("-")) { // switches have started. - if(req) throw new InvalidArgumentsException("Switches must come after arguments."); - break; - } - - state.addArgument(argument.value(), args.remove(0)); - } - - while(!args.isEmpty()) { - String aSwitch = args.remove(0); - if(!aSwitch.startsWith("-")) throw new SwitchFormatException("Invalid switch \"" + aSwitch + "\""); - - String val = aSwitch.substring(1); // remove dash - - if(!commandHolder.switches.containsKey(val)) throw new SwitchFormatException("No such switch \"" + aSwitch + "\""); - - state.addSwitch(commandHolder.switches.get(val)); - } - - invoke(commandClass, state, commandHolder); - } - - private void invoke(Class clazz, ExecutionState state, CommandHolder holder) throws CommandException { - try { - CommandTemplate template = clazz.getConstructor().newInstance(); - - pluginInjector.inject(template); - - for(Field field : ReflectionUtil.getFields(clazz)) { - if(field.isAnnotationPresent(ArgumentTarget.class)) { - ArgumentTarget argumentTarget = field.getAnnotation(ArgumentTarget.class); - if(!holder.argumentMap.containsKey(argumentTarget.value())) { - throw new MalformedCommandException( - "Argument Target specifies nonexistent argument \"" + argumentTarget.value() + "\""); - } - - String argument = argumentTarget.value(); - - ArgumentParser argumentParser = holder.argumentMap.get(argumentTarget.value()) - .argumentParser() - .getConstructor() - .newInstance(); - - pluginInjector.inject(argumentParser); - - field.setAccessible(true); - String value = state.getArgument(argument); - - if(value == null) value = holder.argumentMap.get(argumentTarget.value()).defaultValue(); - - field.set(template, argumentParser.parse(state.getSender(), value)); - } - if(field.isAnnotationPresent(SwitchTarget.class)) { - SwitchTarget switchTarget = field.getAnnotation(SwitchTarget.class); - if(!holder.switches.containsValue(switchTarget.value())) { - throw new MalformedCommandException("Switch Target specifies nonexistent switch \"" + switchTarget.value() + "\""); - } - - if(!(field.getType() == boolean.class)) { - throw new MalformedCommandException("Switch Target must be of type boolean."); - } - - field.setAccessible(true); - field.setBoolean(template, state.hasSwitch(switchTarget.value())); - } - } - - try { - template.execute(state.getSender()); - } catch(Throwable e) { - throw new ExecutionException("Failed to execute command: " + e.getMessage(), e); - } - } catch(InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | InjectionException e) { - throw new MalformedCommandException("Unable to reflectively instantiate command: ", e); - } - } - - private List tabComplete(CommandHolder holder, CommandSender sender, List args) throws CommandException { - if(args.isEmpty()) return Collections.emptyList(); - List completions = new ArrayList<>(); - - if(args.size() == 1) { - completions.addAll(holder.subcommands.keySet()); - } - - if(holder.subcommands.containsKey(args.get(0))) { - List newArgs = new ArrayList<>(args); - newArgs.remove(0); - completions.addAll(tabComplete(holder.subcommands.get(args.get(0)), sender, newArgs)); - } - try { - if(args.size() <= holder.arguments.size()) { - TabCompleter completer = holder.arguments.get(args.size() - 1).tabCompleter().getConstructor().newInstance(); - pluginInjector.inject(completer); - completions.addAll(completer.complete(sender)); - } - } catch(InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | InjectionException e) { - throw new MalformedCommandException("Unable to reflectively instantiate tab-completer: ", e); - } - return completions; - } - - private int getMaxArgumentDepth(CommandHolder holder) { - int max = 0; - max = FastMath.max(holder.arguments.size() + holder.switchList.size(), max); - for(CommandHolder value : holder.subcommands.values()) { - max = FastMath.max(max, getMaxArgumentDepth(value) + 1); - } - return max; - } - - - /** - * Pre-processes command metadata. - */ - private static final class CommandHolder { - private final Class clazz; - private final Map subcommands = new HashMap<>(); - private final Map switches = new HashMap<>(); - private final List arguments; - private final List switchList; - private final Map argumentMap = new HashMap<>(); - - private CommandHolder(Class clazz) throws MalformedCommandException { - this.clazz = clazz; - if(clazz.isAnnotationPresent(Command.class)) { - Command command = clazz.getAnnotation(Command.class); - for(Subcommand subcommand : command.subcommands()) { - if(subcommands.containsKey(subcommand.value())) - throw new MalformedCommandException("Duplicate subcommand: " + subcommand); - CommandHolder holder = new CommandHolder(subcommand.clazz()); - subcommands.put(subcommand.value(), holder); - for(String alias : subcommand.aliases()) { - subcommands.put(alias, holder); - } - } - for(Switch aSwitch : command.switches()) { - if(switches.containsKey(aSwitch.value())) throw new MalformedCommandException("Duplicate switch: " + aSwitch); - switches.put(aSwitch.value(), aSwitch.value()); - for(String alias : aSwitch.aliases()) { - switches.put(alias, aSwitch.value()); - } - } - for(Argument argument : command.arguments()) { - if(argumentMap.containsKey(argument.value())) throw new MalformedCommandException("Duplicate argument: " + argument); - argumentMap.put(argument.value(), argument); - } - arguments = Arrays.asList(command.arguments()); - switchList = Arrays.asList(command.switches()); - } else { - arguments = Collections.emptyList(); - switchList = Collections.emptyList(); - } - } - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/VersionCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/VersionCommand.java deleted file mode 100644 index f1e643ecc..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/VersionCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Command( - usage = "/terra version" -) -public class VersionCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - String terraVersion = platform.getVersion(); - sender.sendMessage("Running Terra version " + terraVersion); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileCommand.java deleted file mode 100644 index 0b33156d4..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileCommand.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands.profiler; - -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.Subcommand; -import com.dfsek.terra.api.command.annotation.type.DebugCommand; -import com.dfsek.terra.api.command.annotation.type.PlayerCommand; -import com.dfsek.terra.api.command.annotation.type.WorldCommand; -import com.dfsek.terra.api.entity.CommandSender; - - -@Command( - subcommands = { - @Subcommand(value = "query", aliases = "q", clazz = ProfileQueryCommand.class), - @Subcommand(value = "start", aliases = "s", clazz = ProfileStartCommand.class), - @Subcommand(value = "stop", aliases = "st", clazz = ProfileStopCommand.class), - @Subcommand(value = "reset", aliases = "r", clazz = ProfileResetCommand.class) - }, - usage = "Commands to enable/disable/query/reset the profiler." -) -@WorldCommand -@PlayerCommand -@DebugCommand -public class ProfileCommand implements CommandTemplate { - @Override - public void execute(CommandSender sender) { - sender.sendMessage(""" - ---------------Terra/profile---------------" - - "start - Starts the profiler" - - "stop - Stops the profiler" - - "query - Fetches profiler data" - - "reset - Resets profiler data"""); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileQueryCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileQueryCommand.java deleted file mode 100644 index 1e639b7d8..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileQueryCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands.profiler; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.type.DebugCommand; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Command -@DebugCommand -public class ProfileQueryCommand implements CommandTemplate { - private static final Logger logger = LoggerFactory.getLogger(ProfileQueryCommand.class); - - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - StringBuilder data = new StringBuilder("Terra Profiler data dump: \n"); - platform.getProfiler().getTimings().forEach((id, timings) -> data.append(id).append(": ").append(timings.toString()).append('\n')); - logger.info(data.toString()); - sender.sendMessage("Profiler data dumped to console."); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileResetCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileResetCommand.java deleted file mode 100644 index c3f7bb564..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileResetCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands.profiler; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.type.DebugCommand; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Command -@DebugCommand -public class ProfileResetCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - platform.getProfiler().reset(); - sender.sendMessage("Profiler reset."); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStartCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStartCommand.java deleted file mode 100644 index 7c7498b31..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStartCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands.profiler; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.type.DebugCommand; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Command -@DebugCommand -public class ProfileStartCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - platform.getProfiler().start(); - sender.sendMessage("Profiling enabled."); - } -} diff --git a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStopCommand.java b/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStopCommand.java deleted file mode 100644 index 5e8a9ec6e..000000000 --- a/common/implementation/base/src/main/java/com/dfsek/terra/commands/profiler/ProfileStopCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.commands.profiler; - -import com.dfsek.terra.api.Platform; -import com.dfsek.terra.api.command.CommandTemplate; -import com.dfsek.terra.api.command.annotation.Command; -import com.dfsek.terra.api.command.annotation.type.DebugCommand; -import com.dfsek.terra.api.entity.CommandSender; -import com.dfsek.terra.api.inject.annotations.Inject; - - -@Command -@DebugCommand -public class ProfileStopCommand implements CommandTemplate { - @Inject - private Platform platform; - - @Override - public void execute(CommandSender sender) { - platform.getProfiler().stop(); - sender.sendMessage("Profiling disabled."); - } -}