From 4394b45743da07894a50fd622641c9f9cb9ac261 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 13 Aug 2018 03:47:21 +1000 Subject: [PATCH] Register BlockExplodeEvent in another class --- .../boydti/fawe/bukkit/v0/ChunkListener.java | 18 ++++++++++++++++-- .../fawe/bukkit/v0/ChunkListener_8Plus.java | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java index 53bb0ff1..082a9a52 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java @@ -7,8 +7,12 @@ import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.FaweTimer; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.TaskManager; +import com.google.common.io.Files; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -42,11 +46,19 @@ import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.plugin.EventExecutor; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; +import org.bukkit.util.FileUtil; +import org.bukkit.util.StringUtil; import org.bukkit.util.Vector; +import java.io.*; import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; +import java.util.Enumeration; import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; public abstract class ChunkListener implements Listener { @@ -56,7 +68,9 @@ public abstract class ChunkListener implements Listener { public ChunkListener() { if (Settings.IMP.TICK_LIMITER.ENABLED) { PluginManager plm = Bukkit.getPluginManager(); - BukkitMain plugin = Fawe.imp().getPlugin(); + Plugin plugin = Fawe.imp().getPlugin(); + plm.registerEvents(this, plugin); + try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} for (Method method : this.getClass().getMethods()) { if (method.isAnnotationPresent(EventHandler.class)) { try { @@ -138,7 +152,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; diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener_8Plus.java new file mode 100644 index 00000000..aaf866f3 --- /dev/null +++ b/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(); + } +}