aboutsummaryrefslogtreecommitdiffstats
path: root/bukkit/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'bukkit/src/main/java/com')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BreedingTaskType.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BreedingTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BreedingTaskType.java
index cbafca32..08c96fd7 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BreedingTaskType.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BreedingTaskType.java
@@ -7,8 +7,7 @@ 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 org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
+import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
@@ -26,6 +25,7 @@ public final class BreedingTaskType extends BukkitTaskType {
super.addConfigValidator(TaskUtils.useRequiredConfigValidator(this, "amount"));
super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "amount"));
+ super.addConfigValidator(TaskUtils.useEntityListConfigValidator(this, "animal", "animals"));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@@ -55,6 +55,32 @@ public final class BreedingTaskType extends BukkitTaskType {
super.debug("Player detected near bred animal", quest.getId(), task.getId(), player.getUniqueId());
+ List<String> configEntities = TaskUtils.getConfigStringList(task, task.getConfigValues().containsKey("mob") ? "mob" : "mobs");
+
+ if (!configEntities.isEmpty()) {
+ super.debug("List of required entities exists; mob type is " + current.getType(), quest.getId(), task.getId(), player.getUniqueId());
+
+ boolean validMob = false;
+ for (String entry : configEntities) {
+ super.debug("Checking against mob '" + entry + "'", quest.getId(), task.getId(), player.getUniqueId());
+ try {
+ EntityType entity = EntityType.valueOf(entry);
+ if (current.getType() == entity) {
+ super.debug("Mob is valid", quest.getId(), task.getId(), player.getUniqueId());
+ validMob = true;
+ break;
+ }
+ } catch (IllegalArgumentException ignored) {
+ }
+ }
+
+ if (!validMob) {
+ super.debug("Mob is not in list of required mobs, continuing...", quest.getId(), task.getId(), player.getUniqueId());
+ continue;
+ }
+ }
+
+
int progress = TaskUtils.incrementIntegerTaskProgress(taskProgress);
super.debug("Incrementing task progress (now " + progress + ")", quest.getId(), task.getId(), player.getUniqueId());