aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2020-07-24 16:28:48 -0400
committerbowser0000 <bowser0000@gmail.com>2020-07-24 16:28:48 -0400
commitb8de3d5ddc0032a96189250e43779af525a31580 (patch)
tree9b52930efef82db611527e8a7b40497414729ae8
parent17643172df0eec7521996b786ea3f74bae8acb43 (diff)
downloadSkyblockMod-b8de3d5ddc0032a96189250e43779af525a31580.tar.gz
SkyblockMod-b8de3d5ddc0032a96189250e43779af525a31580.tar.bz2
SkyblockMod-b8de3d5ddc0032a96189250e43779af525a31580.zip
Add /bank, other small changes
Fix getting profiles of person with 1 profile with no last_save. Toggles are now off by default.
-rw-r--r--README.md3
-rw-r--r--me/Danker/TheMod.java2
-rw-r--r--me/Danker/commands/BankCommand.java105
-rw-r--r--me/Danker/commands/DHelpCommand.java3
-rw-r--r--me/Danker/handlers/APIHandler.java2
-rw-r--r--me/Danker/handlers/ConfigHandler.java4
6 files changed, 114 insertions, 5 deletions
diff --git a/README.md b/README.md
index cf96520..6a1dfc8 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,8 @@ QOL changes that enhances your Hypixel Skyblock experience. Created to add featu
- /slayer [name] - Uses API to get slayer xp of a person. If no name is provided, it checks yours.
- /skills [name] - Uses API to get skill levels of a person. If no name is provided, it checks yours.
- /guildof [name] - Uses API to get guild name and guild master of a person. If no name is provided, it checks yours.
- - /pets [name] - Uses API to get pets of a person. If no name is provided, it checks yours.
+- /pets [name] - Uses API to get pets of a person. If no name is provided, it checks yours.
+- /bank [name] - Uses API to get bank and purse coins of a person. If no name is provided, it checks yours.
### 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.
diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java
index 9dbfd5a..66a4fd8 100644
--- a/me/Danker/TheMod.java
+++ b/me/Danker/TheMod.java
@@ -7,6 +7,7 @@ import java.awt.TrayIcon;
import java.text.NumberFormat;
import java.util.List;
+import me.Danker.commands.BankCommand;
import me.Danker.commands.DHelpCommand;
import me.Danker.commands.DisplayCommand;
import me.Danker.commands.GetkeyCommand;
@@ -74,6 +75,7 @@ public class TheMod
ClientCommandHandler.instance.registerCommand(new GuildOfCommand());
ClientCommandHandler.instance.registerCommand(new DHelpCommand());
ClientCommandHandler.instance.registerCommand(new PetsCommand());
+ ClientCommandHandler.instance.registerCommand(new BankCommand());
}
// It randomly broke, so I had to make it the highest priority
diff --git a/me/Danker/commands/BankCommand.java b/me/Danker/commands/BankCommand.java
new file mode 100644
index 0000000..f569e7f
--- /dev/null
+++ b/me/Danker/commands/BankCommand.java
@@ -0,0 +1,105 @@
+package me.Danker.commands;
+
+import java.text.NumberFormat;
+import java.util.Collections;
+import java.util.List;
+
+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 BankCommand extends CommandBase {
+
+ @Override
+ public String getCommandName() {
+ return "bank";
+ }
+
+ @Override
+ public List<String> getCommandAliases()
+ {
+ return Collections.singletonList("purse");
+ }
+
+ @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 coins of " + EnumChatFormatting.DARK_GREEN + username));
+ } else {
+ username = arg1[0];
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Checking coins 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 bank + purse coins...");
+ double purseCoins = profileResponse.get("profile").getAsJsonObject().get("members").getAsJsonObject().get(uuid).getAsJsonObject().get("coin_purse").getAsDouble();
+ purseCoins = (double) Math.floor(purseCoins * 100.0) / 100.0;
+
+ // Check for bank api
+ if (profileResponse.get("profile").getAsJsonObject().has("banking")) {
+ double bankCoins = profileResponse.get("profile").getAsJsonObject().get("banking").getAsJsonObject().get("balance").getAsDouble();
+ bankCoins = (double) Math.floor(bankCoins * 100.0) / 100.0;
+
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" +
+ EnumChatFormatting.AQUA + " " + username + "'s Coins:\n" +
+ EnumChatFormatting.GREEN + " Bank: " + EnumChatFormatting.GOLD + NumberFormat.getInstance().format(bankCoins) + "\n" +
+ EnumChatFormatting.GREEN + " Purse: " + EnumChatFormatting.GOLD + NumberFormat.getInstance().format(purseCoins) + "\n" +
+ EnumChatFormatting.AQUA + " " + EnumChatFormatting.BOLD + "-------------------"));
+ } else {
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" +
+ EnumChatFormatting.AQUA + " " + username + "'s Coins:\n" +
+ EnumChatFormatting.GREEN + " Bank: " + EnumChatFormatting.RED + "Bank API disabled.\n" +
+ EnumChatFormatting.GREEN + " Purse: " + EnumChatFormatting.GOLD + NumberFormat.getInstance().format(purseCoins) + "\n" +
+ EnumChatFormatting.AQUA + " " + EnumChatFormatting.BOLD + "-------------------"));
+ }
+ }).start();
+ }
+
+}
diff --git a/me/Danker/commands/DHelpCommand.java b/me/Danker/commands/DHelpCommand.java
index 42c33e0..34b1dec 100644
--- a/me/Danker/commands/DHelpCommand.java
+++ b/me/Danker/commands/DHelpCommand.java
@@ -40,7 +40,8 @@ public class DHelpCommand extends CommandBase {
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" +
- EnumChatFormatting.GOLD + "/pets [player]" + EnumChatFormatting.AQUA + " - Uses API to get pets of a person. If no name is provided, it checks yours."));
+ EnumChatFormatting.GOLD + "/pets [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"));
}
}
diff --git a/me/Danker/handlers/APIHandler.java b/me/Danker/handlers/APIHandler.java
index e81b1f1..783ca92 100644
--- a/me/Danker/handlers/APIHandler.java
+++ b/me/Danker/handlers/APIHandler.java
@@ -125,7 +125,7 @@ public class APIHandler {
for (JsonElement profile : profilesArray) {
JsonObject profileJSON = profile.getAsJsonObject();
- long profileLastSave = 0;
+ long profileLastSave = 1;
if (profileJSON.get("members").getAsJsonObject().get(UUID).getAsJsonObject().has("last_save")) {
profileLastSave = profileJSON.get("members").getAsJsonObject().get(UUID).getAsJsonObject().get("last_save").getAsLong();
}
diff --git a/me/Danker/handlers/ConfigHandler.java b/me/Danker/handlers/ConfigHandler.java
index 64ada11..9de284f 100644
--- a/me/Danker/handlers/ConfigHandler.java
+++ b/me/Danker/handlers/ConfigHandler.java
@@ -125,8 +125,8 @@ public class ConfigHandler {
public static void reloadConfig() {
// Config init
- if (!hasKey("toggles", "GParty")) writeBooleanConfig("toggles", "GParty", true);
- if (!hasKey("toggles", "Coords")) writeBooleanConfig("toggles", "Coords", true);
+ if (!hasKey("toggles", "GParty")) writeBooleanConfig("toggles", "GParty", false);
+ if (!hasKey("toggles", "Coords")) writeBooleanConfig("toggles", "Coords", false);
if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", "");
// Wolf Loot