diff options
author | bowser0000 <bowser0000@gmail.com> | 2020-07-27 16:47:26 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2020-07-27 16:47:26 -0400 |
commit | 872799a67524437e39f785ec27ab85d708154e65 (patch) | |
tree | fadd2cdbe6911fabf39b713343546ec0f4ea1dc5 | |
parent | 82a8c9b7f800f4fdcbb20e86ae125cda4dd6631d (diff) | |
download | SkyblockMod-1.5.4.tar.gz SkyblockMod-1.5.4.tar.bz2 SkyblockMod-1.5.4.zip |
Change RNG timestamp from int to doublev1.5.4
-rw-r--r-- | me/Danker/TheMod.java | 22 | ||||
-rw-r--r-- | me/Danker/commands/LootCommand.java | 24 | ||||
-rw-r--r-- | me/Danker/handlers/ConfigHandler.java | 40 |
3 files changed, 57 insertions, 29 deletions
diff --git a/me/Danker/TheMod.java b/me/Danker/TheMod.java index 83a77a4..1c69791 100644 --- a/me/Danker/TheMod.java +++ b/me/Danker/TheMod.java @@ -54,8 +54,8 @@ public class TheMod public static final String MODID = "Danker's Skyblock Mod"; public static final String VERSION = "1.5.4"; - static int checkItemsNow = 0; - static int itemsChecked = 0; + static double checkItemsNow = 0; + static double itemsChecked = 0; static Map<String, String> t6Enchants = new HashMap<String, String>(); static Pattern pattern = Pattern.compile(""); @@ -284,21 +284,21 @@ public class TheMod // 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.wolfTime = System.currentTimeMillis() / 1000; lc.wolfBosses = 0; - cf.writeIntConfig("wolf", "timeRNG", lc.wolfTime); + cf.writeDoubleConfig("wolf", "timeRNG", lc.wolfTime); cf.writeIntConfig("wolf", "bossRNG", 0); } if (spiderRNG) { - lc.spiderTime = (int) System.currentTimeMillis() / 1000; + lc.spiderTime = System.currentTimeMillis() / 1000; lc.spiderBosses = 0; - cf.writeIntConfig("spider", "timeRNG", lc.spiderTime); + cf.writeDoubleConfig("spider", "timeRNG", lc.spiderTime); cf.writeIntConfig("spider", "bossRNG", 0); } if (zombieRNG) { - lc.zombieTime = (int) System.currentTimeMillis() / 1000; + lc.zombieTime = System.currentTimeMillis() / 1000; lc.zombieBosses = 0; - cf.writeIntConfig("zombie", "timeRNG", lc.zombieTime); + cf.writeDoubleConfig("zombie", "timeRNG", lc.zombieTime); cf.writeIntConfig("zombie", "bossRNG", 0); } } @@ -330,7 +330,7 @@ public class TheMod String countText = ""; String timeBetween = "Never"; String bossesBetween = "Never"; - int timeNow = (int) System.currentTimeMillis() / 1000; + double timeNow = System.currentTimeMillis() / 1000; if (displayToggle.equals("wolf")) { if (lc.wolfTime == -1) { @@ -446,7 +446,7 @@ public class TheMod public void onSound(final PlaySoundEvent event) { if (event.name.equals("note.pling")) { // Don't check twice within 3 seconds - checkItemsNow = (int) System.currentTimeMillis() / 1000; + checkItemsNow = System.currentTimeMillis() / 1000; if (checkItemsNow - itemsChecked < 3) return; final ScoreboardHandler sc = new ScoreboardHandler(); @@ -468,7 +468,7 @@ public class TheMod // If no items, are detected, allow check again. Should fix items not being found if (itemTeeth + itemWheels + itemWebs + itemTAP + itemRev + itemFoul > 0) { - itemsChecked = (int) System.currentTimeMillis() / 1000; + itemsChecked = System.currentTimeMillis() / 1000; lc.wolfTeeth += itemTeeth; lc.wolfWheels += itemWheels; lc.spiderWebs += itemWebs; diff --git a/me/Danker/commands/LootCommand.java b/me/Danker/commands/LootCommand.java index e61fde7..4e26287 100644 --- a/me/Danker/commands/LootCommand.java +++ b/me/Danker/commands/LootCommand.java @@ -20,7 +20,7 @@ public class LootCommand extends CommandBase { public static int wolfCoutures; public static int wolfBaits; public static int wolfFluxes; - public static int wolfTime; + public static double wolfTime; public static int wolfBosses; // Spider public static int spiderTarantulas; @@ -32,7 +32,7 @@ public class LootCommand extends CommandBase { public static int spiderSwatters; public static int spiderTalismans; public static int spiderMosquitos; - public static int spiderTime; + public static double spiderTime; public static int spiderBosses; // Zombie public static int zombieRevs; @@ -45,11 +45,11 @@ public class LootCommand extends CommandBase { public static int zombieRevCatas; public static int zombieSnakes; public static int zombieScythes; - public static int zombieTime; + public static double zombieTime; public static int zombieBosses; - public String getTimeBetween(int timeOne, int timeTwo) { - int secondsBetween = timeTwo - timeOne; + public String getTimeBetween(double timeOne, double timeTwo) { + double secondsBetween = Math.floor(timeTwo - timeOne); String timeFormatted = ""; int days; @@ -59,18 +59,18 @@ public class LootCommand extends CommandBase { if (secondsBetween > 86400) { // More than 1d, display #d#h - days = secondsBetween / 86400; - hours = secondsBetween % 86400 / 3600; + days = (int) (secondsBetween / 86400); + hours = (int) (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; + hours = (int) (secondsBetween / 3600); + minutes = (int) (secondsBetween % 3600 / 60); timeFormatted = hours + "h" + minutes + "m"; } else { // Display #m#s - minutes = secondsBetween / 60; - seconds = secondsBetween % 60; + minutes = (int) (secondsBetween / 60); + seconds = (int) (secondsBetween % 60); timeFormatted = minutes + "m" + seconds + "s"; } @@ -101,7 +101,7 @@ public class LootCommand extends CommandBase { return; } - int timeNow = (int) System.currentTimeMillis() / 1000; + double timeNow = System.currentTimeMillis() / 1000; String timeBetween; String bossesBetween; if (arg1[0].equalsIgnoreCase("wolf")) { diff --git a/me/Danker/handlers/ConfigHandler.java b/me/Danker/handlers/ConfigHandler.java index 4900777..8d95c3b 100644 --- a/me/Danker/handlers/ConfigHandler.java +++ b/me/Danker/handlers/ConfigHandler.java @@ -40,6 +40,21 @@ public class ConfigHandler { return 0; } + public static double getDouble(String category, String key) { + config = new Configuration(new File(file)); + try { + config.load(); + if (config.getCategory(category).containsKey(key)) { + return config.get(category, key, 0D).getDouble(); + } + } catch (Exception ex) { + System.err.println(ex); + } finally { + config.save(); + } + return 0D; + } + public static String getString(String category, String key) { config = new Configuration(new File(file)); try { @@ -83,6 +98,19 @@ public class ConfigHandler { } } + public static void writeDoubleConfig(String category, String key, double value) { + config = new Configuration(new File(file)); + try { + config.load(); + double set = config.get(category, key, value).getDouble(); + config.getCategory(category).get(key).set(value); + } catch (Exception ex) { + System.err.println(ex); + } finally { + config.save(); + } + } + public static void writeStringConfig(String category, String key, String value) { config = new Configuration(new File(file)); try { @@ -140,7 +168,7 @@ public class ConfigHandler { 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", "timeRNG")) writeDoubleConfig("wolf", "timeRNG", -1); if (!hasKey("wolf", "bossRNG")) writeIntConfig("wolf", "bossRNG", -1); // Spider Loot if (!hasKey("spider", "tarantulas")) writeIntConfig("spider", "tarantulas", 0); @@ -152,7 +180,7 @@ public class ConfigHandler { 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", "timeRNG")) writeDoubleConfig("spider", "timeRNG", -1); if (!hasKey("spider", "bossRNG")) writeIntConfig("spider", "bossRNG", -1); // Zombie Loot if (!hasKey("zombie", "revs")) writeIntConfig("zombie", "revs", 0); @@ -165,7 +193,7 @@ public class ConfigHandler { 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", "timeRNG")) writeDoubleConfig("zombie", "timeRNG", -1); if (!hasKey("zombie", "bossRNG")) writeIntConfig("zombie", "bossRNG", -1); if (!hasKey("misc", "display")) writeStringConfig("misc", "display", "off"); @@ -193,7 +221,7 @@ public class ConfigHandler { lc.wolfCoutures = getInt("wolf", "couture"); lc.wolfBaits = getInt("wolf", "bait"); lc.wolfFluxes = getInt("wolf", "flux"); - lc.wolfTime = getInt("wolf", "timeRNG"); + lc.wolfTime = getDouble("wolf", "timeRNG"); lc.wolfBosses = getInt("wolf", "bossRNG"); // Spider lc.spiderTarantulas = getInt("spider", "tarantulas"); @@ -205,7 +233,7 @@ public class ConfigHandler { lc.spiderSwatters = getInt("spider", "swatter"); lc.spiderTalismans = getInt("spider", "talisman"); lc.spiderMosquitos = getInt("spider", "mosquito"); - lc.spiderTime = getInt("spider", "timeRNG"); + lc.spiderTime = getDouble("spider", "timeRNG"); lc.spiderBosses = getInt("spider", "bossRNG"); // Zombie lc.zombieRevs = getInt("zombie", "revs"); @@ -218,7 +246,7 @@ public class ConfigHandler { lc.zombieRevCatas = getInt("zombie", "revCatalyst"); lc.zombieSnakes = getInt("zombie", "snake"); lc.zombieScythes = getInt("zombie", "scythe"); - lc.zombieTime = getInt("zombie", "timeRNG"); + lc.zombieTime = getDouble("zombie", "timeRNG"); lc.zombieBosses = getInt("zombie", "bossRNG"); final DisplayCommand ds = new DisplayCommand(); |