diff --git a/pom.xml b/pom.xml index 8b501ddde..1d51c91a1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ me.blackvein.quests quests - 2.7.0 + 2.7.1 quests https://github.com/FlyingPikachu/Quests/ jar diff --git a/src/main/java/me/blackvein/quests/CustomObjective.java b/src/main/java/me/blackvein/quests/CustomObjective.java index 09820a4ae..7eab3fa98 100644 --- a/src/main/java/me/blackvein/quests/CustomObjective.java +++ b/src/main/java/me/blackvein/quests/CustomObjective.java @@ -3,7 +3,6 @@ package me.blackvein.quests; import java.util.HashMap; import java.util.Map; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -151,11 +150,12 @@ public abstract class CustomObjective implements Listener { break; } } - + if (index > -1) { -Material m = null; //TODO remove + if (quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()) >= quester.getCurrentStage(quest).customObjectiveCounts.get(index)) { - quester.finishObjective(quest, "customObj", m, null, null, null, null, null, null, null, null, obj); + + quester.finishObjective(quest, "customObj", null, null, null, null, null, null, null, null, null, obj); } } @@ -231,4 +231,4 @@ Material m = null; //TODO remove return false; } -} +} \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/PlayerListener.java b/src/main/java/me/blackvein/quests/PlayerListener.java index 9447af4dc..314dcbb1b 100644 --- a/src/main/java/me/blackvein/quests/PlayerListener.java +++ b/src/main/java/me/blackvein/quests/PlayerListener.java @@ -241,7 +241,8 @@ public class PlayerListener implements Listener, ColorUtil { for (Quest quest : quester.currentQuests.keySet()) { if (quester.hasObjective(quest, "useBlock")) { - quester.useBlock(quest, evt.getClickedBlock().getType()); + ItemStack i = new ItemStack(evt.getClickedBlock().getType(), 1, evt.getClickedBlock().getState().getData().toItemStack().getDurability()); + quester.useBlock(quest, i); hasObjective = true; } @@ -446,8 +447,8 @@ public class PlayerListener implements Listener, ColorUtil { for (Quest quest : quester.currentQuests.keySet()) { if (quester.hasObjective(quest, "damageBlock")) { - - quester.damageBlock(quest, evt.getBlock().getType()); + ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability()); + quester.damageBlock(quest, i); } @@ -469,7 +470,8 @@ public class PlayerListener implements Listener, ColorUtil { if (quester.hasObjective(quest, "placeBlock")) { if (evt.isCancelled() == false) { - quester.placeBlock(quest, evt.getBlock().getType()); + ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability()); + quester.placeBlock(quest, i); } } @@ -499,25 +501,22 @@ public class PlayerListener implements Listener, ColorUtil { } if (quester.hasObjective(quest, "placeBlock")) { - - if (quester.getQuestData(quest).blocksPlaced.containsKey(evt.getBlock().getType())) { - - if (quester.getQuestData(quest).blocksPlaced.get(evt.getBlock().getType()) > 0) { - + + for (ItemStack is : quester.getQuestData(quest).blocksPlaced) { + if (is.getAmount() > 0) { if (evt.isCancelled() == false) { - quester.getQuestData(quest).blocksPlaced.put(evt.getBlock().getType(), quester.getQuestData(quest).blocksPlaced.get(evt.getBlock().getType()) - 1); + int index = quester.getQuestData(quest).blocksPlaced.indexOf(is); + is.setAmount(is.getAmount() - 1); + quester.getQuestData(quest).blocksPlaced.set(index, is); } - - } - - } - + } + } + } if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS) && quester.hasObjective(quest, "cutBlock")) { - - quester.cutBlock(quest, evt.getBlock().getType()); - + ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability()); + quester.cutBlock(quest, i); } } diff --git a/src/main/java/me/blackvein/quests/QuestData.java b/src/main/java/me/blackvein/quests/QuestData.java index 500e64ca8..e9116866e 100644 --- a/src/main/java/me/blackvein/quests/QuestData.java +++ b/src/main/java/me/blackvein/quests/QuestData.java @@ -26,20 +26,27 @@ public class QuestData { doJournalUpdate = b; } - public Map blocksDamaged = new EnumMap(Material.class) { + public LinkedList blocksDamaged = new LinkedList() { private static final long serialVersionUID = -4211891633163257743L; @Override - public Integer put(Material key, Integer val) { - Integer data = super.put(key, val); + public ItemStack set(int index, ItemStack key) { + ItemStack data = super.set(index, key); + if (doJournalUpdate) quester.updateJournal(); + return data; + } + + @Override + public boolean add(ItemStack key) { + boolean data = super.add(key); if (doJournalUpdate) quester.updateJournal(); return data; } @Override - public Integer remove(Object key) { - Integer i = super.remove(key); + public boolean remove(Object key) { + boolean i = super.remove(key); if (doJournalUpdate) quester.updateJournal(); return i; } @@ -51,9 +58,10 @@ public class QuestData { } @Override - public void putAll(Map m) { - super.putAll(m); + public boolean addAll(Collection m) { + boolean i = super.addAll(m); if (doJournalUpdate) quester.updateJournal(); + return i; } }; @@ -100,20 +108,27 @@ public class QuestData { }; - public Map blocksPlaced = new EnumMap(Material.class) { + public LinkedList blocksPlaced = new LinkedList() { private static final long serialVersionUID = 4226366446050903433L; @Override - public Integer put(Material key, Integer val) { - Integer data = super.put(key, val); + public ItemStack set(int index, ItemStack key) { + ItemStack data = super.set(index, key); + if (doJournalUpdate) quester.updateJournal(); + return data; + } + + @Override + public boolean add(ItemStack key) { + boolean data = super.add(key); if (doJournalUpdate) quester.updateJournal(); return data; } @Override - public Integer remove(Object key) { - Integer i = super.remove(key); + public boolean remove(Object key) { + boolean i = super.remove(key); if (doJournalUpdate) quester.updateJournal(); return i; } @@ -125,28 +140,36 @@ public class QuestData { } @Override - public void putAll(Map m) { - super.putAll(m); + public boolean addAll(Collection m) { + boolean i = super.addAll(m); if (doJournalUpdate) quester.updateJournal(); + return i; } }; - public Map blocksUsed = new EnumMap(Material.class) { + public LinkedList blocksUsed = new LinkedList() { private static final long serialVersionUID = -9057864863810306890L; @Override - public Integer put(Material key, Integer val) { - Integer data = super.put(key, val); + public ItemStack set(int index, ItemStack key) { + ItemStack data = super.set(index, key); + if (doJournalUpdate) quester.updateJournal(); + return data; + } + + @Override + public boolean add(ItemStack key) { + boolean data = super.add(key); if (doJournalUpdate) quester.updateJournal(); return data; } @Override - public Integer remove(Object key) { - Integer i = super.remove(key); + public boolean remove(Object key) { + boolean i = super.remove(key); if (doJournalUpdate) quester.updateJournal(); return i; } @@ -158,28 +181,36 @@ public class QuestData { } @Override - public void putAll(Map m) { - super.putAll(m); + public boolean addAll(Collection m) { + boolean i = super.addAll(m); if (doJournalUpdate) quester.updateJournal(); + return i; } }; - public Map blocksCut = new EnumMap(Material.class) { + public LinkedList blocksCut = new LinkedList() { private static final long serialVersionUID = -8204359763290995080L; @Override - public Integer put(Material key, Integer val) { - Integer data = super.put(key, val); + public ItemStack set(int index, ItemStack key) { + ItemStack data = super.set(index, key); + if (doJournalUpdate) quester.updateJournal(); + return data; + } + + @Override + public boolean add(ItemStack key) { + boolean data = super.add(key); if (doJournalUpdate) quester.updateJournal(); return data; } @Override - public Integer remove(Object key) { - Integer i = super.remove(key); + public boolean remove(Object key) { + boolean i = super.remove(key); if (doJournalUpdate) quester.updateJournal(); return i; } @@ -191,9 +222,10 @@ public class QuestData { } @Override - public void putAll(Map m) { - super.putAll(m); + public boolean addAll(Collection m) { + boolean i = super.addAll(m); if (doJournalUpdate) quester.updateJournal(); + return i; } }; diff --git a/src/main/java/me/blackvein/quests/QuestFactory.java b/src/main/java/me/blackvein/quests/QuestFactory.java index 1589b8ede..4a330c794 100644 --- a/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/src/main/java/me/blackvein/quests/QuestFactory.java @@ -1338,15 +1338,19 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { LinkedList damageIds; LinkedList damageAmounts; + LinkedList damageDurability; LinkedList placeIds; LinkedList placeAmounts; + LinkedList placeDurability; LinkedList useIds; LinkedList useAmounts; + LinkedList useDurability; LinkedList cutIds; LinkedList cutAmounts; + LinkedList cutDurability; Integer fish; Integer players; @@ -1411,15 +1415,19 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { damageIds = null; damageAmounts = null; + damageDurability = null; placeIds = null; placeAmounts = null; + placeDurability = null; useIds = null; useAmounts = null; + useDurability = null; cutIds = null; cutAmounts = null; + cutDurability = null; fish = null; players = null; @@ -1482,21 +1490,25 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { if (cc.getSessionData(pref + CK.S_DAMAGE_NAMES) != null) { damageIds = (LinkedList) cc.getSessionData(pref + CK.S_DAMAGE_NAMES); damageAmounts = (LinkedList) cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS); + damageDurability = (LinkedList) cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY); } if (cc.getSessionData(pref + CK.S_PLACE_NAMES) != null) { placeIds = (LinkedList) cc.getSessionData(pref + CK.S_PLACE_NAMES); placeAmounts = (LinkedList) cc.getSessionData(pref + CK.S_PLACE_AMOUNTS); + placeDurability = (LinkedList) cc.getSessionData(pref + CK.S_PLACE_DURABILITY); } if (cc.getSessionData(pref + CK.S_USE_NAMES) != null) { useIds = (LinkedList) cc.getSessionData(pref + CK.S_USE_NAMES); useAmounts = (LinkedList) cc.getSessionData(pref + CK.S_USE_AMOUNTS); + useDurability = (LinkedList) cc.getSessionData(pref + CK.S_USE_DURABILITY); } if (cc.getSessionData(pref + CK.S_CUT_NAMES) != null) { cutIds = (LinkedList) cc.getSessionData(pref + CK.S_CUT_NAMES); cutAmounts = (LinkedList) cc.getSessionData(pref + CK.S_CUT_AMOUNTS); + cutDurability = (LinkedList) cc.getSessionData(pref + CK.S_CUT_DURABILITY); } if (cc.getSessionData(pref + CK.S_FISH) != null) { @@ -1616,21 +1628,25 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { if (damageIds != null && damageIds.isEmpty() == false) { stage.set("damage-block-names", damageIds); stage.set("damage-block-amounts", damageAmounts); + stage.set("damage-block-durability", damageDurability); } if (placeIds != null && placeIds.isEmpty() == false) { stage.set("place-block-names", placeIds); stage.set("place-block-amounts", placeAmounts); + stage.set("place-block-durability", placeDurability); } if (useIds != null && useIds.isEmpty() == false) { stage.set("use-block-names", useIds); stage.set("use-block-amounts", useAmounts); + stage.set("use-block-durability", useDurability); } if (cutIds != null && cutIds.isEmpty() == false) { stage.set("cut-block-names", cutIds); stage.set("cut-block-amounts", cutAmounts); + stage.set("cut-block-durability", cutDurability); } stage.set("fish-to-catch", fish); @@ -1922,16 +1938,19 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { LinkedList names = new LinkedList(); LinkedList amnts = new LinkedList(); + LinkedList durab = new LinkedList(); - for (Entry e : stage.blocksToDamage.entrySet()) { + for (ItemStack e : stage.blocksToDamage) { - names.add(((Material) e.getKey()).name()); - amnts.add((Integer) e.getValue()); + names.add(e.getType().name()); + amnts.add(e.getAmount()); + durab.add(e.getDurability()); } cc.setSessionData(pref + CK.S_DAMAGE_NAMES, names); cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, amnts); + cc.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durab); } @@ -1939,16 +1958,19 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { LinkedList names = new LinkedList(); LinkedList amnts = new LinkedList(); + LinkedList durab = new LinkedList(); - for (Entry e : stage.blocksToPlace.entrySet()) { + for (ItemStack e : stage.blocksToPlace) { - names.add(((Material) e.getKey()).name()); - amnts.add((Integer) e.getValue()); + names.add(e.getType().name()); + amnts.add(e.getAmount()); + durab.add(e.getDurability()); } cc.setSessionData(pref + CK.S_PLACE_NAMES, names); cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, amnts); + cc.setSessionData(pref + CK.S_PLACE_DURABILITY, durab); } @@ -1956,16 +1978,19 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { LinkedList names = new LinkedList(); LinkedList amnts = new LinkedList(); + LinkedList durab = new LinkedList(); - for (Entry e : stage.blocksToUse.entrySet()) { + for (ItemStack e : stage.blocksToUse) { - names.add(((Material) e.getKey()).name()); - amnts.add((Integer) e.getValue()); + names.add(e.getType().name()); + amnts.add(e.getAmount()); + durab.add(e.getDurability()); } cc.setSessionData(pref + CK.S_USE_NAMES, names); cc.setSessionData(pref + CK.S_USE_AMOUNTS, amnts); + cc.setSessionData(pref + CK.S_USE_DURABILITY, durab); } @@ -1973,16 +1998,19 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil { LinkedList names = new LinkedList(); LinkedList amnts = new LinkedList(); + LinkedList durab = new LinkedList(); - for (Entry e : stage.blocksToCut.entrySet()) { + for (ItemStack e : stage.blocksToCut) { - names.add(((Material) e.getKey()).name()); - amnts.add((Integer) e.getValue()); + names.add(e.getType().name()); + amnts.add(e.getAmount()); + durab.add(e.getDurability()); } cc.setSessionData(pref + CK.S_CUT_NAMES, names); cc.setSessionData(pref + CK.S_CUT_AMOUNTS, amnts); + cc.setSessionData(pref + CK.S_CUT_DURABILITY, durab); } diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 04062eb6b..1b8f9997c 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -12,8 +12,6 @@ import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.MiscUtil; import net.citizensnpcs.api.npc.NPC; -import net.milkbowl.vault.Vault; -import net.milkbowl.vault.item.ItemInfo; import net.milkbowl.vault.item.Items; import org.bukkit.Bukkit; @@ -37,8 +35,6 @@ import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.Potion; -import com.codisimus.plugins.phatloots.loot.Item; - public class Quester { UUID id; @@ -432,19 +428,19 @@ public class Quester { LinkedList finishedObjectives = new LinkedList(); LinkedList objectives = new LinkedList(); - for (Entry e : getCurrentStage(quest).blocksToDamage.entrySet()) { + for (ItemStack e : getCurrentStage(quest).blocksToDamage) { - for (Entry e2 : getQuestData(quest).blocksDamaged.entrySet()) { + for (ItemStack e2 : getQuestData(quest).blocksDamaged) { - if (e2.getKey().equals(e.getKey())) { + if (e2.getType().equals(e.getType())) { - if (e2.getValue() < e.getValue()) { + if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get("damage") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get("damage") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get("damage") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + finishedObjectives.add(ChatColor.GRAY + Lang.get("damage") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } @@ -476,19 +472,19 @@ public class Quester { } - for (Entry e : getCurrentStage(quest).blocksToPlace.entrySet()) { + for (ItemStack e : getCurrentStage(quest).blocksToPlace) { - for (Entry e2 : getQuestData(quest).blocksPlaced.entrySet()) { + for (ItemStack e2 : getQuestData(quest).blocksPlaced) { - if (e2.getKey().equals(e.getKey())) { + if (e2.getType().equals(e.getType())) { - if (e2.getValue() < e.getValue()) { + if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get("place") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get("place") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get("place") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + finishedObjectives.add(ChatColor.GRAY + Lang.get("place") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } @@ -498,19 +494,19 @@ public class Quester { } - for (Entry e : getCurrentStage(quest).blocksToUse.entrySet()) { + for (ItemStack e : getCurrentStage(quest).blocksToUse) { - for (Entry e2 : getQuestData(quest).blocksUsed.entrySet()) { + for (ItemStack e2 : getQuestData(quest).blocksUsed) { - if (e2.getKey().equals(e.getKey())) { + if (e2.getType().equals(e.getType())) { - if (e2.getValue() < e.getValue()) { + if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get("use") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get("use") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get("use") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + finishedObjectives.add(ChatColor.GRAY + Lang.get("use") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } @@ -520,19 +516,19 @@ public class Quester { } - for (Entry e : getCurrentStage(quest).blocksToCut.entrySet()) { + for (ItemStack e : getCurrentStage(quest).blocksToCut) { - for (Entry e2 : getQuestData(quest).blocksCut.entrySet()) { + for (ItemStack e2 : getQuestData(quest).blocksCut) { - if (e2.getKey().equals(e.getKey())) { + if (e2.getType().equals(e.getType())) { - if (e2.getValue() < e.getValue()) { + if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get("cut") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get("cut") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get("cut") + " " + Quester.prettyItemString(e2.getKey().name()) + ": " + e2.getValue() + "/" + e.getValue()); + finishedObjectives.add(ChatColor.GRAY + Lang.get("cut") + " " + Items.itemByStack(e2).getName() + ": " + e2.getAmount() + "/" + e.getAmount()); } @@ -968,21 +964,41 @@ public class Quester { } - public void damageBlock(Quest quest, Material m) { + public void damageBlock(Quest quest, ItemStack m) { + ItemStack temp = m; + temp.setAmount(0); + ItemStack damaged = temp; + ItemStack toDamage = temp; + + for (ItemStack is : getQuestData(quest).blocksDamaged) { - if (getQuestData(quest).blocksDamaged.containsKey(m)) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + damaged = is; + } + } - if (getQuestData(quest).blocksDamaged.get(m) < getCurrentStage(quest).blocksToDamage.get(m)) { - int i = getQuestData(quest).blocksDamaged.get(m); - getQuestData(quest).blocksDamaged.put(m, (i + 1)); + for (ItemStack is : getCurrentStage(quest).blocksToDamage) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + toDamage = is; + } + } - if (getQuestData(quest).blocksDamaged.get(m).equals(getCurrentStage(quest).blocksToDamage.get(m))) { + if (damaged != null && toDamage != null) { + if (damaged.getAmount() < toDamage.getAmount()) { + ItemStack newDamaged = damaged; + newDamaged.setAmount(damaged.getAmount() + 1); + + //TODO is this correct? + getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged.indexOf(damaged), newDamaged); + + if (damaged.getAmount() == toDamage.getAmount()) { finishObjective(quest, "damageBlock", m, null, null, null, null, null, null, null, null, null); } - - } - - } + } + } else { + //Do nothing + System.out.println(quest + " somehow threw a null value. Please report on Github!"); + } } @@ -1025,56 +1041,117 @@ public class Quester { } - public void placeBlock(Quest quest, Material m) { + public void placeBlock(Quest quest, ItemStack m) { + ItemStack temp = m; + temp.setAmount(0); + ItemStack placed = temp; + ItemStack toPlace = temp; + + for (ItemStack is : getQuestData(quest).blocksPlaced) { - if (getQuestData(quest).blocksPlaced.containsKey(m)) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + placed = is; + } + } - if (getQuestData(quest).blocksPlaced.get(m) < getCurrentStage(quest).blocksToPlace.get(m)) { - int i = getQuestData(quest).blocksPlaced.get(m); - getQuestData(quest).blocksPlaced.put(m, (i + 1)); + for (ItemStack is : getCurrentStage(quest).blocksToPlace) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + toPlace = is; + } + } - if (getQuestData(quest).blocksPlaced.get(m).equals(getCurrentStage(quest).blocksToPlace.get(m))) { + if (placed != null && toPlace != null) { + if (placed.getAmount() < toPlace.getAmount()) { + ItemStack newplaced = placed; + newplaced.setAmount(placed.getAmount() + 1); + + //TODO is this correct? + getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced.indexOf(placed), newplaced); + + if (placed.getAmount() == toPlace.getAmount()) { finishObjective(quest, "placeBlock", m, null, null, null, null, null, null, null, null, null); } - } - - } + } + } else { + //Do nothing + System.out.println(quest + " somehow threw a null value. Please report on Github!"); + } } - public void useBlock(Quest quest, Material m) { + public void useBlock(Quest quest, ItemStack m) { + ItemStack temp = m; + temp.setAmount(0); + ItemStack used = temp; + ItemStack toUse = temp; + + for (ItemStack is : getQuestData(quest).blocksUsed) { - if (getQuestData(quest).blocksUsed.containsKey(m)) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + used = is; + } + } - if (getQuestData(quest).blocksUsed.get(m) < getCurrentStage(quest).blocksToUse.get(m)) { - int i = getQuestData(quest).blocksUsed.get(m); - getQuestData(quest).blocksUsed.put(m, (i + 1)); + for (ItemStack is : getCurrentStage(quest).blocksToUse) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + toUse = is; + } + } - if (getQuestData(quest).blocksUsed.get(m).equals(getCurrentStage(quest).blocksToUse.get(m))) { + if (used != null && toUse != null) { + if (used.getAmount() < toUse.getAmount()) { + ItemStack newUsed = used; + newUsed.setAmount(used.getAmount() + 1); + + //TODO is this correct? + getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed.indexOf(used), newUsed); + + if (used.getAmount() == toUse.getAmount()) { finishObjective(quest, "useBlock", m, null, null, null, null, null, null, null, null, null); } - - } - - } + } + } else { + //Do nothing + System.out.println(quest + " somehow threw a null value. Please report on Github!"); + } } - public void cutBlock(Quest quest, Material m) { + public void cutBlock(Quest quest, ItemStack m) { + ItemStack temp = m; + temp.setAmount(0); + ItemStack broken = temp; + ItemStack toCut = temp; + + for (ItemStack is : getQuestData(quest).blocksCut) { - if (getQuestData(quest).blocksCut.containsKey(m)) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + broken = is; + } + } - if (getQuestData(quest).blocksCut.get(m) < getCurrentStage(quest).blocksToCut.get(m)) { - int i = getQuestData(quest).blocksCut.get(m); - getQuestData(quest).blocksCut.put(m, (i + 1)); + for (ItemStack is : getCurrentStage(quest).blocksToCut) { + if (m.getType() == is.getType() && m.getDurability() == is.getDurability()) { + toCut = is; + } + } - if (getQuestData(quest).blocksCut.get(m).equals(getCurrentStage(quest).blocksToCut.get(m))) { + if (broken != null && toCut != null) { + if (broken.getAmount() < toCut.getAmount()) { + ItemStack newCut = broken; + newCut.setAmount(broken.getAmount() + 1); + + //TODO is this correct? + getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(broken), newCut); + + if (broken.getAmount() == toCut.getAmount()) { finishObjective(quest, "cutBlock", m, null, null, null, null, null, null, null, null, null); } - - } - - } + } + } else { + //Do nothing + System.out.println(quest + " somehow threw a null value. Please report on Github!"); + } } @@ -1082,9 +1159,9 @@ public class Quester { if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) { getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1); -Material m = null; + if (((Integer) getQuestData(quest).getFishCaught()).equals(getCurrentStage(quest).fishToCatch)) { - finishObjective(quest, "catchFish", m, null, null, null, null, null, null, null, null, null); + finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null); } } @@ -1107,7 +1184,7 @@ Material m = null; getQuestData(quest).itemsEnchanted.put(entry.getKey(), num); if (num.equals(entry2.getValue())) { - finishObjective(quest, "enchantItem", m, null, e, null, null, null, null, null, null, null); + finishObjective(quest, "enchantItem", new ItemStack(m, 1), null, e, null, null, null, null, null, null, null); } } @@ -1162,9 +1239,9 @@ Material m = null; Integer newNumberOfSpecificMobKilled = numberOfSpecificMobKilled + 1; questData.mobNumKilled.set(indexOfMobKilled, newNumberOfSpecificMobKilled); -Material m = null; + if ((newNumberOfSpecificMobKilled).equals(numberOfSpecificMobNeedsToBeKilledInCurrentStage)) { - finishObjective(quest, "killMob", m, null, null, e, null, null, null, null, null, null); + finishObjective(quest, "killMob", null, null, null, e, null, null, null, null, null, null); } } } @@ -1193,9 +1270,9 @@ Material m = null; if (getQuestData(quest).getPlayersKilled() < getCurrentStage(quest).playersToKill) { getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled() + 1); -Material m = null; + if (((Integer) getQuestData(quest).getPlayersKilled()).equals(getCurrentStage(quest).playersToKill)) { - finishObjective(quest, "killPlayer", m, null, null, null, null, null, null, null, null, null); + finishObjective(quest, "killPlayer", null, null, null, null, null, null, null, null, null, null); } } @@ -1205,10 +1282,10 @@ Material m = null; public void interactWithNPC(Quest quest, NPC n) { if (getQuestData(quest).citizensInteracted.containsKey(n.getId())) { -Material m = null; + if (getQuestData(quest).citizensInteracted.get(n.getId()) == false) { getQuestData(quest).citizensInteracted.put(n.getId(), true); - finishObjective(quest, "talkToNPC", m, null, null, null, null, n, null, null, null, null); + finishObjective(quest, "talkToNPC", null, null, null, null, null, n, null, null, null, null); } } @@ -1218,12 +1295,12 @@ Material m = null; public void killNPC(Quest quest, NPC n) { if (getQuestData(quest).citizensKilled.contains(n.getId())) { -Material m = null; + int index = getQuestData(quest).citizensKilled.indexOf(n.getId()); if (getQuestData(quest).citizenNumKilled.get(index) < getCurrentStage(quest).citizenNumToKill.get(index)) { getQuestData(quest).citizenNumKilled.set(index, getQuestData(quest).citizenNumKilled.get(index) + 1); if (getQuestData(quest).citizenNumKilled.get(index) == getCurrentStage(quest).citizenNumToKill.get(index)) { - finishObjective(quest, "killNPC", m, null, null, null, null, n, null, null, null, null); + finishObjective(quest, "killNPC", null, null, null, null, null, n, null, null, null, null); } } @@ -1246,9 +1323,9 @@ Material m = null; if (l.getY() < (locationToReach.getY() + radius) && l.getY() > (locationToReach.getY() - radius)) { if (getQuestData(quest).hasReached.get(index) == false) { -Material m = null; + getQuestData(quest).hasReached.set(index, true); - finishObjective(quest, "reachLocation", m, null, null, null, null, null, location, null, null, null); + finishObjective(quest, "reachLocation", null, null, null, null, null, null, location, null, null, null); } @@ -1273,9 +1350,9 @@ Material m = null; if (getQuestData(quest).mobsTamed.containsKey(entity)) { getQuestData(quest).mobsTamed.put(entity, (getQuestData(quest).mobsTamed.get(entity) + 1)); -Material m = null; + if (getQuestData(quest).mobsTamed.get(entity).equals(getCurrentStage(quest).mobsToTame.get(entity))) { - finishObjective(quest, "tameMob", m, null, null, entity, null, null, null, null, null, null); + finishObjective(quest, "tameMob", null, null, null, entity, null, null, null, null, null, null); } } @@ -1287,9 +1364,9 @@ Material m = null; if (getQuestData(quest).sheepSheared.containsKey(color)) { getQuestData(quest).sheepSheared.put(color, (getQuestData(quest).sheepSheared.get(color) + 1)); -Material m = null; + if (getQuestData(quest).sheepSheared.get(color).equals(getCurrentStage(quest).sheepToShear.get(color))) { - finishObjective(quest, "shearSheep", m, null, null, null, null, null, null, color, null, null); + finishObjective(quest, "shearSheep", null, null, null, null, null, null, null, color, null, null); } } @@ -1325,14 +1402,14 @@ Material m = null; i.setAmount(i.getAmount() - (req - amount)); //Take away the remaining amount needed to be delivered from the item stack player.getInventory().setItem(index, i); player.updateInventory(); - finishObjective(quest, "deliverItem", m, found, null, null, null, null, null, null, null, null); + finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); } else if ((i.getAmount() + amount) == req) { getQuestData(quest).itemsDelivered.put(found, req); player.getInventory().setItem(player.getInventory().first(i), null); player.updateInventory(); - finishObjective(quest, "deliverItem", m, found, null, null, null, null, null, null, null, null); + finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); } else { @@ -1360,12 +1437,12 @@ Material m = null; for (String pass : passes) { if (pass.equalsIgnoreCase(evt.getMessage())) { -Material m = null; + evt.setCancelled(true); String display = getCurrentStage(quest).passwordDisplays.get(getCurrentStage(quest).passwordPhrases.indexOf(passes)); getQuestData(quest).passwordsSaid.put(display, true); done = true; - finishObjective(quest, "password", m, null, null, null, null, null, null, null, display, null); + finishObjective(quest, "password", null, null, null, null, null, null, null, null, display, null); break; } @@ -1421,8 +1498,7 @@ Material m = null; } else if (objective.equalsIgnoreCase("damageBlock")) { String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("damage") + " " + prettyItemString(material.getType().name()); - message = message + " " + getCurrentStage(quest).blocksToDamage.get(material) + "/" + getCurrentStage(quest).blocksToDamage.get(material); - p.sendMessage(message); + message = message + " " + material.getAmount() + "/" + material.getAmount(); if (testComplete(quest)) { quest.nextStage(this); } @@ -1439,7 +1515,7 @@ Material m = null; } else if (objective.equalsIgnoreCase("placeBlock")) { String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("place") + " " + prettyItemString(material.getType().name()); - message = message + " " + getCurrentStage(quest).blocksToPlace.get(material) + "/" + getCurrentStage(quest).blocksToPlace.get(material); + message = message + " " + material.getAmount() + "/" + material.getAmount(); p.sendMessage(message); if (testComplete(quest)) { quest.nextStage(this); @@ -1448,7 +1524,7 @@ Material m = null; } else if (objective.equalsIgnoreCase("useBlock")) { String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("use") + " " + prettyItemString(material.getType().name()); - message = message + " " + getCurrentStage(quest).blocksToUse.get(material) + "/" + getCurrentStage(quest).blocksToUse.get(material); + message = message + " " + material.getAmount() + "/" + material.getAmount(); p.sendMessage(message); if (testComplete(quest)) { quest.nextStage(this); @@ -1457,7 +1533,7 @@ Material m = null; } else if (objective.equalsIgnoreCase("cutBlock")) { String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("cut") + " " + prettyItemString(material.getType().name()); - message = message + " " + getCurrentStage(quest).blocksToCut.get(material) + "/" + getCurrentStage(quest).blocksToCut.get(material); + message = message + " " + material.getAmount() + "/" + material.getAmount(); p.sendMessage(message); if (testComplete(quest)) { quest.nextStage(this); @@ -1600,213 +1676,6 @@ Material m = null; } } - - //TODO remove - public void finishObjective(Quest quest, String objective, Material material, ItemStack itemstack, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) { - - Player p = getPlayer(); - - if (getCurrentStage(quest).objectiveOverride != null) { - - if (testComplete(quest)) { - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + getCurrentStage(quest).objectiveOverride; - p.sendMessage(message); - quest.nextStage(this); - } - return; - - } - - if (objective.equalsIgnoreCase("password")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + pass; - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("damageBlock")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("damage") + " " + prettyItemString(material.name()); - message = message + " " + getCurrentStage(quest).blocksToDamage.get(material) + "/" + getCurrentStage(quest).blocksToDamage.get(material); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("breakBlock")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("break") + " " + prettyItemString(material.name()); - message = message + " " + 1 + "/" + 1; - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("placeBlock")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("place") + " " + prettyItemString(material.name()); - message = message + " " + getCurrentStage(quest).blocksToPlace.get(material) + "/" + getCurrentStage(quest).blocksToPlace.get(material); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("useBlock")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("use") + " " + prettyItemString(material.name()); - message = message + " " + getCurrentStage(quest).blocksToUse.get(material) + "/" + getCurrentStage(quest).blocksToUse.get(material); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("cutBlock")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("cut") + " " + prettyItemString(material.name()); - message = message + " " + getCurrentStage(quest).blocksToCut.get(material) + "/" + getCurrentStage(quest).blocksToCut.get(material); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("catchFish")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("catchFish") + " "; - message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch; - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("enchantItem")) { - - String obj = Lang.get("enchantItem"); - obj = obj.replaceAll("", prettyItemString(material.name())); - obj = obj.replaceAll("", Quester.prettyEnchantmentString(enchantment)); - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + obj; - for (Map map : getCurrentStage(quest).itemsToEnchant.keySet()) { - - if (map.containsKey(enchantment)) { - - message = message + " " + getCurrentStage(quest).itemsToEnchant.get(map) + "/" + getCurrentStage(quest).itemsToEnchant.get(map); - break; - - } - - } - - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("deliverItem")) { - - String obj = Lang.get("deliver"); - obj = obj.replaceAll("", ItemUtil.getString(getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(itemstack)))); - obj = obj.replaceAll("", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(itemstack)))); - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + obj; - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("killMob")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("kill") + " " + mob.name(); - message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("killPlayer")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("killPlayer"); - message = message + " " + getCurrentStage(quest).playersToKill + "/" + getCurrentStage(quest).playersToKill; - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("talkToNPC")) { - - String obj = Lang.get("talkTo"); - obj = obj.replaceAll("", plugin.getNPCName(npc.getId())); - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + obj; - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("killNPC")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("kill") + " " + npc.getName(); - message = message + " " + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())) + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("tameMob")) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("tame") + " " + getCapitalized(mob.name()); - message = message + " " + getCurrentStage(quest).mobsToTame.get(mob) + "/" + getCurrentStage(quest).mobsToTame.get(mob); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("shearSheep")) { - - String obj = Lang.get("shearSheep"); - obj = obj.replaceAll("", color.name().toLowerCase()); - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + obj; - message = message + " " + getCurrentStage(quest).sheepToShear.get(color) + "/" + getCurrentStage(quest).sheepToShear.get(color); - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (objective.equalsIgnoreCase("reachLocation")) { - - String obj = Lang.get("goTo"); - obj = obj.replaceAll("", getCurrentStage(quest).locationNames.get(getCurrentStage(quest).locationsToReach.indexOf(location))); - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + obj; - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } else if (co != null) { - - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + co.getDisplay(); - - int index = -1; - for (int i = 0; i < getCurrentStage(quest).customObjectives.size(); i++) { - if (getCurrentStage(quest).customObjectives.get(i).getName().equals(co.getName())) { - index = i; - break; - } - } - - Map datamap = getCurrentStage(quest).customObjectiveData.get(index); - for (String key : co.datamap.keySet()) { - message = message.replaceAll("%" + ((String) key) + "%", (String) datamap.get(key)); - } - - if (co.isCountShown() && co.isEnableCount()) { - message = message.replaceAll("%count%", getCurrentStage(quest).customObjectiveCounts.get(index) + "/" + getCurrentStage(quest).customObjectiveCounts.get(index)); - } - p.sendMessage(message); - if (testComplete(quest)) { - quest.nextStage(this); - } - - } - - } public boolean testComplete(Quest quest) { @@ -1826,10 +1695,15 @@ Material m = null; data.setDoJournalUpdate(false); if (quest.getStage(0).blocksToDamage.isEmpty() == false) { - for (Material m : quest.getStage(0).blocksToDamage.keySet()) { - - data.blocksDamaged.put(m, 0); - + for (ItemStack i : quest.getStage(0).blocksToDamage) { + if (data.blocksDamaged.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksDamaged.add(temp); + } } } @@ -1847,26 +1721,41 @@ Material m = null; } if (quest.getStage(0).blocksToPlace.isEmpty() == false) { - for (Material m : quest.getStage(0).blocksToPlace.keySet()) { - - data.blocksPlaced.put(m, 0); - + for (ItemStack i : quest.getStage(0).blocksToPlace) { + if (data.blocksPlaced.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksPlaced.set(data.blocksPlaced.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksPlaced.add(temp); + } } } if (quest.getStage(0).blocksToUse.isEmpty() == false) { - for (Material m : quest.getStage(0).blocksToUse.keySet()) { - - data.blocksUsed.put(m, 0); - + for (ItemStack i : quest.getStage(0).blocksToUse) { + if (data.blocksUsed.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksUsed.set(data.blocksUsed.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksUsed.add(temp); + } } } if (quest.getStage(0).blocksToCut.isEmpty() == false) { - for (Material m : quest.getStage(0).blocksToCut.keySet()) { - - data.blocksCut.put(m, 0); - + for (ItemStack i : quest.getStage(0).blocksToCut) { + if (data.blocksCut.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksCut.set(data.blocksCut.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksCut.add(temp); + } } } @@ -1924,11 +1813,12 @@ Material m = null; } if (quest.getStage(0).blocksToCut.isEmpty() == false) { - for (Material m : quest.getStage(0).blocksToCut.keySet()) { - - data.blocksCut.put(m, 0); - - } + for (ItemStack is : quest.getStage(0).blocksToCut) { + + //TODO should be .set() ? + is.setAmount(0); + data.blocksCut.add(is); + } } if (quest.getStage(0).locationsToReach.isEmpty() == false) { @@ -1979,10 +1869,15 @@ Material m = null; data.setDoJournalUpdate(false); if (quest.getStage(stage).blocksToDamage.isEmpty() == false) { - for (Material m : quest.getStage(stage).blocksToDamage.keySet()) { - - data.blocksDamaged.put(m, 0); - + for (ItemStack i : quest.getStage(stage).blocksToDamage) { + if (data.blocksDamaged.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksDamaged.add(temp); + } } } @@ -2000,26 +1895,41 @@ Material m = null; } if (quest.getStage(stage).blocksToPlace.isEmpty() == false) { - for (Material m : quest.getStage(stage).blocksToPlace.keySet()) { - - data.blocksPlaced.put(m, 0); - + for (ItemStack i : quest.getStage(stage).blocksToPlace) { + if (data.blocksPlaced.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksPlaced.set(data.blocksPlaced.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksPlaced.add(temp); + } } } if (quest.getStage(stage).blocksToUse.isEmpty() == false) { - for (Material m : quest.getStage(stage).blocksToUse.keySet()) { - - data.blocksUsed.put(m, 0); - + for (ItemStack i : quest.getStage(stage).blocksToUse) { + if (data.blocksUsed.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksUsed.set(data.blocksUsed.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksUsed.add(temp); + } } } if (quest.getStage(stage).blocksToCut.isEmpty() == false) { - for (Material m : quest.getStage(stage).blocksToCut.keySet()) { - - data.blocksCut.put(m, 0); - + for (ItemStack i : quest.getStage(stage).blocksToCut) { + if (data.blocksCut.indexOf(i) != -1) { + //TODO Will this ever happen? + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksCut.set(data.blocksCut.indexOf(temp), temp); + } else { + ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability()); + data.blocksCut.add(temp); + } } } @@ -2077,11 +1987,12 @@ Material m = null; } if (quest.getStage(stage).blocksToCut.isEmpty() == false) { - for (Material m : quest.getStage(stage).blocksToCut.keySet()) { - - data.blocksCut.put(m, 0); - - } + for (ItemStack is : quest.getStage(stage).blocksToCut) { + + //TODO should be .set() ? + is.setAmount(0); + data.blocksCut.add(is); + } } if (quest.getStage(stage).locationsToReach.isEmpty() == false) { @@ -2365,14 +2276,17 @@ Material m = null; LinkedList blockNames = new LinkedList(); LinkedList blockAmounts = new LinkedList(); + LinkedList blockDurability = new LinkedList(); - for (Material m : questData.blocksDamaged.keySet()) { - blockNames.add(m.name()); - blockAmounts.add(questData.blocksDamaged.get(m)); + for (ItemStack m : questData.blocksDamaged) { + blockNames.add(m.getType().name()); + blockAmounts.add(m.getAmount()); + blockDurability.add(m.getDurability()); } questSec.set("blocks-damaged-names", blockNames); questSec.set("blocks-damaged-amounts", blockAmounts); + questSec.set("blocks-broken-durability", blockDurability); } @@ -2380,17 +2294,17 @@ Material m = null; LinkedList blockNames = new LinkedList(); LinkedList blockAmounts = new LinkedList(); - LinkedList blockData = new LinkedList(); + LinkedList blockDurability = new LinkedList(); for (ItemStack m : questData.blocksBroken) { blockNames.add(m.getType().name()); blockAmounts.add(m.getAmount()); - blockData.add(m.getDurability()); + blockDurability.add(m.getDurability()); } questSec.set("blocks-broken-names", blockNames); questSec.set("blocks-broken-amounts", blockAmounts); - questSec.set("blocks-broken-data", blockData); + questSec.set("blocks-broken-durability", blockDurability); } @@ -2398,14 +2312,17 @@ Material m = null; LinkedList blockNames = new LinkedList(); LinkedList blockAmounts = new LinkedList(); + LinkedList blockDurability = new LinkedList(); - for (Material m : questData.blocksPlaced.keySet()) { - blockNames.add(m.name()); - blockAmounts.add(questData.blocksPlaced.get(m)); + for (ItemStack m : questData.blocksPlaced) { + blockNames.add(m.getType().name()); + blockAmounts.add(m.getAmount()); + blockDurability.add(m.getDurability()); } questSec.set("blocks-placed-names", blockNames); questSec.set("blocks-placed-amounts", blockAmounts); + questSec.set("blocks-broken-durability", blockDurability); } @@ -2413,14 +2330,17 @@ Material m = null; LinkedList blockNames = new LinkedList(); LinkedList blockAmounts = new LinkedList(); + LinkedList blockDurability = new LinkedList(); - for (Material m : questData.blocksUsed.keySet()) { - blockNames.add(m.name()); - blockAmounts.add(questData.blocksUsed.get(m)); + for (ItemStack m : questData.blocksUsed) { + blockNames.add(m.getType().name()); + blockAmounts.add(m.getAmount()); + blockDurability.add(m.getDurability()); } questSec.set("blocks-used-names", blockNames); questSec.set("blocks-used-amounts", blockAmounts); + questSec.set("blocks-broken-durability", blockDurability); } @@ -2428,14 +2348,17 @@ Material m = null; LinkedList blockNames = new LinkedList(); LinkedList blockAmounts = new LinkedList(); + LinkedList blockDurability = new LinkedList(); - for (Material m : questData.blocksCut.keySet()) { - blockNames.add(m.name()); - blockAmounts.add(questData.blocksCut.get(m)); + for (ItemStack m : questData.blocksCut) { + blockNames.add(m.getType().name()); + blockAmounts.add(m.getAmount()); + blockDurability.add(m.getDurability()); } questSec.set("blocks-cut-names", blockNames); questSec.set("blocks-cut-amounts", blockAmounts); + questSec.set("blocks-broken-durability", blockDurability); } @@ -2895,11 +2818,19 @@ Material m = null; List names = questSec.getStringList("blocks-damaged-names"); List amounts = questSec.getIntegerList("blocks-damaged-amounts"); + List durability = questSec.getShortList("blocks-damaged-durability"); for (String s : names) { - - getQuestData(quest).blocksDamaged.put(Material.matchMaterial(s), amounts.get(names.indexOf(s))); - + ItemStack is; + //if (durability.get(names.indexOf(s)) != -1) { + if (durability.indexOf(names.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); + } + + getQuestData(quest).blocksDamaged.add(is); //TODO should be .set() ? } } @@ -2908,7 +2839,7 @@ Material m = null; List names = questSec.getStringList("blocks-broken-names"); List amounts = questSec.getIntegerList("blocks-broken-amounts"); - List durability = questSec.getShortList("blocks-broken-data"); + List durability = questSec.getShortList("blocks-broken-durability"); for (String s : names) { ItemStack is; @@ -2929,11 +2860,19 @@ Material m = null; List names = questSec.getStringList("blocks-placed-names"); List amounts = questSec.getIntegerList("blocks-placed-amounts"); + List durability = questSec.getShortList("blocks-placed-durability"); for (String s : names) { - - getQuestData(quest).blocksPlaced.put(Material.matchMaterial(s), amounts.get(names.indexOf(s))); - + ItemStack is; + //if (durability.get(names.indexOf(s)) != -1) { + if (durability.indexOf(names.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); + } + + getQuestData(quest).blocksPlaced.add(is); //TODO should be .set() ? } } @@ -2942,11 +2881,19 @@ Material m = null; List names = questSec.getStringList("blocks-used-names"); List amounts = questSec.getIntegerList("blocks-used-amounts"); + List durability = questSec.getShortList("blocks-used-durability"); for (String s : names) { - - getQuestData(quest).blocksUsed.put(Material.matchMaterial(s), amounts.get(names.indexOf(s))); - + ItemStack is; + //if (durability.get(names.indexOf(s)) != -1) { + if (durability.indexOf(names.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); + } + + getQuestData(quest).blocksUsed.add(is); //TODO should be .set() ? } } @@ -2955,11 +2902,19 @@ Material m = null; List names = questSec.getStringList("blocks-cut-names"); List amounts = questSec.getIntegerList("blocks-cut-amounts"); + List durability = questSec.getShortList("blocks-cut-durability"); for (String s : names) { - - getQuestData(quest).blocksCut.put(Material.matchMaterial(s), amounts.get(names.indexOf(s))); - + ItemStack is; + //if (durability.get(names.indexOf(s)) != -1) { + if (durability.indexOf(names.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), durability.get(names.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), amounts.get(names.indexOf(s)), (short) 0); + } + + getQuestData(quest).blocksCut.add(is); //TODO should be .set() ? } } diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 31f6de34f..45b33e71a 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -3448,22 +3448,25 @@ try{ LinkedList itemsToEnchant = new LinkedList(); List amountsToEnchant = new LinkedList(); - //List breakBlocks = new LinkedList(); List breaknames = new LinkedList(); List breakamounts = new LinkedList(); List breakdurability = new LinkedList(); List damagenames = new LinkedList(); List damageamounts = new LinkedList(); + List damagedurability = new LinkedList(); List placenames = new LinkedList(); List placeamounts = new LinkedList(); + List placedurability = new LinkedList(); List usenames = new LinkedList(); List useamounts = new LinkedList(); + List usedurability = new LinkedList(); List cutnames = new LinkedList(); List cutamounts = new LinkedList(); + List cutdurability = new LinkedList(); //Denizen script load if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".script-to-run")) { @@ -3511,6 +3514,22 @@ try{ } } + + for (String s : breaknames) { + ItemStack is; + if (breakdurability.get(breaknames.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), breakamounts.get(breaknames.indexOf(s)), breakdurability.get(breaknames.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), breakamounts.get(breaknames.indexOf(s)), (short) 0); + + } + if (Material.matchMaterial(s) != null) { + oStage.blocksToBreak.add(is); + } else { + stageFailed("" + s + " inside break-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); + } + } if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".damage-block-names")) { @@ -3531,18 +3550,36 @@ try{ } else { stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing damage-block-amounts:"); } + + if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".damage-block-durability")) { - } + if (checkList(config.getList("quests." + questName + ".stages.ordered." + s2 + ".damage-block-durability"), Integer.class)) { + damagedurability = config.getShortList("quests." + questName + ".stages.ordered." + s2 + ".damage-block-durability"); + } else { + stageFailed("damage-block-durability: in Stage " + s2 + " of Quest " + quest.name + " is not a list of numbers!"); + } - for (String s : damagenames) { - - if (Material.matchMaterial(s) != null) { - oStage.blocksToDamage.put(Material.matchMaterial(s), damageamounts.get(damagenames.indexOf(s))); } else { - stageFailed("" + s + " inside damage-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); + stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing damage-block-durability:"); } } + + for (String s : damagenames) { + ItemStack is; + if (damagedurability.get(damagenames.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), damageamounts.get(damagenames.indexOf(s)), damagedurability.get(damagenames.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), damageamounts.get(damagenames.indexOf(s)), (short) 0); + + } + if (Material.matchMaterial(s) != null) { + oStage.blocksToDamage.add(is); + } else { + stageFailed("" + s + " inside damage-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); + } + } if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".place-block-names")) { @@ -3563,17 +3600,35 @@ try{ } else { stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing place-block-amounts:"); } + + if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".place-block-durability")) { + + if (checkList(config.getList("quests." + questName + ".stages.ordered." + s2 + ".place-block-durability"), Integer.class)) { + placedurability = config.getShortList("quests." + questName + ".stages.ordered." + s2 + ".place-block-durability"); + } else { + stageFailed("place-block-durability: in Stage " + s2 + " of Quest " + quest.name + " is not a list of numbers!"); + } + + } else { + stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing place-block-durability:"); + } } for (String s : placenames) { - - if (Material.matchMaterial(s) != null) { - oStage.blocksToPlace.put(Material.matchMaterial(s), placeamounts.get(placenames.indexOf(s))); - } else { - stageFailed("" + s + " inside place-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); - } - + ItemStack is; + if (placedurability.get(placenames.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), placeamounts.get(placenames.indexOf(s)), placedurability.get(placenames.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), placeamounts.get(placenames.indexOf(s)), (short) 0); + + } + if (Material.matchMaterial(s) != null) { + oStage.blocksToPlace.add(is); + } else { + stageFailed("" + s + " inside place-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); + } } if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".use-block-names")) { @@ -3595,17 +3650,35 @@ try{ } else { stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing use-block-amounts:"); } + + if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".use-block-durability")) { + + if (checkList(config.getList("quests." + questName + ".stages.ordered." + s2 + ".use-block-durability"), Integer.class)) { + usedurability = config.getShortList("quests." + questName + ".stages.ordered." + s2 + ".use-block-durability"); + } else { + stageFailed("use-block-durability: in Stage " + s2 + " of Quest " + quest.name + " is not a list of numbers!"); + } + + } else { + stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing use-block-durability:"); + } } for (String s : usenames) { - - if (Material.matchMaterial(s) != null) { - oStage.blocksToUse.put(Material.matchMaterial(s), useamounts.get(usenames.indexOf(s))); - } else { - stageFailed("" + RED + s + " inside use-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); - } - + ItemStack is; + if (usedurability.get(usenames.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), useamounts.get(usenames.indexOf(s)), usedurability.get(usenames.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), useamounts.get(usenames.indexOf(s)), (short) 0); + + } + if (Material.matchMaterial(s) != null) { + oStage.blocksToUse.add(is); + } else { + stageFailed("" + s + " inside use-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); + } } if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".cut-block-names")) { @@ -3627,17 +3700,35 @@ try{ } else { stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing cut-block-amounts:"); } + + if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".cut-block-durability")) { + + if (checkList(config.getList("quests." + questName + ".stages.ordered." + s2 + ".cut-block-durability"), Integer.class)) { + cutdurability = config.getShortList("quests." + questName + ".stages.ordered." + s2 + ".cut-block-durability"); + } else { + stageFailed("cut-block-durability: in Stage " + s2 + " of Quest " + quest.name + " is not a list of numbers!"); + } + + } else { + stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing cut-block-durability:"); + } } for (String s : cutnames) { - - if (Material.matchMaterial(s) != null) { - oStage.blocksToCut.put(Material.matchMaterial(s), cutamounts.get(cutnames.indexOf(s))); - } else { - stageFailed("" + s + " inside cut-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); - } - + ItemStack is; + if (cutdurability.get(cutnames.indexOf(s)) != -1) { + is = new ItemStack(Material.matchMaterial(s), cutamounts.get(cutnames.indexOf(s)), cutdurability.get(cutnames.indexOf(s))); + } else { + //Legacy + is = new ItemStack(Material.matchMaterial(s), cutamounts.get(cutnames.indexOf(s)), (short) 0); + + } + if (Material.matchMaterial(s) != null) { + oStage.blocksToCut.add(is); + } else { + stageFailed("" + s + " inside cut-block-names: inside Stage " + s2 + " of Quest " + quest.name + " is not a valid item name!"); + } } if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".fish-to-catch")) { @@ -4004,22 +4095,6 @@ try{ oStage.itemsToEnchant = enchants; - for (String s : breaknames) { - ItemStack is; - if (breakdurability.get(breaknames.indexOf(s)) != -1) { - is = new ItemStack(Material.matchMaterial(s), breakamounts.get(breaknames.indexOf(s)), breakdurability.get(breaknames.indexOf(s))); - } else { - //Legacy - is = new ItemStack(Material.matchMaterial(s), breakamounts.get(breaknames.indexOf(s)), (short) 0); - - } - oStage.blocksToBreak.add(is); - } - - if (index < questStages.getKeys(false).size()) { - index++; - } - if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".locations-to-reach")) { if (Quests.checkList(config.getList("quests." + questName + ".stages.ordered." + s2 + ".locations-to-reach"), String.class)) { diff --git a/src/main/java/me/blackvein/quests/Stage.java b/src/main/java/me/blackvein/quests/Stage.java index df2526614..e3e6f6026 100644 --- a/src/main/java/me/blackvein/quests/Stage.java +++ b/src/main/java/me/blackvein/quests/Stage.java @@ -15,12 +15,11 @@ import org.bukkit.inventory.ItemStack; public class Stage { - Map blocksToDamage = new EnumMap(Material.class); + LinkedList blocksToDamage = new LinkedList(); LinkedList blocksToBreak = new LinkedList(); - //Map blocksToBreak = new EnumMap(Material.class); - Map blocksToPlace = new EnumMap(Material.class); - Map blocksToUse = new EnumMap(Material.class); - Map blocksToCut = new EnumMap(Material.class); + LinkedList blocksToPlace = new LinkedList(); + LinkedList blocksToUse = new LinkedList(); + LinkedList blocksToCut = new LinkedList(); Integer fishToCatch; Integer playersToKill; Map, Integer> itemsToEnchant = new HashMap, Integer>(); diff --git a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index 946142dc4..aaf8f1e24 100644 --- a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -61,9 +61,9 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { String text = PINK + "- " + AQUA + (String) context.getSessionData(CK.Q_NAME) + PINK + " | " + Lang.get("stageEditorStage") + " " + PURPLE + stageNum + PINK + " -\n"; if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null) { - text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + Lang.get("stageEditorBreakBlocks") + GRAY + " (" + Lang.get("noneSet") + ")\n"; + text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + Lang.get("stageEditorPlaceBlocks") + GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { - text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + Lang.get("stageEditorBreakBlocks") + "\n"; + text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + Lang.get("stageEditorPlaceBlocks") + "\n"; LinkedList names = (LinkedList) context.getSessionData(pref + CK.S_BREAK_NAMES); LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_BREAK_AMOUNTS); @@ -379,7 +379,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { protected Prompt acceptValidatedInput(ConversationContext context, String input) { if (input.equalsIgnoreCase("1")) { - return new BreakBlockListPrompt(); + return new PlaceBlockListPrompt(); } else if (input.equalsIgnoreCase("2")) { return new DamageBlockListPrompt(); } else if (input.equalsIgnoreCase("3")) { @@ -706,7 +706,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null) { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + " (" + Lang.get("noneSet") + ")\n"; text += GRAY + "2 - " + Lang.get("stageEditorSetBlockAmounts") + " (" + Lang.get("noNamesSet") + ")\n"; - text += GRAY + "3 - " + Lang.get("stageEditorSetBlockData") + " (" + Lang.get("noNamesSet") + ")\n"; + text += GRAY + "3 - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noNamesSet") + ")\n"; text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } else { @@ -732,11 +732,11 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } if (context.getSessionData(pref + CK.S_BREAK_DURABILITY) == null) { - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockData") + " (" + Lang.get("noneSet") + ")\n"; + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n"; } else { - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockData") + "\n"; - for (Integer i : getBlockData(context)) { + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n"; + for (Integer i : getBlockDurability(context)) { text += GRAY + " - " + AQUA + i + "\n"; @@ -771,7 +771,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNoBlockNames")); return new BreakBlockListPrompt(); } else { - return new BreakBlockDataPrompt(); + return new BreakBlockDurabilityPrompt(); } } else if (input.equalsIgnoreCase("4")) { context.getForWhom().sendRawMessage(YELLOW + Lang.get("stageEditorBreakBlocksCleared")); @@ -818,7 +818,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } @SuppressWarnings("unchecked") - private List getBlockData(ConversationContext context) { + private List getBlockDurability(ConversationContext context) { return (List) context.getSessionData(pref + CK.S_BREAK_DURABILITY); } } @@ -912,7 +912,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } - private class BreakBlockDataPrompt extends StringPrompt { + private class BreakBlockDurabilityPrompt extends StringPrompt { @Override public String getPromptText(ConversationContext context) { @@ -957,7 +957,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { public DamageBlockListPrompt() { - super("1", "2", "3", "4"); + super("1", "2", "3", "4", "5"); } @@ -968,8 +968,9 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { if (context.getSessionData(pref + CK.S_DAMAGE_NAMES) == null) { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + " (" + Lang.get("noneSet") + ")\n"; text += GRAY + "2 - " + Lang.get("stageEditorSetDamageAmounts") + " (" + Lang.get("noNamesSet") + ")\n"; - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + text += GRAY + "3 - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noNamesSet") + ")\n"; + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } else { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + "\n"; @@ -992,8 +993,21 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + if (context.getSessionData(pref + CK.S_DAMAGE_DURABILITY) == null) { + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n"; + } else { + + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n"; + for (Integer i : getBlockDurability(context)) { + + text += GRAY + " - " + AQUA + i + "\n"; + + } + + } + + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } @@ -1015,11 +1029,19 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { return new DamageBlockAmountsPrompt(); } } else if (input.equalsIgnoreCase("3")) { + if (context.getSessionData(pref + CK.S_DAMAGE_NAMES) == null) { + context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNoBlockNames")); + return new DamageBlockListPrompt(); + } else { + return new DamageBlockDurabilityPrompt(); + } + } else if (input.equalsIgnoreCase("4")) { context.getForWhom().sendRawMessage(YELLOW + Lang.get("stageEditorDamageBlocksCleared")); context.setSessionData(pref + CK.S_DAMAGE_NAMES, null); context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null); + context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null); return new DamageBlockListPrompt(); - } else if (input.equalsIgnoreCase("4")) { + } else if (input.equalsIgnoreCase("5")) { int one; int two; @@ -1056,6 +1078,11 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { private List getBlockAmounts(ConversationContext context) { return (List) context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS); } + + @SuppressWarnings("unchecked") + private List getBlockDurability(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_DAMAGE_DURABILITY); + } } private class DamageBlockNamesPrompt extends StringPrompt { @@ -1146,12 +1173,53 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } + + private class DamageBlockDurabilityPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return YELLOW + Lang.get("stageEditorDamageBlocksPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + + String[] args = input.split(" "); + LinkedList durability = new LinkedList(); + for (String s : args) { + + try { + + if (Integer.parseInt(s) > 0) { + durability.add(Integer.parseInt(s)); + } else { + context.getForWhom().sendRawMessage(PINK + s + RED + " " + Lang.get("stageEditortNotGreaterThanZero")); + return new DamageBlockAmountsPrompt(); + } + + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); + return new DamageBlockAmountsPrompt(); + } + + } + + context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, durability); + + } + + return new DamageBlockListPrompt(); + + } + } private class PlaceBlockListPrompt extends FixedSetPrompt { public PlaceBlockListPrompt() { - super("1", "2", "3", "4"); + super("1", "2", "3", "4", "5"); } @@ -1162,8 +1230,9 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { if (context.getSessionData(pref + CK.S_PLACE_NAMES) == null) { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + " (" + Lang.get("noneSet") + ")\n"; text += GRAY + "2 - " + Lang.get("stageEditorSetPlaceAmounts") + " (" + Lang.get("noNamesSet") + ")\n"; - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + text += GRAY + "3 - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noNamesSet") + ")\n"; + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } else { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + "\n"; @@ -1185,9 +1254,22 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } + + if (context.getSessionData(pref + CK.S_PLACE_DURABILITY) == null) { + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n"; + } else { - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n"; + for (Integer i : getBlockDurability(context)) { + + text += GRAY + " - " + AQUA + i + "\n"; + + } + + } + + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } @@ -1209,11 +1291,19 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { return new PlaceBlockAmountsPrompt(); } } else if (input.equalsIgnoreCase("3")) { + if (context.getSessionData(pref + CK.S_PLACE_NAMES) == null) { + context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNoBlockNames")); + return new PlaceBlockListPrompt(); + } else { + return new PlaceBlockDurabilityPrompt(); + } + } else if (input.equalsIgnoreCase("4")) { context.getForWhom().sendRawMessage(YELLOW + Lang.get("stageEditorPlaceBlocksCleared")); context.setSessionData(pref + CK.S_PLACE_NAMES, null); context.setSessionData(pref + CK.S_PLACE_AMOUNTS, null); + context.setSessionData(pref + CK.S_PLACE_DURABILITY, null); return new PlaceBlockListPrompt(); - } else if (input.equalsIgnoreCase("4")) { + } else if (input.equalsIgnoreCase("5")) { int one; int two; @@ -1250,6 +1340,11 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { private List getBlockAmounts(ConversationContext context) { return (List) context.getSessionData(pref + CK.S_PLACE_AMOUNTS); } + + @SuppressWarnings("unchecked") + private List getBlockDurability(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_PLACE_DURABILITY); + } } private class PlaceBlockNamesPrompt extends StringPrompt { @@ -1340,12 +1435,53 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } + + private class PlaceBlockDurabilityPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return YELLOW + Lang.get("stageEditorPlaceBlocksPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + + String[] args = input.split(" "); + LinkedList durability = new LinkedList(); + for (String s : args) { + + try { + + if (Integer.parseInt(s) > 0) { + durability.add(Integer.parseInt(s)); + } else { + context.getForWhom().sendRawMessage(PINK + s + RED + " " + Lang.get("stageEditortNotGreaterThanZero")); + return new PlaceBlockAmountsPrompt(); + } + + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); + return new PlaceBlockAmountsPrompt(); + } + + } + + context.setSessionData(pref + CK.S_PLACE_DURABILITY, durability); + + } + + return new PlaceBlockListPrompt(); + + } + } private class UseBlockListPrompt extends FixedSetPrompt { public UseBlockListPrompt() { - super("1", "2", "3", "4"); + super("1", "2", "3", "4", "5"); } @@ -1356,8 +1492,9 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { if (context.getSessionData(pref + CK.S_USE_NAMES) == null) { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + " (" + Lang.get("noneSet") + ")\n"; text += GRAY + "2 - " + Lang.get("stageEditorSetUseAmounts") + " (" + Lang.get("noNamesSet") + ")\n"; - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + text += GRAY + "3 - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noNamesSet") + ")\n"; + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } else { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + "\n"; @@ -1379,9 +1516,22 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } + + if (context.getSessionData(pref + CK.S_USE_DURABILITY) == null) { + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n"; + } else { - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n"; + for (Integer i : getBlockDurability(context)) { + + text += GRAY + " - " + AQUA + i + "\n"; + + } + + } + + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } @@ -1403,11 +1553,19 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { return new UseBlockAmountsPrompt(); } } else if (input.equalsIgnoreCase("3")) { + if (context.getSessionData(pref + CK.S_USE_NAMES) == null) { + context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNoBlockNames")); + return new UseBlockListPrompt(); + } else { + return new UseBlockDurabilityPrompt(); + } + } else if (input.equalsIgnoreCase("4")) { context.getForWhom().sendRawMessage(YELLOW + Lang.get("stageEditorUseBlocksCleared")); context.setSessionData(pref + CK.S_USE_NAMES, null); context.setSessionData(pref + CK.S_USE_AMOUNTS, null); + context.setSessionData(pref + CK.S_USE_DURABILITY, null); return new UseBlockListPrompt(); - } else if (input.equalsIgnoreCase("4")) { + } else if (input.equalsIgnoreCase("5")) { int one; int two; @@ -1444,6 +1602,11 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { private List getBlockAmounts(ConversationContext context) { return (List) context.getSessionData(pref + CK.S_USE_AMOUNTS); } + + @SuppressWarnings("unchecked") + private List getBlockDurability(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_USE_DURABILITY); + } } private class UseBlockNamesPrompt extends StringPrompt { @@ -1534,12 +1697,53 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } + + private class UseBlockDurabilityPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return YELLOW + Lang.get("stageEditorUseBlocksPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + + String[] args = input.split(" "); + LinkedList durability = new LinkedList(); + for (String s : args) { + + try { + + if (Integer.parseInt(s) > 0) { + durability.add(Integer.parseInt(s)); + } else { + context.getForWhom().sendRawMessage(PINK + s + RED + " " + Lang.get("stageEditortNotGreaterThanZero")); + return new UseBlockAmountsPrompt(); + } + + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); + return new UseBlockAmountsPrompt(); + } + + } + + context.setSessionData(pref + CK.S_USE_DURABILITY, durability); + + } + + return new UseBlockListPrompt(); + + } + } private class CutBlockListPrompt extends FixedSetPrompt { public CutBlockListPrompt() { - super("1", "2", "3", "4"); + super("1", "2", "3", "4", "5"); } @@ -1550,8 +1754,9 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { if (context.getSessionData(pref + CK.S_CUT_NAMES) == null) { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + " (" + Lang.get("noneSet") + ")\n"; text += GRAY + "2 - " + Lang.get("stageEditorSetCutAmounts") + " (" + Lang.get("noNamesSet") + ")\n"; - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + text += GRAY + "3 - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noNamesSet") + ")\n"; + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } else { text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockNames") + "\n"; @@ -1574,8 +1779,21 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } - text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; - text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("done"); + if (context.getSessionData(pref + CK.S_CUT_DURABILITY) == null) { + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + " (" + Lang.get("noneSet") + ")\n"; + } else { + + text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorSetBlockDurability") + "\n"; + for (Integer i : getBlockDurability(context)) { + + text += GRAY + " - " + AQUA + i + "\n"; + + } + + } + + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; + text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); } @@ -1597,11 +1815,19 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { return new CutBlockAmountsPrompt(); } } else if (input.equalsIgnoreCase("3")) { + if (context.getSessionData(pref + CK.S_CUT_NAMES) == null) { + context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNoBlockNames")); + return new CutBlockListPrompt(); + } else { + return new CutBlockDurabilityPrompt(); + } + } else if (input.equalsIgnoreCase("4")) { context.getForWhom().sendRawMessage(YELLOW + Lang.get("stageEditorCutBlocksCleared")); context.setSessionData(pref + CK.S_CUT_NAMES, null); context.setSessionData(pref + CK.S_CUT_AMOUNTS, null); + context.setSessionData(pref + CK.S_CUT_DURABILITY, null); return new CutBlockListPrompt(); - } else if (input.equalsIgnoreCase("4")) { + } else if (input.equalsIgnoreCase("5")) { int one; int two; @@ -1638,6 +1864,11 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { private List getBlockAmounts(ConversationContext context) { return (List) context.getSessionData(pref + CK.S_CUT_AMOUNTS); } + + @SuppressWarnings("unchecked") + private List getBlockDurability(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_CUT_DURABILITY); + } } private class CutBlockNamesPrompt extends StringPrompt { @@ -1728,6 +1959,47 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } + + private class CutBlockDurabilityPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return YELLOW + Lang.get("stageEditorCutBlocksPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + + String[] args = input.split(" "); + LinkedList durability = new LinkedList(); + for (String s : args) { + + try { + + if (Integer.parseInt(s) > 0) { + durability.add(Integer.parseInt(s)); + } else { + context.getForWhom().sendRawMessage(PINK + s + RED + " " + Lang.get("stageEditortNotGreaterThanZero")); + return new CutBlockAmountsPrompt(); + } + + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); + return new CutBlockAmountsPrompt(); + } + + } + + context.setSessionData(pref + CK.S_CUT_DURABILITY, durability); + + } + + return new CutBlockListPrompt(); + + } + } private class FishPrompt extends NumericPrompt { diff --git a/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java b/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java index fcd5d5550..fb4060fd5 100644 --- a/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/ItemStackPrompt.java @@ -56,7 +56,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil { menu += GOLD + "" + BOLD + "0. " + RESET + "" + YELLOW + Lang.get("itemCreateLoadHand") + "\n"; menu += YELLOW + "" + BOLD + "1. " + RESET + "" + GOLD + Lang.get("itemCreateSetName") + "\n"; menu += YELLOW + "" + BOLD + "2. " + RESET + "" + GOLD + Lang.get("itemCreateSetAmount") + "\n"; - menu += YELLOW + "" + BOLD + "3. " + RESET + "" + GOLD + Lang.get("itemCreateSetData") + "\n"; + menu += YELLOW + "" + BOLD + "3. " + RESET + "" + GOLD + Lang.get("itemCreateSetDurab") + "\n"; menu += YELLOW + "" + BOLD + "4. " + RESET + "" + GOLD + Lang.get("itemCreateSetEnchs") + "\n"; menu += YELLOW + "" + BOLD + "5. " + RESET + "" + ITALIC + GOLD + Lang.get("itemCreateSetDisplay") + "\n"; menu += YELLOW + "" + BOLD + "6. " + RESET + "" + ITALIC + GOLD + Lang.get("itemCreateSetLore") + "\n"; @@ -324,7 +324,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil { @Override public String getPromptText(ConversationContext cc) { - return YELLOW + Lang.get("itemCreateEnterData"); + return YELLOW + Lang.get("itemCreateEnterDurab"); } @Override @@ -335,7 +335,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil { int amt = Integer.parseInt(input); if (amt < 1) { - cc.getForWhom().sendRawMessage(RED + Lang.get("itemCreateInvalidData")); + cc.getForWhom().sendRawMessage(RED + Lang.get("itemCreateInvalidDurab")); return new DataPrompt(); } else { cc.setSessionData("tempData", Short.parseShort(input)); diff --git a/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java b/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java index 4ed3c274e..321eb211c 100644 --- a/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/StagesPrompt.java @@ -118,15 +118,19 @@ public class StagesPrompt extends StringPrompt implements ColorUtil { cc.setSessionData(newPref + CK.S_DAMAGE_NAMES, cc.getSessionData(pref + CK.S_DAMAGE_NAMES)); cc.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS)); + cc.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY)); cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_NAMES)); cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_AMOUNTS)); + cc.setSessionData(newPref + CK.S_PLACE_DURABILITY, cc.getSessionData(pref + CK.S_PLACE_DURABILITY)); cc.setSessionData(newPref + CK.S_USE_NAMES, cc.getSessionData(pref + CK.S_USE_NAMES)); cc.setSessionData(newPref + CK.S_USE_AMOUNTS, cc.getSessionData(pref + CK.S_USE_AMOUNTS)); + cc.setSessionData(newPref + CK.S_USE_DURABILITY, cc.getSessionData(pref + CK.S_USE_DURABILITY)); cc.setSessionData(newPref + CK.S_CUT_NAMES, cc.getSessionData(pref + CK.S_CUT_NAMES)); cc.setSessionData(newPref + CK.S_CUT_AMOUNTS, cc.getSessionData(pref + CK.S_CUT_AMOUNTS)); + cc.setSessionData(newPref + CK.S_CUT_DURABILITY, cc.getSessionData(pref + CK.S_CUT_DURABILITY)); cc.setSessionData(newPref + CK.S_FISH, cc.getSessionData(pref + CK.S_FISH)); @@ -195,15 +199,19 @@ public class StagesPrompt extends StringPrompt implements ColorUtil { cc.setSessionData(pref + CK.S_DAMAGE_NAMES, null); cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null); + cc.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null); cc.setSessionData(pref + CK.S_PLACE_NAMES, null); cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, null); + cc.setSessionData(pref + CK.S_PLACE_DURABILITY, null); cc.setSessionData(pref + CK.S_USE_NAMES, null); cc.setSessionData(pref + CK.S_USE_AMOUNTS, null); + cc.setSessionData(pref + CK.S_USE_DURABILITY, null); cc.setSessionData(pref + CK.S_CUT_NAMES, null); cc.setSessionData(pref + CK.S_CUT_AMOUNTS, null); + cc.setSessionData(pref + CK.S_CUT_DURABILITY, null); cc.setSessionData(pref + CK.S_FISH, null); diff --git a/src/main/java/me/blackvein/quests/util/CK.java b/src/main/java/me/blackvein/quests/util/CK.java index fdc5d5108..311d61f0e 100644 --- a/src/main/java/me/blackvein/quests/util/CK.java +++ b/src/main/java/me/blackvein/quests/util/CK.java @@ -57,12 +57,16 @@ public class CK { public static final String S_BREAK_DURABILITY = "breakDurability"; public static final String S_DAMAGE_NAMES = "damageNames"; public static final String S_DAMAGE_AMOUNTS = "damageAmounts"; + public static final String S_DAMAGE_DURABILITY = "damageDurability"; public static final String S_PLACE_NAMES = "placeNames"; public static final String S_PLACE_AMOUNTS = "placeAmounts"; + public static final String S_PLACE_DURABILITY = "placeDurability"; public static final String S_USE_NAMES = "useNames"; public static final String S_USE_AMOUNTS = "useAmounts"; + public static final String S_USE_DURABILITY = "useDurability"; public static final String S_CUT_NAMES = "cutNames"; public static final String S_CUT_AMOUNTS = "cutAmounts"; + public static final String S_CUT_DURABILITY = "cutDurability"; public static final String S_FISH = "fish"; public static final String S_PLAYER_KILL = "playerKill"; public static final String S_ENCHANT_TYPES = "enchantTypes"; diff --git a/src/main/java/me/blackvein/quests/util/Lang.java b/src/main/java/me/blackvein/quests/util/Lang.java index 61ddbc94d..df3df6b82 100644 --- a/src/main/java/me/blackvein/quests/util/Lang.java +++ b/src/main/java/me/blackvein/quests/util/Lang.java @@ -298,7 +298,7 @@ public class Lang { langMap.put("stageEditorSetBlockNames", "Set block names"); langMap.put("stageEditorSetBlockAmounts", "Set block amounts"); - langMap.put("stageEditorSetBlockData", "Set block data"); + langMap.put("stageEditorSetBlockDurability", "Set block durability"); langMap.put("stageEditorSetDamageAmounts", "Set damage amounts"); langMap.put("stageEditorSetPlaceAmounts", "Set place amounts"); langMap.put("stageEditorSetUseAmounts", "Set use amounts"); @@ -732,14 +732,14 @@ public class Lang { langMap.put("itemCreateLoadHand", "Load item in hand"); langMap.put("itemCreateSetName", "Set name"); langMap.put("itemCreateSetAmount", "Set amount"); - langMap.put("itemCreateSetData", "Set data"); + langMap.put("itemCreateSetDurab", "Set durability"); langMap.put("itemCreateSetEnchs", "Add/clear enchantments"); langMap.put("itemCreateSetDisplay", "Set display name"); langMap.put("itemCreateSetLore", "Set lore"); langMap.put("itemCreateEnterName", "Enter an item name, or 'cancel' to return."); langMap.put("itemCreateEnterAmount", "Enter item amount (max. 64), or 'cancel' to return."); - langMap.put("itemCreateEnterData", "Enter item data, or 'clear' to clear the data, or 'cancel' to return."); + langMap.put("itemCreateEnterDurab", "Enter item durability, or 'clear' to clear the data, or 'cancel' to return."); langMap.put("itemCreateEnterEnch", "Enter an enchantment name, or 'clear' to clear the enchantments, or 'cancel' to return."); langMap.put("itemCreateEnterLevel", "Enter a level (number) for "); langMap.put("itemCreateEnterDisplay", "Enter item display name, or 'clear' to clear the display name, or 'cancel' to return."); @@ -750,7 +750,7 @@ public class Lang { langMap.put("itemCreateNoName", "You must set a name first!"); langMap.put("itemCreateInvalidName", "Invalid item name!"); langMap.put("itemCreateInvalidAmount", "Amount must be between 1-64!"); - langMap.put("itemCreateInvalidData", "Invalid item data!"); + langMap.put("itemCreateInvalidDurab", "Invalid item durability!"); langMap.put("itemCreateInvalidEnch", "Invalid enchantment name!"); langMap.put("itemCreateInvalidLevel", "Level must be greater than 0!"); langMap.put("itemCreateInvalidInput", "Invalid input!");