aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2020-08-05 20:28:13 -0400
committerbowser0000 <bowser0000@gmail.com>2020-08-05 20:28:13 -0400
commitcd9303b0c510005f6162468beb26eb4ec397a757 (patch)
tree75cd784c1829139bdbfb2b5c63dd4bd2dd59f410
parent92b0a7959090b56ab313f77143ffd07a1483ea71 (diff)
downloadSkyblockMod-cd9303b0c510005f6162468beb26eb4ec397a757.tar.gz
SkyblockMod-cd9303b0c510005f6162468beb26eb4ec397a757.tar.bz2
SkyblockMod-cd9303b0c510005f6162468beb26eb4ec397a757.zip
Add ability to reset trackers
With confirmation in case some person decides to randomly type /resetloot
-rw-r--r--README.md1
-rw-r--r--me/Danker/TheMod.java2
-rw-r--r--me/Danker/commands/DHelpCommand.java1
-rw-r--r--me/Danker/commands/ResetLootCommand.java177
-rw-r--r--me/Danker/handlers/ConfigHandler.java31
5 files changed, 204 insertions, 8 deletions
diff --git a/README.md b/README.md
index b4cf7cb..c05317c 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ QOL changes that enhances your Hypixel Skyblock experience. Created to add featu
- /loot <zombie/spider/wolf/fishing> [winter/session] - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead.
- /display <zombie/spider/wolf/fishing/off> [winter/session] - Text display for trackers. /display fishing winter displays winter sea creatures instead.
- /move <coords/display> <x> <y> - Moves text display to specified X and Y coordinates.
+- /resetloot <zombie/spider/wolf/fishing/confirm/cancel> - - Resets loot for trackers. /resetloot confirm confirms the reset.
- /slayer [player] - Uses API to get slayer xp of a person. If no name is provided, it checks yours.
- /skills [player] - Uses API to get skill levels of a person. If no name is provided, it checks yours.
- /guildof [player] - Uses API to get guild name and guild master of a person. If no name is provided, it checks yours.
diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java
index b6cf9be..1ef3b84 100644
--- a/me/Danker/TheMod.java
+++ b/me/Danker/TheMod.java
@@ -24,6 +24,7 @@ import me.Danker.commands.LootCommand;
import me.Danker.commands.MoveCommand;
import me.Danker.commands.PetsCommand;
import me.Danker.commands.ReloadConfigCommand;
+import me.Danker.commands.ResetLootCommand;
import me.Danker.commands.SetkeyCommand;
import me.Danker.commands.SkillsCommand;
import me.Danker.commands.SlayerCommand;
@@ -125,6 +126,7 @@ public class TheMod
ClientCommandHandler.instance.registerCommand(new BankCommand());
ClientCommandHandler.instance.registerCommand(new ArmourCommand());
ClientCommandHandler.instance.registerCommand(new ImportFishingCommand());
+ ClientCommandHandler.instance.registerCommand(new ResetLootCommand());
}
// Update checker
diff --git a/me/Danker/commands/DHelpCommand.java b/me/Danker/commands/DHelpCommand.java
index e4bc278..e36adb0 100644
--- a/me/Danker/commands/DHelpCommand.java
+++ b/me/Danker/commands/DHelpCommand.java
@@ -37,6 +37,7 @@ public class DHelpCommand extends CommandBase {
EnumChatFormatting.GOLD + " /getkey" + EnumChatFormatting.AQUA + " - Returns key set with /setkey.\n" +
EnumChatFormatting.GOLD + " /loot <zombie/spider/wolf/fishing> [winter/session]" + EnumChatFormatting.AQUA + " - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead.\n" +
EnumChatFormatting.GOLD + " /display <zombie/spider/wolf/fishing/off> [winter/session]" + EnumChatFormatting.AQUA + " - Text display for trackers. /display fishing winter displays winter sea creatures instead.\n" +
+ EnumChatFormatting.GOLD + "/resetloot <zombie/spider/wolf/fishing/confirm/cancel>" + EnumChatFormatting.AQUA + " - Resets loot for trackers. /resetloot confirm confirms the reset.\n" +
EnumChatFormatting.GOLD + " /move <coords/display> <x> <y>" + EnumChatFormatting.AQUA + " - Moves text display to specified X and Y coordinates.\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" +
diff --git a/me/Danker/commands/ResetLootCommand.java b/me/Danker/commands/ResetLootCommand.java
new file mode 100644
index 0000000..af58a8d
--- /dev/null
+++ b/me/Danker/commands/ResetLootCommand.java
@@ -0,0 +1,177 @@
+package me.Danker.commands;
+
+import java.util.List;
+
+import me.Danker.handlers.ConfigHandler;
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+
+public class ResetLootCommand extends CommandBase {
+
+ static String resetOption;
+ static boolean confirmReset = false;
+
+ @Override
+ public String getCommandName() {
+ return "resetloot";
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender arg0) {
+ return getCommandName() + "<zombie/spider/wolf/fishing/confirm/cancel>";
+ }
+
+ @Override
+ public int getRequiredPermissionLevel() {
+ return 0;
+ }
+
+ @Override
+ public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
+ if (args.length != 1) return null;
+
+ if (confirmReset) {
+ return getListOfStringsMatchingLastWord(args, "confirm", "cancel");
+ } else {
+ return getListOfStringsMatchingLastWord(args, "zombie", "spider", "wolf", "fishing");
+ }
+ }
+
+ @Override
+ public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException {
+ final EntityPlayer player = (EntityPlayer) arg0;
+
+ if (arg1.length == 0) {
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: /resetloot <zombie/spider/wolf/fishing>"));
+ return;
+ }
+
+ if (confirmReset) {
+ if (arg1[0].equalsIgnoreCase("confirm")) {
+ confirmReset = false;
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Resetting " + resetOption + " tracker..."));
+ if (resetOption.equalsIgnoreCase("zombie")) {
+ resetZombie();
+ } else if (resetOption.equalsIgnoreCase("spider")) {
+ resetSpider();
+ } else if (resetOption.equalsIgnoreCase("wolf")) {
+ resetWolf();
+ } else if (resetOption.equalsIgnoreCase("fishing")) {
+ resetFishing();
+ }
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Reset complete."));
+ } else if (arg1[0].equalsIgnoreCase("cancel")) {
+ confirmReset = false;
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Reset cancelled."));
+ } else {
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Please confirm the reset of the " + resetOption + " tracker by using /resetloot confirm." +
+ EnumChatFormatting.RED + " Cancel by using /resetloot cancel."));
+ }
+ } else {
+ if (arg1[0].equalsIgnoreCase("zombie") || arg1[0].equalsIgnoreCase("spider") || arg1[0].equalsIgnoreCase("wolf") || arg1[0].equalsIgnoreCase("fishing")) {
+ resetOption = arg1[0];
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Are you sure you want to reset the " + resetOption + " tracker?" +
+ " Confirm with " + EnumChatFormatting.GREEN + "/resetloot confirm" + EnumChatFormatting.YELLOW + "." +
+ " Cancel by using " + EnumChatFormatting.GREEN + "/resetloot cancel" + EnumChatFormatting.YELLOW + "."));
+ confirmReset = true;
+ } else if (arg1[0].equalsIgnoreCase("confirm") || arg1[0].equalsIgnoreCase("cancel")) {
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Pick something to reset first."));
+ } else {
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: /resetloot <zombie/spider/wolf/fishing>"));
+ }
+ }
+ }
+
+ static void resetZombie() {
+ LootCommand lc = new LootCommand();
+ ConfigHandler cf = new ConfigHandler();
+
+ lc.zombieRevsSession = 0;
+ lc.zombieRevFleshSession = 0;
+ lc.zombieFoulFleshSession = 0;
+ lc.zombiePestilencesSession = 0;
+ lc.zombieUndeadCatasSession = 0;
+ lc.zombieBooksSession = 0;
+ lc.zombieBeheadedsSession = 0;
+ lc.zombieRevCatasSession = 0;
+ lc.zombieSnakesSession = 0;
+ lc.zombieScythesSession = 0;
+ lc.zombieTimeSession = -1;
+ lc.zombieBossesSession = -1;
+ cf.deleteCategory("zombie");
+ cf.reloadConfig();
+ }
+
+ static void resetSpider() {
+ LootCommand lc = new LootCommand();
+ ConfigHandler cf = new ConfigHandler();
+
+ lc.spiderTarantulasSession = 0;
+ lc.spiderWebsSession = 0;
+ lc.spiderTAPSession = 0;
+ lc.spiderBitesSession = 0;
+ lc.spiderCatalystsSession = 0;
+ lc.spiderBooksSession = 0;
+ lc.spiderSwattersSession = 0;
+ lc.spiderTalismansSession = 0;
+ lc.spiderMosquitosSession = 0;
+ lc.spiderTimeSession = -1;
+ lc.spiderBossesSession = -1;
+ cf.deleteCategory("spider");
+ cf.reloadConfig();
+ }
+
+ static void resetWolf() {
+ LootCommand lc = new LootCommand();
+ ConfigHandler cf = new ConfigHandler();
+ lc.wolfSvensSession = 0;
+ lc.wolfTeethSession = 0;
+ lc.wolfWheelsSession = 0;
+ lc.wolfSpiritsSession = 0;
+ lc.wolfBooksSession = 0;
+ lc.wolfEggsSession = 0;
+ lc.wolfCouturesSession = 0;
+ lc.wolfBaitsSession = 0;
+ lc.wolfFluxesSession = 0;
+ lc.wolfTimeSession = -1;
+ lc.wolfBossesSession = -1;
+ cf.deleteCategory("wolf");
+ cf.reloadConfig();
+ }
+
+ static void resetFishing() {
+ LootCommand lc = new LootCommand();
+ ConfigHandler cf = new ConfigHandler();
+ lc.seaCreaturesSession = 0;
+ lc.goodCatchesSession = 0;
+ lc.greatCatchesSession = 0;
+ lc.squidsSession = 0;
+ lc.seaWalkersSession = 0;
+ lc.nightSquidsSession = 0;
+ lc.seaGuardiansSession = 0;
+ lc.seaWitchesSession = 0;
+ lc.seaArchersSession = 0;
+ lc.monsterOfTheDeepsSession = 0;
+ lc.catfishesSession = 0;
+ lc.carrotKingsSession = 0;
+ lc.seaLeechesSession = 0;
+ lc.guardianDefendersSession = 0;
+ lc.deepSeaProtectorsSession = 0;
+ lc.hydrasSession = 0;
+ lc.seaEmperorsSession = 0;
+ lc.empTimeSession = -1;
+ lc.empSCsSession = -1;
+ lc.frozenStevesSession = 0;
+ lc.frostyTheSnowmansSession = 0;
+ lc.grinchesSession = 0;
+ lc.yetisSession = 0;
+ cf.deleteCategory("fishing");
+ cf.reloadConfig();
+ }
+
+}
diff --git a/me/Danker/handlers/ConfigHandler.java b/me/Danker/handlers/ConfigHandler.java
index 95aa3fe..9d7c110 100644
--- a/me/Danker/handlers/ConfigHandler.java
+++ b/me/Danker/handlers/ConfigHandler.java
@@ -8,6 +8,7 @@ import me.Danker.commands.MoveCommand;
import me.Danker.commands.ToggleCommand;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
+import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.Configuration;
public class ConfigHandler {
@@ -19,7 +20,7 @@ public class ConfigHandler {
try {
config.load();
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
@@ -33,7 +34,7 @@ public class ConfigHandler {
return config.get(category, key, 0).getInt();
}
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
@@ -63,7 +64,7 @@ public class ConfigHandler {
return config.get(category, key, "").getString();
}
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
@@ -78,7 +79,7 @@ public class ConfigHandler {
return config.get(category, key, false).getBoolean();
}
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
@@ -92,7 +93,7 @@ public class ConfigHandler {
int set = config.get(category, key, value).getInt();
config.getCategory(category).get(key).set(value);
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
@@ -118,7 +119,7 @@ public class ConfigHandler {
String set = config.get(category, key, value).getString();
config.getCategory(category).get(key).set(value);
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
@@ -131,7 +132,7 @@ public class ConfigHandler {
boolean set = config.get(category, key, value).getBoolean();
config.getCategory(category).get(key).set(value);
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
@@ -144,13 +145,27 @@ public class ConfigHandler {
if (!config.hasCategory(category)) return false;
return config.getCategory(category).containsKey(key);
} catch (Exception ex) {
- System.err.print(ex);
+ System.err.println(ex);
} finally {
config.save();
}
return false;
}
+ public static void deleteCategory(String category) {
+ config = new Configuration(new File(file));
+ try {
+ config.load();
+ if (config.hasCategory(category)) {
+ config.removeCategory(new ConfigCategory(category));
+ }
+ } catch (Exception ex) {
+ System.err.println(ex);
+ } finally {
+ config.save();
+ }
+ }
+
public static void reloadConfig() {
// Config init
if (!hasKey("toggles", "GParty")) writeBooleanConfig("toggles", "GParty", false);