From f2a0838b850925145fede82fb92f4586d43154d4 Mon Sep 17 00:00:00 2001 From: gecko10000 Date: Fri, 10 May 2024 21:32:58 -0700 Subject: [PATCH 1/2] Fix dragon egg teleportation on left click --- .../towny/listeners/TownyPlayerListener.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java b/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java index 123dc69c5e..ff76e8c5d3 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java @@ -487,6 +487,32 @@ public void onPlayerInteract(PlayerInteractEvent event) { } } + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onDragonEggLeftClick(PlayerInteractEvent event) { + + if (plugin.isError()) { + event.setCancelled(true); + return; + } + + Player player = event.getPlayer(); + if (!TownyAPI.getInstance().isTownyWorld(player.getWorld())) + return; + + if (!event.hasBlock() || event.getAction() != Action.LEFT_CLICK_BLOCK) + return; + + Block block = event.getClickedBlock(); + if (block.getType() != Material.DRAGON_EGG) + return; + + if (TownyActionEventExecutor.canSwitch(player, block.getLocation(), Material.DRAGON_EGG)) + return; + + event.setCancelled(true); + + } + /** * Handles clicking on beds in the nether/respawn anchors in the overworld sending blocks to a map so we can track when explosions occur from beds. * Spigot API's BlockExplodeEvent#getBlock() always returns AIR for beds/anchors exploding, which is why this is necessary. From 34087226e6378960672f04dbad6ae1d9f6710fc8 Mon Sep 17 00:00:00 2001 From: gecko10000 Date: Sat, 11 May 2024 00:41:10 -0700 Subject: [PATCH 2/2] Switch to destroy check --- .../palmergames/bukkit/towny/listeners/TownyPlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java b/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java index ff76e8c5d3..c3597f9c35 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/listeners/TownyPlayerListener.java @@ -506,7 +506,7 @@ public void onDragonEggLeftClick(PlayerInteractEvent event) { if (block.getType() != Material.DRAGON_EGG) return; - if (TownyActionEventExecutor.canSwitch(player, block.getLocation(), Material.DRAGON_EGG)) + if (TownyActionEventExecutor.canDestroy(player, block)) return; event.setCancelled(true);