diff options
-rw-r--r-- | README.md | 36 | ||||
-rw-r--r-- | src/main/java/me/Danker/DankersSkyblockMod.java | 11 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/warp/WarpCommand.java | 79 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/warp/WarpCommandHandler.java | 94 |
4 files changed, 203 insertions, 17 deletions
@@ -101,16 +101,34 @@ Discord Server: https://discord.gg/QsEkNQS - /dsmfarmlength <min coords> <max coords> - Sets coords to be used for end of farm alert. - /hotmof [player] - Uses API to find total powder and HotM tree of a person. If no name is provided, it checks yours. -##Warps -Commands for to warp to the MVP+ exclusive warps -- /crypt - Warps you to the Crypt in the Hub. -- /da - Warps you to the Dark Auction in the Hub. -- /drag - Warps you to the Dragons Nest in the End. -- /dun - Warps you to the Dungeon Hub. -- /howl - Warps you to the Howling Cave in the Park. -- /magma - Warps you to the Magma Fields in the Blazing Fortress. -- /nest - Warps you to the Top of the Spider's Nest in the Spider's Den. +<details> + <summary>Warps</summary> +### Warps +Shortcut commands that save you the time of typing the whole warp command. + - /deep - Warps you to the Deep Caverns. + - /nether - Warps you to the Crimson Isle. + - /isle - Warps you to the Crimson Isle. + - /crimson - Warps you to the Crimson Isle. + - /mines - Warps you to the Dwarven Mines. + - /forge - Warps you to the Dwarven Forge. + - /crystals - Warps you to the Crystal Hollows. + - /gold - Warps you to the Gold Mine. + - /desert - Warps you to the Desert. + - /spider - Warps you to the Spiders Den. + - /barn - Warps you to the Barn. + - /end - Warps you to the End. + - /park - Warps you to the Park. + - /castle - Warps you to the Hub Castle. + - /da - Warps you to the Dark Auction. + - /crypt - Warps you to the Crypt in the Hub. + - /nest - Warps you to the top of the Spider's Den. + - /void - Warps you to the Void Sepulture in the End. + - /drag - Warps you to the Dragons Nest in the End. + - /jungle - Warps you to the Jungle. + - /howl - Warps you to the Howling Cave in the Park. + - /dun - Warps you to the Dungeon Hub. +</details> ## Keybinds - Open Maddox menu - M by default. diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 6fa1995..16c73c8 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -2,7 +2,7 @@ package me.Danker; import com.google.gson.JsonObject; import me.Danker.commands.*; -import me.Danker.commands.warp.*; +import me.Danker.commands.warp.WarpCommandHandler; import me.Danker.events.ChestSlotClickedEvent; import me.Danker.events.GuiChestBackgroundDrawnEvent; import me.Danker.events.RenderOverlayEvent; @@ -79,6 +79,7 @@ public class DankersSkyblockMod { public static boolean firstLaunch = false; public static String configDirectory; public static JsonObject data = null; + public static WarpCommandHandler warpCommandHandler; public static int farmingLevel; public static int miningLevel; @@ -232,13 +233,7 @@ public class DankersSkyblockMod { ClientCommandHandler.instance.registerCommand(new ToggleCommand()); ClientCommandHandler.instance.registerCommand(new WeightCommand()); - ClientCommandHandler.instance.registerCommand(new Crypt()); - ClientCommandHandler.instance.registerCommand(new DarkAuction()); - ClientCommandHandler.instance.registerCommand(new Dragon()); - ClientCommandHandler.instance.registerCommand(new DungeonHub()); - ClientCommandHandler.instance.registerCommand(new HowlingCave()); - ClientCommandHandler.instance.registerCommand(new Magma()); - ClientCommandHandler.instance.registerCommand(new SpidersNest()); + warpCommandHandler = new WarpCommandHandler(); configDirectory = event.getModConfigurationDirectory().toString(); } diff --git a/src/main/java/me/Danker/commands/warp/WarpCommand.java b/src/main/java/me/Danker/commands/warp/WarpCommand.java new file mode 100644 index 0000000..730e7cd --- /dev/null +++ b/src/main/java/me/Danker/commands/warp/WarpCommand.java @@ -0,0 +1,79 @@ +package me.Danker.commands.warp; + +import me.Danker.utils.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; + +public class WarpCommand extends CommandBase { + + + private boolean custom_command = false; + public String name; + public String destination; + + /** + * A Command blueprint extending CommandBase that uses the name and sends the destination as "/warp {@link #destination}" + * @param name the name that the command is called as + * @param destination the location name that is sent + */ + public WarpCommand(String name, String destination) { + this.name = name; + this.destination = destination; + } + + /** + * A Command blueprint extending CommandBase that uses the name and sends the destination as "/warp {@link #destination}" + * @param name the name that the command is called as + * @param destination the location name that is sent + * @param custom_command is the custom command should use the /warp format or send a custom command. + * Adds the "/" to the destination. + */ + public WarpCommand(String name, String destination, boolean custom_command) { + this.name = name; + this.destination = destination; + this.custom_command = custom_command; + } + + /** + * Returns the commands name that is set in the constructor + */ + @Override + public String getCommandName() { + return name; + } + + /** + * Returns the command usage for the builtin help + * @param sender the command sender + * @return "/" + the command name + */ + @Override + public String getCommandUsage(ICommandSender sender) { + return "/" + getCommandName(); + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + /** + * The logic that is called when the command is executed + * Sends a message as the player containing "/warp {@link #destination}" + * @param sender the command sender + * @param args what is written after the command + */ + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (!Utils.inSkyblock) return; + if (custom_command) { + Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + this.destination); + return; + } + Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp " + this.destination); + + } + +} diff --git a/src/main/java/me/Danker/commands/warp/WarpCommandHandler.java b/src/main/java/me/Danker/commands/warp/WarpCommandHandler.java new file mode 100644 index 0000000..6cdf840 --- /dev/null +++ b/src/main/java/me/Danker/commands/warp/WarpCommandHandler.java @@ -0,0 +1,94 @@ +package me.Danker.commands.warp; + +import net.minecraftforge.client.ClientCommandHandler; + +import java.util.ArrayList; +import java.util.List; + +public class WarpCommandHandler { + + private List<WarpCommand> commands; + + /** + * Constructor of the WarpCommandHandler, it will register all commands when it is created + */ + public WarpCommandHandler() { + this.commands = new ArrayList<WarpCommand>(); + registerCommands(); + } + + + /** + * @return List of all registered commands + */ + public List<WarpCommand> getCommands() { + return this.commands; + } + + /** + * Registers a command to the handler + * @param warpCommand WarpCommand to register + */ + public void registerCommand(WarpCommand warpCommand) { + this.commands.add(warpCommand); + ClientCommandHandler.instance.registerCommand(warpCommand); + } + + /** + * Get a command by its name + * @param name Name of the command + * @return WarpCommand with the given name + */ + public WarpCommand getCommand(String name) { + for (WarpCommand command : this.commands) { + if (command.getCommandName().equalsIgnoreCase(name)) { + return command; + } + } + return null; + } + + /** + * Get a command by the class it extends from + * @param clazz Class to get the command from + * @return WarpCommand with the given class + */ + public WarpCommand getCommand(Class<? extends WarpCommand> clazz) { + for (WarpCommand command : this.commands) { + if (command.getClass() == clazz) { + return command; + } + } + return null; + } + + /** + * Register all commands + */ + private void registerCommands() { + registerCommand(new WarpCommand("deep", "deep")); + registerCommand(new WarpCommand("nether", "nether")); + registerCommand(new WarpCommand("isle", "isle")); + registerCommand(new WarpCommand("crimson", "crimson")); + registerCommand(new WarpCommand("mines", "mines")); + registerCommand(new WarpCommand("forge", "forge")); + registerCommand(new WarpCommand("crystals", "crystals")); + registerCommand(new WarpCommand("gold", "gold")); + registerCommand(new WarpCommand("desert", "desert")); + registerCommand(new WarpCommand("spider", "spider")); + registerCommand(new WarpCommand("barn", "barn")); + registerCommand(new WarpCommand("end", "end")); + registerCommand(new WarpCommand("park", "park")); + registerCommand(new WarpCommand("castle", "castle")); + registerCommand(new WarpCommand("museum", "museum")); + registerCommand(new WarpCommand("da", "da")); + registerCommand(new WarpCommand("crypt", "crypt")); + registerCommand(new WarpCommand("nest", "nest")); + registerCommand(new WarpCommand("void", "void")); + registerCommand(new WarpCommand("drag", "dragon")); + registerCommand(new WarpCommand("jungle", "jungle")); + registerCommand(new WarpCommand("howl", "howl")); + registerCommand(new WarpCommand("dun", "dungeon_hub")); + } + +} |