From c27a5488666ffb8fb9249698529a3b48132a7358 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 9 Sep 2020 22:45:28 +0200 Subject: [PATCH] Added Function on Tripwire for 1.12 --- .../bausystem/world/AutoLoader_12.java | 25 ++++++++++++++++--- .../bausystem/world/AutoLoader_15.java | 2 +- .../steamwar/bausystem/world/AutoLoader.java | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java index 4ab81c5..13d2137 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java @@ -23,10 +23,13 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockState; -import org.bukkit.event.block.Action; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.material.Tripwire; + +import java.util.List; +import java.util.stream.Collectors; class AutoLoader_12 { @@ -55,6 +58,20 @@ class AutoLoader_12 { block.setData((byte) 1); else block.setData((byte) 0); + }else if(material == Material.TRIPWIRE) { + if(active) { + ArmorStand armorStand = (ArmorStand) Bukkit.getWorlds().get(0).spawnEntity(location, EntityType.ARMOR_STAND); + armorStand.setVisible(false); + armorStand.setBasePlate(false); + armorStand.addScoreboardTag("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ()); + }else { + List entityList = Bukkit.getWorlds().get(0).getEntitiesByClasses(ArmorStand.class).stream().filter(entity -> + entity.getScoreboardTags().contains("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ())) + .limit(1) + .collect(Collectors.toList()); + if(entityList.isEmpty()) return false; + entityList.get(0).remove(); + } }else{ return false; } @@ -80,6 +97,8 @@ class AutoLoader_12 { return new Detoloader("Noteblock", 1); }else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){ return new Detoloader("Druckplatte", 20); + }else if (material == Material.TRIPWIRE) { + return new Detoloader("Tripwire", 10); } return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", 0).setAddBack(false); } diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java index 38d1ca2..f76b6c4 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -108,7 +108,7 @@ class AutoLoader_15 { }else if (material == Material.NOTE_BLOCK) { return new Detoloader("Noteblock", 1); }else if (material.name().equals("TRIPWIRE")) { - return new Detoloader("Tripwire", 20); + return new Detoloader("Tripwire", 10); } else { return new Detoloader("§eUnbekannter Block betätigt", 0).setAddBack(false); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java index fe8787a..4ffb48a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/AutoLoader.java @@ -175,7 +175,7 @@ public class AutoLoader extends IAutoLoader implements Listener { if(detoloader.useActive) new IAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation() , detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation() - , detoloader.isActiv()); + , detoloader.isActive()); else new IAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation() , detoloader.getActivation());