diff options
6 files changed, 64 insertions, 3 deletions
diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 9830f1ab..6b463f2c 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -81,6 +81,8 @@ dependencies { compileOnly 'com.vexsoftware:NuVotifier:2.7.3' // PlaceholderAPI compileOnly 'me.clip:placeholderapi:2.11.3-DEV-160' + // PlayerBlockTracker + compileOnly('com.github.Flo0:PlayerBlockTracker:1.0.2') { transitive = false } // SCore compileOnly 'com.github.Ssomar-Developement:SCore:3.4.7' // ShopGUIPlus diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java index 5d4f1c32..633509a5 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java @@ -13,6 +13,8 @@ import com.leonardobishop.quests.bukkit.hook.itemgetter.ItemGetter_1_13; import com.leonardobishop.quests.bukkit.hook.itemgetter.ItemGetter_Late_1_8; import com.leonardobishop.quests.bukkit.hook.papi.AbstractPlaceholderAPIHook; import com.leonardobishop.quests.bukkit.hook.papi.PlaceholderAPIHook; +import com.leonardobishop.quests.bukkit.hook.playerblocktracker.AbstractPlayerBlockTrackerHook; +import com.leonardobishop.quests.bukkit.hook.playerblocktracker.PlayerBlockTrackerHook; import com.leonardobishop.quests.bukkit.hook.title.Title; import com.leonardobishop.quests.bukkit.hook.title.Title_Bukkit; import com.leonardobishop.quests.bukkit.hook.title.Title_BukkitNoTimings; @@ -89,6 +91,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests { private AbstractPlaceholderAPIHook placeholderAPIHook; private AbstractCoreProtectHook coreProtectHook; private AbstractEssentialsHook essentialsHook; + private AbstractPlayerBlockTrackerHook playerBlockTrackerHook; private ItemGetter itemGetter; private Title titleHandle; private VersionSpecificHandler versionSpecificHandler; @@ -277,6 +280,9 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests { if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) { this.essentialsHook = new EssentialsHook(); } + if (Bukkit.getPluginManager().isPluginEnabled("PlayerBlockTracker")) { + this.playerBlockTrackerHook = new PlayerBlockTrackerHook(); + } taskTypeManager.registerTaskType(new MiningTaskType(this)); taskTypeManager.registerTaskType(new BuildingTaskType(this)); @@ -569,6 +575,10 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests { return essentialsHook; } + public @Nullable AbstractPlayerBlockTrackerHook getPlayerBlockTrackerHook() { + return playerBlockTrackerHook; + } + public ItemGetter getItemGetter() { return itemGetter; } diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/playerblocktracker/AbstractPlayerBlockTrackerHook.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/playerblocktracker/AbstractPlayerBlockTrackerHook.java new file mode 100644 index 00000000..2e07316b --- /dev/null +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/playerblocktracker/AbstractPlayerBlockTrackerHook.java @@ -0,0 +1,15 @@ +package com.leonardobishop.quests.bukkit.hook.playerblocktracker; + +import org.bukkit.block.Block; + +public interface AbstractPlayerBlockTrackerHook { + + /** + * Check whether or not the most recent edit to a block was the result of a player. + * + * @param block the block + * @return true if from a player + */ + boolean checkBlock(Block block); + +} diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/playerblocktracker/PlayerBlockTrackerHook.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/playerblocktracker/PlayerBlockTrackerHook.java new file mode 100644 index 00000000..34bf95af --- /dev/null +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/hook/playerblocktracker/PlayerBlockTrackerHook.java @@ -0,0 +1,13 @@ +package com.leonardobishop.quests.bukkit.hook.playerblocktracker; + +import com.gestankbratwurst.playerblocktracker.PlayerBlockTracker; +import org.bukkit.block.Block; + +public class PlayerBlockTrackerHook implements AbstractPlayerBlockTrackerHook { + + @Override + public boolean checkBlock(Block block) { + return PlayerBlockTracker.isTracked(block); + } + +} diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java index 4249600e..e0395d83 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java @@ -2,6 +2,7 @@ package com.leonardobishop.quests.bukkit.tasktype.type; import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin; import com.leonardobishop.quests.bukkit.hook.coreprotect.AbstractCoreProtectHook; +import com.leonardobishop.quests.bukkit.hook.playerblocktracker.AbstractPlayerBlockTrackerHook; import com.leonardobishop.quests.bukkit.tasktype.BukkitTaskType; import com.leonardobishop.quests.bukkit.util.TaskUtils; import com.leonardobishop.quests.common.player.QPlayer; @@ -30,6 +31,7 @@ public final class MiningTaskType extends BukkitTaskType { super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "amount")); super.addConfigValidator(TaskUtils.useMaterialListConfigValidator(this, TaskUtils.MaterialListConfigValidatorMode.BLOCK, "block", "blocks")); super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "data")); + super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "check-playerblocktracker")); super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "check-coreprotect")); super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "check-coreprotect-time")); super.addConfigValidator(TaskUtils.useBooleanConfigValidator(this, "reverse-if-placed")); @@ -68,8 +70,24 @@ public final class MiningTaskType extends BukkitTaskType { super.debug("allow-silk-touch is disabled, checking block", quest.getId(), task.getId(), player.getUniqueId()); if (TaskUtils.matchBlock(this, pendingTask, block, player.getUniqueId())) { - boolean coreProtectEnabled = (boolean) task.getConfigValue("check-coreprotect", false); - int coreProtectTime = (int) task.getConfigValue("check-coreprotect-time", 3600); + boolean playerBlockTrackerEnabled = (boolean) task.getConfigValue("check-playerblocktracker", false); + + if (playerBlockTrackerEnabled) { + AbstractPlayerBlockTrackerHook playerBlockTrackerHook = plugin.getPlayerBlockTrackerHook(); + if (playerBlockTrackerHook != null) { + super.debug("Running PlayerBlockTracker lookup", quest.getId(), task.getId(), player.getUniqueId()); + + boolean result = playerBlockTrackerHook.checkBlock(block); + if (result) { + super.debug("PlayerBlockTracker lookup indicates this is a player placed block, continuing...", quest.getId(), task.getId(), player.getUniqueId()); + continue; + } + + super.debug("PlayerBlockTracker lookup OK", quest.getId(), task.getId(), player.getUniqueId()); + } else { + super.debug("check-playerblocktracker is enabled, but PlayerBlockTracker is not detected on the server", quest.getId(), task.getId(), player.getUniqueId()); + } + } Runnable increment = () -> { int progress = TaskUtils.incrementIntegerTaskProgress(taskProgress); @@ -82,6 +100,9 @@ public final class MiningTaskType extends BukkitTaskType { } }; + boolean coreProtectEnabled = (boolean) task.getConfigValue("check-coreprotect", false); + int coreProtectTime = (int) task.getConfigValue("check-coreprotect-time", 3600); + if (coreProtectEnabled) { AbstractCoreProtectHook coreProtectHook = plugin.getCoreProtectHook(); if (coreProtectHook != null) { diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 0ec4ca48..4f31e2ec 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -6,7 +6,7 @@ version: "${version}" main: com.leonardobishop.quests.bukkit.BukkitQuestsPlugin website: https://github.com/LMBishop/Quests author: "LMBishop & contributors" -softdepend: [ASkyBlock, BentoBox, Citizens, CoreProtect, Essentials, FabledSkyblock, IridiumSkyblock, MythicMobs, PlaceholderAPI, ShopGUIPlus, SuperiorSkyblock2, uSkyBlock, Votifier, VotingPlugin] +softdepend: [ASkyBlock, BentoBox, Citizens, CoreProtect, Essentials, FabledSkyblock, IridiumSkyblock, MythicMobs, PlaceholderAPI, PlayerBlockTracker, ShopGUIPlus, SuperiorSkyblock2, uSkyBlock, Votifier, VotingPlugin] prefix: Quests api-version: "1.13" # allows new API features but Quests will still work pre-1.13 |
