aboutsummaryrefslogtreecommitdiffstats
path: root/bukkit/src/main
diff options
context:
space:
mode:
authorKrakenied <Krakenied1@gmail.com>2023-09-17 22:16:42 +0200
committerKrakenied <Krakenied1@gmail.com>2023-09-24 15:57:11 +0200
commitb94b596b8a7925b95d62c7c14682870dac4f1128 (patch)
tree4918cca8e1ef1e0264d78485703e3a6d47c09e7d /bukkit/src/main
parent43812ea231b338fd2f92288d204a8f0691cf76db (diff)
Fix up task type manager
Diffstat (limited to 'bukkit/src/main')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java48
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/BukkitTaskTypeManager.java3
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingTaskType.java4
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/MiningTaskType.java2
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PositionTaskType.java4
5 files changed, 30 insertions, 31 deletions
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 901cee71..f86261fd 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java
@@ -407,37 +407,37 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
taskTypeManager.registerTaskType(new WalkingTaskType(this));
// Register task types with class/method compatibility requirement
- taskTypeManager.registerTaskType(new BrewingTaskType(this), () -> CompatUtils.classWithMethodExists("org.bukkit.event.inventory.BrewEvent", "getResults"));
- taskTypeManager.registerTaskType(new SmithingTaskType(this), () -> CompatUtils.classExists("org.bukkit.event.inventory.SmithItemEvent"));
- taskTypeManager.registerTaskType(new FarmingTaskType(this), () -> CompatUtils.classExists("org.bukkit.block.data.Ageable"));
- taskTypeManager.registerTaskType(new BlockshearingTaskType(this), () -> CompatUtils.classExists("io.papermc.paper.event.block.PlayerShearBlockEvent"));
- taskTypeManager.registerTaskType(new ReplenishingTaskType(this), () -> CompatUtils.classExists("com.destroystokyo.paper.loottable.LootableInventoryReplenishEvent"));
- taskTypeManager.registerTaskType(new BlockItemdroppingTaskType(this), () -> CompatUtils.classExists("org.bukkit.event.block.BlockDropItemEvent"));
+ taskTypeManager.registerTaskType(() -> new BrewingTaskType(this), () -> CompatUtils.classWithMethodExists("org.bukkit.event.inventory.BrewEvent", "getResults"));
+ taskTypeManager.registerTaskType(() -> new SmithingTaskType(this), () -> CompatUtils.classExists("org.bukkit.event.inventory.SmithItemEvent"));
+ taskTypeManager.registerTaskType(() -> new FarmingTaskType(this), () -> CompatUtils.classExists("org.bukkit.block.data.Ageable"));
+ taskTypeManager.registerTaskType(() -> new BlockshearingTaskType(this), () -> CompatUtils.classExists("io.papermc.paper.event.block.PlayerShearBlockEvent"));
+ taskTypeManager.registerTaskType(() -> new ReplenishingTaskType(this), () -> CompatUtils.classExists("com.destroystokyo.paper.loottable.LootableInventoryReplenishEvent"));
+ taskTypeManager.registerTaskType(() -> new BlockItemdroppingTaskType(this), () -> CompatUtils.classExists("org.bukkit.event.block.BlockDropItemEvent"));
// Register task types with enabled plugin compatibility requirement
- taskTypeManager.registerTaskType(new ASkyBlockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("ASkyBlock"));
- taskTypeManager.registerTaskType(new CitizensDeliverTaskType(this), () -> CompatUtils.isPluginEnabled("Citizens"));
- taskTypeManager.registerTaskType(new CitizensInteractTaskType(this), () -> CompatUtils.isPluginEnabled("Citizens"));
- taskTypeManager.registerTaskType(new EcoBossesKillingTaskType(this), () -> CompatUtils.isPluginEnabled("EcoBosses"));
- taskTypeManager.registerTaskType(new EssentialsBalanceTaskType(this), () -> CompatUtils.isPluginEnabled("Essentials"));
- taskTypeManager.registerTaskType(new EssentialsMoneyEarnTaskType(this), () -> CompatUtils.isPluginEnabled("Essentials"));
- taskTypeManager.registerTaskType(new FabledSkyblockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("FabledSkyblock")); // not tested
- taskTypeManager.registerTaskType(new PlaceholderAPIEvaluateTaskType(this), () -> CompatUtils.isPluginEnabled("PlaceholderAPI"));
- taskTypeManager.registerTaskType(new PlayerPointsEarnTaskType(this), () -> CompatUtils.isPluginEnabled("PlayerPoints"));
- taskTypeManager.registerTaskType(new ShopGUIPlusBuyTaskType(this), () -> CompatUtils.isPluginEnabled("ShopGUIPlus")); // not tested
- taskTypeManager.registerTaskType(new ShopGUIPlusSellTaskType(this), () -> CompatUtils.isPluginEnabled("ShopGUIPlus")); // not tested
- taskTypeManager.registerTaskType(new SuperiorSkyblockLevelType(this), () -> CompatUtils.isPluginEnabled("SuperiorSkyblock2")); // not tested
- taskTypeManager.registerTaskType(new SuperiorSkyblockWorthType(this), () -> CompatUtils.isPluginEnabled("SuperiorSkyblock2")); // not tested
- taskTypeManager.registerTaskType(new uSkyBlockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("uSkyBlock"));
- taskTypeManager.registerTaskType(new NuVotifierVoteTaskType(this), () -> CompatUtils.isPluginEnabled("Votifier")); // not tested
- taskTypeManager.registerTaskType(new VotingPluginVoteType(this), () -> CompatUtils.isPluginEnabled("VotingPlugin")); // not tested
+ taskTypeManager.registerTaskType(() -> new ASkyBlockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("ASkyBlock"));
+ taskTypeManager.registerTaskType(() -> new CitizensDeliverTaskType(this), () -> CompatUtils.isPluginEnabled("Citizens"));
+ taskTypeManager.registerTaskType(() -> new CitizensInteractTaskType(this), () -> CompatUtils.isPluginEnabled("Citizens"));
+ taskTypeManager.registerTaskType(() -> new EcoBossesKillingTaskType(this), () -> CompatUtils.isPluginEnabled("EcoBosses"));
+ taskTypeManager.registerTaskType(() -> new EssentialsBalanceTaskType(this), () -> CompatUtils.isPluginEnabled("Essentials"));
+ taskTypeManager.registerTaskType(() -> new EssentialsMoneyEarnTaskType(this), () -> CompatUtils.isPluginEnabled("Essentials"));
+ taskTypeManager.registerTaskType(() -> new FabledSkyblockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("FabledSkyblock")); // not tested
+ taskTypeManager.registerTaskType(() -> new PlaceholderAPIEvaluateTaskType(this), () -> CompatUtils.isPluginEnabled("PlaceholderAPI"));
+ taskTypeManager.registerTaskType(() -> new PlayerPointsEarnTaskType(this), () -> CompatUtils.isPluginEnabled("PlayerPoints"));
+ taskTypeManager.registerTaskType(() -> new ShopGUIPlusBuyTaskType(this), () -> CompatUtils.isPluginEnabled("ShopGUIPlus")); // not tested
+ taskTypeManager.registerTaskType(() -> new ShopGUIPlusSellTaskType(this), () -> CompatUtils.isPluginEnabled("ShopGUIPlus")); // not tested
+ taskTypeManager.registerTaskType(() -> new SuperiorSkyblockLevelType(this), () -> CompatUtils.isPluginEnabled("SuperiorSkyblock2")); // not tested
+ taskTypeManager.registerTaskType(() -> new SuperiorSkyblockWorthType(this), () -> CompatUtils.isPluginEnabled("SuperiorSkyblock2")); // not tested
+ taskTypeManager.registerTaskType(() -> new uSkyBlockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("uSkyBlock"));
+ taskTypeManager.registerTaskType(() -> new NuVotifierVoteTaskType(this), () -> CompatUtils.isPluginEnabled("Votifier")); // not tested
+ taskTypeManager.registerTaskType(() -> new VotingPluginVoteType(this), () -> CompatUtils.isPluginEnabled("VotingPlugin")); // not tested
// Register task types with enabled specific version plugin compatibility requirement
- taskTypeManager.registerTaskType(new IridiumSkyblockValueTaskType(this), () -> { // TODO FIX
+ taskTypeManager.registerTaskType(() -> new IridiumSkyblockValueTaskType(this), () -> { // TODO FIX
String pluginVersion = CompatUtils.getPluginVersion("IridiumSkyblock");
return pluginVersion != null && pluginVersion.startsWith("2");
});
- taskTypeManager.registerTaskType(new MythicMobsKillingTaskType(this), () -> {
+ taskTypeManager.registerTaskType(() -> new MythicMobsKillingTaskType(this), () -> {
String pluginVersion = CompatUtils.getPluginVersion("MythicMobs");
return pluginVersion != null && (pluginVersion.startsWith("4") || pluginVersion.startsWith("5"));
});
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/BukkitTaskTypeManager.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/BukkitTaskTypeManager.java
index cf747cd1..ec41039d 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/BukkitTaskTypeManager.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/BukkitTaskTypeManager.java
@@ -12,7 +12,6 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.UUID;
-import java.util.function.BooleanSupplier;
public class BukkitTaskTypeManager extends TaskTypeManager {
@@ -28,7 +27,7 @@ public class BukkitTaskTypeManager extends TaskTypeManager {
}
@Override
- public boolean registerTaskType(@NotNull TaskType taskType, @NotNull BooleanSupplier... suppliers) {
+ public boolean registerTaskType(@NotNull TaskType taskType) {
if (!(taskType instanceof BukkitTaskType bukkitTaskType)) throw new RuntimeException("BukkitTaskTypeManager implementation can only accept instances of BukkitTaskType!");
if (super.registerTaskType(taskType)) {
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingTaskType.java
index 2fd91c8c..27fcc937 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BuildingTaskType.java
@@ -89,14 +89,14 @@ public final class BuildingTaskType extends BukkitTaskType {
Task task = pendingTask.task();
TaskProgress taskProgress = pendingTask.taskProgress();
- super.debug("Player mined block " + block.getType(), quest.getId(), task.getId(), event.getPlayer().getUniqueId());
+ super.debug("Player mined block " + block.getType(), quest.getId(), task.getId(), player.getUniqueId());
boolean reverseIfBroken = TaskUtils.getConfigBoolean(task, "reverse-if-broken");
if (!reverseIfBroken) {
return;
}
- super.debug("reverse-if-broken is enabled, checking block", quest.getId(), task.getId(), event.getPlayer().getUniqueId());
+ super.debug("reverse-if-broken is enabled, checking block", quest.getId(), task.getId(), player.getUniqueId());
if (!TaskUtils.matchBlock(this, pendingTask, block, player.getUniqueId())) {
super.debug("Continuing...", quest.getId(), task.getId(), player.getUniqueId());
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 b0f2c328..4df51308 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
@@ -62,7 +62,7 @@ public final class MiningTaskType extends BukkitTaskType {
Task task = pendingTask.task();
TaskProgress taskProgress = pendingTask.taskProgress();
- super.debug("Player mined block " + material.name(), quest.getId(), task.getId(), event.getPlayer().getUniqueId());
+ super.debug("Player mined block " + material.name(), quest.getId(), task.getId(), player.getUniqueId());
boolean allowSilkTouch = TaskUtils.getConfigBoolean(task, "allow-silk-touch", true);
if (!allowSilkTouch && silkTouchPresent) {
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PositionTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PositionTaskType.java
index 459199ae..ee72aba7 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PositionTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PositionTaskType.java
@@ -82,11 +82,11 @@ public final class PositionTaskType extends BukkitTaskType {
if (padding != null && (distanceSquared <= padding * padding)) {
super.debug("Player is within distance padding", quest.getId(), task.getId(), player.getUniqueId());
- super.debug("Marking task as complete", quest.getId(), task.getId(), event.getPlayer().getUniqueId());
+ super.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId());
taskProgress.setCompleted(true);
} else if (!blockLocationsDiffer(location, to, true)) {
super.debug("Player is precisely at location", quest.getId(), task.getId(), player.getUniqueId());
- super.debug("Marking task as complete", quest.getId(), task.getId(), event.getPlayer().getUniqueId());
+ super.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId());
taskProgress.setCompleted(true);
}
}