diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 13e423c4..626d6b44 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -18,7 +18,7 @@ repositories { // Paper (adventure-bom snapshots) maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // ASkyBlock, BentoBox, bStats, Citizens - maven("https://repo.codemc.org/repository/maven-public/") + maven("https://repo.codemc.io/repository/maven-public/") // AuthLib maven("https://libraries.minecraft.net/") // CoreProtect @@ -36,7 +36,7 @@ repositories { // Oraxen maven("https://repo.oraxen.com/releases") // PlaceholderAPI - maven("https://repo.extendedclip.com/content/repositories/dev/") + maven("https://repo.extendedclip.com/releases") // CustomFishing, ItemsAdder, SCore, ShopGUIPlus, Slimefun4, Vault maven("https://jitpack.io/") // PlayerPoints @@ -68,7 +68,8 @@ dependencies { // AuthLib compileOnlyPlugin("com.mojang:authlib:1.5.21") // BentoBox - compileOnlyPlugin("world.bentobox:bentobox:1.22.0-SNAPSHOT") + compileOnly("world.bentobox:bentobox:2.5.4-SNAPSHOT") + compileOnly("world.bentobox:level:2.16.1-SNAPSHOT") // Citizens compileOnlyPlugin("net.citizensnpcs:citizensapi:2.0.30-SNAPSHOT") // CoreProtect @@ -101,7 +102,7 @@ dependencies { // Oraxen compileOnlyPlugin("io.th0rgal:oraxen:1.175.0") // PlaceholderAPI - compileOnlyPlugin("me.clip:placeholderapi:2.11.3-DEV-160") + compileOnlyPlugin("me.clip:placeholderapi:2.11.6") // PlayerPoints compileOnlyPlugin("org.black_ixx:playerpoints:3.2.5") // SCore 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 7de0c1bd..bafe5381 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java @@ -477,6 +477,7 @@ public void onEnable() { // Register task types with enabled plugin compatibility requirement taskTypeManager.registerTaskType(() -> new ASkyBlockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("ASkyBlock")); + taskTypeManager.registerTaskType(() -> new BentoBoxLevelTaskType(this), () -> CompatUtils.isPluginEnabled("BentoBox") && CompatUtils.classExists("world.bentobox.level.events.IslandLevelCalculatedEvent")); taskTypeManager.registerTaskType(() -> new CitizensDeliverTaskType(this), () -> CompatUtils.isPluginEnabled("Citizens")); taskTypeManager.registerTaskType(() -> new CitizensInteractTaskType(this), () -> CompatUtils.isPluginEnabled("Citizens")); taskTypeManager.registerTaskType(() -> new CustomFishingFishingTaskType(this), () -> CompatUtils.isPluginEnabled("CustomFishing")); @@ -511,11 +512,6 @@ public void onEnable() { return pluginVersion != null && (pluginVersion.startsWith("4") || pluginVersion.startsWith("5")); }); - // Register task types with even more weird requirements - if (CompatUtils.isPluginEnabled("BentoBox")) { - BentoBoxLevelTaskType.register(this, taskTypeManager); - } - // Close task type registrations taskTypeManager.closeRegistrations(); diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InventoryTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InventoryTaskType.java index 81ebf24e..ecdb0b1f 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InventoryTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/InventoryTaskType.java @@ -112,7 +112,6 @@ private void checkInventory(Player player) { super.debug("Inventory check triggered", quest.getId(), task.getId(), player.getUniqueId()); - boolean remove = TaskUtils.getConfigBoolean(task, "remove-items-when-complete"); boolean allowPartial = TaskUtils.getConfigBoolean(task, "allow-partial-completion"); QuestItem qi; @@ -167,6 +166,8 @@ private void checkInventory(Player player) { taskProgress.setCompleted(true); super.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId()); + boolean remove = TaskUtils.getConfigBoolean(task, "remove-items-when-complete"); + if (remove) { TaskUtils.removeItemsInSlots(player, amountPerSlot, progress); super.debug("Removing items from inventory", quest.getId(), task.getId(), player.getUniqueId()); diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/BentoBoxLevelTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/BentoBoxLevelTaskType.java index fd18c916..7b9e3c98 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/BentoBoxLevelTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/BentoBoxLevelTaskType.java @@ -3,78 +3,78 @@ import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin; import com.leonardobishop.quests.bukkit.tasktype.BukkitTaskType; import com.leonardobishop.quests.bukkit.util.TaskUtils; +import com.leonardobishop.quests.bukkit.util.constraint.TaskConstraintSet; import com.leonardobishop.quests.common.player.QPlayer; import com.leonardobishop.quests.common.player.questprogressfile.TaskProgress; import com.leonardobishop.quests.common.quest.Quest; import com.leonardobishop.quests.common.quest.Task; -import com.leonardobishop.quests.common.tasktype.TaskTypeManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import world.bentobox.bentobox.BentoBox; -import world.bentobox.bentobox.api.events.IslandBaseEvent; +import org.jetbrains.annotations.NotNull; import world.bentobox.bentobox.database.objects.Island; +import world.bentobox.level.events.IslandLevelCalculatedEvent; +import java.util.Set; import java.util.UUID; public final class BentoBoxLevelTaskType extends BukkitTaskType { private final BukkitQuestsPlugin plugin; - public BentoBoxLevelTaskType(BukkitQuestsPlugin plugin) { + public BentoBoxLevelTaskType(final @NotNull BukkitQuestsPlugin plugin) { super("bentobox_level", TaskUtils.TASK_ATTRIBUTION_STRING, "Reach a certain island level in the level addon for BentoBox."); this.plugin = plugin; - super.addConfigValidator(TaskUtils.useRequiredConfigValidator(this, "level")); - super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "level")); + this.addConfigValidator(TaskUtils.useRequiredConfigValidator(this, "level")); + this.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "level")); } - public static void register(BukkitQuestsPlugin plugin, TaskTypeManager manager) { - if (BentoBox.getInstance().getAddonsManager().getAddonByName("Level").isPresent()) { - manager.registerTaskType(new BentoBoxLevelTaskType(plugin)); - } - } - - // https://github.com/BentoBoxWorld/bentobox/issues/352 @EventHandler - public void onBentoBoxIslandLevelCalculated(IslandBaseEvent event) { - if ("IslandLevelCalculatedEvent".equals(event.getEventName())) { - Island island = (Island) event.getKeyValues().get("island"); + public void onIslandLevelCalculated(final @NotNull IslandLevelCalculatedEvent event) { + final Island island = event.getIsland(); + final Set memberIds = island.getMemberSet(); + final long level = event.getLevel(); - for (UUID member : island.getMemberSet()) { - QPlayer qPlayer = plugin.getPlayerManager().getPlayer(member); - if (qPlayer == null) { - continue; - } + for (final UUID memberId : memberIds) { + final Player player = Bukkit.getPlayer(memberId); - Player player = Bukkit.getPlayer(member); + if (player != null) { + this.handle(player, level); + } + } + } - if (player == null) { - continue; - } + private void handle(final @NotNull Player player, final long level) { + if (player.hasMetadata("NPC")) { + return; + } - for (TaskUtils.PendingTask pendingTask : TaskUtils.getApplicableTasks(player, qPlayer, this)) { - Quest quest = pendingTask.quest(); - Task task = pendingTask.task(); - TaskProgress taskProgress = pendingTask.taskProgress(); + final QPlayer qPlayer = this.plugin.getPlayerManager().getPlayer(player.getUniqueId()); + if (qPlayer == null) { + return; + } - long islandLevelNeeded = (long) (int) task.getConfigValue("level"); - long newLevel = (long) event.getKeyValues().get("level"); + for (final TaskUtils.PendingTask pendingTask : TaskUtils.getApplicableTasks(player, qPlayer, this, TaskConstraintSet.ALL)) { + final Quest quest = pendingTask.quest(); + final Task task = pendingTask.task(); + final TaskProgress taskProgress = pendingTask.taskProgress(); - super.debug("Player island level updated to " + newLevel, quest.getId(), task.getId(), member); + this.debug("Player island level updated to " + level, quest.getId(), task.getId(), player.getUniqueId()); - taskProgress.setProgress(newLevel); - super.debug("Updating task progress (now " + newLevel + ")", quest.getId(), task.getId(), player.getUniqueId()); + //noinspection DataFlowIssue // TODO quest data rework + final long levelNeeded = (long) task.getConfigValue("level"); - if (newLevel >= islandLevelNeeded) { - super.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId()); - taskProgress.setProgress(newLevel); - taskProgress.setCompleted(true); - } + final long clampedLevel = Math.max(level, levelNeeded); + taskProgress.setProgress(clampedLevel); + this.debug("Updating task progress (now " + clampedLevel + ")", quest.getId(), task.getId(), player.getUniqueId()); - TaskUtils.sendTrackAdvancement(player, quest, task, pendingTask, islandLevelNeeded); - } + if (level >= levelNeeded) { + this.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId()); + taskProgress.setCompleted(true); } + + TaskUtils.sendTrackAdvancement(player, quest, task, pendingTask, levelNeeded); } } } diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/DeliverTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/DeliverTaskType.java index d73a40ff..f927319a 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/DeliverTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/DeliverTaskType.java @@ -97,7 +97,6 @@ public void checkInventory(Player player, T npcId, String npcName, BukkitQuestsP } } - boolean remove = TaskUtils.getConfigBoolean(task, "remove-items-when-complete"); boolean allowPartial = TaskUtils.getConfigBoolean(task, "allow-partial-completion"); QuestItem qi; @@ -143,6 +142,8 @@ public void checkInventory(Player player, T npcId, String npcName, BukkitQuestsP taskProgress.setCompleted(true); super.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId()); + boolean remove = TaskUtils.getConfigBoolean(task, "remove-items-when-complete"); + if (remove) { TaskUtils.removeItemsInSlots(player, amountPerSlot, progress); super.debug("Removing items from inventory", quest.getId(), task.getId(), player.getUniqueId()); diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136..a4b76b95 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9355b415..0aaefbca 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf13..f5feea6d 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 7101f8e4..9b42019c 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ##########################################################################