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 13d2137..72bfcd1 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/world/AutoLoader_12.java @@ -90,17 +90,17 @@ class AutoLoader_12 { return new Detoloader("Hebel", 0).setActive(true); } }else if(material == Material.STONE_BUTTON){ - return new Detoloader("Knopf", 20); + return new Detoloader("Knopf", Detoloader.STONE_BUTTON); }else if(material == Material.WOOD_BUTTON){ - return new Detoloader("Knopf", 30); + return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON); }else if (material == Material.NOTE_BLOCK) { - return new Detoloader("Noteblock", 1); + return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK); }else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){ - return new Detoloader("Druckplatte", 20); + return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE); }else if (material == Material.TRIPWIRE) { - return new Detoloader("Tripwire", 10); + return new Detoloader("Tripwire", Detoloader.TRIPWIRE); } - return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", 0).setAddBack(false); + return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", -1).setAddBack(false); } static boolean getLever(Block block) { 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 f76b6c4..a2c9c42 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/world/AutoLoader_15.java @@ -100,17 +100,17 @@ class AutoLoader_15 { return new Detoloader("Hebel", 0).setActive(true); } } else if (material == Material.STONE_BUTTON) { - return new Detoloader("Knopf", 20); + return new Detoloader("Knopf", Detoloader.STONE_BUTTON); } else if (material.name().contains("PRESSURE_PLATE")){ - return new Detoloader("Druckplatte", 20); + return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE); } else if (material.name().contains("BUTTON")) { - return new Detoloader("Knopf", 30); + return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON); }else if (material == Material.NOTE_BLOCK) { - return new Detoloader("Noteblock", 1); + return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK); }else if (material.name().equals("TRIPWIRE")) { - return new Detoloader("Tripwire", 10); + return new Detoloader("Tripwire", Detoloader.TRIPWIRE); } else { - return new Detoloader("§eUnbekannter Block betätigt", 0).setAddBack(false); + return new Detoloader("§eUnbekannter Block betätigt (aufgenommen)", 0).setAddBack(false); } } diff --git a/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java b/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java index 9e16e10..4e1401a 100644 --- a/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java +++ b/BauSystem_API/src/de/steamwar/bausystem/world/Detoloader.java @@ -77,4 +77,11 @@ public class Detoloader { this.location = location; } } + + //Timings + public static final int STONE_BUTTON = 20; + public static final int WOODEN_BUTTON = 30; + public static final int PRESSURE_PLATE = 20; + public static final int NOTE_BLOCK = 20; + public static final int TRIPWIRE = 10; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 4291ad0..2ccc71e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -36,9 +36,11 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; @@ -160,8 +162,6 @@ public class BauSystem extends JavaPlugin implements Listener { if (Core.getVersion() == 15) Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, false); - if (p.getInventory().contains(Detonator.WAND)) - Detonator.getDetonator(p); } @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java index 86d49b4..4d2f046 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/Detonator.java @@ -24,7 +24,6 @@ import de.steamwar.core.Core; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -52,7 +51,6 @@ public class Detonator implements Listener { ItemMeta im = WAND.getItemMeta(); im.setDisplayName("§6Fernzünder"); - im.addItemFlags(ItemFlag.HIDE_ENCHANTS); List lorelist = Arrays.asList("§eLinks Klick §8- §7Setzte einen Punkt zum Aktivieren", "§eLinks Klick + Shift §8- §7Füge einen Punkt hinzu", "§eRechts Klick §8- §7Löse alle Punkte aus"); @@ -74,7 +72,8 @@ public class Detonator implements Listener { } public static void deleteDetonator(Player player) { - players.remove(player); + if(players.containsKey(player)) + players.remove(player); } public void execute() { @@ -129,12 +128,16 @@ public class Detonator implements Listener { locs.forEach(detonatorActivation -> { if(detonatorActivation.location.equals(event.getClickedBlock().getLocation())) locs.remove(detonatorActivation); }); + print(detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" : + detoloader.getBlock(), detoloader.addBack); }else { if(detoloader.getActivation() == 0) { locs.add(new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation())); }else { locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation())); } + print(detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" : + detoloader.getBlock(), detoloader.addBack); } }else { locs.clear(); @@ -143,9 +146,9 @@ public class Detonator implements Listener { }else { locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation())); } + print(detoloader.addBack ? "§e" + detoloader.getBlock() + " getsetzt" : + detoloader.getBlock(), detoloader.addBack); } - print(detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" : - detoloader.getBlock(), detoloader.addBack); break; case RIGHT_CLICK_AIR: case RIGHT_CLICK_BLOCK: @@ -157,22 +160,13 @@ public class Detonator implements Listener { @EventHandler(ignoreCancelled = true) public void onPlayerQuit(PlayerQuitEvent event) { - players.remove(event.getPlayer()); + deleteDetonator(event.getPlayer()); } Set getLocations() { return locs; } - boolean setRedstone(Location location, boolean active) { - switch(Core.getVersion()){ - case 15: - return AutoLoader_15.setRedstone(location, active); - default: - return AutoLoader_12.setRedstone(location, active); - } - } - Player getPlayer() { return player; }