aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java39
6 files changed, 53 insertions, 47 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);
}
}
diff --git a/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java b/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java
index e3ee82dc..3461ec6f 100644
--- a/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java
+++ b/common/src/main/java/com/leonardobishop/quests/common/tasktype/TaskTypeManager.java
@@ -14,6 +14,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BooleanSupplier;
+import java.util.function.Supplier;
/**
* The task type manager stores all registered task types and registers individual quests to each task type.
@@ -68,28 +69,12 @@ public abstract class TaskTypeManager {
* @param taskType the task type to register
*/
public boolean registerTaskType(@NotNull TaskType taskType) {
- return registerTaskType(taskType, new BooleanSupplier[]{});
- }
-
- /**
- * Register a task type with the task type manager.
- *
- * @param taskType the task type to register
- * @param suppliers suppliers to check for task type compatibility
- */
- public boolean registerTaskType(@NotNull TaskType taskType, @NotNull BooleanSupplier... suppliers) {
Objects.requireNonNull(taskType, "taskType cannot be null");
if (!allowRegistrations) {
throw new IllegalStateException("No longer accepting new task types (must be done before quests are loaded)");
}
- for (BooleanSupplier supplier : suppliers) {
- if (!supplier.getAsBoolean()) {
- return false;
- }
- }
-
if (exclusions.contains(taskType.getType()) || taskTypes.containsKey(taskType.getType())) {
skipped++;
return false;
@@ -104,6 +89,28 @@ public abstract class TaskTypeManager {
}
/**
+ * Register a task type with the task type manager.
+ *
+ * @param taskTypeSupplier supplier of the task type to register
+ * @param compatibilitySuppliers suppliers to check for task type compatibility
+ */
+ public boolean registerTaskType(@NotNull Supplier<TaskType> taskTypeSupplier, @NotNull BooleanSupplier... compatibilitySuppliers) {
+ Objects.requireNonNull(taskTypeSupplier, "taskTypeSupplier cannot be null");
+
+ if (!allowRegistrations) {
+ throw new IllegalStateException("No longer accepting new task types (must be done before quests are loaded)");
+ }
+
+ for (BooleanSupplier supplier : compatibilitySuppliers) {
+ if (!supplier.getAsBoolean()) {
+ return false;
+ }
+ }
+
+ return registerTaskType(taskTypeSupplier.get());
+ }
+
+ /**
* Register a quest with its task types. This will register the quest to each task type it contains.
*
* @param quest the quest to register