Re-enabled BlocksHub & disabled logging integration with AWE

This commit is contained in:
Intelli 2022-03-01 16:49:22 -07:00
parent 0bbeee65e8
commit 6a22903240
2 changed files with 8 additions and 24 deletions

View File

@ -31,8 +31,6 @@ import net.coreprotect.utility.Util;
public class CoreProtectAPI extends Queue { public class CoreProtectAPI extends Queue {
private boolean checkedBlocksHub = false;
public class ParseResult { public class ParseResult {
String[] parse; String[] parse;
@ -168,24 +166,6 @@ public class CoreProtectAPI extends Queue {
} }
public int APIVersion() { 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; return 8;
} }

View File

@ -18,6 +18,7 @@ import net.coreprotect.utility.Chat;
public class CoreProtectEditSessionEvent { public class CoreProtectEditSessionEvent {
private static boolean initialized = false; private static boolean initialized = false;
private static boolean isFAWE = false;
private static CoreProtectEditSessionEvent event = new CoreProtectEditSessionEvent(); private static CoreProtectEditSessionEvent event = new CoreProtectEditSessionEvent();
public static boolean isInitialized() { public static boolean isInitialized() {
@ -30,9 +31,12 @@ public class CoreProtectEditSessionEvent {
} }
try { try {
WorldEdit.getInstance().getEventBus().register(event); if (Bukkit.getServer().getPluginManager().getPlugin("AsyncWorldEdit") == null) {
initialized = true; WorldEdit.getInstance().getEventBus().register(event);
ConfigHandler.worldeditEnabled = true; initialized = true;
ConfigHandler.worldeditEnabled = true;
isFAWE = (Bukkit.getServer().getPluginManager().getPlugin("FastAsyncWorldEdit") != null);
}
} }
catch (Exception e) { catch (Exception e) {
// Failed to initialize WorldEdit logging // Failed to initialize WorldEdit logging
@ -73,7 +77,7 @@ public class CoreProtectEditSessionEvent {
public void wrapForLogging(EditSessionEvent event) { public void wrapForLogging(EditSessionEvent event) {
Actor actor = event.getActor(); Actor actor = event.getActor();
World world = event.getWorld(); 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())); event.setExtent(new CoreProtectLogger(actor, world, event.getExtent()));
} }
} }