From e788d419b25267ac41782e2f1ccf66f98f3b2a86 Mon Sep 17 00:00:00 2001 From: Stefatorus Date: Sun, 18 Apr 2021 13:55:19 +0300 Subject: [PATCH] Added farm item stacker --- plugin.yml | 2 +- server.yml | 14 ++++++++++- src/cx/sfy/LagAssist/Main.java | 2 +- src/cx/sfy/LagAssist/Redstone.java | 11 ++++----- src/cx/sfy/LagAssist/cmd/CommandListener.java | 2 +- .../LagAssist/microfeatures/MicroManager.java | 1 + src/cx/sfy/LagAssist/utils/V1_11.java | 24 ++++++++++++------- src/cx/sfy/LagAssist/utils/VersionMgr.java | 2 +- 8 files changed, 38 insertions(+), 20 deletions(-) diff --git a/plugin.yml b/plugin.yml index 3d81996..05ff730 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: LagAssist author: Stefatorus -version: 2.23.3 +version: 2.23.4 api-version: 1.13 description: LagAssist is an advanced anti-lag solution that allows server owners find and remove lag using multiple advanced and efficient methods. main: cx.sfy.LagAssist.Main diff --git a/server.yml b/server.yml index 8ca0231..71375b6 100644 --- a/server.yml +++ b/server.yml @@ -167,7 +167,19 @@ microfeatures: increment: 20 # Max value before showing the message max: 80 - + # This feature stack growables in a chunk and only drops items on a full stack. + # IT should reduce the entity counts in the chunk, and can help on servers where + # chunkhoppers are not fully adopted. + # + # (!) Not recommended for servers that do not have extremely huge farms, as the + # drops from smaller farms will get delayed. + stack-growables: + enable: false + # What is the stack size? Amounts over 64 won't render. + stacksize: 64 + blocks: + - "CACTUS" + - "SUGAR_CANE" # Laggy Chunk detection. You can fiddle around and find the best settings for your # server. diff --git a/src/cx/sfy/LagAssist/Main.java b/src/cx/sfy/LagAssist/Main.java index 551f478..f80d509 100644 --- a/src/cx/sfy/LagAssist/Main.java +++ b/src/cx/sfy/LagAssist/Main.java @@ -135,7 +135,7 @@ public class Main extends JavaPlugin implements Listener { p.sendMessage(msg + "(MINDEBUG: " + mindebug + ")"); } - if (debug == 2) { + if (debug == 3) { try { throw new Exception(msg); } catch (Exception e) { diff --git a/src/cx/sfy/LagAssist/Redstone.java b/src/cx/sfy/LagAssist/Redstone.java index 4cd4e81..5bbb2c5 100644 --- a/src/cx/sfy/LagAssist/Redstone.java +++ b/src/cx/sfy/LagAssist/Redstone.java @@ -13,7 +13,6 @@ import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; import cx.sfy.LagAssist.utils.V1_11; -import cx.sfy.LagAssist.utils.VersionMgr; import cx.sfy.LagAssist.utils.WorldMgr; public class Redstone implements Listener { @@ -56,16 +55,14 @@ public class Redstone implements Listener { @Override public void run() { redstoneculler = false; - if (VersionMgr.isV1_11()) { - V1_11.ObserverBreaker(); - } + V1_11.observerBreaker(); } }.runTaskLater(Main.p, ticks); } @EventHandler - public void RedstoneCuller(BlockRedstoneEvent e) { + public void redstoneCuller(BlockRedstoneEvent e) { if (!redstoneculler) { return; } @@ -98,14 +95,14 @@ public class Redstone implements Listener { if (WorldMgr.isBlacklisted(e.getBlock().getWorld())) { return; } - if (VersionMgr.isV1_11()) { +// if (VersionMgr.isNewMaterials()) { if (destructives) { V1_11.ObserverAdd(e.getBlock()); } if (V1_11.isObserver(e.getBlock())) { e.setCancelled(true); } - } +// } } } diff --git a/src/cx/sfy/LagAssist/cmd/CommandListener.java b/src/cx/sfy/LagAssist/cmd/CommandListener.java index a39e812..4893fd6 100644 --- a/src/cx/sfy/LagAssist/cmd/CommandListener.java +++ b/src/cx/sfy/LagAssist/cmd/CommandListener.java @@ -97,7 +97,7 @@ public class CommandListener implements CommandExecutor { .reduce((s1, s2) -> s1 + "\n" + s2).orElse("NOT FOUND")); } } else if (arg.equalsIgnoreCase("debugmode")) { - Main.debug = Main.debug >= 2 ? 0 : Main.debug+1; + Main.debug = Main.debug >= 3 ? 0 : Main.debug+1; sender.sendMessage(Main.PREFIX + "Debug setting currently at: " + Main.debug); } else { sendHelp(sender); diff --git a/src/cx/sfy/LagAssist/microfeatures/MicroManager.java b/src/cx/sfy/LagAssist/microfeatures/MicroManager.java index 199ca18..5109cde 100644 --- a/src/cx/sfy/LagAssist/microfeatures/MicroManager.java +++ b/src/cx/sfy/LagAssist/microfeatures/MicroManager.java @@ -34,6 +34,7 @@ public class MicroManager implements Listener { } Main.p.getServer().getPluginManager().registerEvents(new MicroManager(), Main.p); + Main.p.getServer().getPluginManager().registerEvents(new GrowableStack(), Main.p); } private static void runTask() { diff --git a/src/cx/sfy/LagAssist/utils/V1_11.java b/src/cx/sfy/LagAssist/utils/V1_11.java index 5e9923f..d9f0629 100644 --- a/src/cx/sfy/LagAssist/utils/V1_11.java +++ b/src/cx/sfy/LagAssist/utils/V1_11.java @@ -15,16 +15,20 @@ public class V1_11 { public static Map removable = new HashMap(); public static void ObserverAdd(Block b) { - if (b.getType().equals(Material.OBSERVER)) { - if (removable.containsKey(b)) { - removable.put(b, removable.get(b) + 1); - } else { - removable.put(b, 1); - } + + Material mat = Material.getMaterial("OBSERVER"); + + if (mat == null) { + return; + } + + if (b.getType().equals(mat)) { + int val = removable.compute(b, (k, v) -> v == null ? 1 : v+1); + Main.sendDebug("Incremented value for observer: " + val, 2); } } - public static void ObserverBreaker() { + public static void observerBreaker() { int min = Main.config.getInt("redstone-culler.destructive.value"); for (Block bs : removable.keySet()) { if (removable.get(bs) > min) { @@ -78,7 +82,11 @@ public class V1_11 { // } public static boolean isObserver(Block b) { - if (b.getType().equals(Material.OBSERVER)) { + if (b == null) { + return false; + } + + if (b.getType().equals(Material.getMaterial("OBSERVER"))) { return true; } return false; diff --git a/src/cx/sfy/LagAssist/utils/VersionMgr.java b/src/cx/sfy/LagAssist/utils/VersionMgr.java index 3b3c35a..a2e0a44 100644 --- a/src/cx/sfy/LagAssist/utils/VersionMgr.java +++ b/src/cx/sfy/LagAssist/utils/VersionMgr.java @@ -43,7 +43,7 @@ public class VersionMgr { } public static boolean isV1_11() { - return Bukkit.getVersion().contains("1.11"); + return !isV1_8() && !isV1_9() && !isV1_10(); } public static boolean isV1_12() {