From b6b92c4be968581ab288562e6ef97452b5f6abdf Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 5 Jan 2021 16:13:37 +0100 Subject: [PATCH 1/2] Fixing Loader String Double Activation --- .../steamwar/bausystem/world/Detoloader.java | 2 +- .../steamwar/bausystem/world/AutoLoader.java | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java b/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java index 00c5363..d81ca0d 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java +++ b/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java @@ -83,5 +83,5 @@ public class Detoloader { public static final int WOODEN_BUTTON = 30; public static final int PRESSURE_PLATE = 20; public static final int NOTE_BLOCK = 1; - public static final int TRIPWIRE = 10; + public static final int TRIPWIRE = 20; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java index 384dfe8..95a9578 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.core.Core; +import de.steamwar.core.VersionedCallable; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -64,6 +65,7 @@ public class AutoLoader extends IAutoLoader implements Listener { private int waitTicks; private ListIterator lastAction; private boolean setup; + private Location lastLocation; private AutoLoader(Player player){ this.player = player; @@ -166,16 +168,19 @@ public class AutoLoader extends IAutoLoader implements Listener { if(!setup || !event.getPlayer().equals(player)) return; - Detoloader detoloader = null; - switch(Core.getVersion()){ - case 15: - detoloader = AutoLoader_15.onPlayerInteractLoader(event); - break; - default: - detoloader = AutoLoader_12.onPlayerInteractLoader(event); + Detoloader detoloader = VersionedCallable.call( + new VersionedCallable<>(() -> + AutoLoader_12.onPlayerInteractLoader(event), 12), + new VersionedCallable<>(() -> + AutoLoader_15.onPlayerInteractLoader(event), 15)); + if(detoloader == null || detoloader.getActivation() < 0) + return; + + if(lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) { + return; } - if(detoloader == null || detoloader.getActivation() < 0) return; + if(detoloader.useActive) new IAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation() , detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation() @@ -185,6 +190,7 @@ public class AutoLoader extends IAutoLoader implements Listener { , detoloader.getActivation()); print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" : detoloader.getBlock(), detoloader.addBack); + lastLocation = event.getClickedBlock().getLocation(); } @EventHandler From 7e9fb81faa90c73ca7d7c7fbc8789345d9d33da5 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 5 Jan 2021 16:44:40 +0100 Subject: [PATCH 2/2] Fixing Loader String Double Activation --- .../steamwar/bausystem/world/AutoLoader.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java index 95a9578..6763ac7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java @@ -165,29 +165,25 @@ public class AutoLoader extends IAutoLoader implements Listener { if (event.getPlayer().isSneaking()) return; - if(!setup || !event.getPlayer().equals(player)) + if (!setup || !event.getPlayer().equals(player)) return; Detoloader detoloader = VersionedCallable.call( - new VersionedCallable<>(() -> - AutoLoader_12.onPlayerInteractLoader(event), 12), - new VersionedCallable<>(() -> - AutoLoader_15.onPlayerInteractLoader(event), 15)); + new VersionedCallable<>(() -> AutoLoader_12.onPlayerInteractLoader(event), 12), + new VersionedCallable<>(() -> AutoLoader_15.onPlayerInteractLoader(event), 15)); - if(detoloader == null || detoloader.getActivation() < 0) - return; + if (detoloader == null || detoloader.getActivation() < 0) return; - if(lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) { - return; - } + if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return; - if(detoloader.useActive) + if (detoloader.useActive) { new IAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation() , detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation() , detoloader.isActive()); - else + } else { new IAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation() , detoloader.getActivation()); + } print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" : detoloader.getBlock(), detoloader.addBack); lastLocation = event.getClickedBlock().getLocation();