diff options
Diffstat (limited to 'src/main/java/me/Danker/features')
9 files changed, 234 insertions, 6 deletions
diff --git a/src/main/java/me/Danker/features/Alerts.java b/src/main/java/me/Danker/features/Alerts.java index 8f45423..e54a212 100644 --- a/src/main/java/me/Danker/features/Alerts.java +++ b/src/main/java/me/Danker/features/Alerts.java @@ -3,6 +3,7 @@ package me.Danker.features; import com.google.gson.GsonBuilder; import javafx.scene.control.Alert; import me.Danker.commands.ToggleCommand; +import me.Danker.events.ModInitEvent; import me.Danker.utils.Utils; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StringUtils; @@ -25,6 +26,11 @@ public class Alerts { public static String configFile; @SubscribeEvent + public void init(ModInitEvent event) { + configFile = event.configDirectory + "/dsmalerts.json"; + } + + @SubscribeEvent public void onChat(ClientChatReceivedEvent event) { if (!ToggleCommand.alerts || event.type == 2) return; diff --git a/src/main/java/me/Danker/features/ChatAliases.java b/src/main/java/me/Danker/features/ChatAliases.java index ae9e0f7..76ab5f6 100644 --- a/src/main/java/me/Danker/features/ChatAliases.java +++ b/src/main/java/me/Danker/features/ChatAliases.java @@ -1,6 +1,7 @@ package me.Danker.features; import com.google.gson.GsonBuilder; +import me.Danker.events.ModInitEvent; import me.Danker.events.PacketWriteEvent; import net.minecraft.client.Minecraft; import net.minecraft.network.play.client.C01PacketChatMessage; @@ -17,6 +18,11 @@ public class ChatAliases { public static String configFile; @SubscribeEvent + public void init(ModInitEvent event) { + configFile = event.configDirectory + "/dsmaliases.json"; + } + + @SubscribeEvent public void onPacketWrite(PacketWriteEvent event) { if (event.packet instanceof C01PacketChatMessage) { C01PacketChatMessage packet = (C01PacketChatMessage) event.packet; diff --git a/src/main/java/me/Danker/features/CustomMusic.java b/src/main/java/me/Danker/features/CustomMusic.java index 8ce8c05..e6f8131 100644 --- a/src/main/java/me/Danker/features/CustomMusic.java +++ b/src/main/java/me/Danker/features/CustomMusic.java @@ -2,6 +2,7 @@ package me.Danker.features; import me.Danker.DankersSkyblockMod; import me.Danker.commands.ToggleCommand; +import me.Danker.events.ModInitEvent; import me.Danker.handlers.ScoreboardHandler; import me.Danker.utils.Utils; import net.minecraft.client.Minecraft; @@ -13,6 +14,7 @@ import net.minecraft.world.World; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -196,6 +198,11 @@ public class CustomMusic { } } + @SubscribeEvent + public void init(ModInitEvent event) { + init(event.configDirectory); + } + public static void init(String configDirectory) { if (configDirectory == null) return; File directory = new File(configDirectory + "/dsmmusic"); diff --git a/src/main/java/me/Danker/features/GemstonesLore.java b/src/main/java/me/Danker/features/GemstonesLore.java index 7db2d33..b16edaf 100644 --- a/src/main/java/me/Danker/features/GemstonesLore.java +++ b/src/main/java/me/Danker/features/GemstonesLore.java @@ -1,6 +1,7 @@ package me.Danker.features; import me.Danker.commands.ToggleCommand; +import me.Danker.events.ModInitEvent; import me.Danker.utils.Utils; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; @@ -18,7 +19,8 @@ public class GemstonesLore { static Map<String, EnumChatFormatting> gemstoneColours = new HashMap<>(); - public static void init() { + @SubscribeEvent + public void init(ModInitEvent event) { gemstoneColours.put("Amber", EnumChatFormatting.GOLD); gemstoneColours.put("Sapphire", EnumChatFormatting.AQUA); gemstoneColours.put("Jasper", EnumChatFormatting.LIGHT_PURPLE); diff --git a/src/main/java/me/Danker/features/GoldenEnchants.java b/src/main/java/me/Danker/features/GoldenEnchants.java index d633ec5..228d43e 100644 --- a/src/main/java/me/Danker/features/GoldenEnchants.java +++ b/src/main/java/me/Danker/features/GoldenEnchants.java @@ -1,6 +1,7 @@ package me.Danker.features; import me.Danker.commands.ToggleCommand; +import me.Danker.events.ModInitEvent; import me.Danker.utils.Utils; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; @@ -15,7 +16,8 @@ public class GoldenEnchants { public static Map<String, String> t6Enchants = new HashMap<>(); public static Pattern t6EnchantPattern = Pattern.compile(""); - public static void init() { + @SubscribeEvent + public void init(ModInitEvent event) { t6Enchants.put("9Angler VI", "6Angler VI"); t6Enchants.put("9Bane of Arthropods VI", "6Bane of Arthropods VI"); t6Enchants.put("9Caster VI", "6Caster VI"); diff --git a/src/main/java/me/Danker/features/MinionLastCollected.java b/src/main/java/me/Danker/features/MinionLastCollected.java index 884dccf..7079f40 100644 --- a/src/main/java/me/Danker/features/MinionLastCollected.java +++ b/src/main/java/me/Danker/features/MinionLastCollected.java @@ -3,6 +3,7 @@ package me.Danker.features; import com.google.gson.GsonBuilder; import me.Danker.commands.ToggleCommand; import me.Danker.events.ChestSlotClickedEvent; +import me.Danker.events.ModInitEvent; import me.Danker.events.PacketWriteEvent; import me.Danker.utils.RenderUtils; import me.Danker.utils.Utils; @@ -29,6 +30,11 @@ public class MinionLastCollected { public static int LAST_COLLECTED_COLOUR; @SubscribeEvent + public void init(ModInitEvent event) { + configFile = event.configDirectory + "/dsmminions.json"; + } + + @SubscribeEvent public void onPacketWrite(PacketWriteEvent event) { if (ToggleCommand.minionLastCollected && Utils.inSkyblock && Utils.isInScoreboard("Your Island")) { if (event.packet instanceof C02PacketUseEntity) { diff --git a/src/main/java/me/Danker/features/loot/LootDisplay.java b/src/main/java/me/Danker/features/loot/LootDisplay.java index 7832362..556108c 100644 --- a/src/main/java/me/Danker/features/loot/LootDisplay.java +++ b/src/main/java/me/Danker/features/loot/LootDisplay.java @@ -946,6 +946,82 @@ public class LootDisplay { EnumChatFormatting.AQUA + timeBetween + "\n" + EnumChatFormatting.AQUA + bossesBetween; break; + case "fishing_trophy": + dropsText = EnumChatFormatting.WHITE + "Sulpher Skitter:\n" + + EnumChatFormatting.WHITE + "Obfuscated 1:\n" + + EnumChatFormatting.WHITE + "Steaminghot Flounder:\n" + + EnumChatFormatting.WHITE + "Gusher:\n" + + EnumChatFormatting.WHITE + "Blobfish:\n" + + EnumChatFormatting.GREEN + "Obfuscated 2:\n" + + EnumChatFormatting.GREEN + "Slugfish:\n" + + EnumChatFormatting.GREEN + "Flyfish:\n" + + EnumChatFormatting.BLUE + "Obfuscated 3:\n" + + EnumChatFormatting.BLUE + "Lavahorse:\n" + + EnumChatFormatting.BLUE + "Mana Ray:\n" + + EnumChatFormatting.BLUE + "Volcanic Stonefish:\n" + + EnumChatFormatting.BLUE + "Vanille:\n" + + EnumChatFormatting.DARK_PURPLE + "Skeleton Fish:\n" + + EnumChatFormatting.DARK_PURPLE + "Moldfin:\n" + + EnumChatFormatting.DARK_PURPLE + "Soul Fish:\n" + + EnumChatFormatting.DARK_PURPLE + "Karate Fish:\n" + + EnumChatFormatting.GOLD + "Golden Fish:"; + countText = EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Sulpher Skitter") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Obfuscated 1") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Steaming-Hot Flounder") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Gusher") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Blobfish") + "\n" + + EnumChatFormatting.GREEN + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Obfuscated 2") + "\n" + + EnumChatFormatting.GREEN + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Slugfish") + "\n" + + EnumChatFormatting.GREEN + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Flyfish") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Obfuscated 3") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Lavahorse") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Mana Ray") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Volcanic Stonefish") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Vanille") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Skeleton Fish") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Moldfin") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Soul Fish") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Karate Fish") + "\n" + + EnumChatFormatting.GOLD + TrophyFishTracker.getTierCount(TrophyFishTracker.fish, "Golden Fish"); + break; + case "fishing_trophy_session": + dropsText = EnumChatFormatting.WHITE + "Sulpher Skitter:\n" + + EnumChatFormatting.WHITE + "Obfuscated 1:\n" + + EnumChatFormatting.WHITE + "Steaminghot Flounder:\n" + + EnumChatFormatting.WHITE + "Gusher:\n" + + EnumChatFormatting.WHITE + "Blobfish:\n" + + EnumChatFormatting.GREEN + "Obfuscated 2:\n" + + EnumChatFormatting.GREEN + "Slugfish:\n" + + EnumChatFormatting.GREEN + "Flyfish:\n" + + EnumChatFormatting.BLUE + "Obfuscated 3:\n" + + EnumChatFormatting.BLUE + "Lavahorse:\n" + + EnumChatFormatting.BLUE + "Mana Ray:\n" + + EnumChatFormatting.BLUE + "Volcanic Stonefish:\n" + + EnumChatFormatting.BLUE + "Vanille:\n" + + EnumChatFormatting.DARK_PURPLE + "Skeleton Fish:\n" + + EnumChatFormatting.DARK_PURPLE + "Moldfin:\n" + + EnumChatFormatting.DARK_PURPLE + "Soul Fish:\n" + + EnumChatFormatting.DARK_PURPLE + "Karate Fish:\n" + + EnumChatFormatting.GOLD + "Golden Fish:"; + countText = EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Sulpher Skitter") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Obfuscated 1") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Steaming-Hot Flounder") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Gusher") + "\n" + + EnumChatFormatting.WHITE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Blobfish") + "\n" + + EnumChatFormatting.GREEN + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Obfuscated 2") + "\n" + + EnumChatFormatting.GREEN + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Slugfish") + "\n" + + EnumChatFormatting.GREEN + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Flyfish") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Obfuscated 3") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Lavahorse") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Mana Ray") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Volcanic Stonefish") + "\n" + + EnumChatFormatting.BLUE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Vanille") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Skeleton Fish") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Moldfin") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Soul Fish") + "\n" + + EnumChatFormatting.DARK_PURPLE + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Karate Fish") + "\n" + + EnumChatFormatting.GOLD + TrophyFishTracker.getTierCount(TrophyFishTracker.fishSession, "Golden Fish"); + break; case "mythological": dropsText = EnumChatFormatting.GOLD + "Coins:\n" + EnumChatFormatting.WHITE + "Griffin Feathers:\n" + diff --git a/src/main/java/me/Danker/features/loot/TrophyFishTracker.java b/src/main/java/me/Danker/features/loot/TrophyFishTracker.java new file mode 100644 index 0000000..d11fcfe --- /dev/null +++ b/src/main/java/me/Danker/features/loot/TrophyFishTracker.java @@ -0,0 +1,120 @@ +package me.Danker.features.loot; + +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import me.Danker.events.ModInitEvent; +import me.Danker.utils.Utils; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StringUtils; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TrophyFishTracker { + + public static JsonObject fish = new JsonObject(); + public static JsonObject fishSession = new JsonObject(); + public static Pattern fishPattern = Pattern.compile("TROPHY FISH! You caught a (?<fish>.*) (?<tier>.*)."); + public static String configFile; + + public static JsonObject createEmpty() { + JsonObject fish = new JsonObject(); + + JsonObject tiers = new JsonObject(); + tiers.addProperty("BRONZE", 0); + tiers.addProperty("SILVER", 0); + tiers.addProperty("GOLD", 0); + tiers.addProperty("DIAMOND", 0); + + fish.add("Sulpher Skitter", Utils.deepCopy(tiers)); + fish.add("Obfuscated 1", Utils.deepCopy(tiers)); + fish.add("Steaming-Hot Flounder", Utils.deepCopy(tiers)); + fish.add("Obfuscated 2", Utils.deepCopy(tiers)); + fish.add("Gusher", Utils.deepCopy(tiers)); + fish.add("Blobfish", Utils.deepCopy(tiers)); + fish.add("Slugfish", Utils.deepCopy(tiers)); + fish.add("Obfuscated 3", Utils.deepCopy(tiers)); + fish.add("Flyfish", Utils.deepCopy(tiers)); + fish.add("Lavahorse", Utils.deepCopy(tiers)); + fish.add("Mana Ray", Utils.deepCopy(tiers)); + fish.add("Volcanic Stonefish", Utils.deepCopy(tiers)); + fish.add("Vanille", Utils.deepCopy(tiers)); + fish.add("Skeleton Fish", Utils.deepCopy(tiers)); + fish.add("Moldfin", Utils.deepCopy(tiers)); + fish.add("Soul Fish", Utils.deepCopy(tiers)); + fish.add("Karate Fish", Utils.deepCopy(tiers)); + fish.add("Golden Fish", Utils.deepCopy(tiers)); + + return fish; + } + + @SubscribeEvent + public void init(ModInitEvent event) { + configFile = event.configDirectory + "/dsmtrophyfish.json"; + if (fish.entrySet().isEmpty()) fish = createEmpty(); + fishSession = createEmpty(); + } + + @SubscribeEvent(receiveCanceled = true) + public void onChat(ClientChatReceivedEvent event) { + String message = StringUtils.stripControlCodes(event.message.getUnformattedText()); + + if (!Utils.inSkyblock) return; + if (!Utils.tabLocation.equals("Crimson Isle")) return; + if (event.type == 2) return; + if (message.contains(":")) return; + + Matcher matcher = fishPattern.matcher(message); + + if (matcher.matches()) { + String fishName = matcher.group("fish"); + String tier = matcher.group("tier"); + + JsonObject fishObj = fish.get(fishName).getAsJsonObject(); + int amount = fishObj.get(tier).getAsInt(); + fishObj.addProperty(tier, amount + 1); + + JsonObject fishSessionObj = fishSession.get(fishName).getAsJsonObject(); + int amountSession = fishSessionObj.get(tier).getAsInt(); + fishSessionObj.addProperty(tier, amountSession + 1); + + save(); + } + } + + public static void save() { + try (FileWriter writer = new FileWriter(configFile)) { + new GsonBuilder().create().toJson(fish, writer); + writer.flush(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + public static String getTierCount(JsonObject obj, String name) { + JsonObject type = obj.get(name).getAsJsonObject(); + + int bronze = type.get("BRONZE").getAsInt(); + int silver = type.get("SILVER").getAsInt(); + int gold = type.get("GOLD").getAsInt(); + int diamond = type.get("DIAMOND").getAsInt(); + + return EnumChatFormatting.DARK_GRAY + "" + bronze + EnumChatFormatting.WHITE + "-" + + EnumChatFormatting.GRAY + silver + EnumChatFormatting.WHITE + "-" + + EnumChatFormatting.GOLD + gold + EnumChatFormatting.WHITE + "-" + + EnumChatFormatting.AQUA + diamond; + } + + public static int getSum(JsonObject obj, String name) { + JsonObject type = obj.get(name).getAsJsonObject(); + return type.get("BRONZE").getAsInt() + + type.get("SILVER").getAsInt() + + type.get("GOLD").getAsInt() + + type.get("DIAMOND").getAsInt(); + } + +} diff --git a/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java index dd2c23e..23d0228 100644 --- a/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java +++ b/src/main/java/me/Danker/features/puzzlesolvers/TriviaSolver.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import me.Danker.DankersSkyblockMod; import me.Danker.commands.ToggleCommand; +import me.Danker.events.ModInitEvent; import me.Danker.utils.Utils; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -26,7 +27,8 @@ public class TriviaSolver { static JsonArray triviaAnswersJson = null; public static String TRIVIA_WRONG_ANSWER_COLOUR; - public static void init() { + @SubscribeEvent + public void init(ModInitEvent event) { // Hard coded solutions if api call fails triviaSolutions.put("What is the status of The Watcher?", new String[]{"Stalker"}); triviaSolutions.put("What is the status of Bonzo?", new String[]{"New Necromancer"}); @@ -39,11 +41,12 @@ public class TriviaSolver { triviaSolutions.put("What is the status of Goldor?", new String[]{"Wither Soldier"}); triviaSolutions.put("What is the status of Storm?", new String[]{"Elementalist"}); triviaSolutions.put("What is the status of Necron?", new String[]{"Wither Lord"}); - triviaSolutions.put("How many total Fairy Souls are there?", new String[]{"227 Fairy Souls"}); + triviaSolutions.put("What is the status of Maxor, Storm, Goldor and Necron?", new String[]{"Wither Lord"}); + triviaSolutions.put("How many total Fairy Souls are there?", new String[]{"238 Fairy Souls"}); triviaSolutions.put("How many Fairy Souls are there in Spider's Den?", new String[]{"19 Fairy Souls"}); triviaSolutions.put("How many Fairy Souls are there in The End?", new String[]{"12 Fairy Souls"}); triviaSolutions.put("How many Fairy Souls are there in The Farming Islands?", new String[]{"20 Fairy Souls"}); - triviaSolutions.put("How many Fairy Souls are there in Blazing Fortress?", new String[]{"19 Fairy Souls"}); + triviaSolutions.put("How many Fairy Souls are there in Crimson Isle?", new String[]{"29 Fairy Souls"}); triviaSolutions.put("How many Fairy Souls are there in The Park?", new String[]{"11 Fairy Souls"}); triviaSolutions.put("How many Fairy Souls are there in Jerry's Workshop?", new String[]{"5 Fairy Souls"}); triviaSolutions.put("How many Fairy Souls are there in Hub?", new String[]{"79 Fairy Souls"}); @@ -57,7 +60,7 @@ public class TriviaSolver { triviaSolutions.put("What is the name of the person that upgrades pets?", new String[]{"Kat"}); triviaSolutions.put("What is the name of the lady of the Nether?", new String[]{"Elle"}); triviaSolutions.put("Which villager in the Village gives you a Rogue Sword?", new String[]{"Jamie"}); - triviaSolutions.put("How many unique minions are there?", new String[]{"53 Minions"}); + triviaSolutions.put("How many unique minions are there?", new String[]{"55 Minions"}); triviaSolutions.put("Which of these enemies does not spawn in the Spider's Den?", new String[]{"Zombie Spider", "Cave Spider", "Wither Skeleton", "Dashing Spooder", "Broodfather", "Night Spider"}); triviaSolutions.put("Which of these monsters only spawns at night?", new String[]{"Zombie Villager", "Ghast"}); |