From dbaba2fbcce50bf37c0a6830f5b7f7958c943c00 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 24 Sep 2020 22:38:27 +0200 Subject: [PATCH 1/3] Fixed CCE When Block is Changed --- .../src/de/steamwar/bausystem/world/Detonator.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java index 955f556..fa6dbee 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java @@ -25,6 +25,7 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.block.data.Powerable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -81,7 +82,14 @@ public class Detonator implements Listener { Boolean powered; if(activation.activation == -1) switch (Core.getVersion()) { case 15: - powered = AutoLoader_15.getLever(activation.location.getBlock()); + try { + powered = AutoLoader_15.getLever(activation.location.getBlock()); + }catch (ClassCastException e) { + locs.forEach(detonatorActivation -> { + if(detonatorActivation.location.equals(activation.location)) locs.remove(detonatorActivation); + }); + return; + } AutoLoader_15.setRedstone(activation.location, !powered); break; default: @@ -111,7 +119,7 @@ public class Detonator implements Listener { event.setCancelled(true); switch (event.getAction()) { case LEFT_CLICK_BLOCK: - Detoloader detoloader = null; + Detoloader detoloader; switch(Core.getVersion()){ case 15: detoloader = AutoLoader_15.onPlayerInteractLoader(event); -- 2.39.5 From 19cf553654b2d6a022b9b7be01bb7ac2800a3802 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 24 Sep 2020 22:40:32 +0200 Subject: [PATCH 2/3] Fixed CCE When Block is Changed --- BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java | 1 - 1 file changed, 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java index fa6dbee..36dc574 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java @@ -25,7 +25,6 @@ import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.block.data.Powerable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -- 2.39.5 From 9d02ce78627be6b12967f95cfb1f9cafeb09013d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 25 Sep 2020 13:31:51 +0200 Subject: [PATCH 3/3] Simplified Remove --- BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java index 36dc574..b96c414 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java @@ -84,9 +84,7 @@ public class Detonator implements Listener { try { powered = AutoLoader_15.getLever(activation.location.getBlock()); }catch (ClassCastException e) { - locs.forEach(detonatorActivation -> { - if(detonatorActivation.location.equals(activation.location)) locs.remove(detonatorActivation); - }); + locs.remove(activation); return; } AutoLoader_15.setRedstone(activation.location, !powered); -- 2.39.5