From 9663756211f0f714ed0963138586191b1b55a6dd Mon Sep 17 00:00:00 2001 From: HappyPikachu Date: Sun, 18 Feb 2018 15:28:11 -0500 Subject: [PATCH] Only show tameable mobs in list, allow Llamas, fixes #298 --- src/main/java/me/blackvein/quests/Quests.java | 3 ++- .../me/blackvein/quests/prompts/CreateStagePrompt.java | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index a8931a4c4..690cbbce3 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -66,6 +66,7 @@ import org.bukkit.conversations.StringPrompt; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -3031,7 +3032,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener List mobs = config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".mobs-to-tame"); List mobAmounts = config.getIntegerList("quests." + questName + ".stages.ordered." + s2 + ".mob-tame-amounts"); for (String mob : mobs) { - if (mob.equalsIgnoreCase("Wolf") || mob.equalsIgnoreCase("Ocelot") || mob.equalsIgnoreCase("Horse") || mob.equalsIgnoreCase("Parrot")) { + if (Tameable.class.isAssignableFrom(EntityType.valueOf(mob.toUpperCase()).getEntityClass())) { oStage.mobsToTame.put(EntityType.valueOf(mob.toUpperCase()), mobAmounts.get(mobs.indexOf(mob))); } else { stageFailed("" + mob + " inside mobs-to-tame: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid tameable mob!"); diff --git a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index ac226b9b0..11e939b7c 100644 --- a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -31,6 +31,7 @@ import org.bukkit.conversations.StringPrompt; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; import org.bukkit.inventory.ItemStack; import me.blackvein.quests.CustomObjective; @@ -2915,15 +2916,12 @@ public class CreateStagePrompt extends FixedSetPrompt { final EntityType[] mobArr = EntityType.values(); for (int i = 0; i < mobArr.length; i++) { final EntityType type = mobArr[i]; - if (type.isAlive() == false) { + if (type.isAlive() == false || Tameable.class.isAssignableFrom(type.getEntityClass()) == false) { continue; } - if (i < (mobArr.length - 1)) { - mobs += MiscUtil.getProperMobName(mobArr[i]) + ", "; - } else { - mobs += MiscUtil.getProperMobName(mobArr[i]) + "\n"; - } + mobs += MiscUtil.getProperMobName(mobArr[i]) + ", "; } + mobs = mobs.substring(0, mobs.length() - 2) + "\n"; return mobs + ChatColor.YELLOW + Lang.get("stageEditorMobsPrompt"); }