From 633b4c5d179555ff1dbd386327daab5cdc70e03d Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Thu, 7 Jan 2021 22:17:09 +0000 Subject: Add support for worlds --- .../quests/quests/tasktypes/TaskUtils.java | 39 ++++++++++++++++++++++ .../quests/tasktypes/types/BreedingTaskType.java | 4 +++ .../quests/tasktypes/types/BrewingTaskType.java | 4 +++ .../tasktypes/types/BuildingCertainTaskType.java | 4 +++ .../quests/tasktypes/types/BuildingTaskType.java | 4 +++ .../tasktypes/types/CitizensDeliverTaskType.java | 4 +++ .../tasktypes/types/CitizensInteractTaskType.java | 4 +++ .../quests/tasktypes/types/DealDamageTaskType.java | 4 +++ .../quests/tasktypes/types/EnchantingTaskType.java | 4 +++ .../quests/tasktypes/types/ExpEarnTaskType.java | 4 +++ .../quests/tasktypes/types/FarmingTaskType.java | 4 +++ .../quests/tasktypes/types/FishingTaskType.java | 4 +++ .../quests/tasktypes/types/InventoryTaskType.java | 4 +++ .../quests/tasktypes/types/MilkingTaskType.java | 4 +++ .../tasktypes/types/MiningCertainTaskType.java | 7 ++-- .../quests/tasktypes/types/MiningTaskType.java | 3 ++ .../tasktypes/types/MobkillingCertainTaskType.java | 3 ++ .../quests/tasktypes/types/MobkillingTaskType.java | 3 ++ .../tasktypes/types/MythicMobsKillingType.java | 3 ++ .../types/PlaceholderAPIEvaluateTaskType.java | 2 ++ .../tasktypes/types/PlayerkillingTaskType.java | 3 ++ .../quests/tasktypes/types/PlaytimeTaskType.java | 3 ++ .../quests/tasktypes/types/PositionTaskType.java | 1 + .../quests/tasktypes/types/ShearingTaskType.java | 3 ++ .../quests/tasktypes/types/TamingTaskType.java | 3 ++ .../quests/tasktypes/types/WalkingTaskType.java | 3 ++ 26 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/leonardobishop/quests/quests/tasktypes/TaskUtils.java (limited to 'src') diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/TaskUtils.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/TaskUtils.java new file mode 100644 index 00000000..e036a4c1 --- /dev/null +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/TaskUtils.java @@ -0,0 +1,39 @@ +package com.leonardobishop.quests.quests.tasktypes; + +import com.leonardobishop.quests.quests.Task; +import org.bukkit.entity.Player; + +import java.util.List; + +public class TaskUtils { + + public static boolean validateWorld(Player player, Task task) { + return validateWorld(player.getLocation().getWorld().getName(), task.getConfigValue("worlds")); + } + + public static boolean validateWorld(String worldName, Task task) { + return validateWorld(worldName, task.getConfigValue("worlds")); + } + + public static boolean validateWorld(String worldName, Object configurationData) { + if (configurationData == null) { + return true; + } + + if (configurationData instanceof List) { + List allowedWorlds = (List) configurationData; + if (!allowedWorlds.isEmpty() && allowedWorlds.get(0) instanceof String) { + List allowedWorldNames = (List) allowedWorlds; + return allowedWorldNames.contains(worldName); + } + return true; + } + + if (configurationData instanceof String) { + String allowedWorld = (String) configurationData; + return worldName.equals(allowedWorld); + } + + return true; + } +} diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BreedingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BreedingTaskType.java index 20e1a2c6..b18bcd08 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BreedingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BreedingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -26,6 +27,7 @@ public final class BreedingTaskType extends TaskType { public BreedingTaskType() { super("breeding", "toasted", "Breed a set amount of animals."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of animals to be bred")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -58,6 +60,8 @@ public final class BreedingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BrewingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BrewingTaskType.java index 9a88b75b..fdee1dc9 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BrewingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BrewingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -33,6 +34,7 @@ public final class BrewingTaskType extends TaskType { public BrewingTaskType() { super("brewing", "LMBishop", "Brew a potion."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of potions to be brewed.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -67,6 +69,8 @@ public final class BrewingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java index 1713d7da..2898242e 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; @@ -30,6 +31,7 @@ public final class BuildingCertainTaskType extends TaskType { this.creatorConfigValues.add(new ConfigValue("data", false, "Data code for block.")); this.creatorConfigValues.add(new ConfigValue("reverse-if-broken", false, "Will reverse progression if block of same type is broken.")); this.creatorConfigValues.add(new ConfigValue("use-similar-blocks", false, "(Deprecated) If true, this will ignore orientation of doors, logs etc.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -47,6 +49,8 @@ public final class BuildingCertainTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(event.getPlayer(), task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingTaskType.java index 7fc6f03a..b25c70af 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPlaceEvent; @@ -23,6 +24,7 @@ public final class BuildingTaskType extends TaskType { public BuildingTaskType() { super("blockplace", "LMBishop", "Place a set amount of blocks."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of blocks to be placed.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -40,6 +42,8 @@ public final class BuildingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(event.getPlayer(), task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java index a5a6914d..8a64d0ac 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import net.citizensnpcs.api.event.NPCRightClickEvent; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -33,6 +34,7 @@ public final class CitizensDeliverTaskType extends TaskType { this.creatorConfigValues.add(new ConfigValue("npc-name", true, "Name of the NPC.")); this.creatorConfigValues.add(new ConfigValue("remove-items-when-complete", false, "Take the items away from the player on completion (true/false, " + "default = false).")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -63,6 +65,8 @@ public final class CitizensDeliverTaskType extends TaskType { .stripColor(ChatColor.translateAlternateColorCodes('&', citizenName)))) { return; } + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensInteractTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensInteractTaskType.java index 56293f9b..ed277996 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensInteractTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensInteractTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import net.citizensnpcs.api.event.NPCRightClickEvent; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; @@ -24,6 +25,7 @@ public final class CitizensInteractTaskType extends TaskType { public CitizensInteractTaskType() { super("citizens_interact", "LMBishop", "Interact with an NPC to complete the quest."); this.creatorConfigValues.add(new ConfigValue("npc-name", true, "Name of the NPC.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -45,6 +47,8 @@ public final class CitizensInteractTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(event.getClicker(), task)) continue; + if (!ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', String.valueOf(task.getConfigValue("npc-name")))).equals(ChatColor .stripColor(ChatColor.translateAlternateColorCodes('&', event.getNPC().getName())))) { return; diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/DealDamageTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/DealDamageTaskType.java index 9313b1b3..277f1fff 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/DealDamageTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/DealDamageTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -24,6 +25,7 @@ public final class DealDamageTaskType extends TaskType { public DealDamageTaskType() { super("dealdamage", "toasted", "Deal a certain amount of damage."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of damage you need to deal")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -49,6 +51,8 @@ public final class DealDamageTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/EnchantingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/EnchantingTaskType.java index 5391813b..aee02dc4 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/EnchantingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/EnchantingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -24,6 +25,7 @@ public final class EnchantingTaskType extends TaskType { public EnchantingTaskType() { super("enchanting", "toasted", "Enchant a certain amount of items."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of items you need to enchant.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -43,6 +45,8 @@ public final class EnchantingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ExpEarnTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ExpEarnTaskType.java index 97eb0d21..b1731dd7 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ExpEarnTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ExpEarnTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerExpChangeEvent; @@ -23,6 +24,7 @@ public final class ExpEarnTaskType extends TaskType { public ExpEarnTaskType() { super("expearn", "toasted", "Earn a set amount of exp."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of exp that needs to be earned.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -40,6 +42,8 @@ public final class ExpEarnTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(e.getPlayer(), task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java index 7f3f9f11..590c1545 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -26,6 +27,7 @@ public final class FarmingTaskType extends TaskType { super("farming", "LMBishop", "Break a set amount of a crop."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of crops to be broken.")); this.creatorConfigValues.add(new ConfigValue("crop", true, "Name or ID of crop.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -50,6 +52,8 @@ public final class FarmingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(event.getPlayer(), task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java index 2b918f99..5e57a0c1 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -24,6 +25,7 @@ public final class FishingTaskType extends TaskType { public FishingTaskType() { super("fishing", "LMBishop", "Catch a set amount of items from the sea."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of fish to be caught.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -52,6 +54,8 @@ public final class FishingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java index f5b941cd..74caace5 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java @@ -10,6 +10,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -35,6 +36,7 @@ public final class InventoryTaskType extends TaskType { this.creatorConfigValues.add(new ConfigValue("remove-items-when-complete", false, "Take the items away from the player on completion (true/false, " + "default = false).")); this.creatorConfigValues.add(new ConfigValue("update-progress", false, "Update the displayed progress (if this causes lag then disable it).")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -67,6 +69,8 @@ public final class InventoryTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MilkingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MilkingTaskType.java index 208f642b..6d81ba4c 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MilkingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MilkingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Material; import org.bukkit.entity.Cow; import org.bukkit.entity.Player; @@ -26,6 +27,7 @@ public final class MilkingTaskType extends TaskType { public MilkingTaskType() { super("milking", "LMBishop", "Milk a set amount of cows."); this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of cows to be milked.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -50,6 +52,8 @@ public final class MilkingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java index bf5930cb..30314968 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -32,6 +33,7 @@ public final class MiningCertainTaskType extends TaskType { this.creatorConfigValues.add(new ConfigValue("data", false, "Data code for block.")); // only used if no datacode provided in block or blocks this.creatorConfigValues.add(new ConfigValue("reverse-if-placed", false, "Will reverse progression if block of same type is placed.")); this.creatorConfigValues.add(new ConfigValue("use-similar-blocks", false, "(Deprecated) If true, this will ignore orientation of doors, logs etc.")); + this.creatorConfigValues.add(new ConfigValue("worlds", false, "Permitted worlds the player must be in.")); } @Override @@ -74,6 +76,8 @@ public final class MiningCertainTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(event.getPlayer(), task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { @@ -94,7 +98,6 @@ public final class MiningCertainTaskType extends TaskType { private boolean matchBlock(Task task, Block block) { Material material; - Object configBlock = task.getConfigValues().containsKey("block") ? task.getConfigValue("block") : task.getConfigValue("blocks"); Object configData = task.getConfigValue("data"); Object configSimilarBlocks = task.getConfigValue("use-similar-blocks"); @@ -109,7 +112,7 @@ public final class MiningCertainTaskType extends TaskType { for (String materialName : checkBlocks) { // LOG:1 LOG:2 LOG should all be supported with this String[] split = materialName.split(":"); - int comparableData = (int) configData; + int comparableData = 0; if (split.length > 1) { comparableData = Integer.parseInt(split[1]); } diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningTaskType.java index fbba46cc..60712235 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; @@ -44,6 +45,8 @@ public final class MiningTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); // get their progress for the specific quest for (Task task : quest.getTasksOfType(super.getType())) { // get all tasks of this type + if (!TaskUtils.validateWorld(event.getPlayer(), task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); // get the task progress and increment progress by 1 if (taskProgress.isCompleted()) { // dont need to increment a completed task diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java index 238d3387..61a0a557 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingCertainTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.ChatColor; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -57,6 +58,8 @@ public final class MobkillingCertainTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(killer, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java index 770f197a..6bcd835e 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MobkillingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Animals; import org.bukkit.entity.Entity; import org.bukkit.entity.Monster; @@ -56,6 +57,8 @@ public final class MobkillingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(killer, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java index 24b70a82..75570108 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MythicMobsKillingType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -56,6 +57,8 @@ public final class MythicMobsKillingType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(killer.getWorld().getName(), task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaceholderAPIEvaluateTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaceholderAPIEvaluateTaskType.java index f1aff597..7e4af335 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaceholderAPIEvaluateTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaceholderAPIEvaluateTaskType.java @@ -10,6 +10,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -42,6 +43,7 @@ public final class PlaceholderAPIEvaluateTaskType extends TaskType { if (questProgressFile.hasStartedQuest(quest)) { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(PlaceholderAPIEvaluateTaskType.super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { continue; diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java index e28f82e7..f2ef4981 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlayerkillingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -54,6 +55,8 @@ public final class PlayerkillingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(killer, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaytimeTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaytimeTaskType.java index d7ee0505..f3940d07 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaytimeTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PlaytimeTaskType.java @@ -10,6 +10,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -40,6 +41,8 @@ public final class PlaytimeTaskType extends TaskType { if (questProgressFile.hasStartedQuest(quest)) { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(PlaytimeTaskType.super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { continue; diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PositionTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PositionTaskType.java index 7bb1d0a1..2f5d7336 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PositionTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/PositionTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ShearingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ShearingTaskType.java index 8606f8ef..9c78bb2a 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ShearingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/ShearingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; @@ -48,6 +49,8 @@ public final class ShearingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/TamingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/TamingTaskType.java index c057ca57..53428c8f 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/TamingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/TamingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -47,6 +48,8 @@ public final class TamingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/WalkingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/WalkingTaskType.java index 9df9b250..62ced7d9 100644 --- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/WalkingTaskType.java +++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/WalkingTaskType.java @@ -9,6 +9,7 @@ import com.leonardobishop.quests.quests.Quest; import com.leonardobishop.quests.quests.Task; import com.leonardobishop.quests.quests.tasktypes.ConfigValue; import com.leonardobishop.quests.quests.tasktypes.TaskType; +import com.leonardobishop.quests.quests.tasktypes.TaskUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -47,6 +48,8 @@ public final class WalkingTaskType extends TaskType { QuestProgress questProgress = questProgressFile.getQuestProgress(quest); for (Task task : quest.getTasksOfType(super.getType())) { + if (!TaskUtils.validateWorld(player, task)) continue; + TaskProgress taskProgress = questProgress.getTaskProgress(task.getId()); if (taskProgress.isCompleted()) { -- cgit v1.2.3-70-g09d2