From 050a1b2d8fbea8567de76d6515908470054d81c1 Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Thu, 24 Sep 2020 23:14:56 -0400 Subject: Add option for displaying total skill xp instead of progress to next level --- src/main/java/me/Danker/TheMod.java | 34 +++++++++++++++++++++- src/main/java/me/Danker/commands/DHelpCommand.java | 6 ++-- src/main/java/me/Danker/commands/MoveCommand.java | 11 +++++-- src/main/java/me/Danker/commands/ScaleCommand.java | 9 ++++-- .../java/me/Danker/commands/ToggleCommand.java | 12 ++++++-- .../java/me/Danker/handlers/ConfigHandler.java | 8 +++++ src/main/java/me/Danker/utils/Utils.java | 9 ++++++ 7 files changed, 78 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/me/Danker/TheMod.java b/src/main/java/me/Danker/TheMod.java index 8c0660f..44cc938 100644 --- a/src/main/java/me/Danker/TheMod.java +++ b/src/main/java/me/Danker/TheMod.java @@ -96,6 +96,9 @@ public class TheMod public static int titleTimer = -1; public static boolean showTitle = false; public static String titleText = ""; + public static int skillTimer = -1; + public static boolean showSkill = false; + public static String skillText = ""; static int tickAmount = 1; public static String lastMaddoxCommand = "/cb placeholdervalue"; static KeyBinding[] keyBindings = new KeyBinding[1]; @@ -230,9 +233,29 @@ public class TheMod final ToggleCommand tc = new ToggleCommand(); String message = event.message.getUnformattedText(); - if (event.type == 2) return; if (!Utils.inSkyblock) return; + // Action Bar + if (event.type == 2) { + String[] actionBarSections = event.message.getUnformattedText().split(" {3,}"); + for (String section : actionBarSections) { + if (tc.skill50DisplayToggled) { + if (section.contains("(")) { + if (section.contains("Runecrafting")) return; + + String xpGained = section.substring(section.indexOf("+"), section.indexOf("(") - 1); + double currentXp = Double.parseDouble(section.substring(section.indexOf("(") + 1, section.indexOf("/")).replaceAll(",", "")); + int previousXp = Utils.getPastXpEarned(Integer.parseInt(section.substring(section.indexOf("/") + 1, section.indexOf(")")).replaceAll(",", ""))); + + skillTimer = 40; + showSkill = true; + skillText = EnumChatFormatting.AQUA + xpGained + " (" + NumberFormat.getNumberInstance(Locale.US).format(currentXp + previousXp) + "/55,172,425)"; + } + } + } + return; + } + // Replace chat messages with Maddox command List chatSiblings = event.message.getSiblings(); for (IChatComponent sibling : chatSiblings) { @@ -1677,6 +1700,9 @@ public class TheMod if (showTitle) { Utils.drawTitle(titleText); } + if (showSkill) { + new TextRenderer(Minecraft.getMinecraft(), skillText, moc.skill50XY[0], moc.skill50XY[1], ScaleCommand.skill50Scale); + } } @SubscribeEvent(priority = EventPriority.HIGHEST) @@ -1783,6 +1809,12 @@ public class TheMod } titleTimer--; } + if (skillTimer >= 0) { + if (skillTimer == 0) { + showSkill = false; + } + skillTimer--; + } } @SubscribeEvent diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index e4783f2..0afa767 100644 --- a/src/main/java/me/Danker/commands/DHelpCommand.java +++ b/src/main/java/me/Danker/commands/DHelpCommand.java @@ -33,14 +33,14 @@ public class DHelpCommand extends CommandBase { EnumChatFormatting.AQUA + " <> = Mandatory parameter. [] = Optional parameter.\n" + EnumChatFormatting.GOLD + " Commands, " + EnumChatFormatting.GREEN + " Keybinds.\n" + EnumChatFormatting.GOLD + " /dhelp" + EnumChatFormatting.AQUA + " - Returns this message.\n" + - EnumChatFormatting.GOLD + " /toggle " + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" + + EnumChatFormatting.GOLD + " /toggle " + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" + EnumChatFormatting.GOLD + " /setkey " + EnumChatFormatting.AQUA + " - Sets API key.\n" + EnumChatFormatting.GOLD + " /getkey" + EnumChatFormatting.AQUA + " - Returns key set with /setkey and copies it to your clipboard.\n" + EnumChatFormatting.GOLD + " /loot [winter/f(1-5)/session]" + EnumChatFormatting.AQUA + " - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead.\n" + EnumChatFormatting.GOLD + " /display [winter/f(1-5)/session]" + EnumChatFormatting.AQUA + " - Text display for trackers. /display fishing winter displays winter sea creatures instead.\n" + EnumChatFormatting.GOLD + " /resetloot " + EnumChatFormatting.AQUA + " - Resets loot for trackers. /resetloot confirm confirms the reset.\n" + - EnumChatFormatting.GOLD + " /move " + EnumChatFormatting.AQUA + " - Moves text display to specified X and Y coordinates.\n" + - EnumChatFormatting.GOLD + " /scale " + EnumChatFormatting.AQUA + " - Scales text display to a specified multipler between 0.1x and 10x.\n" + + EnumChatFormatting.GOLD + " /move " + EnumChatFormatting.AQUA + " - Moves text display to specified X and Y coordinates.\n" + + EnumChatFormatting.GOLD + " /scale " + EnumChatFormatting.AQUA + " - Scales text display to a specified multipler between 0.1x and 10x.\n" + EnumChatFormatting.GOLD + " /slayer [player]" + EnumChatFormatting.AQUA + " - Uses API to get slayer xp of a person. If no name is provided, it checks yours.\n" + EnumChatFormatting.GOLD + " /skills [player]" + EnumChatFormatting.AQUA + " - Uses API to get skill levels of a person. If no name is provided, it checks yours.\n" + EnumChatFormatting.GOLD + " /guildof [player]" + EnumChatFormatting.AQUA + " - Uses API to get guild name and guild master of a person. If no name is provided, it checks yours.\n" + diff --git a/src/main/java/me/Danker/commands/MoveCommand.java b/src/main/java/me/Danker/commands/MoveCommand.java index bbc62b8..7fb9acd 100644 --- a/src/main/java/me/Danker/commands/MoveCommand.java +++ b/src/main/java/me/Danker/commands/MoveCommand.java @@ -16,6 +16,7 @@ public class MoveCommand extends CommandBase { public static int[] coordsXY = {0, 0}; public static int[] displayXY = {0, 0}; public static int[] dungeonTimerXY = {0, 0}; + public static int[] skill50XY = {0, 0}; @Override public String getCommandName() { @@ -24,7 +25,7 @@ public class MoveCommand extends CommandBase { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " "; + return "/" + getCommandName() + " "; } @Override @@ -35,7 +36,7 @@ public class MoveCommand extends CommandBase { @Override public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "coords", "display", "dungeontimer"); + return getListOfStringsMatchingLastWord(args, "coords", "display", "dungeontimer", "skill50"); } return null; } @@ -68,6 +69,12 @@ public class MoveCommand extends CommandBase { cf.writeIntConfig("locations", "dungeonTimerX", dungeonTimerXY[0]); cf.writeIntConfig("locations", "dungeonTimerY", dungeonTimerXY[1]); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Dungeon timer has been moved to " + EnumChatFormatting.DARK_GREEN + arg1[1] + ", " + arg1[2])); + } else if (arg1[0].equalsIgnoreCase("skill50")) { + skill50XY[0] = Integer.parseInt(arg1[1]); + skill50XY[1] = Integer.parseInt(arg1[2]); + cf.writeIntConfig("locations", "skill50X", skill50XY[0]); + cf.writeIntConfig("locations", "skill50Y", skill50XY[1]); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Skill 50 display has been moved to " + EnumChatFormatting.DARK_GREEN + arg1[1] + ", " + arg1[2])); } else { player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(arg0))); } diff --git a/src/main/java/me/Danker/commands/ScaleCommand.java b/src/main/java/me/Danker/commands/ScaleCommand.java index cd53add..5f21b77 100644 --- a/src/main/java/me/Danker/commands/ScaleCommand.java +++ b/src/main/java/me/Danker/commands/ScaleCommand.java @@ -16,6 +16,7 @@ public class ScaleCommand extends CommandBase { public static double coordsScale; public static double displayScale; public static double dungeonTimerScale; + public static double skill50Scale; @Override public String getCommandName() { @@ -24,7 +25,7 @@ public class ScaleCommand extends CommandBase { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " "; + return "/" + getCommandName() + " "; } @Override @@ -35,7 +36,7 @@ public class ScaleCommand extends CommandBase { @Override public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "coords", "display", "dungeontimer"); + return getListOfStringsMatchingLastWord(args, "coords", "display", "dungeontimer", "skill50"); } return null; } @@ -67,6 +68,10 @@ public class ScaleCommand extends CommandBase { dungeonTimerScale = scaleAmount; ConfigHandler.writeDoubleConfig("scales", "dungeonTimerScale", dungeonTimerScale); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Dungeon timer has been scaled to " + EnumChatFormatting.DARK_GREEN + dungeonTimerScale + "x")); + } else if (arg1[0].equalsIgnoreCase("skill50")) { + skill50Scale = scaleAmount; + ConfigHandler.writeDoubleConfig("scales", "skill50Scale", skill50Scale); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Skill 50 display has been scaled to " + EnumChatFormatting.DARK_GREEN + skill50Scale + "x")); } else { player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(arg0))); } diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 321eb33..0172ab1 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -27,6 +27,7 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean dungeonTimerToggled; public static boolean golemAlertToggled; public static boolean expertiseLoreToggled; + public static boolean skill50DisplayToggled; @Override public String getCommandName() { @@ -35,7 +36,7 @@ public class ToggleCommand extends CommandBase implements ICommand { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " "; + return "/" + getCommandName() + " "; } @Override @@ -46,7 +47,7 @@ public class ToggleCommand extends CommandBase implements ICommand { @Override public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "gparty", "coords", "golden", "slayercount", "rngesusalerts", "splitfishing", "chatmaddox", "spiritbearalerts", "aotd", "sceptremessages", "petcolors", "dungeontimer", "golemalerts", "expertiselore", "list"); + return getListOfStringsMatchingLastWord(args, "gparty", "coords", "golden", "slayercount", "rngesusalerts", "splitfishing", "chatmaddox", "spiritbearalerts", "aotd", "sceptremessages", "petcolors", "dungeontimer", "golemalerts", "expertiselore", "skill50display", "list"); } return null; } @@ -117,6 +118,10 @@ public class ToggleCommand extends CommandBase implements ICommand { expertiseLoreToggled = !expertiseLoreToggled; cf.writeBooleanConfig("toggles", "ExpertiseLore", expertiseLoreToggled); player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Expertise in lore has been set to " + EnumChatFormatting.DARK_GREEN + expertiseLoreToggled + EnumChatFormatting.GREEN + ".")); + } else if (arg1[0].equalsIgnoreCase("skill50display")) { + skill50DisplayToggled = !skill50DisplayToggled; + cf.writeBooleanConfig("toggles", "Skill50Display", skill50DisplayToggled); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Skill 50 display has been set to " + EnumChatFormatting.DARK_GREEN + skill50DisplayToggled + EnumChatFormatting.GREEN + ".")); } else if (arg1[0].equalsIgnoreCase("list")) { player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Guild party notifications: " + EnumChatFormatting.DARK_GREEN + gpartyToggled + "\n" + EnumChatFormatting.GREEN + " Coord/Angle display: " + EnumChatFormatting.DARK_GREEN + coordsToggled + "\n" + @@ -131,7 +136,8 @@ public class ToggleCommand extends CommandBase implements ICommand { EnumChatFormatting.GREEN + " Pet colours: " + EnumChatFormatting.DARK_GREEN + petColoursToggled + "\n" + EnumChatFormatting.GREEN + " Dungeon timer: " + EnumChatFormatting.DARK_GREEN + dungeonTimerToggled + "\n" + EnumChatFormatting.GREEN + " Golem spawn alerts: " + EnumChatFormatting.DARK_GREEN + golemAlertToggled + "\n" + - EnumChatFormatting.GREEN + " Expertise in lore: " + EnumChatFormatting.DARK_GREEN + expertiseLoreToggled)); + EnumChatFormatting.GREEN + " Expertise in lore: " + EnumChatFormatting.DARK_GREEN + expertiseLoreToggled + "\n" + + EnumChatFormatting.GREEN + " Skill 50 display: " + EnumChatFormatting.DARK_GREEN + skill50DisplayToggled)); } else { player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(arg0))); } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index e58d092..ac7d656 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -185,6 +185,7 @@ public class ConfigHandler { if (!hasKey("toggles", "BlockSlayer")) writeStringConfig("toggles", "BlockSlayer", ""); if (!hasKey("toggles", "GolemAlerts")) writeBooleanConfig("toggles", "GolemAlerts", false); if (!hasKey("toggles", "ExpertiseLore")) writeBooleanConfig("toggles", "ExpertiseLore", true); + if (!hasKey("toggles", "Skill50Display")) writeBooleanConfig("toggles", "Skill50Display", false); if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", ""); @@ -312,9 +313,12 @@ public class ConfigHandler { if (!hasKey("locations", "displayY")) writeIntConfig("locations", "displayY", 5); if (!hasKey("locations", "dungeonTimerX")) writeIntConfig("locations", "dungeonTimerX", 5); if (!hasKey("locations", "dungeonTimerY")) writeIntConfig("locations", "dungeonTimerY", 5); + if (!hasKey("locations", "skill50X")) writeIntConfig("locations", "skill50X", 40); + if (!hasKey("locations", "skill50Y")) writeIntConfig("locations", "skill50Y", 10); if (!hasKey("scales", "coordsScale")) writeDoubleConfig("scales", "coordsScale", 1); if (!hasKey("scales", "displayScale")) writeDoubleConfig("scales", "displayScale", 1); if (!hasKey("scales", "dungeonTimerScale")) writeDoubleConfig("scales", "dungeonTimerScale", 1); + if (!hasKey("scales", "skill50Scale")) writeDoubleConfig("scales", "skill50Scale", 1); final ToggleCommand tf = new ToggleCommand(); tf.gpartyToggled = getBoolean("toggles", "GParty"); @@ -331,6 +335,7 @@ public class ConfigHandler { tf.dungeonTimerToggled = getBoolean("toggles", "DungeonTimer"); tf.golemAlertToggled = getBoolean("toggles", "GolemAlerts"); tf.expertiseLoreToggled = getBoolean("toggles", "ExpertiseLore"); + tf.skill50DisplayToggled = getBoolean("toggles", "Skill50Display"); final BlockSlayerCommand bs = new BlockSlayerCommand(); String onlySlayer = getString("toggles", "BlockSlayer"); @@ -464,11 +469,14 @@ public class ConfigHandler { moc.displayXY[1] = getInt("locations", "displayY"); moc.dungeonTimerXY[0] = getInt("locations", "dungeonTimerX"); moc.dungeonTimerXY[1] = getInt("locations", "dungeonTimerY"); + moc.skill50XY[0] = getInt("locations", "skill50X"); + moc.skill50XY[1] = getInt("locations", "skill50Y"); final ScaleCommand sc = new ScaleCommand(); sc.coordsScale = getDouble("scales", "coordsScale"); sc.displayScale = getDouble("scales", "displayScale"); sc.dungeonTimerScale = getDouble("scales", "dungeonTimerScale"); + sc.skill50Scale = getDouble("scales", "skill50Scale"); } } diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java index d7aa112..e6f35b4 100644 --- a/src/main/java/me/Danker/utils/Utils.java +++ b/src/main/java/me/Danker/utils/Utils.java @@ -212,4 +212,13 @@ public class Utils { return -1; } + public static int getPastXpEarned(int currentLevelXp) { + if (currentLevelXp == 0) return 55172425; + for (int i = 1, xpAdded = 0; i < skillXPPerLevel.length; i++) { + xpAdded += skillXPPerLevel[i - 1]; + if (currentLevelXp == skillXPPerLevel[i]) return xpAdded; + } + return 0; + } + } -- cgit