diff options
author | bowser0000 <bowser0000@gmail.com> | 2022-08-09 20:33:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-09 20:33:04 -0400 |
commit | 0345c0ce9594d76a9ac1601bd039b1b64a6a38dc (patch) | |
tree | 7f762c94a742a07e5c3939e70d35cf7128071b32 /src/main | |
parent | f56302bee3939677fc3fd015a97b12b5100c45b1 (diff) | |
parent | 4d2a84d9fd2f522b2ade9954f8d40f6d80e2b12b (diff) | |
download | SkyblockMod-0345c0ce9594d76a9ac1601bd039b1b64a6a38dc.tar.gz SkyblockMod-0345c0ce9594d76a9ac1601bd039b1b64a6a38dc.tar.bz2 SkyblockMod-0345c0ce9594d76a9ac1601bd039b1b64a6a38dc.zip |
Merge pull request #90 from CuzImClicks/development
Highlight completed Commissions
Fast warp commands
Fix kill combo hider
Diffstat (limited to 'src/main')
9 files changed, 251 insertions, 4 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 280fc96..73c996b 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -2,6 +2,7 @@ package me.Danker; import com.google.gson.JsonObject; import me.Danker.commands.*; +import me.Danker.commands.warp.WarpCommandHandler; import me.Danker.events.*; import me.Danker.features.*; import me.Danker.features.loot.*; @@ -76,6 +77,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; @@ -165,7 +167,7 @@ public class DankersSkyblockMod { MinecraftForge.EVENT_BUS.register(new UpdateChecker()); MinecraftForge.EVENT_BUS.register(new WatcherReadyAlert()); MinecraftForge.EVENT_BUS.register(new WaterSolver()); - + MinecraftForge.EVENT_BUS.register(new HighlightCommissions()); MinecraftForge.EVENT_BUS.register(new LootDisplay()); MinecraftForge.EVENT_BUS.register(new LootTracker()); MinecraftForge.EVENT_BUS.register(new BlazeTracker()); @@ -205,7 +207,6 @@ public class DankersSkyblockMod { ClientCommandHandler.instance.registerCommand(new DHelpCommand()); ClientCommandHandler.instance.registerCommand(new DankerGuiCommand()); ClientCommandHandler.instance.registerCommand(new DisplayCommand()); - ClientCommandHandler.instance.registerCommand(new DungeonsCommand()); ClientCommandHandler.instance.registerCommand(new FairySoulsCommand()); ClientCommandHandler.instance.registerCommand(new FarmLengthCommand()); ClientCommandHandler.instance.registerCommand(new GetkeyCommand()); @@ -232,6 +233,8 @@ public class DankersSkyblockMod { ClientCommandHandler.instance.registerCommand(new ToggleCommand()); ClientCommandHandler.instance.registerCommand(new WeightCommand()); + warpCommandHandler = new WarpCommandHandler(); + configDirectory = event.getModConfigurationDirectory().toString(); } diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 3c353c8..00b41f3 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -48,6 +48,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean teammatesInRadius; public static boolean giantHP; public static boolean hidePetCandy; + public static boolean highlightCommissions; public static boolean customColouredNames; public static boolean customNametags; public static boolean endOfFarmAlert; @@ -157,7 +158,7 @@ public class ToggleCommand extends CommandBase implements ICommand { "gemstonelore", "crystalhollowwaypoints", "crystalautowaypoints", "autoacceptreparty", "itemcooldowns", "hubmusic", "islandmusic", "dungeonhubmusic", "farmingislandsmusic", "goldminemusic", "deepcavernsmusic", "dwarvenminesmusic", "crystalhollowsmusic", "spidersdenmusic", "blazingfortressmusic", - "endmusic", "parkmusic", "alerts", "dungeonscore", "list"); + "endmusic", "parkmusic", "alerts", "dungeonscore", "highlightcommissions", "list"); } return null; } @@ -473,6 +474,10 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "HidePetCandy", hidePetCandy); player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Hide pet candy has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + hidePetCandy + DankersSkyblockMod.MAIN_COLOUR + ".")); break; + case "highlightcommissions": + highlightCommissions = !highlightCommissions; + ConfigHandler.writeBooleanConfig("toggles", "HighlightCommissions", highlightCommissions); + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Highlight Commissions has been set to " + DankersSkyblockMod.SECONDARY_COLOUR + highlightCommissions + DankersSkyblockMod.MAIN_COLOUR + ".")); case "customcolorednames": case "customcolourednames": customColouredNames = !customColouredNames; @@ -661,6 +666,7 @@ public class ToggleCommand extends CommandBase implements ICommand { DankersSkyblockMod.TYPE_COLOUR + " Teammates in radius: " + DankersSkyblockMod.VALUE_COLOUR + teammatesInRadius + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Giant HP display: " + DankersSkyblockMod.VALUE_COLOUR + giantHP + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Hide pet candy: " + DankersSkyblockMod.VALUE_COLOUR + hidePetCandy + "\n" + + DankersSkyblockMod.TYPE_COLOUR + " Highlight commissions: " + DankersSkyblockMod.VALUE_COLOUR + highlightCommissions + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Custom name colors: " + DankersSkyblockMod.VALUE_COLOUR + customColouredNames + "\n" + DankersSkyblockMod.TYPE_COLOUR + " End of farm alert: " + DankersSkyblockMod.VALUE_COLOUR + endOfFarmAlert + "\n" + DankersSkyblockMod.TYPE_COLOUR + " Gemstone in lore: " + DankersSkyblockMod.VALUE_COLOUR + gemstoneLore + "\n" + 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")); + } + +} diff --git a/src/main/java/me/Danker/features/HighlightCommissions.java b/src/main/java/me/Danker/features/HighlightCommissions.java new file mode 100644 index 0000000..f59951a --- /dev/null +++ b/src/main/java/me/Danker/features/HighlightCommissions.java @@ -0,0 +1,39 @@ +package me.Danker.features; + +import me.Danker.commands.ToggleCommand; +import me.Danker.events.GuiChestBackgroundDrawnEvent; +import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.Utils; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.item.ItemWritableBook; + +import org.lwjgl.util.Color; +import java.util.List; + +public class HighlightCommissions { + + public static int HIGHLIGHT_COLOUR; + + @SubscribeEvent + public void onGuiRender(GuiChestBackgroundDrawnEvent event) { + if(!Utils.inSkyblock) return; + if(!ToggleCommand.highlightCommissions) return; + List<Slot> slots = event.slots; + if (!event.displayName.equals("Commissions")) return; + + for (Slot slot : slots) { + if (slot != null && slot.getStack() == null) continue; + if (slot.getStack().getItem() instanceof ItemWritableBook) { + for (String line : Utils.getItemLore(slot.getStack())) { + if (line.contains("COMPLETED")) { + Utils.drawOnSlot(event.chestSize, slot.xDisplayPosition, slot.yDisplayPosition, HIGHLIGHT_COLOUR + 0xD7000000); + break; + } + } + + } + } + } + +} diff --git a/src/main/java/me/Danker/features/SpamHider.java b/src/main/java/me/Danker/features/SpamHider.java index a88d9e5..f1a40c9 100644 --- a/src/main/java/me/Danker/features/SpamHider.java +++ b/src/main/java/me/Danker/features/SpamHider.java @@ -49,7 +49,7 @@ public class SpamHider { } // Kill Combo if (!ToggleCommand.killComboMessages) { - if ((message.contains("+") && message.contains(" Kill Combo ")) || message.contains("Your Kill Combo has expired!")) { + if ((message.contains("+") && message.contains(" Kill Combo")) || message.contains("Your Kill Combo has expired!")) { event.setCanceled(true); } } diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index cab2b5c..06c50d0 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -14,6 +14,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.client.gui.*; import net.minecraft.util.StringUtils; import java.awt.*; @@ -73,6 +74,7 @@ public class DankerGui extends GuiScreen { private GuiButton teammatesInRadius; private GuiButton giantHP; private GuiButton hidePetCandy; + private GuiButton highlightCommissions; private GuiButton customColouredNames; private GuiButton customNametags; private GuiButton endOfFarmAlert; @@ -179,6 +181,7 @@ public class DankerGui extends GuiScreen { teammatesInRadius = new FeatureButton("Display Players in 30 Block Radius: " + Utils.getColouredBoolean(ToggleCommand.teammatesInRadius), "Displays dungeon teammates in 30 block radius for tether and diversion."); giantHP = new FeatureButton("Display Giant HP: " + Utils.getColouredBoolean(ToggleCommand.giantHP), "Displays health of Sadan's giants during F6 bossfight and F7 blood room."); hidePetCandy = new FeatureButton("Hide Pet Candy: " + Utils.getColouredBoolean(ToggleCommand.hidePetCandy), "Hide pet candy in pet tooltips."); + highlightCommissions = new FeatureButton("Highlight Commissions: " + Utils.getColouredBoolean(ToggleCommand.highlightCommissions), "Show which commissions are completed."); customColouredNames = new FeatureButton("Custom Name Colors: " + Utils.getColouredBoolean(ToggleCommand.customColouredNames), "Replaces some player's usernames with a custom color."); customNametags = new FeatureButton("Custom Color on Nametags: " + Utils.getColouredBoolean(ToggleCommand.customNametags), "Displays custom name colors on nametags. Disabling will increase performance with custom colors."); endOfFarmAlert = new FeatureButton("Alert When Reaching End of Farm: " + Utils.getColouredBoolean(ToggleCommand.endOfFarmAlert), "Alerts when you go past coords set with /dsmfarmlength."); @@ -243,6 +246,7 @@ public class DankerGui extends GuiScreen { allButtons.add(teammatesInRadius); allButtons.add(giantHP); allButtons.add(hidePetCandy); + allButtons.add(highlightCommissions); allButtons.add(customColouredNames); allButtons.add(customNametags); allButtons.add(endOfFarmAlert); @@ -509,6 +513,10 @@ public class DankerGui extends GuiScreen { ToggleCommand.hidePetCandy = !ToggleCommand.hidePetCandy; ConfigHandler.writeBooleanConfig("toggles", "HidePetCandy", ToggleCommand.hidePetCandy); hidePetCandy.displayString = "Hide Pet Candy: " + Utils.getColouredBoolean(ToggleCommand.hidePetCandy); + } else if (button == highlightCommissions) { + ToggleCommand.highlightCommissions = !ToggleCommand.highlightCommissions; + ConfigHandler.writeBooleanConfig("toggles", "HighlightCommissions", ToggleCommand.highlightCommissions); + highlightCommissions.displayString = "Highlight Commissions: " + Utils.getColouredBoolean(ToggleCommand.highlightCommissions); } else if (button == customColouredNames) { ToggleCommand.customColouredNames = !ToggleCommand.customColouredNames; ConfigHandler.writeBooleanConfig("toggles", "CustomColouredNames", ToggleCommand.customColouredNames); diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 484a7d5..edbd0b4 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -220,6 +220,7 @@ public class ConfigHandler { ToggleCommand.melodyTooltips = initBoolean("toggles", "MelodyTooltips", false); ToggleCommand.highlightSlayers = initBoolean("toggles", "HighlightSlayers", false); ToggleCommand.highlightArachne = initBoolean("toggles", "HighlightArachne", false); + ToggleCommand.highlightCommissions = initBoolean("toggles", "HighlightCommissions", false); ToggleCommand.highlightSkeletonMasters = initBoolean("toggles", "HighlightSkeletonMasters", false); ToggleCommand.teammatesInRadius = initBoolean("toggles", "TeammatesInRadius", false); ToggleCommand.giantHP = initBoolean("toggles", "GiantHP", false); @@ -718,6 +719,7 @@ public class ConfigHandler { BoulderSolver.BOULDER_ARROW_COLOUR = initInt("colors", "boulderArrow", 0x006000); SilverfishSolver.SILVERFISH_LINE_COLOUR = initInt("colors", "silverfishLine", 0x40FF40); IceWalkSolver.ICE_WALK_LINE_COLOUR = initInt("colors", "iceWalkLine", 0x40FF40); + HighlightCommissions.HIGHLIGHT_COLOUR = initInt("colors", "highlight_colour", 0x51FF51); MinionLastCollected.LAST_COLLECTED_COLOUR = initInt("colors", "lastCollected", 0x55FFFF); // Commands diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java index 8791a43..deb5018 100644 --- a/src/main/java/me/Danker/utils/Utils.java +++ b/src/main/java/me/Danker/utils/Utils.java @@ -10,6 +10,8 @@ import me.Danker.handlers.ConfigHandler; import me.Danker.handlers.ScoreboardHandler; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItemFrame; @@ -20,6 +22,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.util.*; +import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.List; @@ -506,6 +509,19 @@ public class Utils { return (Math.floor(level / 2D) + 25) / 100D; } + public static void drawOnSlot(int size, int xSlotPos, int ySlotPos, int colour) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + int guiLeft = (sr.getScaledWidth() - 176) / 2; + int guiTop = (sr.getScaledHeight() - 222) / 2; + int x = guiLeft + xSlotPos; + int y = guiTop + ySlotPos; + // Move down when chest isn't 6 rows + if (size != 90) y += (6 - (size - 36) / 9) * 9; + + GL11.glTranslated(0, 0, 1); + Gui.drawRect(x, y, x + 16, y + 16, colour); + GL11.glTranslated(0, 0, -1); + public static void desktopNotification(String name, String title, String text, TrayIcon.MessageType messageType) { try { final SystemTray tray = SystemTray.getSystemTray(); |