From bb21d2ff5167429fff3613df7628e4cb4ad7c74a Mon Sep 17 00:00:00 2001 From: Zelytra Date: Fri, 27 Aug 2021 10:27:35 +0200 Subject: [PATCH] Ticket #169 --- .../respawnable/PlayerBreakBlockListener.java | 5 ++++- .../environnement/structure/BreakBlockListener.java | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/zelytra/daedalus/events/running/environnement/respawnable/PlayerBreakBlockListener.java b/src/main/java/fr/zelytra/daedalus/events/running/environnement/respawnable/PlayerBreakBlockListener.java index a79a8a6..4ae07ea 100644 --- a/src/main/java/fr/zelytra/daedalus/events/running/environnement/respawnable/PlayerBreakBlockListener.java +++ b/src/main/java/fr/zelytra/daedalus/events/running/environnement/respawnable/PlayerBreakBlockListener.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.ExperienceOrb; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; @@ -22,8 +23,10 @@ public class PlayerBreakBlockListener implements Listener { private static HashMap taskIDs = new HashMap<>(); - @EventHandler + @EventHandler (priority = EventPriority.HIGH) public void onBreak(BlockBreakEvent e) { + if(e.isCancelled()) + return; try { BlockEnum block = BlockEnum.valueOf(e.getBlock().getType().toString()); diff --git a/src/main/java/fr/zelytra/daedalus/events/running/environnement/structure/BreakBlockListener.java b/src/main/java/fr/zelytra/daedalus/events/running/environnement/structure/BreakBlockListener.java index ff623a1..fba09ec 100644 --- a/src/main/java/fr/zelytra/daedalus/events/running/environnement/structure/BreakBlockListener.java +++ b/src/main/java/fr/zelytra/daedalus/events/running/environnement/structure/BreakBlockListener.java @@ -1,12 +1,12 @@ package fr.zelytra.daedalus.events.running.environnement.structure; import fr.zelytra.daedalus.Daedalus; -import fr.zelytra.daedalus.events.running.environnement.respawnable.BlockEnum; import fr.zelytra.daedalus.managers.maze.Maze; import fr.zelytra.daedalus.managers.maze.Vector2; import fr.zelytra.daedalus.managers.structure.Structure; import org.bukkit.Material; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.util.BoundingBox; @@ -22,7 +22,7 @@ public class BreakBlockListener implements Listener { blacklist.add(Material.BROWN_MUSHROOM_BLOCK); } - @EventHandler + @EventHandler (priority = EventPriority.LOW) public void onBreak(BlockBreakEvent e) { if (!Daedalus.getInstance().getGameManager().isRunning()) { return; @@ -46,9 +46,6 @@ public void onBreak(BlockBreakEvent e) { case -5: case -6: case -7: - if (BlockEnum.containType(e.getBlock().getType())) { - break; - } //Loop structures for (Map.Entry entry : Daedalus.getInstance().getStructureManager().getStructuresPosition().entrySet()) { if (entry.getKey().contains(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ())) {