From a596dd66a90d5b7308492e7bb75a978e0a215b64 Mon Sep 17 00:00:00 2001 From: Intelli Date: Mon, 28 Feb 2022 18:49:20 -0700 Subject: [PATCH] Blocked access to BlocksHub to prevent duplicate data from being logged --- .../java/net/coreprotect/CoreProtectAPI.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/net/coreprotect/CoreProtectAPI.java b/src/main/java/net/coreprotect/CoreProtectAPI.java index f1c5730..edb53c7 100755 --- a/src/main/java/net/coreprotect/CoreProtectAPI.java +++ b/src/main/java/net/coreprotect/CoreProtectAPI.java @@ -31,6 +31,8 @@ import net.coreprotect.utility.Util; public class CoreProtectAPI extends Queue { + private boolean checkedBlocksHub = false; + public class ParseResult { String[] parse; @@ -167,6 +169,24 @@ public class CoreProtectAPI extends Queue { public int APIVersion() { return 8; + 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 + } + } public List blockLookup(Block block, int time) {