diff options
Diffstat (limited to 'me/Danker')
-rw-r--r-- | me/Danker/TheMod.java | 268 | ||||
-rw-r--r-- | me/Danker/commands/DisplayCommand.java | 55 | ||||
-rw-r--r-- | me/Danker/commands/GetkeyCommand.java | 40 | ||||
-rw-r--r-- | me/Danker/commands/LootCommand.java | 192 | ||||
-rw-r--r-- | me/Danker/commands/ReloadConfigCommand.java | 35 | ||||
-rw-r--r-- | me/Danker/commands/SetkeyCommand.java | 42 | ||||
-rw-r--r-- | me/Danker/commands/ToggleCommand.java | 64 | ||||
-rw-r--r-- | me/Danker/handlers/ConfigHandler.java | 216 | ||||
-rw-r--r-- | me/Danker/handlers/ScoreboardHandler.java | 60 | ||||
-rw-r--r-- | me/Danker/handlers/TextRenderer.java | 13 |
10 files changed, 79 insertions, 906 deletions
diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java index 3e9791b..8850bff 100644 --- a/me/Danker/TheMod.java +++ b/me/Danker/TheMod.java @@ -6,28 +6,14 @@ import java.awt.Toolkit; import java.awt.TrayIcon; import java.util.List; -import me.Danker.commands.DisplayCommand; -import me.Danker.commands.GetkeyCommand; -import me.Danker.commands.LootCommand; -import me.Danker.commands.ReloadConfigCommand; -import me.Danker.commands.SetkeyCommand; -import me.Danker.commands.ToggleCommand; -import me.Danker.handlers.ConfigHandler; -import me.Danker.handlers.ScoreboardHandler; -import me.Danker.handlers.TextRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -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; 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.living.LivingDropsEvent; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; @@ -35,14 +21,11 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -@Mod(modid = TheMod.MODID, version = TheMod.VERSION, clientSideOnly = true) +@Mod(modid = TheMod.MODID, version = TheMod.VERSION) public class TheMod { public static final String MODID = "Danker's Skyblock Mod"; - public static final String VERSION = "1.4"; - - static int checkItemsNow = 0; - static int itemsChecked = 0; + public static final String VERSION = "1.3"; @EventHandler public void init(FMLInitializationEvent event) @@ -50,8 +33,81 @@ public class TheMod FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); + // Config init final ConfigHandler cf = new ConfigHandler(); - cf.reloadConfig(); + if (!cf.hasKey("toggles", "GParty")) cf.writeBooleanConfig("toggles", "GParty", true); + if (!cf.hasKey("toggles", "Coords")) cf.writeBooleanConfig("toggles", "Coords", true); + if (!cf.hasKey("api", "APIKey")) cf.writeStringConfig("api", "APIKey", ""); + + // Wolf Loot + if (!cf.hasKey("wolf", "svens")) cf.writeIntConfig("wolf", "svens", 0); + if (!cf.hasKey("wolf", "spirit")) cf.writeIntConfig("wolf", "spirit", 0); + if (!cf.hasKey("wolf", "book")) cf.writeIntConfig("wolf", "book", 0); + if (!cf.hasKey("wolf", "egg")) cf.writeIntConfig("wolf", "egg", 0); + if (!cf.hasKey("wolf", "couture")) cf.writeIntConfig("wolf", "couture", 0); + if (!cf.hasKey("wolf", "bait")) cf.writeIntConfig("wolf", "bait", 0); + if (!cf.hasKey("wolf", "flux")) cf.writeIntConfig("wolf", "flux", 0); + if (!cf.hasKey("wolf", "timeRNG")) cf.writeIntConfig("wolf", "timeRNG", -1); + if (!cf.hasKey("wolf", "bossRNG")) cf.writeIntConfig("wolf", "bossRNG", -1); + // Spider Loot + if (!cf.hasKey("spider", "tarantulas")) cf.writeIntConfig("spider", "tarantulas", 0); + if (!cf.hasKey("spider", "bite")) cf.writeIntConfig("spider", "bite", 0); + if (!cf.hasKey("spider", "catalyst")) cf.writeIntConfig("spider", "catalyst", 0); + if (!cf.hasKey("spider", "book")) cf.writeIntConfig("spider", "book", 0); + if (!cf.hasKey("spider", "swatter")) cf.writeIntConfig("spider", "swatter", 0); + if (!cf.hasKey("spider", "talisman")) cf.writeIntConfig("spider", "talisman", 0); + if (!cf.hasKey("spider", "mosquito")) cf.writeIntConfig("spider", "mosquito", 0); + if (!cf.hasKey("spider", "timeRNG")) cf.writeIntConfig("spider", "timeRNG", -1); + if (!cf.hasKey("spider", "bossRNG")) cf.writeIntConfig("spider", "bossRNG", -1); + // Zombie Loot + if (!cf.hasKey("zombie", "revs")) cf.writeIntConfig("zombie", "revs", 0); + if (!cf.hasKey("zombie", "pestilence")) cf.writeIntConfig("zombie", "pestilence", 0); + if (!cf.hasKey("zombie", "undeadCatalyst")) cf.writeIntConfig("zombie", "undeadCatalyst", 0); + if (!cf.hasKey("zombie", "book")) cf.writeIntConfig("zombie", "book", 0); + if (!cf.hasKey("zombie", "beheaded")) cf.writeIntConfig("zombie", "beheaded", 0); + if (!cf.hasKey("zombie", "revCatalyst")) cf.writeIntConfig("zombie", "revCatalyst", 0); + if (!cf.hasKey("zombie", "snake")) cf.writeIntConfig("zombie", "snake", 0); + if (!cf.hasKey("zombie", "scythe")) cf.writeIntConfig("zombie", "scythe", 0); + if (!cf.hasKey("zombie", "timeRNG")) cf.writeIntConfig("zombie", "timeRNG", -1); + if (!cf.hasKey("zombie", "bossRNG")) cf.writeIntConfig("zombie", "bossRNG", -1); + + final ToggleCommand tf = new ToggleCommand(); + tf.gpartyToggled = cf.getBoolean("toggles", "GParty"); + tf.coordsToggled = cf.getBoolean("toggles", "Coords"); + + final LootCommand lc = new LootCommand(); + // Wolf + lc.wolfSvens = cf.getInt("wolf", "svens"); + lc.wolfSpirits = cf.getInt("wolf", "spirit"); + lc.wolfBooks = cf.getInt("wolf", "book"); + lc.wolfEggs = cf.getInt("wolf", "egg"); + lc.wolfCoutures = cf.getInt("wolf", "couture"); + lc.wolfBaits = cf.getInt("wolf", "bait"); + lc.wolfFluxes = cf.getInt("wolf", "flux"); + lc.wolfTime = cf.getInt("wolf", "timeRNG"); + lc.wolfBosses = cf.getInt("wolf", "bossRNG"); + // Spider + lc.spiderTarantulas = cf.getInt("spider", "tarantulas"); + lc.spiderBites = cf.getInt("spider", "bite"); + lc.spiderCatalysts = cf.getInt("spider", "catalyst"); + lc.spiderBooks = cf.getInt("spider", "book"); + lc.spiderSwatters = cf.getInt("spider", "swatter"); + lc.spiderTalismans = cf.getInt("spider", "talisman"); + lc.spiderMosquitos = cf.getInt("spider", "mosquito"); + lc.spiderTime = cf.getInt("spider", "timeRNG"); + lc.spiderBosses = cf.getInt("spider", "bossRNG"); + // Zombie + lc.zombieRevs = cf.getInt("zombie", "revs"); + lc.zombiePestilences = cf.getInt("zombie", "pestilence"); + lc.zombieUndeadCatas = cf.getInt("zombie", "undeadCatalyst"); + lc.zombieBooks = cf.getInt("zombie", "book"); + lc.zombieBeheadeds = cf.getInt("zombie", "beheaded"); + lc.zombieRevCatas = cf.getInt("zombie", "revCatalyst"); + lc.zombieSnakes = cf.getInt("zombie", "snake"); + lc.zombieScythes = cf.getInt("zombie", "scythe"); + lc.zombieTime = cf.getInt("zombie", "timeRNG"); + lc.zombieBosses = cf.getInt("zombie", "bossRNG"); + } @EventHandler @@ -60,8 +116,6 @@ public class TheMod ClientCommandHandler.instance.registerCommand(new SetkeyCommand()); ClientCommandHandler.instance.registerCommand(new GetkeyCommand()); ClientCommandHandler.instance.registerCommand(new LootCommand()); - ClientCommandHandler.instance.registerCommand(new ReloadConfigCommand()); - ClientCommandHandler.instance.registerCommand(new DisplayCommand()); } @SubscribeEvent @@ -89,6 +143,8 @@ public class TheMod } } + // Time is stored as a 32-bit int in seconds, so if Skyblock + // survives until 2038, I'll just update it then final LootCommand lc = new LootCommand(); final ConfigHandler cf = new ConfigHandler(); boolean wolfRNG = false; @@ -214,8 +270,6 @@ public class TheMod cf.writeIntConfig("zombie", "scythe", lc.zombieScythes); } - // Time is stored in seconds, so if Skyblock - // survives until 2038, I'll just update it then if (wolfRNG) { lc.wolfTime = (int) System.currentTimeMillis() / 1000; lc.wolfBosses = 0; @@ -271,170 +325,6 @@ public class TheMod int height = scaled.getScaledHeight(); new TextRenderer(Minecraft.getMinecraft(), coordText, 5, height - 25, Integer.parseInt("FFFFFF", 16)); } - - final DisplayCommand ds = new DisplayCommand(); - final String displayToggle = ds.display; - - if (!displayToggle.equals("off")) { - final LootCommand lc = new LootCommand(); - String dropsText = ""; - String countText = ""; - String timeBetween = "Never"; - String bossesBetween = "Never"; - int timeNow = (int) System.currentTimeMillis() / 1000; - - if (displayToggle.equals("wolf")) { - if (lc.wolfTime == -1) { - timeBetween = "Never"; - } else { - timeBetween = lc.getTimeBetween(lc.wolfTime, timeNow); - } - if (lc.wolfBosses == -1) { - bossesBetween = "Never"; - } else { - bossesBetween = Integer.toString(lc.wolfBosses); - } - - dropsText = EnumChatFormatting.GOLD + "Svens Killed:\n" + - EnumChatFormatting.GREEN + "Wolf Teeth:\n" + - EnumChatFormatting.BLUE + "Hamster Wheels:\n" + - EnumChatFormatting.AQUA + "Spirit Runes:\n" + - EnumChatFormatting.WHITE + "Critical VI Books:\n" + - EnumChatFormatting.DARK_RED + "Red Claw Eggs:\n" + - EnumChatFormatting.GOLD + "Couture Runes:\n" + - EnumChatFormatting.AQUA + "Grizzly Baits:\n" + - EnumChatFormatting.DARK_PURPLE + "Overfluxes:\n" + - EnumChatFormatting.AQUA + "Time Since RNG:\n" + - EnumChatFormatting.AQUA + "Bosses Since RNG:\n"; - countText = EnumChatFormatting.GOLD + "" + lc.wolfSvens + "\n" + - EnumChatFormatting.GREEN + lc.wolfTeeth + "\n" + - EnumChatFormatting.BLUE + lc.wolfWheels + "\n" + - EnumChatFormatting.AQUA + lc.wolfSpirits + "\n" + - EnumChatFormatting.WHITE + lc.wolfBooks + "\n" + - EnumChatFormatting.DARK_RED + lc.wolfEggs + "\n" + - EnumChatFormatting.GOLD + lc.wolfCoutures + "\n" + - EnumChatFormatting.AQUA + lc.wolfBaits + "\n" + - EnumChatFormatting.DARK_PURPLE + lc.wolfFluxes + "\n" + - EnumChatFormatting.AQUA + timeBetween + "\n" + - EnumChatFormatting.AQUA + bossesBetween + "\n"; - } else if (displayToggle.equals("spider")) { - if (lc.spiderTime == -1) { - timeBetween = "Never"; - } else { - timeBetween = lc.getTimeBetween(lc.spiderTime, timeNow); - } - if (lc.spiderBosses == -1) { - bossesBetween = "Never"; - } else { - bossesBetween = Integer.toString(lc.spiderBosses); - } - - dropsText = EnumChatFormatting.GOLD + "Tarantulas Killed:\n" + - EnumChatFormatting.GREEN + "Tarantula Webs:\n" + - EnumChatFormatting.DARK_GREEN + "Arrow Poison:\n" + - EnumChatFormatting.DARK_GRAY + "Bite Runes:\n" + - EnumChatFormatting.WHITE + "Bane VI Books:\n" + - EnumChatFormatting.AQUA + "Spider Catalysts:\n" + - EnumChatFormatting.DARK_PURPLE + "Tarantula Talismans:\n" + - EnumChatFormatting.LIGHT_PURPLE + "Fly Swatters:\n" + - EnumChatFormatting.GOLD + "Digested Mosquitos:\n" + - EnumChatFormatting.AQUA + "Time Since RNG:\n" + - EnumChatFormatting.AQUA + "Bosses Since RNG:\n"; - countText = EnumChatFormatting.GOLD + "" + lc.spiderTarantulas + "\n" + - EnumChatFormatting.GREEN + lc.spiderWebs + "\n" + - EnumChatFormatting.DARK_GREEN + lc.spiderTAP + "\n" + - EnumChatFormatting.DARK_GRAY + lc.spiderBites + "\n" + - EnumChatFormatting.WHITE + lc.spiderBooks + "\n" + - EnumChatFormatting.AQUA + lc.spiderCatalysts + "\n" + - EnumChatFormatting.DARK_PURPLE + lc.spiderTalismans + "\n" + - EnumChatFormatting.LIGHT_PURPLE + lc.spiderSwatters + "\n" + - EnumChatFormatting.GOLD + lc.spiderMosquitos + "\n" + - EnumChatFormatting.AQUA + timeBetween + "\n" + - EnumChatFormatting.AQUA + bossesBetween + "\n"; - } else { - // Zombie - dropsText = EnumChatFormatting.GOLD + "Revs Killed:\n" + - EnumChatFormatting.GREEN + "Revenant Flesh:\n" + - EnumChatFormatting.BLUE + "Foul Flesh:\n" + - EnumChatFormatting.DARK_GREEN + "Pestilence Runes:\n" + - EnumChatFormatting.WHITE + "Smite VI Books:\n" + - EnumChatFormatting.AQUA + "Undead Catalysts:\n" + - EnumChatFormatting.DARK_PURPLE + "Beheaded Horrors:\n" + - EnumChatFormatting.RED + "Revenant Catalysts:\n" + - EnumChatFormatting.DARK_GREEN + "Snake Runes:\n" + - EnumChatFormatting.GOLD + "Scythe Blades:\n" + - EnumChatFormatting.AQUA + "Time Since RNG:\n" + - EnumChatFormatting.AQUA + "Bosses Since RNG:\n"; - countText = EnumChatFormatting.GOLD + "" + lc.zombieRevs + "\n" + - EnumChatFormatting.GREEN + lc.zombieRevFlesh + "\n" + - EnumChatFormatting.BLUE + lc.zombieFoulFlesh + "\n" + - EnumChatFormatting.DARK_GREEN + lc.zombiePestilences + "\n" + - EnumChatFormatting.WHITE + lc.zombieBooks + "\n" + - EnumChatFormatting.AQUA + lc.zombieUndeadCatas + "\n" + - EnumChatFormatting.DARK_PURPLE + lc.zombieBeheadeds + "\n" + - EnumChatFormatting.RED + lc.zombieRevCatas + "\n" + - EnumChatFormatting.DARK_GREEN + lc.zombieSnakes + "\n" + - EnumChatFormatting.GOLD + lc.zombieScythes + "\n" + - EnumChatFormatting.AQUA + timeBetween + "\n" + - EnumChatFormatting.AQUA + bossesBetween + "\n"; - } - new TextRenderer(Minecraft.getMinecraft(), dropsText, 80, 5, Integer.parseInt("FFFFFF", 16)); - new TextRenderer(Minecraft.getMinecraft(), countText, 190, 5, Integer.parseInt("FFFFFF", 16)); - } - } - - @SubscribeEvent - public void onSound(final PlaySoundEvent event) { - if (event.name.equals("note.pling")) { - // Don't check twice within 5 seconds - checkItemsNow = (int) System.currentTimeMillis() / 1000; - if (checkItemsNow - itemsChecked <= 5) return; - - final ScoreboardHandler sc = new ScoreboardHandler(); - List<String> scoreboard = sc.getSidebarLines(); - - for (String line : scoreboard) { - String cleanedLine = sc.cleanSB(line); - if (cleanedLine.contains("Boss slain!")) { - final LootCommand lc = new LootCommand(); - final ConfigHandler cf = new ConfigHandler(); - - itemsChecked = (int) System.currentTimeMillis() / 1000; - - lc.wolfTeeth += getItems("Wolf Teeth"); - lc.wolfWheels += getItems("Hamster Wheel"); - lc.spiderWebs += getItems("Tarantula Web"); - lc.spiderTAP += getItems("Toxic Arrow Poison"); - lc.zombieRevFlesh += getItems("Revenant Flesh"); - lc.zombieFoulFlesh += getItems("Foul Flesh"); - - cf.writeIntConfig("wolf", "teeth", lc.wolfTeeth); - cf.writeIntConfig("wolf", "wheel", lc.wolfWheels); - cf.writeIntConfig("spider", "web", lc.spiderWebs); - cf.writeIntConfig("spider", "tap", lc.spiderTAP); - cf.writeIntConfig("zombie", "revFlesh", lc.zombieRevFlesh); - cf.writeIntConfig("zombie", "foulFlesh", lc.zombieFoulFlesh); - } - } - } - } - - public int getItems(String item) { - Minecraft mc = Minecraft.getMinecraft(); - EntityPlayer player = mc.thePlayer; - - double x = player.posX; - double y = player.posY; - double z = player.posZ; - AxisAlignedBB scan = new AxisAlignedBB(x - 6, y - 6, z - 6, x + 6, y + 6, z + 6); - List<EntityItem> items = mc.theWorld.getEntitiesWithinAABB(EntityItem.class, scan); - - for (EntityItem i : items) { - String itemName = StringUtils.stripControlCodes(i.getEntityItem().getDisplayName()); - if (itemName.equals(item)) return i.getEntityItem().stackSize; - } - // No items found - return 0; } } diff --git a/me/Danker/commands/DisplayCommand.java b/me/Danker/commands/DisplayCommand.java deleted file mode 100644 index 534ce16..0000000 --- a/me/Danker/commands/DisplayCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package me.Danker.commands; - -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; - -public class DisplayCommand extends CommandBase { - public static String display; - - @Override - public String getCommandName() { - return "display"; - } - - @Override - public String getCommandUsage(ICommandSender arg0) { - return getCommandName() + " [zombie/spider/wolf/off]"; - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { - final EntityPlayer player = (EntityPlayer) arg0; - - if (arg1.length == 0) { - player.addChatMessage(new ChatComponentText("Usage: /display [zombie/spider/wolf/off]")); - return; - } - - final ConfigHandler cf = new ConfigHandler(); - - if (arg1[0].equalsIgnoreCase("wolf")) { - display = "wolf"; - } else if (arg1[0].equalsIgnoreCase("spider")) { - display = "spider"; - } else if (arg1[0].equalsIgnoreCase("zombie")) { - display = "zombie"; - } else if (arg1[0].equalsIgnoreCase("off")) { - display = "off"; - } else { - player.addChatMessage(new ChatComponentText("Usage: /display [zombie/spider/wolf/off]")); - return; - } - player.addChatMessage(new ChatComponentText("Display set to " + display + ".")); - cf.writeStringConfig("misc", "display", display); - } - -} diff --git a/me/Danker/commands/GetkeyCommand.java b/me/Danker/commands/GetkeyCommand.java deleted file mode 100644 index e8b29e6..0000000 --- a/me/Danker/commands/GetkeyCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.Danker.commands; - -import me.Danker.handlers.ConfigHandler; -import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; - -public class GetkeyCommand extends CommandBase implements ICommand { - - @Override - public String getCommandName() { - return "getkey"; - } - - @Override - public String getCommandUsage(ICommandSender arg0) { - return getCommandName(); - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { - final EntityPlayer player = (EntityPlayer)arg0; - final ConfigHandler cf = new ConfigHandler(); - - if (cf.getString("api", "APIKey").equals("")) { - player.addChatMessage(new ChatComponentText("API key not set. Set your API key using /setkey.")); - } else { - player.addChatMessage(new ChatComponentText("Your set API key is " + cf.getString("api", "APIKey"))); - } - } - -} diff --git a/me/Danker/commands/LootCommand.java b/me/Danker/commands/LootCommand.java deleted file mode 100644 index 4b05d25..0000000 --- a/me/Danker/commands/LootCommand.java +++ /dev/null @@ -1,192 +0,0 @@ -package me.Danker.commands; - -import java.util.List; - -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 LootCommand extends CommandBase { - // Wolf - public static int wolfSvens; - public static int wolfTeeth; - public static int wolfWheels; - public static int wolfSpirits; - public static int wolfBooks; - public static int wolfEggs; - public static int wolfCoutures; - public static int wolfBaits; - public static int wolfFluxes; - public static int wolfTime; - public static int wolfBosses; - // Spider - public static int spiderTarantulas; - public static int spiderWebs; - public static int spiderTAP; - public static int spiderBites; - public static int spiderCatalysts; - public static int spiderBooks; - public static int spiderSwatters; - public static int spiderTalismans; - public static int spiderMosquitos; - public static int spiderTime; - public static int spiderBosses; - // Zombie - public static int zombieRevs; - public static int zombieRevFlesh; - public static int zombieFoulFlesh; - public static int zombiePestilences; - public static int zombieUndeadCatas; - public static int zombieBooks; - public static int zombieBeheadeds; - public static int zombieRevCatas; - public static int zombieSnakes; - public static int zombieScythes; - public static int zombieTime; - public static int zombieBosses; - - public String getTimeBetween(int timeOne, int timeTwo) { - int secondsBetween = timeTwo - timeOne; - - String timeFormatted = ""; - int days; - int hours; - int minutes; - int seconds; - - if (secondsBetween > 86400) { - // More than 1d, display #d#h - days = secondsBetween / 86400; - hours = secondsBetween % 86400 / 3600; - timeFormatted = days + "d" + hours + "h"; - } else if (secondsBetween > 3600) { - // More than 1h, display #h#m - hours = secondsBetween / 3600; - minutes = secondsBetween % 3600 / 60; - timeFormatted = hours + "h" + minutes + "m"; - } else { - // Display #m#s - minutes = secondsBetween / 60; - seconds = secondsBetween % 60; - timeFormatted = minutes + "m" + seconds + "s"; - } - - return timeFormatted; - } - - @Override - public String getCommandName() { - return "loot"; - } - - @Override - public String getCommandUsage(ICommandSender arg0) { - return getCommandName() + " [zombie/spider/wolf]"; - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { - final EntityPlayer player = (EntityPlayer) arg0; - - if (arg1.length == 0) { - player.addChatMessage(new ChatComponentText("Usage: /loot [zombie/spider/wolf]")); - return; - } - - int timeNow = (int) System.currentTimeMillis() / 1000; - String timeBetween; - String bossesBetween; - if (arg1[0].equalsIgnoreCase("wolf")) { - if (wolfTime == -1) { - timeBetween = "Never"; - } else { - timeBetween = getTimeBetween(wolfTime, timeNow); - } - if (wolfBosses == -1) { - bossesBetween = "Never"; - } else { - bossesBetween = Integer.toString(wolfBosses); - } - - player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "-------------------\n" + - EnumChatFormatting.DARK_AQUA + "" + EnumChatFormatting.BOLD + " Sven Loot Summary:\n" + - EnumChatFormatting.GOLD + " Svens Killed: " + wolfSvens + "\n" + - EnumChatFormatting.GREEN + " Wolf Teeth: " + wolfTeeth + "\n" + - EnumChatFormatting.BLUE + " Hamster Wheels: " + wolfWheels + "\n" + - EnumChatFormatting.AQUA + " Spirit Runes: " + wolfSpirits + "\n" + - EnumChatFormatting.WHITE + " Critical VI Books: " + wolfBooks + "\n" + - EnumChatFormatting.DARK_RED + " Red Claw Eggs: " + wolfEggs + "\n" + - EnumChatFormatting.GOLD + " Couture Runes: " + wolfCoutures + "\n" + - EnumChatFormatting.AQUA + " Grizzly Baits: " + wolfBaits + "\n" + - EnumChatFormatting.DARK_PURPLE + " Overfluxes: " + wolfFluxes + "\n" + - EnumChatFormatting.AQUA + " Time Since RNG: " + timeBetween + "\n" + - EnumChatFormatting.AQUA + " Bosses Since RNG: " + bossesBetween + "\n" + - EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + " -------------------")); - } else if (arg1[0].equalsIgnoreCase("spider")) { - if (spiderTime == -1) { - timeBetween = "Never"; - } else { - timeBetween = getTimeBetween(spiderTime, timeNow); - } - if (spiderBosses == -1) { - bossesBetween = "Never"; - } else { - bossesBetween = Integer.toString(spiderBosses); - } - - player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "-------------------\n" + - EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.BOLD + " Spider Loot Summary:\n" + - EnumChatFormatting.GOLD + " Tarantulas Killed: " + spiderTarantulas + "\n" + - EnumChatFormatting.GREEN + " Tarantula Webs: " + spiderWebs + "\n" + - EnumChatFormatting.DARK_GREEN + " Arrow Poison: " + spiderTAP + "\n" + - EnumChatFormatting.DARK_GRAY + " Bite Runes: " + spiderBites + "\n" + - EnumChatFormatting.WHITE + " Bane VI Books: " + spiderBooks + "\n" + - EnumChatFormatting.AQUA + " Spider Catalysts: " + spiderCatalysts + "\n" + - EnumChatFormatting.DARK_PURPLE + " Tarantula Talismans: " + spiderTalismans + "\n" + - 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: " + bossesBetween + "\n" + - EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + " -------------------")); - } else if (arg1[0].equalsIgnoreCase("zombie")) { - if (zombieTime == -1) { - timeBetween = "Never"; - } else { - timeBetween = getTimeBetween(zombieTime, timeNow); - } - if (zombieBosses == -1) { - bossesBetween = "Never"; - } else { - bossesBetween = Integer.toString(zombieBosses); - } - - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + "-------------------\n" + - EnumChatFormatting.DARK_GREEN + "" + EnumChatFormatting.BOLD + " Zombie Loot Summary:\n" + - EnumChatFormatting.GOLD + " Revs Killed: " + zombieRevs + "\n" + - EnumChatFormatting.GREEN + " Revenant Flesh: " + zombieRevFlesh + "\n" + - EnumChatFormatting.BLUE + " Foul Flesh: " + zombieFoulFlesh + "\n" + - EnumChatFormatting.DARK_GREEN + " Pestilence Runes: " + zombiePestilences + "\n" + - EnumChatFormatting.WHITE + " Smite VI Books: " + zombieBooks + "\n" + - EnumChatFormatting.AQUA + " Undead Catalysts: " + zombieUndeadCatas + "\n" + - EnumChatFormatting.DARK_PURPLE + " Beheaded Horrors: " + zombieBeheadeds + "\n" + - EnumChatFormatting.RED + " Revenant Catalysts: " + zombieRevCatas + "\n" + - 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: " + bossesBetween + "\n" + - EnumChatFormatting.GREEN + "" + EnumChatFormatting.BOLD + " -------------------")); - } else { - player.addChatMessage(new ChatComponentText("Usage: /loot [zombie/spider/wolf]")); - } - - } - -} diff --git a/me/Danker/commands/ReloadConfigCommand.java b/me/Danker/commands/ReloadConfigCommand.java deleted file mode 100644 index 4eda66b..0000000 --- a/me/Danker/commands/ReloadConfigCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.Danker.commands; - -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; - -public class ReloadConfigCommand extends CommandBase { - - @Override - public String getCommandName() { - return "reloadconfig"; - } - - @Override - public String getCommandUsage(ICommandSender arg0) { - return getCommandName(); - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { - final EntityPlayer player = (EntityPlayer)arg0; - final ConfigHandler cf = new ConfigHandler(); - cf.reloadConfig(); - player.addChatMessage(new ChatComponentText("Reloaded config.")); - } - -} diff --git a/me/Danker/commands/SetkeyCommand.java b/me/Danker/commands/SetkeyCommand.java deleted file mode 100644 index 85e9dd7..0000000 --- a/me/Danker/commands/SetkeyCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.Danker.commands; - -import me.Danker.handlers.ConfigHandler; -import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; - -public class SetkeyCommand extends CommandBase implements ICommand { - - @Override - public String getCommandName() { - return "setkey"; - } - - @Override - public String getCommandUsage(ICommandSender arg0) { - return getCommandName() + " [key]"; - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { - final EntityPlayer player = (EntityPlayer)arg0; - - if (arg1.length == 0) { - player.addChatMessage(new ChatComponentText("Usage: /setkey [key]")); - return; - } - - final ConfigHandler cf = new ConfigHandler(); - cf.writeStringConfig("api", "APIKey", arg1[0]); - player.addChatMessage(new ChatComponentText("Set API key to " + arg1[0])); - } - -} diff --git a/me/Danker/commands/ToggleCommand.java b/me/Danker/commands/ToggleCommand.java deleted file mode 100644 index 7e1b83a..0000000 --- a/me/Danker/commands/ToggleCommand.java +++ /dev/null @@ -1,64 +0,0 @@ -package me.Danker.commands; - -import me.Danker.handlers.ConfigHandler; -import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; - -public class ToggleCommand extends CommandBase implements ICommand { - public static boolean gpartyToggled; - public static boolean coordsToggled; - - public boolean getToggle(String type) { - if (type.equals("gparty")) { - return gpartyToggled; - } else if (type.equals("coords")) { - return coordsToggled; - } - return true; - } - - @Override - public String getCommandName() { - return "toggle"; - } - - @Override - public String getCommandUsage(ICommandSender arg0) { - return getCommandName() + " [gparty/coords/list]"; - } - - @Override - public int getRequiredPermissionLevel() { - return 0; - } - - @Override - public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { - final EntityPlayer player = (EntityPlayer)arg0; - final ConfigHandler cf = new ConfigHandler(); - - if (arg1.length == 0) { - player.addChatMessage(new ChatComponentText("Usage: /toggle [gparty/coords/list]")); - return; - } - - if (arg1[0].equalsIgnoreCase("gparty")) { - gpartyToggled = !gpartyToggled; - cf.writeBooleanConfig("toggles", "GParty", gpartyToggled); - player.addChatMessage(new ChatComponentText("Guild party notifications has been set to " + gpartyToggled + ".")); - } else if (arg1[0].equalsIgnoreCase("coords")) { - coordsToggled = !coordsToggled; - cf.writeBooleanConfig("toggles", "Coords", coordsToggled); - player.addChatMessage(new ChatComponentText("Coord/Angle display has been set to " + coordsToggled + ".")); - } else if (arg1[0].equalsIgnoreCase("list")) { - player.addChatMessage(new ChatComponentText("Guild party notifications: " + gpartyToggled)); - player.addChatMessage(new ChatComponentText("Coord/Angle display: " + coordsToggled)); - } else { - player.addChatMessage(new ChatComponentText("Usage: /toggle [gparty/coords/list]")); - } - } -} diff --git a/me/Danker/handlers/ConfigHandler.java b/me/Danker/handlers/ConfigHandler.java deleted file mode 100644 index c9556f1..0000000 --- a/me/Danker/handlers/ConfigHandler.java +++ /dev/null @@ -1,216 +0,0 @@ -package me.Danker.handlers; - -import java.io.File; - -import me.Danker.commands.DisplayCommand; -import me.Danker.commands.LootCommand; -import me.Danker.commands.ToggleCommand; -import net.minecraftforge.common.config.Configuration; - -public class ConfigHandler { - public static Configuration config; - private static String file = "config/Danker's Skyblock Mod.cfg"; - - public static void init() { - config = new Configuration(new File(file)); - try { - config.load(); - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - } - - public static int getInt(String category, String key) { - config = new Configuration(new File(file)); - try { - config.load(); - if (config.getCategory(category).containsKey(key)) { - return config.get(category, key, 0).getInt(); - } - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - return 0; - } - - public static String getString(String category, String key) { - config = new Configuration(new File(file)); - try { - config.load(); - if (config.getCategory(category).containsKey(key)) { - return config.get(category, key, "").getString(); - } - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - return ""; - } - - public static boolean getBoolean(String category, String key) { - config = new Configuration(new File(file)); - try { - config.load(); - if (config.getCategory(category).containsKey(key)) { - return config.get(category, key, false).getBoolean(); - } - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - return true; - } - - public static void writeIntConfig(String category, String key, int value) { - config = new Configuration(new File(file)); - try { - config.load(); - int set = config.get(category, key, value).getInt(); - config.getCategory(category).get(key).set(value); - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - } - - public static void writeStringConfig(String category, String key, String value) { - config = new Configuration(new File(file)); - try { - config.load(); - String set = config.get(category, key, value).getString(); - config.getCategory(category).get(key).set(value); - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - } - - public static void writeBooleanConfig(String category, String key, boolean value) { - config = new Configuration(new File(file)); - try { - config.load(); - boolean set = config.get(category, key, value).getBoolean(); - config.getCategory(category).get(key).set(value); - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - } - - public static boolean hasKey(String category, String key) { - config = new Configuration(new File(file)); - try { - config.load(); - if (!config.hasCategory(category)) return false; - return config.getCategory(category).containsKey(key); - } catch (Exception ex) { - System.err.print(ex); - } finally { - config.save(); - } - return false; - } - - public static void reloadConfig() { - // Config init - if (!hasKey("toggles", "GParty")) writeBooleanConfig("toggles", "GParty", true); - if (!hasKey("toggles", "Coords")) writeBooleanConfig("toggles", "Coords", true); - if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", ""); - - // Wolf Loot - if (!hasKey("wolf", "svens")) writeIntConfig("wolf", "svens", 0); - if (!hasKey("wolf", "teeth")) writeIntConfig("wolf", "teeth", 0); - if (!hasKey("wolf", "wheel")) writeIntConfig("wolf", "wheel", 0); - if (!hasKey("wolf", "spirit")) writeIntConfig("wolf", "spirit", 0); - if (!hasKey("wolf", "book")) writeIntConfig("wolf", "book", 0); - if (!hasKey("wolf", "egg")) writeIntConfig("wolf", "egg", 0); - if (!hasKey("wolf", "couture")) writeIntConfig("wolf", "couture", 0); - if (!hasKey("wolf", "bait")) writeIntConfig("wolf", "bait", 0); - if (!hasKey("wolf", "flux")) writeIntConfig("wolf", "flux", 0); - if (!hasKey("wolf", "timeRNG")) writeIntConfig("wolf", "timeRNG", -1); - if (!hasKey("wolf", "bossRNG")) writeIntConfig("wolf", "bossRNG", -1); - // Spider Loot - if (!hasKey("spider", "tarantulas")) writeIntConfig("spider", "tarantulas", 0); - if (!hasKey("spider", "web")) writeIntConfig("spider", "web", 0); - if (!hasKey("spider", "tap")) writeIntConfig("spider", "tap", 0); - if (!hasKey("spider", "bite")) writeIntConfig("spider", "bite", 0); - if (!hasKey("spider", "catalyst")) writeIntConfig("spider", "catalyst", 0); - if (!hasKey("spider", "book")) writeIntConfig("spider", "book", 0); - if (!hasKey("spider", "swatter")) writeIntConfig("spider", "swatter", 0); - if (!hasKey("spider", "talisman")) writeIntConfig("spider", "talisman", 0); - if (!hasKey("spider", "mosquito")) writeIntConfig("spider", "mosquito", 0); - if (!hasKey("spider", "timeRNG")) writeIntConfig("spider", "timeRNG", -1); - if (!hasKey("spider", "bossRNG")) writeIntConfig("spider", "bossRNG", -1); - // Zombie Loot - if (!hasKey("zombie", "revs")) writeIntConfig("zombie", "revs", 0); - if (!hasKey("zombie", "revFlesh")) writeIntConfig("zombie", "revFlesh", 0); - if (!hasKey("zombie", "foulFlesh")) writeIntConfig("zombie", "foulFlesh", 0); - if (!hasKey("zombie", "pestilence")) writeIntConfig("zombie", "pestilence", 0); - if (!hasKey("zombie", "undeadCatalyst")) writeIntConfig("zombie", "undeadCatalyst", 0); - if (!hasKey("zombie", "book")) writeIntConfig("zombie", "book", 0); - if (!hasKey("zombie", "beheaded")) writeIntConfig("zombie", "beheaded", 0); - if (!hasKey("zombie", "revCatalyst")) writeIntConfig("zombie", "revCatalyst", 0); - if (!hasKey("zombie", "snake")) writeIntConfig("zombie", "snake", 0); - if (!hasKey("zombie", "scythe")) writeIntConfig("zombie", "scythe", 0); - if (!hasKey("zombie", "timeRNG")) writeIntConfig("zombie", "timeRNG", -1); - if (!hasKey("zombie", "bossRNG")) writeIntConfig("zombie", "bossRNG", -1); - - if (!hasKey("misc", "display")) writeStringConfig("misc", "display", "off"); - - final ToggleCommand tf = new ToggleCommand(); - tf.gpartyToggled = getBoolean("toggles", "GParty"); - tf.coordsToggled = getBoolean("toggles", "Coords"); - - final LootCommand lc = new LootCommand(); - // Wolf - lc.wolfSvens = getInt("wolf", "svens"); - lc.wolfTeeth = getInt("wolf", "teeth"); - lc.wolfWheels = getInt("wolf", "wheel"); - lc.wolfSpirits = getInt("wolf", "spirit"); - lc.wolfBooks = getInt("wolf", "book"); - lc.wolfEggs = getInt("wolf", "egg"); - lc.wolfCoutures = getInt("wolf", "couture"); - lc.wolfBaits = getInt("wolf", "bait"); - lc.wolfFluxes = getInt("wolf", "flux"); - lc.wolfTime = getInt("wolf", "timeRNG"); - lc.wolfBosses = getInt("wolf", "bossRNG"); - // Spider - lc.spiderTarantulas = getInt("spider", "tarantulas"); - lc.spiderWebs = getInt("spider", "web"); - lc.spiderTAP = getInt("spider", "tap"); - lc.spiderBites = getInt("spider", "bite"); - lc.spiderCatalysts = getInt("spider", "catalyst"); - lc.spiderBooks = getInt("spider", "book"); - lc.spiderSwatters = getInt("spider", "swatter"); - lc.spiderTalismans = getInt("spider", "talisman"); - lc.spiderMosquitos = getInt("spider", "mosquito"); - lc.spiderTime = getInt("spider", "timeRNG"); - lc.spiderBosses = getInt("spider", "bossRNG"); - // Zombie - lc.zombieRevs = getInt("zombie", "revs"); - lc.zombieRevFlesh = getInt("zombie", "revFlesh"); - lc.zombieFoulFlesh = getInt("zombie", "foulFlesh"); - lc.zombiePestilences = getInt("zombie", "pestilence"); - lc.zombieUndeadCatas = getInt("zombie", "undeadCatalyst"); - lc.zombieBooks = getInt("zombie", "book"); - lc.zombieBeheadeds = getInt("zombie", "beheaded"); - lc.zombieRevCatas = getInt("zombie", "revCatalyst"); - lc.zombieSnakes = getInt("zombie", "snake"); - lc.zombieScythes = getInt("zombie", "scythe"); - lc.zombieTime = getInt("zombie", "timeRNG"); - lc.zombieBosses = getInt("zombie", "bossRNG"); - - final DisplayCommand ds = new DisplayCommand(); - ds.display = getString("misc", "display"); - } - -} diff --git a/me/Danker/handlers/ScoreboardHandler.java b/me/Danker/handlers/ScoreboardHandler.java deleted file mode 100644 index e89591b..0000000 --- a/me/Danker/handlers/ScoreboardHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -package me.Danker.handlers; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - -import net.minecraft.client.Minecraft; -import net.minecraft.scoreboard.Score; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.util.StringUtils; - -public class ScoreboardHandler { - - public static String cleanSB(String scoreboard) { - char[] nvString = StringUtils.stripControlCodes(scoreboard).toCharArray(); - StringBuilder cleaned = new StringBuilder(); - - for (char c : nvString) { - if ((int) c > 20 && (int) c < 127) { - cleaned.append(c); - } - } - - return cleaned.toString(); - } - - public static List<String> getSidebarLines() { - List<String> lines = new ArrayList<>(); - Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard(); - if (scoreboard == null) return lines; - - ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1); - if (objective == null) return lines; - - Collection<Score> scores = scoreboard.getSortedScores(objective); - List<Score> list = Lists.newArrayList(scores.stream() - .filter(input -> input != null && input.getPlayerName() != null && !input.getPlayerName() - .startsWith("#")) - .collect(Collectors.toList())); - - if (list.size() > 15) { - scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15)); - } else { - scores = list; - } - - for (Score score : scores) { - ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName()); - lines.add(ScorePlayerTeam.formatPlayerName(team, score.getPlayerName())); - } - - return lines; - } -} diff --git a/me/Danker/handlers/TextRenderer.java b/me/Danker/handlers/TextRenderer.java deleted file mode 100644 index 262f932..0000000 --- a/me/Danker/handlers/TextRenderer.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.Danker.handlers; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; - -public class TextRenderer extends Gui { - public TextRenderer(Minecraft mc, String text, int x, int y, int colour) { - y -= mc.fontRendererObj.FONT_HEIGHT; - for (String line : text.split("\n")) { - drawString(mc.fontRendererObj, line, x, y += mc.fontRendererObj.FONT_HEIGHT, colour); - } - } -} |