diff --git a/src/main/java/me/blackvein/quests/Event.java b/src/main/java/me/blackvein/quests/Event.java index 6abd99417..2f31f3f03 100644 --- a/src/main/java/me/blackvein/quests/Event.java +++ b/src/main/java/me/blackvein/quests/Event.java @@ -69,6 +69,11 @@ public class Event { float health = -1; Location teleport; + public int hashCode() { + assert false : "hashCode not designed"; + return 42; // any arbitrary constant will do + } + @Override public boolean equals(Object o) { diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java index 85cf2795c..5182f9cb3 100644 --- a/src/main/java/me/blackvein/quests/Quest.java +++ b/src/main/java/me/blackvein/quests/Quest.java @@ -272,7 +272,10 @@ public class Quest { } for (String q : blockQuests) { - if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(q)) { + //TODO make sure this works + Quest questObject = new Quest(); + questObject.name = q; + if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) { return false; } } diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 314fd9fcc..33ea3e215 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -139,10 +139,10 @@ public class Quester { private static final long serialVersionUID = 5475202358792520975L; - @SuppressWarnings("unused") + /*@SuppressWarnings("unused") public void hardClear() { super.clear(); - } + }*/ @Override public Integer put(String key, Integer val) { @@ -318,11 +318,17 @@ public class Quester { } public Stage getCurrentStage(Quest quest) { - return quest.getStage(currentQuests.get(quest)); + if (currentQuests.containsKey(quest)) { + return quest.getStage(currentQuests.get(quest)); + } + return null; } public QuestData getQuestData(Quest quest) { - return questData.get(quest); + if (questData.containsKey(quest)) { + return questData.get(quest); + } + return null; } public void takeQuest(Quest q, boolean override) { @@ -609,7 +615,7 @@ public class Quester { for (EntityType e2 : getQuestData(quest).mobsKilled) { if (e == e2) { - if (getQuestData(quest).mobNumKilled.size() > getQuestData(quest).mobsKilled.indexOf(e2) & getCurrentStage(quest).mobNumToKill.size() > getCurrentStage(quest).mobsToKill.indexOf(e)) { + if (getQuestData(quest).mobNumKilled.size() > getQuestData(quest).mobsKilled.indexOf(e2) && getCurrentStage(quest).mobNumToKill.size() > getCurrentStage(quest).mobsToKill.indexOf(e)) { if (getQuestData(quest).mobNumKilled.get(getQuestData(quest).mobsKilled.indexOf(e2)) < getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(e))) { @@ -710,7 +716,7 @@ public class Quester { for (Integer n2 : getQuestData(quest).citizensKilled) { if (n.equals(n2)) { - if (getQuestData(quest).citizenNumKilled.size() > getQuestData(quest).citizensKilled.indexOf(n2) & getCurrentStage(quest).citizenNumToKill.size() > getCurrentStage(quest).citizensToKill.indexOf(n)) { + if (getQuestData(quest).citizenNumKilled.size() > getQuestData(quest).citizensKilled.indexOf(n2) && getCurrentStage(quest).citizenNumToKill.size() > getCurrentStage(quest).citizensToKill.indexOf(n)) { if (getQuestData(quest).citizenNumKilled.get(getQuestData(quest).citizensKilled.indexOf(n2)) < getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(n))) { diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 90ccf3c51..133a67b6d 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -2618,7 +2618,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, if (config.contains("quests." + questName + ".guiDisplay")) { String item = config.getString("quests." + questName + ".guiDisplay"); - quest.guiDisplay = ItemUtil.readItemStack(item); + try { + ItemStack stack = ItemUtil.readItemStack(item); + + if (stack != null) { + quest.guiDisplay = stack; + } + } catch (Exception e) { + instance.getLogger().warning(item + " in items: Gui Display in Quest " + quest.name + "is not properly formatted!"); + } } @@ -3514,8 +3522,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, deliveryMessages.addAll(config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".delivery-messages")); for (String item : itemsToDeliver) { + // TODO + getLogger().severe("hello"); + getLogger().info("hello"); getLogger().severe("item: " + item); - ItemStack is = ItemUtil.readItemStack(item); + ItemStack is = ItemUtil.readItemStack("" + item); if (is != null) { diff --git a/src/main/java/me/blackvein/quests/Stage.java b/src/main/java/me/blackvein/quests/Stage.java index e586a20d2..b6a470343 100644 --- a/src/main/java/me/blackvein/quests/Stage.java +++ b/src/main/java/me/blackvein/quests/Stage.java @@ -46,7 +46,7 @@ public class Stage { for (Integer i : this) { Integer other = otherList.get(this.indexOf(i)); - if (other != i) { + if (!other.equals(i)) { return false; } } @@ -75,7 +75,7 @@ public class Stage { for (Integer i : this) { Integer other = otherList.get(this.indexOf(i)); - if (other != i) { + if (!other.equals(i)) { return false; } } @@ -102,7 +102,7 @@ public class Stage { for (Integer i : this) { Integer other = otherList.get(this.indexOf(i)); - if (other != i) { + if (!other.equals(i)) { return false; } } @@ -141,6 +141,11 @@ public class Stage { public String startMessage = null; public String objectiveOverride = null; + public int hashCode() { + assert false : "hashCode not designed"; + return 42; // any arbitrary constant will do + } + @Override public boolean equals(Object o) { diff --git a/src/main/java/me/blackvein/quests/util/ItemUtil.java b/src/main/java/me/blackvein/quests/util/ItemUtil.java index 9ce7778a7..84f1e8dbe 100644 --- a/src/main/java/me/blackvein/quests/util/ItemUtil.java +++ b/src/main/java/me/blackvein/quests/util/ItemUtil.java @@ -73,13 +73,11 @@ public class ItemUtil implements ColorUtil { } else { return 0; } - } //Formats -> name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore: //Returns null if invalid format public static ItemStack readItemStack(String data) { - plugin.getLogger().severe("data: " + data); if (data == null) { return null; } @@ -89,9 +87,13 @@ public class ItemUtil implements ColorUtil { ItemMeta meta = null; LinkedList lore = new LinkedList(); for (String arg : args) { - if (arg.startsWith("name-")) { - stack = new ItemStack(Material.matchMaterial(arg.substring(3))); + //Attempt to match item name. Returns null if invalid format + try { + stack = new ItemStack(Material.matchMaterial(arg.substring(5))); + } catch (NullPointerException npe) { + return null; + } meta = stack.getItemMeta(); } else if (arg.startsWith("amount-")) { stack.setAmount(Integer.parseInt(arg.substring(7))); @@ -106,7 +108,6 @@ public class ItemUtil implements ColorUtil { } else if (arg.startsWith("lore-")) { lore.add(arg.substring(5)); } else { - plugin.getLogger().severe("Malformed itemstack data in quests.yml: " + arg); return null; } diff --git a/src/main/java/me/blackvein/quests/util/MiscUtil.java b/src/main/java/me/blackvein/quests/util/MiscUtil.java index 860c9cf35..b5b56340d 100644 --- a/src/main/java/me/blackvein/quests/util/MiscUtil.java +++ b/src/main/java/me/blackvein/quests/util/MiscUtil.java @@ -41,7 +41,7 @@ public class MiscUtil { } if (type.equals("d")) { - timeMilliSeconds += t * 86400000; + timeMilliSeconds += t * 86400000L; } else if (type.equals("h")) { timeMilliSeconds += t * 3600000; } else if (type.equals("m")) { diff --git a/src/main/java/me/blackvein/quests/util/QuestMob.java b/src/main/java/me/blackvein/quests/util/QuestMob.java index 8b171de73..619edd92c 100644 --- a/src/main/java/me/blackvein/quests/util/QuestMob.java +++ b/src/main/java/me/blackvein/quests/util/QuestMob.java @@ -220,6 +220,11 @@ public class QuestMob { return qm; } + public int hashCode() { + assert false : "hashCode not designed"; + return 42; // any arbitrary constant will do + } + @Override public boolean equals(Object o) { if ((o instanceof QuestMob) == false) { @@ -237,11 +242,11 @@ public class QuestMob { return false; } - if (entityType != other.entityType) { + if (!entityType.equals(other.entityType)) { return false; } - if (dropChances != other.dropChances) { + if (!dropChances.equals(other.dropChances)) { return false; } @@ -255,11 +260,11 @@ public class QuestMob { return false; } - if (spawnAmounts != other.spawnAmounts) { + if (!spawnAmounts.equals(other.spawnAmounts)) { return false; } - if (spawnLocation != other.spawnLocation) { + if (!spawnLocation.equals(other.spawnLocation)) { return false; } diff --git a/src/main/resources/quests.yml b/src/main/resources/quests.yml index b9a825183..1eab9f746 100644 --- a/src/main/resources/quests.yml +++ b/src/main/resources/quests.yml @@ -6,7 +6,7 @@ quests: redo-delay: 1800000 requirements: items: - - name-wooden_pickaxe:amount-1 + - name-wood_pickaxe:amount-1 remove-items: - false fail-requirement-message: 'You must have a Wooden Pickaxe first.'