From 6a22903240aed953f8e1a14ef9a76407ec589270 Mon Sep 17 00:00:00 2001 From: Intelli Date: Tue, 1 Mar 2022 16:49:22 -0700 Subject: [PATCH] Re-enabled BlocksHub & disabled logging integration with AWE --- .../java/net/coreprotect/CoreProtectAPI.java | 20 ------------------- .../CoreProtectEditSessionEvent.java | 12 +++++++---- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/main/java/net/coreprotect/CoreProtectAPI.java b/src/main/java/net/coreprotect/CoreProtectAPI.java index 8157a24..e41dbba 100755 --- a/src/main/java/net/coreprotect/CoreProtectAPI.java +++ b/src/main/java/net/coreprotect/CoreProtectAPI.java @@ -31,8 +31,6 @@ import net.coreprotect.utility.Util; public class CoreProtectAPI extends Queue { - private boolean checkedBlocksHub = false; - public class ParseResult { String[] parse; @@ -168,24 +166,6 @@ public class CoreProtectAPI extends Queue { } public int APIVersion() { - try { - // deny access to BlocksHub to prevent duplicate data from being logged - if (!checkedBlocksHub && Bukkit.getPluginManager().getPlugin("BlocksHub") != null) { - for (StackTraceElement element : Thread.currentThread().getStackTrace()) { - if (element.getClassName().startsWith("org.primesoft.blockshub")) { - checkedBlocksHub = true; - return 0; - } - } - } - else if (!checkedBlocksHub) { - checkedBlocksHub = true; - } - } - catch (Exception e) { - // proceed with returning API version - } - return 8; } diff --git a/src/main/java/net/coreprotect/worldedit/CoreProtectEditSessionEvent.java b/src/main/java/net/coreprotect/worldedit/CoreProtectEditSessionEvent.java index e052dfc..1f4305e 100755 --- a/src/main/java/net/coreprotect/worldedit/CoreProtectEditSessionEvent.java +++ b/src/main/java/net/coreprotect/worldedit/CoreProtectEditSessionEvent.java @@ -18,6 +18,7 @@ import net.coreprotect.utility.Chat; public class CoreProtectEditSessionEvent { private static boolean initialized = false; + private static boolean isFAWE = false; private static CoreProtectEditSessionEvent event = new CoreProtectEditSessionEvent(); public static boolean isInitialized() { @@ -30,9 +31,12 @@ public class CoreProtectEditSessionEvent { } try { - WorldEdit.getInstance().getEventBus().register(event); - initialized = true; - ConfigHandler.worldeditEnabled = true; + if (Bukkit.getServer().getPluginManager().getPlugin("AsyncWorldEdit") == null) { + WorldEdit.getInstance().getEventBus().register(event); + initialized = true; + ConfigHandler.worldeditEnabled = true; + isFAWE = (Bukkit.getServer().getPluginManager().getPlugin("FastAsyncWorldEdit") != null); + } } catch (Exception e) { // Failed to initialize WorldEdit logging @@ -73,7 +77,7 @@ public class CoreProtectEditSessionEvent { public void wrapForLogging(EditSessionEvent event) { Actor actor = event.getActor(); World world = event.getWorld(); - if (actor != null && event.getStage() == Stage.BEFORE_HISTORY) { + if (actor != null && event.getStage() == (isFAWE ? Stage.BEFORE_HISTORY : Stage.BEFORE_CHANGE)) { event.setExtent(new CoreProtectLogger(actor, world, event.getExtent())); } }