diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | me/Danker/TheMod.java | 50 | ||||
-rw-r--r-- | me/Danker/commands/DHelpCommand.java | 5 | ||||
-rw-r--r-- | me/Danker/commands/PetsCommand.java | 2 |
4 files changed, 54 insertions, 8 deletions
@@ -7,6 +7,7 @@ QOL changes that enhances your Hypixel Skyblock experience. Created to add featu - Golden T6/T4 enchant display (toggleable) - Slayer item tracker (with GUI display) - API commands +- Update checker ## Commands - /dhelp - Returns this message in-game. @@ -19,12 +20,12 @@ QOL changes that enhances your Hypixel Skyblock experience. Created to add featu - /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. -- /pets [player] - Uses API to get pets of a person. If no name is provided, it checks yours. +- /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. ### 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. +- 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. diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java index 1c69791..52b1c50 100644 --- a/me/Danker/TheMod.java +++ b/me/Danker/TheMod.java @@ -11,6 +11,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import com.google.gson.JsonObject; + import me.Danker.commands.ArmourCommand; import me.Danker.commands.BankCommand; import me.Danker.commands.DHelpCommand; @@ -25,13 +27,17 @@ import me.Danker.commands.SetkeyCommand; import me.Danker.commands.SkillsCommand; import me.Danker.commands.SlayerCommand; import me.Danker.commands.ToggleCommand; +import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; import me.Danker.handlers.ScoreboardHandler; import me.Danker.handlers.TextRenderer; import net.minecraft.client.Minecraft; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.ClickEvent.Action; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StringUtils; import net.minecraftforge.client.ClientCommandHandler; @@ -39,6 +45,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; @@ -47,17 +54,19 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; @Mod(modid = TheMod.MODID, version = TheMod.VERSION, clientSideOnly = true) public class TheMod { public static final String MODID = "Danker's Skyblock Mod"; - public static final String VERSION = "1.5.4"; + public static final String VERSION = "1.5.5"; static double checkItemsNow = 0; static double itemsChecked = 0; static Map<String, String> t6Enchants = new HashMap<String, String>(); static Pattern pattern = Pattern.compile(""); + static boolean updateChecked = false; @EventHandler public void init(FMLInitializationEvent event) @@ -82,12 +91,12 @@ public class TheMod t6Enchants.put("Scavenger V", EnumChatFormatting.GOLD + "Scavenger V" + EnumChatFormatting.BLUE); t6Enchants.put("Sharpness VI", EnumChatFormatting.GOLD + "Sharpness VI" + EnumChatFormatting.BLUE); t6Enchants.put("Smite VI", EnumChatFormatting.GOLD + "Smite VI" + EnumChatFormatting.BLUE); - t6Enchants.put("Smite VI", EnumChatFormatting.GOLD + "Smite VII" + EnumChatFormatting.BLUE); + t6Enchants.put("Smite VII", EnumChatFormatting.GOLD + "Smite VII" + EnumChatFormatting.BLUE); t6Enchants.put("Vampirism VI", EnumChatFormatting.GOLD + "Vampirism VI" + EnumChatFormatting.BLUE); t6Enchants.put("Power VI", EnumChatFormatting.GOLD + "Power VI" + EnumChatFormatting.BLUE); t6Enchants.put("Growth VI", EnumChatFormatting.GOLD + "Growth VI" + EnumChatFormatting.BLUE); t6Enchants.put("Protection VI", EnumChatFormatting.GOLD + "Protection VI" + EnumChatFormatting.BLUE); - t6Enchants.put("Efficiency VI", EnumChatFormatting.GOLD + "Efficieny VI" + EnumChatFormatting.BLUE); + t6Enchants.put("Efficiency VI", EnumChatFormatting.GOLD + "Efficiency VI" + EnumChatFormatting.BLUE); t6Enchants.put("Angler VI", EnumChatFormatting.GOLD + "Angler VI" + EnumChatFormatting.BLUE); t6Enchants.put("Caster VI", EnumChatFormatting.GOLD + "Caster VI" + EnumChatFormatting.BLUE); t6Enchants.put("Frail VI", EnumChatFormatting.GOLD + "Frail VI" + EnumChatFormatting.BLUE); @@ -118,6 +127,41 @@ public class TheMod ClientCommandHandler.instance.registerCommand(new ArmourCommand()); } + // Update checker + @SubscribeEvent + public void onJoin(EntityJoinWorldEvent event) { + if (!updateChecked) { + updateChecked = true; + + // MULTI THREAD DRIFTING + new Thread(() -> { + APIHandler ah = new APIHandler(); + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + + System.err.println("Checking for updates..."); + JsonObject latestRelease = ah.getResponse("https://api.github.com/repos/bowser0000/SkyblockMod/releases/latest"); + + String latestTag = latestRelease.get("tag_name").getAsString(); + DefaultArtifactVersion currentVersion = new DefaultArtifactVersion(VERSION); + DefaultArtifactVersion latestVersion = new DefaultArtifactVersion(latestTag.substring(1)); + + if (currentVersion.compareTo(latestVersion) < 0) { + String releaseURL = latestRelease.get("html_url").getAsString(); + + ChatComponentText update = new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " [UPDATE] "); + update.setChatStyle(update.getChatStyle().setChatClickEvent(new ClickEvent(Action.OPEN_URL, releaseURL))); + + try { + Thread.sleep(2000); + } catch (InterruptedException ex) { + System.err.println(ex); + } + player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + MODID + " is outdated. Please update to " + latestTag + ".\n").appendSibling(update)); + } + }).start(); + } + } + // It randomly broke, so I had to make it the highest priority @SubscribeEvent(priority = EventPriority.HIGHEST) public void onChat(ClientChatReceivedEvent event) { diff --git a/me/Danker/commands/DHelpCommand.java b/me/Danker/commands/DHelpCommand.java index 9c064d7..54724a9 100644 --- a/me/Danker/commands/DHelpCommand.java +++ b/me/Danker/commands/DHelpCommand.java @@ -1,5 +1,6 @@ package me.Danker.commands; +import me.Danker.TheMod; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; @@ -28,7 +29,7 @@ public class DHelpCommand extends CommandBase { public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { EntityPlayer player = (EntityPlayer) arg0; - player.addChatMessage(new ChatComponentText("\n" + EnumChatFormatting.GOLD + " Danker's Skyblock Mod Version 1.5.4\n" + + player.addChatMessage(new ChatComponentText("\n" + EnumChatFormatting.GOLD + " " + TheMod.MODID + " Version " + TheMod.VERSION + "\n" + EnumChatFormatting.AQUA + " <> = Mandatory parameter. [] = Optional parameter.\n" + EnumChatFormatting.GOLD + " /dhelp" + EnumChatFormatting.AQUA + " - Returns this message.\n" + EnumChatFormatting.GOLD + " /toggle <gparty/coords/golden/list>" + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" + @@ -40,7 +41,7 @@ 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.\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")); } diff --git a/me/Danker/commands/PetsCommand.java b/me/Danker/commands/PetsCommand.java index 1ffdd77..8c53732 100644 --- a/me/Danker/commands/PetsCommand.java +++ b/me/Danker/commands/PetsCommand.java @@ -56,7 +56,7 @@ public class PetsCommand extends CommandBase { @Override public String getCommandName() { - return "pets"; + return "petsof"; } @Override |