diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-08 16:12:55 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-08 16:12:55 +0200 |
commit | 4463c7fa78f886a8abc09e867dd17cde2a685ad4 (patch) | |
tree | 9245b4eed7f410f1c168688a77eeda6bfd55c994 /src/main/java/com/thatgravyboat/skyblockhud_2/commands | |
parent | 9e08dbf2baa9819abd281ad285df7462c99491e2 (diff) | |
download | skyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.tar.gz skyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.tar.bz2 skyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.zip |
code cleanup
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud_2/commands')
3 files changed, 209 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud_2/commands/Commands.java b/src/main/java/com/thatgravyboat/skyblockhud_2/commands/Commands.java new file mode 100644 index 000000000..21bf4529f --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud_2/commands/Commands.java @@ -0,0 +1,88 @@ +package com.thatgravyboat.skyblockhud_2.commands; + +import at.lorenz.mod.LorenzMod; +import com.thatgravyboat.skyblockhud_2.config.SBHConfigEditor; +import com.thatgravyboat.skyblockhud_2.core.GuiScreenElementWrapper; +//import com.thatgravyboat.skyblockhud.handlers.CrystalWaypoints; +import net.minecraft.command.ICommandSender; +import net.minecraftforge.client.ClientCommandHandler; +import org.apache.commons.lang3.StringUtils; + +public class Commands { + + private static final boolean devMode = false; + + private static final SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + if (args.length > 0) { + LorenzMod.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(LorenzMod.feature, StringUtils.join(args, " "))); + } else { + LorenzMod.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(LorenzMod.feature)); + } + } + }; + + // private static final SimpleSubCommand devCommand = new SimpleSubCommand("sbhdev", ImmutableSet.of("copyNpcSkin", "copyBossBar", "copyScoreboard", "copyActionBar", "mobDeathLogging")) { + // @Override + // void processSubCommand(ICommandSender sender, String subCommand, String[] args) { + // StringSelection clipboard = null; + // switch (subCommand) { + // case "copyBossBar": + // clipboard = new StringSelection(BossStatus.bossName); + // break; + // case "copyScoreboard": + // StringBuilder builder = new StringBuilder(); + // LeaderboardGetter.getCachedScores().forEach(s -> builder.append(s).append("\n")); + // clipboard = new StringSelection(builder.toString()); + // break; + // case "copyActionBar": + // clipboard = new StringSelection(ActionBarParsing.lastLowActionBar); + // break; + // case "copySkin": + // Entity entity = Minecraft.getMinecraft().objectMouseOver.entityHit; + // if (entity instanceof AbstractClientPlayer) { + // clipboard = new StringSelection("http://textures.minecraft.net/texture/" + ((AbstractClientPlayer) entity).getLocationSkin().getResourcePath().replace("skins/", "")); + // } else { + // sendSBHMessage(sender, "Not a player!"); + // } + // break; + // case "mobDeathLogging": + // DevModeConstants.mobDeathLogging = !DevModeConstants.mobDeathLogging; + // sendSBHMessage(sender, "Mob Death Logging " + (DevModeConstants.mobDeathLogging ? "Enabled!" : "Disabled!")); + // } + // if (clipboard != null) { + // Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); + // sendSBHMessage(sender, "Info copied to clipboard!"); + // } + // } + // + // @Override + // void processNoSubCommand(ICommandSender sender) { + // devMode = !devMode; + // sender.addChatMessage(new ChatComponentText("Dev Mode " + (devMode ? "Enabled!" : "Disabled!"))); + // } + // }; + + private static final SimpleCommand settingsCommand = new SimpleCommand("lm", settingsRunnable); + private static final SimpleCommand settingsCommand2 = new SimpleCommand("lorenzmod", settingsRunnable); + + // private static final SimpleCommand mapCommand = new SimpleCommand( + // "sbhmap", + // new SimpleCommand.ProcessCommandRunnable() { + // public void processCommand(ICommandSender sender, String[] args) { + // if (LocationHandler.getCurrentLocation().getCategory().getMap() != null && SkyblockHud.hasSkyblockScoreboard()) SkyblockHud.screenToOpen = new MapHandler.MapScreen(); + // } + // } + // ); + + public static void init() { + ClientCommandHandler.instance.registerCommand(settingsCommand); + ClientCommandHandler.instance.registerCommand(settingsCommand2); + // ClientCommandHandler.instance.registerCommand(mapCommand); + // ClientCommandHandler.instance.registerCommand(devCommand); +// ClientCommandHandler.instance.registerCommand(new CrystalWaypoints.WaypointCommand()); + } + // private static void sendSBHMessage(ICommandSender sender, String message) { + // sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.RED + EnumChatFormatting.BOLD + "SkyBlockHud" + EnumChatFormatting.RESET + "] : " + EnumChatFormatting.GRAY + message)); + // } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud_2/commands/SimpleCommand.java b/src/main/java/com/thatgravyboat/skyblockhud_2/commands/SimpleCommand.java new file mode 100644 index 000000000..851ea8c5c --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud_2/commands/SimpleCommand.java @@ -0,0 +1,60 @@ +package com.thatgravyboat.skyblockhud_2.commands; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.BlockPos; + +/** + @author Moulberry + **/ +public class SimpleCommand extends CommandBase { + + private final String commandName; + private final ProcessCommandRunnable runnable; + private TabCompleteRunnable tabRunnable; + + public SimpleCommand(String commandName, ProcessCommandRunnable runnable) { + this.commandName = commandName; + this.runnable = runnable; + } + + public SimpleCommand(String commandName, ProcessCommandRunnable runnable, TabCompleteRunnable tabRunnable) { + this.commandName = commandName; + this.runnable = runnable; + this.tabRunnable = tabRunnable; + } + + public abstract static class ProcessCommandRunnable { + + public abstract void processCommand(ICommandSender sender, String[] args); + } + + public abstract static class TabCompleteRunnable { + + public abstract List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos); + } + + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } + + public String getCommandName() { + return commandName; + } + + public String getCommandUsage(ICommandSender sender) { + return "/" + commandName; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + runnable.processCommand(sender, args); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos); + return null; + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud_2/commands/SimpleSubCommand.java b/src/main/java/com/thatgravyboat/skyblockhud_2/commands/SimpleSubCommand.java new file mode 100644 index 000000000..4869d6bc9 --- /dev/null +++ b/src/main/java/com/thatgravyboat/skyblockhud_2/commands/SimpleSubCommand.java @@ -0,0 +1,61 @@ +//package com.thatgravyboat.skyblockhud.commands; +// +//import java.util.List; +//import java.util.Set; +//import net.minecraft.command.CommandBase; +//import net.minecraft.command.ICommandSender; +//import net.minecraft.util.BlockPos; +//import org.apache.commons.lang3.ArrayUtils; +// +//public abstract class SimpleSubCommand extends CommandBase { +// +// private final String commandName; +// private final Set<String> subCommands; +// +// public SimpleSubCommand(String commandName, Set<String> subCommands) { +// this.commandName = commandName; +// this.subCommands = subCommands; +// } +// +// @Override +// public String getCommandName() { +// return commandName; +// } +// +// @Override +// public String getCommandUsage(ICommandSender sender) { +// return "/" + commandName; +// } +// +// @Override +// public void processCommand(ICommandSender sender, String[] args) { +// if (args.length == 0) { +// processNoSubCommand(sender); +// return; +// } +// if (subCommands.contains(args[0])) { +// processSubCommand(sender, args[0], ArrayUtils.remove(args, 0)); +// return; +// } +// processBadSubCommand(sender, args[0]); +// } +// +// @Override +// public boolean canCommandSenderUseCommand(ICommandSender sender) { +// return true; +// } +// +// @Override +// public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { +// if (args.length == 1) { +// return getListOfStringsMatchingLastWord(args, subCommands); +// } +// return null; +// } +// +// abstract void processSubCommand(ICommandSender sender, String subCommand, String[] args); +// +// abstract void processNoSubCommand(ICommandSender sender); +// +// public void processBadSubCommand(ICommandSender sender, String subCommand) {} +//} |