From f72977e69a788f4b280dca2a901bc2fc859b60c3 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 13 Aug 2018 03:46:57 +1000 Subject: [PATCH] Register BlockExplodeEvent in separate class --- .../boydti/fawe/bukkit/v0/ChunkListener.java | 24 +++---------------- .../fawe/bukkit/v0/ChunkListener_8Plus.java | 18 ++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java index d01ca808c..25d62e3f7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java @@ -24,7 +24,6 @@ import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockExpEvent; -import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockGrowEvent; @@ -57,22 +56,8 @@ public abstract class ChunkListener implements Listener { if (Settings.IMP.TICK_LIMITER.ENABLED) { PluginManager plm = Bukkit.getPluginManager(); Plugin plugin = Fawe.imp().getPlugin(); - for (Method method : this.getClass().getMethods()) { - if (method.isAnnotationPresent(EventHandler.class)) { - try { - EventHandler annotation = method.getAnnotation(EventHandler.class); - EventPriority priority = annotation.priority(); - boolean ignoreC = annotation.ignoreCancelled(); - Class event = (Class) method.getParameterTypes()[0]; - EventExecutor executor = EventExecutor.create(method, event); - plm.registerEvent(event, this, priority, executor, plugin, ignoreC); - System.out.println("Registered " + method); - } catch (Throwable e) { - Fawe.debug("Failed to register " + method + " | " + e.getMessage()); - e.printStackTrace(); - } - } - } + plm.registerEvents(this, plugin); + try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} TaskManager.IMP.repeat(new Runnable() { @Override public void run() { @@ -139,7 +124,7 @@ public abstract class ChunkListener implements Listener { protected long physStart; protected long physTick; - private void reset() { + public final void reset() { physSkip = 0; physStart = System.currentTimeMillis(); physCancel = false; @@ -160,9 +145,6 @@ public abstract class ChunkListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void event(BlockExpEvent event) { reset(); } - @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockExplodeEvent event) { reset(); } - @EventHandler(priority = EventPriority.LOWEST) public void event(BlockFadeEvent event) { reset(); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java new file mode 100644 index 000000000..ab419aa7b --- /dev/null +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java @@ -0,0 +1,18 @@ +package com.boydti.fawe.bukkit.v0; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockExplodeEvent; + +public class ChunkListener_8Plus implements Listener{ + private final ChunkListener listener; + + public ChunkListener_8Plus(ChunkListener listener) { + this.listener = listener; + } + @EventHandler(priority = EventPriority.LOWEST) + public void event(BlockExplodeEvent event) { + listener.reset(); + } +}