aboutsummaryrefslogtreecommitdiff
path: root/me/Danker
diff options
context:
space:
mode:
Diffstat (limited to 'me/Danker')
-rw-r--r--me/Danker/TheMod.java4
-rw-r--r--me/Danker/commands/LootCommand.java12
-rw-r--r--me/Danker/commands/SkillsCommand.java322
-rw-r--r--me/Danker/commands/SlayerCommand.java14
4 files changed, 338 insertions, 14 deletions
diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java
index 76e367e..5d603a3 100644
--- a/me/Danker/TheMod.java
+++ b/me/Danker/TheMod.java
@@ -13,6 +13,7 @@ import me.Danker.commands.LootCommand;
import me.Danker.commands.MoveCommand;
import me.Danker.commands.ReloadConfigCommand;
import me.Danker.commands.SetkeyCommand;
+import me.Danker.commands.SkillsCommand;
import me.Danker.commands.SlayerCommand;
import me.Danker.commands.ToggleCommand;
import me.Danker.handlers.ConfigHandler;
@@ -41,7 +42,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class TheMod
{
public static final String MODID = "Danker's Skyblock Mod";
- public static final String VERSION = "1.5.1";
+ public static final String VERSION = "1.5.2";
static int checkItemsNow = 0;
static int itemsChecked = 0;
@@ -66,6 +67,7 @@ public class TheMod
ClientCommandHandler.instance.registerCommand(new DisplayCommand());
ClientCommandHandler.instance.registerCommand(new MoveCommand());
ClientCommandHandler.instance.registerCommand(new SlayerCommand());
+ ClientCommandHandler.instance.registerCommand(new SkillsCommand());
}
// It randomly broke, so I had to make it the highest priority
diff --git a/me/Danker/commands/LootCommand.java b/me/Danker/commands/LootCommand.java
index 046c729..9beec87 100644
--- a/me/Danker/commands/LootCommand.java
+++ b/me/Danker/commands/LootCommand.java
@@ -113,7 +113,7 @@ public class LootCommand extends CommandBase {
if (wolfBosses == -1) {
bossesBetween = "Never";
} else {
- bossesBetween = Integer.toString(wolfBosses);
+ bossesBetween = NumberFormat.getIntegerInstance().format(wolfBosses);
}
player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" +
@@ -128,7 +128,7 @@ public class LootCommand extends CommandBase {
EnumChatFormatting.AQUA + " Grizzly Baits: " + wolfBaits + "\n" +
EnumChatFormatting.DARK_PURPLE + " Overfluxes: " + wolfFluxes + "\n" +
EnumChatFormatting.AQUA + " Time Since RNG: " + timeBetween + "\n" +
- EnumChatFormatting.AQUA + " Bosses Since RNG: " + NumberFormat.getIntegerInstance().format(bossesBetween) + "\n" +
+ EnumChatFormatting.AQUA + " Bosses Since RNG: " + bossesBetween + "\n" +
EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + " -------------------"));
} else if (arg1[0].equalsIgnoreCase("spider")) {
if (spiderTime == -1) {
@@ -139,7 +139,7 @@ public class LootCommand extends CommandBase {
if (spiderBosses == -1) {
bossesBetween = "Never";
} else {
- bossesBetween = Integer.toString(spiderBosses);
+ bossesBetween = NumberFormat.getIntegerInstance().format(spiderBosses);
}
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "-------------------\n" +
@@ -154,7 +154,7 @@ public class LootCommand extends CommandBase {
EnumChatFormatting.LIGHT_PURPLE + " Fly Swatters: " + spiderSwatters + "\n" +
EnumChatFormatting.GOLD + " Digested Mosquitos: " + spiderMosquitos + "\n" +
EnumChatFormatting.AQUA + " Time Since RNG: " + timeBetween + "\n" +
- EnumChatFormatting.AQUA + " Bosses Since RNG: " + NumberFormat.getIntegerInstance().format(bossesBetween) + "\n" +
+ EnumChatFormatting.AQUA + " Bosses Since RNG: " + bossesBetween + "\n" +
EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + " -------------------"));
} else if (arg1[0].equalsIgnoreCase("zombie")) {
if (zombieTime == -1) {
@@ -165,7 +165,7 @@ public class LootCommand extends CommandBase {
if (zombieBosses == -1) {
bossesBetween = "Never";
} else {
- bossesBetween = Integer.toString(zombieBosses);
+ bossesBetween = NumberFormat.getIntegerInstance().format(zombieBosses);
}
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + "-------------------\n" +
@@ -181,7 +181,7 @@ public class LootCommand extends CommandBase {
EnumChatFormatting.DARK_GREEN + " Snake Runes: " + zombieSnakes + "\n" +
EnumChatFormatting.GOLD + " Scythe Blades: " + zombieScythes + "\n" +
EnumChatFormatting.AQUA + " Time Since RNG: " + timeBetween + "\n" +
- EnumChatFormatting.AQUA + " Bosses Since RNG: " + NumberFormat.getIntegerInstance().format(bossesBetween) + "\n" +
+ EnumChatFormatting.AQUA + " Bosses Since RNG: " + bossesBetween + "\n" +
EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " -------------------"));
} else {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: /loot [zombie/spider/wolf]"));
diff --git a/me/Danker/commands/SkillsCommand.java b/me/Danker/commands/SkillsCommand.java
new file mode 100644
index 0000000..00a1e5d
--- /dev/null
+++ b/me/Danker/commands/SkillsCommand.java
@@ -0,0 +1,322 @@
+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 SkillsCommand extends CommandBase {
+
+ static double xpToLevel(double xp) {
+ int level;
+ double progress;
+
+ if (xp < 50) {
+ level = 0;
+ progress = xp / 50;
+ } else if (xp < 175) {
+ level = 1;
+ progress = (xp - 50) / 125;
+ } else if (xp < 375) {
+ level = 2;
+ progress = (xp - 175) / 200;
+ } else if (xp < 675) {
+ level = 3;
+ progress = (xp - 375) / 300;
+ } else if (xp < 1175) {
+ level = 4;
+ progress = (xp - 675) / 500;
+ } else if (xp < 1925) {
+ level = 5;
+ progress = (xp - 1175) / 750;
+ } else if (xp < 2925) {
+ level = 6;
+ progress = (xp - 1925) / 1000;
+ } else if (xp < 4425) {
+ level = 7;
+ progress = (xp - 2925) / 1500;
+ } else if (xp < 6425) {
+ level = 8;
+ progress = (xp - 4425) / 2000;
+ } else if (xp < 9925) {
+ level = 9;
+ progress = (xp - 6425) / 3500;
+ } else if (xp < 14925) {
+ level = 10;
+ progress = (xp - 9925) / 5000;
+ } else if (xp < 22425) {
+ level = 11;
+ progress = (xp - 14925) / 7500;
+ } else if (xp < 32425) {
+ level = 12;
+ progress = (xp - 22425) / 10000;
+ } else if (xp < 47425) {
+ level = 13;
+ progress = (xp - 32425) / 15000;
+ } else if (xp < 67425) {
+ level = 14;
+ progress = (xp - 47425) / 20000;
+ } else if (xp < 97425) {
+ level = 15;
+ progress = (xp - 67425) / 30000;
+ } else if (xp < 147425) {
+ level = 16;
+ progress = (xp - 97425) / 50000;
+ } else if (xp < 222425) {
+ level = 17;
+ progress = (xp - 147425) / 75000;
+ } else if (xp < 322425) {
+ level = 18;
+ progress = (xp - 222425) / 100000;
+ } else if (xp < 522425) {
+ level = 19;
+ progress = (xp - 322425) / 200000;
+ } else if (xp < 822425) {
+ level = 20;
+ progress = (xp - 522425) / 300000;
+ } else if (xp < 1222425) {
+ level = 21;
+ progress = (xp - 822425) / 400000;
+ } else if (xp < 1722425) {
+ level = 22;
+ progress = (xp - 1222425) / 500000;
+ } else if (xp < 2322425) {
+ level = 23;
+ progress = (xp - 1722425) / 600000;
+ } else if (xp < 3022425) {
+ level = 24;
+ progress = (xp - 2322425) / 700000;
+ } else if (xp < 3822425) {
+ level = 25;
+ progress = (xp - 3022425) / 800000;
+ } else if (xp < 4722425) {
+ level = 26;
+ progress = (xp - 3822425) / 900000;
+ } else if (xp < 5722425) {
+ level = 27;
+ progress = (xp - 4722425) / 1000000;
+ } else if (xp < 6822425) {
+ level = 28;
+ progress = (xp - 5722425) / 1100000;
+ } else if (xp < 8022425) {
+ level = 29;
+ progress = (xp - 6822425) / 1200000;
+ } else if (xp < 9322425) {
+ level = 30;
+ progress = (xp - 8022425) / 1300000;
+ } else if (xp < 10722425) {
+ level = 31;
+ progress = (xp - 9322425) / 1400000;
+ } else if (xp < 12222425) {
+ level = 32;
+ progress = (xp - 10722425) / 1500000;
+ } else if (xp < 13822425) {
+ level = 33;
+ progress = (xp - 12222425) / 1600000;
+ } else if (xp < 15522425) {
+ level = 34;
+ progress = (xp - 13822425) / 1700000;
+ } else if (xp < 17322425) {
+ level = 35;
+ progress = (xp - 15522425) / 1800000;
+ } else if (xp < 19222425) {
+ level = 36;
+ progress = (xp - 17322425) / 1900000;
+ } else if (xp < 21222425) {
+ level = 37;
+ progress = (xp - 19222425) / 2000000;
+ } else if (xp < 23322425) {
+ level = 38;
+ progress = (xp - 21222425) / 2100000;
+ } else if (xp < 25522425) {
+ level = 39;
+ progress = (xp - 23322425) / 2200000;
+ } else if (xp < 27822425) {
+ level = 40;
+ progress = (xp - 25522425) / 2300000;
+ } else if (xp < 30222425) {
+ level = 41;
+ progress = (xp - 27822425) / 2400000;
+ } else if (xp < 32722425) {
+ level = 42;
+ progress = (xp - 30222425) / 2500000;
+ } else if (xp < 35322425) {
+ level = 43;
+ progress = (xp - 32722425) / 2600000;
+ } else if (xp < 38072425) {
+ level = 44;
+ progress = (xp - 35322425) / 2750000;
+ } else if (xp < 40972425) {
+ level = 45;
+ progress = (xp - 38072425) / 2900000;
+ } else if (xp < 44072425) {
+ level = 46;
+ progress = (xp - 40972425) / 3100000;
+ } else if (xp < 47472425) {
+ level = 47;
+ progress = (xp - 44072425) / 3400000;
+ } else if (xp < 51172425) {
+ level = 48;
+ progress = (xp - 47472425) / 3700000;
+ } else if (xp < 55172425) {
+ level = 49;
+ progress = (xp - 51172425) / 4000000;
+ } else {
+ level = 50;
+ progress = 0;
+ }
+
+ return level + progress;
+ }
+
+ @Override
+ public String getCommandName() {
+ return "skills";
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender arg0) {
+ return getCommandName() + " <name>";
+ }
+
+ @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();
+ ConfigHandler cf = new ConfigHandler();
+ EntityPlayer player = (EntityPlayer) arg0;
+
+ // 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;
+ String uuid;
+ if (arg1.length == 0) {
+ username = player.getName();
+ uuid = player.getUniqueID().toString().replaceAll("[\\-]", "");
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking skills of " + EnumChatFormatting.DARK_GREEN + username));
+ } else {
+ username = arg1[0];
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking skills of " + EnumChatFormatting.DARK_GREEN + username));
+ uuid = ah.getUUID(username);
+ }
+
+ // Find stats of latest profile
+ 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 skills...");
+ JsonObject userObject = profileResponse.get("profile").getAsJsonObject().get("members").getAsJsonObject().get(uuid).getAsJsonObject();
+
+ double farmingLevel = 0;
+ double miningLevel = 0;
+ double combatLevel = 0;
+ double foragingLevel = 0;
+ double fishingLevel = 0;
+ double enchantingLevel = 0;
+ double alchemyLevel = 0;
+ double tamingLevel = 0;
+
+ if (userObject.has("experience_skill_farming") || userObject.has("experience_skill_mining") || userObject.has("experience_skill_combat") || userObject.has("experience_skill_foraging") || userObject.has("experience_skill_fishing") || userObject.has("experience_skill_enchanting") || userObject.has("experience_skill_alchemy")) {
+ if (userObject.has("experience_skill_farming")) {
+ farmingLevel = xpToLevel(userObject.get("experience_skill_farming").getAsDouble());
+ farmingLevel = (double) Math.round(farmingLevel * 100) / 100;
+ }
+ if (userObject.has("experience_skill_mining")) {
+ miningLevel = xpToLevel(userObject.get("experience_skill_mining").getAsDouble());
+ miningLevel = (double) Math.round(miningLevel * 100) / 100;
+ }
+ if (userObject.has("experience_skill_combat")) {
+ combatLevel = xpToLevel(userObject.get("experience_skill_combat").getAsDouble());
+ combatLevel = (double) Math.round(combatLevel * 100) / 100;
+ }
+ if (userObject.has("experience_skill_foraging")) {
+ foragingLevel = xpToLevel(userObject.get("experience_skill_foraging").getAsDouble());
+ foragingLevel = (double) Math.round(foragingLevel * 100) / 100;
+ }
+ if (userObject.has("experience_skill_fishing")) {
+ fishingLevel = xpToLevel(userObject.get("experience_skill_fishing").getAsDouble());
+ fishingLevel = (double) Math.round(fishingLevel * 100) / 100;
+ }
+ if (userObject.has("experience_skill_enchanting")) {
+ enchantingLevel = xpToLevel(userObject.get("experience_skill_enchanting").getAsDouble());
+ enchantingLevel = (double) Math.round(enchantingLevel * 100) / 100;
+ }
+ if (userObject.has("experience_skill_alchemy")) {
+ alchemyLevel = xpToLevel(userObject.get("experience_skill_alchemy").getAsDouble());
+ alchemyLevel = (double) Math.round(alchemyLevel * 100) / 100;
+ }
+ if (userObject.has("experience_skill_taming")) {
+ tamingLevel = xpToLevel(userObject.get("experience_skill_taming").getAsDouble());
+ tamingLevel = (double) Math.round(tamingLevel * 100) / 100;
+ }
+ } else {
+ // Get skills from achievement API, will be floored
+
+ String playerURL = "https://api.hypixel.net/player?uuid=" + uuid + "&key=" + key;
+ System.out.println("Fetching skills from achievement API");
+ JsonObject playerObject = ah.getResponse(playerURL);
+
+ if (!playerObject.get("success").getAsBoolean()) {
+ String reason = profileResponse.get("cause").getAsString();
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed with reason: " + reason));
+ return;
+ }
+
+ JsonObject achievementObject = playerObject.get("player").getAsJsonObject().get("achievements").getAsJsonObject();
+ farmingLevel = achievementObject.get("skyblock_harvester").getAsInt();
+ miningLevel = achievementObject.get("skyblock_excavator").getAsInt();
+ combatLevel = achievementObject.get("skyblock_combat").getAsInt();
+ foragingLevel = achievementObject.get("skyblock_gatherer").getAsInt();
+ fishingLevel = achievementObject.get("skyblock_angler").getAsInt();
+ enchantingLevel = achievementObject.get("skyblock_augmentation").getAsInt();
+ alchemyLevel = achievementObject.get("skyblock_concoctor").getAsInt();
+ tamingLevel = achievementObject.get("skyblock_domesticator").getAsInt();
+ }
+
+ double skillAvg = (farmingLevel + miningLevel + combatLevel + foragingLevel + fishingLevel + enchantingLevel + alchemyLevel + tamingLevel) / 8;
+ skillAvg = (double) Math.round(skillAvg * 100) / 100;
+ double trueAvg = (Math.floor(farmingLevel) + Math.floor(miningLevel) + Math.floor(combatLevel) + Math.floor(foragingLevel) + Math.floor(fishingLevel) + Math.floor(enchantingLevel) + Math.floor(alchemyLevel) + Math.floor(tamingLevel)) / 8;
+
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" +
+ EnumChatFormatting.AQUA + " " + username + "'s Skills:\n" +
+ EnumChatFormatting.GREEN + " Farming: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + farmingLevel + "\n" +
+ EnumChatFormatting.GREEN + " Mining: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + miningLevel + "\n" +
+ EnumChatFormatting.GREEN + " Combat: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + combatLevel + "\n" +
+ EnumChatFormatting.GREEN + " Foraging: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + foragingLevel + "\n" +
+ EnumChatFormatting.GREEN + " Fishing: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + fishingLevel + "\n" +
+ EnumChatFormatting.GREEN + " Enchanting: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + enchantingLevel + "\n" +
+ EnumChatFormatting.GREEN + " Alchemy: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + alchemyLevel + "\n" +
+ EnumChatFormatting.GREEN + " Taming: " + EnumChatFormatting.DARK_GREEN + EnumChatFormatting.BOLD + tamingLevel + "\n" +
+ EnumChatFormatting.AQUA + " Average Skill Level: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + skillAvg + "\n" +
+ EnumChatFormatting.AQUA + " True Average Skill Level: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + trueAvg + "\n" +
+ EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------"));
+ }).start();
+ }
+
+}
diff --git a/me/Danker/commands/SlayerCommand.java b/me/Danker/commands/SlayerCommand.java
index 9fae3ef..090e85f 100644
--- a/me/Danker/commands/SlayerCommand.java
+++ b/me/Danker/commands/SlayerCommand.java
@@ -52,18 +52,16 @@ public class SlayerCommand extends CommandBase {
if (arg1.length == 0) {
username = player.getName();
uuid = player.getUniqueID().toString().replaceAll("[\\-]", "");
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking slayer of " + username));
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking slayer of " + EnumChatFormatting.DARK_GREEN + username));
} else {
username = arg1[0];
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking slayer of " + username));
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking slayer of " + EnumChatFormatting.DARK_GREEN + username));
uuid = ah.getUUID(username);
}
// Find stats of latest profile
String latestProfile = ah.getLatestProfileID(uuid, key);
- if (latestProfile == null) {
- return;
- }
+ if (latestProfile == null) return;
String profileURL = "https://api.hypixel.net/skyblock/profile?profile=" + latestProfile + "&key=" + key;
System.out.println("Fetching profile...");
@@ -92,10 +90,12 @@ public class SlayerCommand extends CommandBase {
wolfXP = slayersObject.get("wolf").getAsJsonObject().get("xp").getAsInt();
}
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + username + "'s Total XP: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + NumberFormat.getIntegerInstance().format(zombieXP + spiderXP + wolfXP) + "\n" +
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" +
+ EnumChatFormatting.AQUA + " " + username + "'s Total XP: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + NumberFormat.getIntegerInstance().format(zombieXP + spiderXP + wolfXP) + "\n" +
EnumChatFormatting.AQUA + " Zombie XP: " + EnumChatFormatting.BLUE + EnumChatFormatting.BOLD + NumberFormat.getIntegerInstance().format(zombieXP) + "\n" +
EnumChatFormatting.AQUA + " Spider XP: " + EnumChatFormatting.BLUE + EnumChatFormatting.BOLD + NumberFormat.getIntegerInstance().format(spiderXP) + "\n" +
- EnumChatFormatting.AQUA + " Wolf XP: " + EnumChatFormatting.BLUE + EnumChatFormatting.BOLD + NumberFormat.getIntegerInstance().format(wolfXP)));
+ EnumChatFormatting.AQUA + " Wolf XP: " + EnumChatFormatting.BLUE + EnumChatFormatting.BOLD + NumberFormat.getIntegerInstance().format(wolfXP) + "\n" +
+ EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------"));
}).start();
}