diff options
author | bowser0000 <bowser0000@gmail.com> | 2020-07-31 20:27:25 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2020-07-31 20:27:25 -0400 |
commit | 685fc067d3742e67b2e4bfb6f7949d62e4953eff (patch) | |
tree | 51dbd580104fc179fc6dd6e1bcf80b0ef8fe840d | |
parent | 3a3cd409f16953d9b7392482d70f2e09f3cffb28 (diff) | |
download | SkyblockMod-685fc067d3742e67b2e4bfb6f7949d62e4953eff.tar.gz SkyblockMod-685fc067d3742e67b2e4bfb6f7949d62e4953eff.tar.bz2 SkyblockMod-685fc067d3742e67b2e4bfb6f7949d62e4953eff.zip |
Add fishing stats import, move second fishing display
Right half of the fishing display was covering numbers on the left half if it was in the hundreds/thousands
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | me/Danker/TheMod.java | 8 | ||||
-rw-r--r-- | me/Danker/commands/DHelpCommand.java | 3 | ||||
-rw-r--r-- | me/Danker/commands/ImportFishingCommand.java | 227 |
4 files changed, 236 insertions, 4 deletions
@@ -24,9 +24,11 @@ QOL changes that enhances your Hypixel Skyblock experience. Created to add featu - /petsof [player] - Uses API to get pets of a person. If no name is provided, it checks yours. - /bank [player] - Uses API to get bank and purse coins of a person. If no name is provided, it checks yours. - /armor [player] - Uses API to get armour of a person. If no name is provided, it checks yours. +- /importfishing - Imports your fishing stats from your latest profile to your fishing tracker using the API. ### Notes - Slayer tracker for token drops and 20% chance drops uses a 12x12x12 bounding box centered on the player to detect the drops. If you are out of the range of the item drop, it will not count on the tracker. - API commands may take a while depending on your internet connection. The API may also go down. - If you use too many API commands too fast, you can and will get rate-limited. - An incorrect API key will result in an HTTP error code of 402. +- Importing fishing uses your sea creature kills, which may not always be exactly correct (e.x. someone else kills your sea creature). diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java index fb304a2..6f7d525 100644 --- a/me/Danker/TheMod.java +++ b/me/Danker/TheMod.java @@ -19,6 +19,7 @@ import me.Danker.commands.DHelpCommand; import me.Danker.commands.DisplayCommand; import me.Danker.commands.GetkeyCommand; import me.Danker.commands.GuildOfCommand; +import me.Danker.commands.ImportFishingCommand; import me.Danker.commands.LootCommand; import me.Danker.commands.MoveCommand; import me.Danker.commands.PetsCommand; @@ -60,7 +61,7 @@ import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; public class TheMod { public static final String MODID = "Danker's Skyblock Mod"; - public static final String VERSION = "1.5.6"; + public static final String VERSION = "1.6"; static double checkItemsNow = 0; static double itemsChecked = 0; @@ -125,6 +126,7 @@ public class TheMod ClientCommandHandler.instance.registerCommand(new PetsCommand()); ClientCommandHandler.instance.registerCommand(new BankCommand()); ClientCommandHandler.instance.registerCommand(new ArmourCommand()); + ClientCommandHandler.instance.registerCommand(new ImportFishingCommand()); } // Update checker @@ -668,8 +670,8 @@ public class TheMod EnumChatFormatting.AQUA + timeBetween + "\n" + EnumChatFormatting.AQUA + bossesBetween; - new TextRenderer(Minecraft.getMinecraft(), dropsTextTwo, moc.displayXY[0] + 130, moc.displayXY[1], Integer.parseInt("FFFFFF", 16)); - new TextRenderer(Minecraft.getMinecraft(), countTextTwo, moc.displayXY[0] + 240, moc.displayXY[1], Integer.parseInt("FFFFFF", 16)); + new TextRenderer(Minecraft.getMinecraft(), dropsTextTwo, moc.displayXY[0] + 145, moc.displayXY[1], Integer.parseInt("FFFFFF", 16)); + new TextRenderer(Minecraft.getMinecraft(), countTextTwo, moc.displayXY[0] + 255, moc.displayXY[1], Integer.parseInt("FFFFFF", 16)); } else if (ds.display.equals("fishingwinter")) { dropsText = EnumChatFormatting.AQUA + "Creatures Caught:\n" + diff --git a/me/Danker/commands/DHelpCommand.java b/me/Danker/commands/DHelpCommand.java index c88d295..3d6d7ad 100644 --- a/me/Danker/commands/DHelpCommand.java +++ b/me/Danker/commands/DHelpCommand.java @@ -43,7 +43,8 @@ public class DHelpCommand extends CommandBase { 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" + EnumChatFormatting.GOLD + " /petsof [player]" + EnumChatFormatting.AQUA + " - Uses API to get pets of a person. If no name is provided, it checks yours.\n" + EnumChatFormatting.GOLD + " /bank [player]" + EnumChatFormatting.AQUA + " - Uses API to get bank and purse coins of a person. If no name is provided, it checks yours.\n" + - EnumChatFormatting.GOLD + " /armor [player]" + EnumChatFormatting.AQUA + " - Uses API to get armour of a person. If no name is provided, it checks yours.\n")); + EnumChatFormatting.GOLD + " /armor [player]" + EnumChatFormatting.AQUA + " - Uses API to get armour of a person. If no name is provided, it checks yours.\n" + + EnumChatFormatting.GOLD + " /importfishing" + EnumChatFormatting.AQUA + " - Imports your fishing stats from your latest profile to your fishing tracker using the API.\n")); } } diff --git a/me/Danker/commands/ImportFishingCommand.java b/me/Danker/commands/ImportFishingCommand.java new file mode 100644 index 0000000..158b4a1 --- /dev/null +++ b/me/Danker/commands/ImportFishingCommand.java @@ -0,0 +1,227 @@ +package me.Danker.commands; + +import com.google.gson.JsonObject; + +import me.Danker.handlers.APIHandler; +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.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; + +public class ImportFishingCommand extends CommandBase { + + @Override + public String getCommandName() { + return "importfishing"; + } + + @Override + public String getCommandUsage(ICommandSender arg0) { + return getCommandName(); + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { + // MULTI THREAD DRIFTING + new Thread(() -> { + APIHandler ah = new APIHandler(); + LootCommand lc = new LootCommand(); + ConfigHandler cf = new ConfigHandler(); + EntityPlayer player = (EntityPlayer) arg0; + + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Importing your fishing stats...")); + + // Check key + String key = cf.getString("api", "APIKey"); + if (key.equals("")) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "API key not set. Use /setkey.")); + } + + // Get UUID for Hypixel API requests + String username = player.getName(); + String uuid = player.getUniqueID().toString().replaceAll("[\\-]", ""); + + String latestProfile = ah.getLatestProfileID(uuid, key); + if (latestProfile == null) return; + + String profileURL = "https://api.hypixel.net/skyblock/profile?profile=" + latestProfile + "&key=" + key; + System.out.println("Fetching profile..."); + JsonObject profileResponse = ah.getResponse(profileURL); + if (!profileResponse.get("success").getAsBoolean()) { + String reason = profileResponse.get("cause").getAsString(); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed with reason: " + reason)); + return; + } + + System.out.println("Fetching fishing stats..."); + JsonObject statsObject = profileResponse.get("profile").getAsJsonObject().get("members").getAsJsonObject().get(uuid).getAsJsonObject().get("stats").getAsJsonObject(); + + lc.greatCatches = 0; + lc.goodCatches = 0; + if (statsObject.has("items_fished_treasure")) { + if (statsObject.has("items_fished_large_treasure")) { + lc.greatCatches = statsObject.get("items_fished_large_treasure").getAsInt(); + lc.goodCatches = statsObject.get("items_fished_treasure").getAsInt() - lc.greatCatches; + } else { + lc.goodCatches = statsObject.get("items_fished_treasure").getAsInt(); + } + } + + lc.seaCreatures = 0; + lc.squids = 0; + if (statsObject.has("kills_pond_squid")) { + lc.squids = statsObject.get("kills_pond_squid").getAsInt(); + } + lc.seaCreatures += lc.squids; + + lc.seaWalkers = 0; + if (statsObject.has("kills_sea_walker")) { + lc.seaWalkers = statsObject.get("kills_sea_walker").getAsInt(); + } + lc.seaCreatures += lc.seaWalkers; + + lc.nightSquids = 0; + if (statsObject.has("kills_night_squid")) { + lc.nightSquids = statsObject.get("kills_night_squid").getAsInt(); + } + lc.seaCreatures += lc.nightSquids; + + lc.seaGuardians = 0; + if (statsObject.has("kills_sea_guardian")) { + lc.seaGuardians = statsObject.get("kills_sea_guardian").getAsInt(); + } + lc.seaCreatures += lc.seaGuardians; + + lc.seaWitches = 0; + if (statsObject.has("kills_sea_witch")) { + lc.seaWitches = statsObject.get("kills_sea_witch").getAsInt(); + } + lc.seaCreatures += lc.seaWitches; + + lc.seaArchers = 0; + if (statsObject.has("kills_sea_archer")) { + lc.seaArchers = statsObject.get("kills_sea_archer").getAsInt(); + } + lc.seaCreatures += lc.seaArchers; + + lc.monsterOfTheDeeps = 0; + if (statsObject.has("kills_zombie_deep")) { + if (statsObject.has("kills_chicken_deep")) { + lc.monsterOfTheDeeps = statsObject.get("kills_zombie_deep").getAsInt() + statsObject.get("kills_chicken_deep").getAsInt(); + } else { + lc.monsterOfTheDeeps = statsObject.get("kills_zombie_deep").getAsInt(); + } + } else if (statsObject.has("kills_chicken_deep")) { + lc.monsterOfTheDeeps = statsObject.get("kills_chicken_deep").getAsInt(); + } + lc.seaCreatures += lc.monsterOfTheDeeps; + + lc.catfishes = 0; + if (statsObject.has("kills_catfish")) { + lc.catfishes = statsObject.get("kills_catfish").getAsInt(); + } + lc.seaCreatures += lc.catfishes; + + lc.carrotKings = 0; + if (statsObject.has("kills_carrot_king")) { + lc.carrotKings = statsObject.get("kills_carrot_king").getAsInt(); + } + lc.seaCreatures += lc.carrotKings; + + lc.seaLeeches = 0; + if (statsObject.has("kills_sea_leech")) { + lc.seaLeeches = statsObject.get("kills_sea_leech").getAsInt(); + } + lc.seaCreatures += lc.seaLeeches; + + lc.guardianDefenders = 0; + if (statsObject.has("kills_guardian_defender")) { + lc.guardianDefenders = statsObject.get("kills_guardian_defender").getAsInt(); + } + lc.seaCreatures += lc.guardianDefenders; + + lc.deepSeaProtectors = 0; + if (statsObject.has("kills_deep_sea_protector")) { + lc.deepSeaProtectors = statsObject.get("kills_deep_sea_protector").getAsInt(); + } + lc.seaCreatures += lc.deepSeaProtectors; + + lc.hydras = 0; + if (statsObject.has("kills_water_hydra")) { + // Hydra splits + lc.hydras = statsObject.get("kills_water_hydra").getAsInt() / 2; + } + lc.seaCreatures += lc.hydras; + + lc.seaEmperors = 0; + if (statsObject.has("kills_skeleton_emperor")) { + if (statsObject.has("kills_guardian_emperor")) { + lc.seaEmperors = statsObject.get("kills_skeleton_emperor").getAsInt() + statsObject.get("kills_guardian_emperor").getAsInt(); + } else { + lc.seaEmperors = statsObject.get("kills_skeleton_emperor").getAsInt(); + } + } else if (statsObject.has("kills_guardian_emperor")) { + lc.seaEmperors = statsObject.get("kills_guardian_emperor").getAsInt(); + } + lc.seaCreatures += lc.seaEmperors; + + lc.frozenSteves = 0; + if (statsObject.has("kills_frozen_steve")) { + lc.frozenSteves = statsObject.get("kills_frozen_steve").getAsInt(); + } + lc.seaCreatures += lc.frozenSteves; + + lc.frostyTheSnowmans = 0; + if (statsObject.has("kills_frosty_the_snowman")) { + lc.frostyTheSnowmans = statsObject.get("kills_frosty_the_snowman").getAsInt(); + } + lc.seaCreatures += lc.frostyTheSnowmans; + + lc.grinches = 0; + if (statsObject.has("kills_grinch")) { + lc.grinches = statsObject.get("kills_grinch").getAsInt(); + } + lc.seaCreatures += lc.grinches; + + lc.yetis = 0; + if (statsObject.has("kills_yeti")) { + lc.yetis = statsObject.get("kills_yeti").getAsInt(); + } + lc.seaCreatures += lc.yetis; + + System.out.println("Writing to config..."); + cf.writeIntConfig("fishing", "goodCatch", lc.goodCatches); + cf.writeIntConfig("fishing", "greatCatch", lc.greatCatches); + cf.writeIntConfig("fishing", "seaCreature", lc.seaCreatures); + cf.writeIntConfig("fishing", "squid", lc.squids); + cf.writeIntConfig("fishing", "seaWalker", lc.seaWalkers); + cf.writeIntConfig("fishing", "nightSquid", lc.nightSquids); + cf.writeIntConfig("fishing", "seaGuardian", lc.seaGuardians); + cf.writeIntConfig("fishing", "seaWitch", lc.seaWitches); + cf.writeIntConfig("fishing", "seaArcher", lc.seaArchers); + cf.writeIntConfig("fishing", "monsterOfDeep", lc.monsterOfTheDeeps); + cf.writeIntConfig("fishing", "catfish", lc.catfishes); + cf.writeIntConfig("fishing", "carrotKing", lc.carrotKings); + cf.writeIntConfig("fishing", "seaLeech", lc.seaLeeches); + cf.writeIntConfig("fishing", "guardianDefender", lc.guardianDefenders); + cf.writeIntConfig("fishing", "deepSeaProtector", lc.deepSeaProtectors); + cf.writeIntConfig("fishing", "hydra", lc.hydras); + cf.writeIntConfig("fishing", "seaEmperor", lc.seaEmperors); + cf.writeIntConfig("fishing", "frozenSteve", lc.frozenSteves); + cf.writeIntConfig("fishing", "snowman", lc.frostyTheSnowmans); + cf.writeIntConfig("fishing", "grinch", lc.grinches); + cf.writeIntConfig("fishing", "yeti", lc.yetis); + + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Fishing stats imported.")); + }).start(); + } + +} |