aboutsummaryrefslogtreecommitdiffstats
path: root/bukkit/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'bukkit/src/main')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/coreprotect/CoreProtectHook.java18
-rw-r--r--bukkit/src/main/resources/resources/bukkit/config.yml4
2 files changed, 22 insertions, 0 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/coreprotect/CoreProtectHook.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/coreprotect/CoreProtectHook.java
index 516f5ae2..e2bf8e78 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/coreprotect/CoreProtectHook.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/coreprotect/CoreProtectHook.java
@@ -23,6 +23,7 @@ public class CoreProtectHook implements AbstractCoreProtectHook {
CompletableFuture<Boolean> future = new CompletableFuture<>();
plugin.getScheduler().doAsync(() -> {
List<String[]> queueLookup = api.queueLookup(block);
+
if (queueLookup.size() >= 2) {
// first queue element when breaking a block is always
// a break action so we just get the second one
@@ -38,7 +39,17 @@ public class CoreProtectHook implements AbstractCoreProtectHook {
}
}
+ long blockLookupDelay = plugin.getConfig().getLong("options.coreprotect-block-lookup-delay", -1L);
+ if (blockLookupDelay > 0L) {
+ try {
+ Thread.sleep(blockLookupDelay);
+ } catch (InterruptedException ignored) {
+ }
+ }
+
List<String[]> blockLookup = api.blockLookup(block, time);
+ boolean first = true;
+
for (String[] result : blockLookup) {
CoreProtectAPI.ParseResult parseResult = api.parseResult(result);
@@ -47,6 +58,13 @@ public class CoreProtectHook implements AbstractCoreProtectHook {
continue;
}
+ // we need to skip first break interaction too in case it's already been inserted
+ if (first && parseResult.getActionId() == 0) {
+ first = false;
+
+ continue;
+ }
+
// due to the order the first element that is not
// an interaction is always the one we need to check
// (0=removed, 1=placed, 2=interaction)
diff --git a/bukkit/src/main/resources/resources/bukkit/config.yml b/bukkit/src/main/resources/resources/bukkit/config.yml
index c4d7df4b..4b26dfc0 100644
--- a/bukkit/src/main/resources/resources/bukkit/config.yml
+++ b/bukkit/src/main/resources/resources/bukkit/config.yml
@@ -124,6 +124,10 @@ options:
# How frequently placeholderapi_evaluate task placeholders will be refreshed (def=30 - 1.5s)
# (multiply SECONDS by 20 to get the number of ticks)
placeholderapi-global-refresh-ticks: 30
+ # By how much (in millis) CoreProtect database async block lookups will be
+ # delayed. It may be helpful in case CoreProtect block lookups work sometimes
+ # weird and doesn't account for some last instant/spammed block changes
+ coreprotect-block-lookup-delay: -1
# Verify quests exist when a player's data is loaded - inconsistencies may arise when
# players progress on specific quests and those quests are later removed. The problem is that their progress
# is still kept in the quest progress file, which may lead to issues such as players reaching a quest started