From d75fe24ebec33bc2feefcbbec27dddc26a09e6ee Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 24 May 2021 12:01:09 +0200 Subject: [PATCH 1/2] Add and increase Threshold Signed-off-by: Chaoscaot --- .../bausystem/features/world/InventoryListener_15.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java b/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java index 06d5e8cf..7160055c 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/features/world/InventoryListener_15.java @@ -27,6 +27,8 @@ import org.bukkit.inventory.ItemStack; public class InventoryListener_15 { + private static final int threshold = 2048; + public static boolean checkItemStack(ItemStack item) { net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); NBTTagCompound tag = nmsItem.getTag(); @@ -34,13 +36,13 @@ public class InventoryListener_15 { NBTTagCompound blockTag = tag.getCompound("BlockEntityTag"); assert blockTag != null; if (blockTag.hasKey("Items")) { - return drillDown(blockTag.getList("Items", 10), 0, 0) > 1024; + return drillDown(blockTag.getList("Items", 10), 0, 0) > threshold; } return false; } private static int drillDown(NBTTagList items, int layer, int start) { - if (layer > 2) return start + 1024; + if (layer > 2) return start + threshold; int invalid = start; for (NBTBase nbtBase : items) { if (!(nbtBase instanceof NBTTagCompound)) @@ -56,7 +58,7 @@ public class InventoryListener_15 { } } } - if (invalid > 1024) + if (invalid > threshold) break; } return invalid; From d70dda463cbe34118a65a0b7248b888758b90f8b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 24 May 2021 12:17:42 +0200 Subject: [PATCH 2/2] Add Permission to Loader Signed-off-by: Chaoscaot --- .../features/loader/LoaderCommand.java | 135 +++++++++++------- 1 file changed, 81 insertions(+), 54 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index ce0b178d..a9e352cd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; @@ -58,100 +59,126 @@ public class LoaderCommand extends SWCommand { @Register("setup") public void setupLoader(Player p) { - if (Loader.getLoader(p) != null) { - Loader.getLoader(p).setup(); - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Dein Loader ist nun wieder im Setup"); - } else { - Loader.newLoader(p); - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Belade und feuer einmal die Kanone ab, um den Loader zu initialisieren."); - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Führe dann /" + ColorConfig.HIGHLIGHT + "loader start" + ColorConfig.BASE + " um den Loader zu starten"); + if (permissionCheck(p)) { + if (Loader.getLoader(p) != null) { + Loader.getLoader(p).setup(); + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Dein Loader ist nun wieder im Setup"); + } else { + Loader.newLoader(p); + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Belade und feuer einmal die Kanone ab, um den Loader zu initialisieren."); + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Führe dann /" + ColorConfig.HIGHLIGHT + "loader start" + ColorConfig.BASE + " um den Loader zu starten"); + } } } @Register("start") public void startLoader(Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; + if (permissionCheck(p)) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + loader.start(); + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun aktiviert."); } - loader.start(); - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun aktiviert."); } @Register("stop") public void stopLoader(Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; + if (permissionCheck(p)) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + loader.stop(); + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun gestoppt."); } - loader.stop(); - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun gestoppt."); } @Register("pause") public void pauseLoader(Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; + if (permissionCheck(p)) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + loader.pause(); + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun pausiert."); } - loader.pause(); - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader ist nun pausiert."); } @Register("resume") public void resumeLoader(Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; + if (permissionCheck(p)) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + loader.resume(); + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader läuft nun weiter."); } - loader.resume(); - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Der Loader läuft nun weiter."); } @Register("wait") public void shotDelayLoader(Player p, int delay) { - if (delay < 1) { - p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein"); - return; + if (permissionCheck(p)) { + if (delay < 1) { + p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein"); + return; + } + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Die Schusswartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenShots()); + loader.setTicksBetweenShots(delay); } - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Die Schusswartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenShots()); - loader.setTicksBetweenShots(delay); } @Register("speed") public void speedLoader(Player p, int delay) { - if (delay < 1) { - p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein"); - return; + if (permissionCheck(p)) { + if (delay < 1) { + p.sendMessage(BauSystem.PREFIX + ColorConfig.ERROR + "Die Wartezeit ist zu klein"); + return; + } + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "die Setzwartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenBlocks()); + loader.setTicksBetweenShots(delay); } - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; - } - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "die Setzwartezeit ist nun: " + delay + ", zuvor " + loader.getTicksBetweenBlocks()); - loader.setTicksBetweenShots(delay); } @Register("undo") public void undoLast(Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; + if (permissionCheck(p)) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Undo erfolgreich."); + loader.undo(); } - p.sendMessage(BauSystem.PREFIX + ColorConfig.BASE + "Undo erfolgreich."); - loader.undo(); } @Register("clear") public void clearLoader(Player p) { - Loader loader = Loader.getLoader(p); - if (loaderNullCheck(loader, p)) { - return; + if (permissionCheck(p)) { + Loader loader = Loader.getLoader(p); + if (loaderNullCheck(loader, p)) { + return; + } + loader.clear(); } - loader.clear(); + } + + private boolean permissionCheck(Player player) { + if (!Permission.hasPermission(player, Permission.WORLD)) { + player.sendMessage(BauSystem.PREFIX + ColorConfig.DISABLE + "Du darfst hier nicht den Detonator nutzen"); + return false; + } + return true; } }