From e42b9cb6a04bc74b5a43ef4c354564e23080a10a Mon Sep 17 00:00:00 2001 From: Stefatorus Date: Mon, 4 Jan 2021 20:55:06 +0200 Subject: [PATCH] Push several fixes to upstream --- .classpath | 2 +- src/cx/sfy/LagAssist/Data.java | 60 +++++++++++++------------ src/cx/sfy/LagAssist/mobs/SmartMob.java | 2 + src/cx/sfy/LagAssist/utils/V1_13.java | 7 ++- 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/.classpath b/.classpath index 941d965..de8a4ab 100644 --- a/.classpath +++ b/.classpath @@ -14,7 +14,7 @@ - + diff --git a/src/cx/sfy/LagAssist/Data.java b/src/cx/sfy/LagAssist/Data.java index f50abfc..6fac2b8 100644 --- a/src/cx/sfy/LagAssist/Data.java +++ b/src/cx/sfy/LagAssist/Data.java @@ -39,42 +39,44 @@ public class Data { e.printStackTrace(); } - + if (!data.contains("version")) { - - + if (data.contains("hoppers")) { for (String rawh : data.getConfigurationSection("hoppers").getKeys(false)) { String loc = "hoppers." + rawh; - + List values = data.getStringList(loc); data.set(loc, null); data.set(loc + ".materials", values); - } + } } - + data.set("version", 1); - + saveData(); - + } } + private static long last; + private static void saveData() { -// -// if (System.currentTimeMillis() - last < 1000) { -// return; -// } -// -// -// Bukkit.getScheduler().runTaskAsynchronously(Main.p, () -> { - try { - data.save(dataf); - } catch (IOException e) { - e.printStackTrace(); + + if (System.currentTimeMillis() - last < 3000) { + return; } -// }); + + last = System.currentTimeMillis(); + + Bukkit.getScheduler().runTaskAsynchronously(Main.p, () -> { + try { + data.save(dataf); + } catch (IOException e) { + e.printStackTrace(); + } + }); } private static short genMapId() { @@ -99,32 +101,32 @@ public class Data { } } - + public static void deleteHopper(Hopper h) { String cloc = "hoppers." + WorldMgr.serializeLocation(h.getLocation()); - + data.set(cloc, null); saveData(); } - + public static boolean isSellHopper(Location loc) { String cloc = "hoppers." + WorldMgr.serializeLocation(loc); - + return data.getBoolean(cloc + ".sellhopper", false); } - + public static boolean toggleSellHopper(Player p, Location loc) { String cloc = "hoppers." + WorldMgr.serializeLocation(loc); String owner = data.getString(cloc + ".owner", "NONE"); - + if (!(p.getUniqueId().toString().equals(owner) || p.hasPermission("lagassist.hopper.bypass"))) { p.sendMessage(Main.PREFIX + "You can't toggle selling for a hopper not owned by you"); return false; } - + String percentage = "§e" + SellHoppers.getMultiplierPercentage(Bukkit.getOfflinePlayer(p.getUniqueId())) + "%"; - + if (isSellHopper(loc)) { data.set(cloc + ".sellhopper", false); p.sendMessage(Main.PREFIX + "This sellhopper has been §cdisabled§f at " + percentage + "§f."); @@ -138,7 +140,7 @@ public class Data { } } - public static OfflinePlayer getOwningPlayer(Location loc) { + public static OfflinePlayer getOwningPlayer(Location loc) { String cloc = "hoppers." + WorldMgr.serializeLocation(loc); if (data.contains(cloc + ".owner")) { diff --git a/src/cx/sfy/LagAssist/mobs/SmartMob.java b/src/cx/sfy/LagAssist/mobs/SmartMob.java index b2f1cf9..8eea5a3 100644 --- a/src/cx/sfy/LagAssist/mobs/SmartMob.java +++ b/src/cx/sfy/LagAssist/mobs/SmartMob.java @@ -27,6 +27,8 @@ import cx.sfy.LagAssist.utils.WorldMgr; public class SmartMob implements Listener { + EventPriority prio; + private static SplittableRandom rand = new SplittableRandom(); public static boolean Spawning; diff --git a/src/cx/sfy/LagAssist/utils/V1_13.java b/src/cx/sfy/LagAssist/utils/V1_13.java index 55c1c63..1a61d22 100644 --- a/src/cx/sfy/LagAssist/utils/V1_13.java +++ b/src/cx/sfy/LagAssist/utils/V1_13.java @@ -64,13 +64,18 @@ public class V1_13 { public static List getLootTable(Entity ent) { LootTables lt = LootTables.valueOf(ent.getType().toString()); + // TODO: FIX in 1.16 + // java.lang.IllegalArgumentException: + // Missing required parameters: + // [, ] + List itms = new ArrayList(); if (lt == null) { return itms; } - itms.addAll(lt.getLootTable().populateLoot(r, new LootContext.Builder(ent.getLocation()).build())); + itms.addAll(lt.getLootTable().populateLoot(r, new LootContext.Builder(ent.getLocation()).lootedEntity(ent).build())); return itms; }