diff options
author | bowser0000 <bowser0000@gmail.com> | 2020-07-11 00:56:53 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2020-07-11 00:56:53 -0400 |
commit | c0017a23a6aefa6ac779551022b928bca451d46a (patch) | |
tree | 149e30a6be1b4f4d79c9d73c0a914a028a54b62f /me | |
parent | 126f20c221bd2626bb873faa14843e669ad5859f (diff) | |
download | SkyblockMod-c0017a23a6aefa6ac779551022b928bca451d46a.tar.gz SkyblockMod-c0017a23a6aefa6ac779551022b928bca451d46a.tar.bz2 SkyblockMod-c0017a23a6aefa6ac779551022b928bca451d46a.zip |
Add tracker and display for all slayer drops
Added token and 20% chance slayer drops. Also added display for the slayer tracker with /display.
This was more difficult than I thought. I first tried to use the PlayerEvent.ItemPickupEvent event, but it was server side only. Then I tried to use the ClientChatReceivedEvent event, but the boss slain message was sent to late. Ultimately, I decided on the PlaySoundEvent event, which waits for the noise for when a slayer boss dies.
Diffstat (limited to 'me')
-rw-r--r-- | me/Danker/ConfigHandler.java | 120 | ||||
-rw-r--r-- | me/Danker/CoordRenderer.java | 13 | ||||
-rw-r--r-- | me/Danker/GetkeyCommand.java | 39 | ||||
-rw-r--r-- | me/Danker/LootCommand.java | 180 | ||||
-rw-r--r-- | me/Danker/ScoreboardHandler.java | 60 | ||||
-rw-r--r-- | me/Danker/SetkeyCommand.java | 41 | ||||
-rw-r--r-- | me/Danker/TextRenderer.java | 10 | ||||
-rw-r--r-- | me/Danker/ToggleCommand.java | 63 |
8 files changed, 0 insertions, 526 deletions
diff --git a/me/Danker/ConfigHandler.java b/me/Danker/ConfigHandler.java deleted file mode 100644 index 0399588..0000000 --- a/me/Danker/ConfigHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -package me.Danker;
-
-import java.io.File;
-
-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;
- }
-
-}
diff --git a/me/Danker/CoordRenderer.java b/me/Danker/CoordRenderer.java deleted file mode 100644 index 66cdb5e..0000000 --- a/me/Danker/CoordRenderer.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.Danker;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.ScaledResolution;
-
-public class CoordRenderer extends Gui {
- public CoordRenderer(Minecraft mc, String text) {
- ScaledResolution scaled = new ScaledResolution(mc);
- int height = scaled.getScaledHeight();
- drawString(mc.fontRendererObj, text, 5, height - 25, Integer.parseInt("FFFFFF", 16));
- }
-}
diff --git a/me/Danker/GetkeyCommand.java b/me/Danker/GetkeyCommand.java deleted file mode 100644 index fcbe133..0000000 --- a/me/Danker/GetkeyCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.Danker;
-
-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/LootCommand.java b/me/Danker/LootCommand.java deleted file mode 100644 index f4970ff..0000000 --- a/me/Danker/LootCommand.java +++ /dev/null @@ -1,180 +0,0 @@ -package me.Danker;
-
-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 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 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 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() + " [wolf/spider/zombie]";
- }
-
- @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 [wolf/spider/zombie]"));
- 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.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.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.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 [wolf/spider/zombie]"));
- }
-
- }
-
-}
diff --git a/me/Danker/ScoreboardHandler.java b/me/Danker/ScoreboardHandler.java deleted file mode 100644 index 4198a82..0000000 --- a/me/Danker/ScoreboardHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -package me.Danker;
-
-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/SetkeyCommand.java b/me/Danker/SetkeyCommand.java deleted file mode 100644 index 6490611..0000000 --- a/me/Danker/SetkeyCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -package me.Danker;
-
-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/TextRenderer.java b/me/Danker/TextRenderer.java deleted file mode 100644 index e8205bd..0000000 --- a/me/Danker/TextRenderer.java +++ /dev/null @@ -1,10 +0,0 @@ -package me.Danker;
-
-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) {
- drawString(mc.fontRendererObj, text, x, y, colour);
- }
-}
diff --git a/me/Danker/ToggleCommand.java b/me/Danker/ToggleCommand.java deleted file mode 100644 index daf59d0..0000000 --- a/me/Danker/ToggleCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -package me.Danker;
-
-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]";
- }
-
- @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]"));
- 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]"));
- }
- }
-}
|