diff --git a/pom.xml b/pom.xml index cba0aca4d..0941aaccf 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,10 @@ me.blackvein.quests quests - 3.1.7 + 3.1.8 quests https://github.com/FlyingPikachu/Quests/ jar - UTF-8 diff --git a/src/main/java/me/blackvein/quests/NpcListener.java b/src/main/java/me/blackvein/quests/NpcListener.java index 991c6476c..311cb24bb 100644 --- a/src/main/java/me/blackvein/quests/NpcListener.java +++ b/src/main/java/me/blackvein/quests/NpcListener.java @@ -81,7 +81,7 @@ public class NpcListener implements Listener { if (hand.hasItemMeta()) { text += ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC + (hand.getItemMeta().hasDisplayName() ? hand.getItemMeta().getDisplayName() + ChatColor.GRAY + " (" : ""); } - text += ChatColor.AQUA + Quester.prettyItemString(hand.getType().name()) + (hand.getDurability() != 0 ? (":" + ChatColor.BLUE + hand.getDurability()) : "") + ChatColor.GRAY; + text += ChatColor.AQUA + ItemUtil.getName(hand) + (hand.getDurability() != 0 ? (":" + ChatColor.BLUE + hand.getDurability()) : "") + ChatColor.GRAY; if (hand.hasItemMeta()) { text += (hand.getItemMeta().hasDisplayName() ? ")" : ""); } diff --git a/src/main/java/me/blackvein/quests/PlayerListener.java b/src/main/java/me/blackvein/quests/PlayerListener.java index 2bd26ee46..2e9936d7a 100644 --- a/src/main/java/me/blackvein/quests/PlayerListener.java +++ b/src/main/java/me/blackvein/quests/PlayerListener.java @@ -200,42 +200,42 @@ public class PlayerListener implements Listener { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.questFactory.selectedBlockStarts.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")"); } else if (plugin.eventFactory.selectedExplosionLocations.containsKey(evt.getPlayer().getUniqueId())) { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.eventFactory.selectedExplosionLocations.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")"); } else if (plugin.eventFactory.selectedEffectLocations.containsKey(evt.getPlayer().getUniqueId())) { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.eventFactory.selectedEffectLocations.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")"); } else if (plugin.eventFactory.selectedMobLocations.containsKey(evt.getPlayer().getUniqueId())) { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.eventFactory.selectedMobLocations.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType()))+ ChatColor.GOLD + ")"); } else if (plugin.eventFactory.selectedLightningLocations.containsKey(evt.getPlayer().getUniqueId())) { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.eventFactory.selectedLightningLocations.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")"); } else if (plugin.eventFactory.selectedTeleportLocations.containsKey(evt.getPlayer().getUniqueId())) { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.eventFactory.selectedTeleportLocations.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")"); } else if (plugin.questFactory.selectedKillLocations.containsKey(evt.getPlayer().getUniqueId())) { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.questFactory.selectedKillLocations.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")"); } else if (plugin.questFactory.selectedReachLocations.containsKey(evt.getPlayer().getUniqueId())) { Block block = evt.getClickedBlock(); Location loc = block.getLocation(); plugin.questFactory.selectedReachLocations.put(evt.getPlayer().getUniqueId(), block); - evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")"); + evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")"); } else if (player.isConversing() == false) { for (final Quest q : plugin.quests) { if (q.blockStart != null) { diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java index bf4efd392..91ed55e83 100644 --- a/src/main/java/me/blackvein/quests/Quest.java +++ b/src/main/java/me/blackvein/quests/Quest.java @@ -379,15 +379,15 @@ public class Quest { } } else if (i.getDurability() != 0) { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); } } else { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount()); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount()); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); } } none = null; @@ -401,15 +401,15 @@ public class Quest { } } else if (i.getDurability() != 0) { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); } } else { if (i.getEnchantments().isEmpty()) { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount()); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount()); } else { - player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); + player.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem")); } } none = null; diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index eefb3c460..3e9ad8cc6 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -468,12 +468,12 @@ public class Quester { if (enchantment2 == enchantment) { if (num1 < num2) { String obj = Lang.get("enchantItem"); - obj = obj.replaceAll("", Quester.prettyItemString(mat.name())); + obj = obj.replaceAll("", ItemUtil.getName(new ItemStack(mat))); obj = obj.replaceAll("", Quester.prettyEnchantmentString(enchantment)); unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + num1 + "/" + num2); } else { String obj = Lang.get("enchantItem"); - obj = obj.replaceAll("", Quester.prettyItemString(mat.name())); + obj = obj.replaceAll("", ItemUtil.getName(new ItemStack(mat))); obj = obj.replaceAll("", Quester.prettyEnchantmentString(enchantment)); finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + num1 + "/" + num2); } @@ -1074,7 +1074,7 @@ public class Quester { quest.nextStage(this); } } else if (objective.equalsIgnoreCase("breakBlock")) { - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("break") + " " + prettyItemString(material.getType().name()); + String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("break") + " " + ItemUtil.getName(material); String stack = getQuestData(quest).blocksBroken.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; @@ -1083,7 +1083,7 @@ public class Quester { quest.nextStage(this); } } else if (objective.equalsIgnoreCase("damageBlock")) { - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("damage") + " " + prettyItemString(material.getType().name()); + String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("damage") + " " + ItemUtil.getName(material); String stack = getQuestData(quest).blocksDamaged.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; @@ -1091,7 +1091,7 @@ public class Quester { quest.nextStage(this); } } else if (objective.equalsIgnoreCase("placeBlock")) { - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("place") + " " + prettyItemString(material.getType().name()); + String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("place") + " " + ItemUtil.getName(material); String stack = getQuestData(quest).blocksPlaced.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; @@ -1100,7 +1100,7 @@ public class Quester { quest.nextStage(this); } } else if (objective.equalsIgnoreCase("useBlock")) { - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("use") + " " + prettyItemString(material.getType().name()); + String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("use") + " " + ItemUtil.getName(material); String stack = getQuestData(quest).blocksUsed.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; @@ -1109,7 +1109,7 @@ public class Quester { quest.nextStage(this); } } else if (objective.equalsIgnoreCase("cutBlock")) { - String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("cut") + " " + prettyItemString(material.getType().name()); + String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("cut") + " " + ItemUtil.getName(material); String stack = getQuestData(quest).blocksCut.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; @@ -1126,7 +1126,7 @@ public class Quester { } } else if (objective.equalsIgnoreCase("enchantItem")) { String obj = Lang.get("enchantItem"); - obj = obj.replaceAll("", prettyItemString(material.getType().name())); + obj = obj.replaceAll("", ItemUtil.getName(material)); obj = obj.replaceAll("", Quester.prettyEnchantmentString(enchantment)); String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + obj; for (Map map : getCurrentStage(quest).itemsToEnchant.keySet()) { @@ -1500,7 +1500,7 @@ public class Quester { return capitalized; } - // TODO eliminate and replace all with Items.itemByType(is.getType()).getName() + // NOTE: Use ItemUtil.getString(itemStack) instead if possible public static String prettyItemString(String itemName) { String baseString = Material.matchMaterial(itemName).toString(); String[] substrings = baseString.split("_"); diff --git a/src/main/java/me/blackvein/quests/util/ItemUtil.java b/src/main/java/me/blackvein/quests/util/ItemUtil.java index 5be2b68d1..3c37bd684 100644 --- a/src/main/java/me/blackvein/quests/util/ItemUtil.java +++ b/src/main/java/me/blackvein/quests/util/ItemUtil.java @@ -161,7 +161,7 @@ public class ItemUtil { if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) { text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.AQUA + " x " + is.getAmount(); } else { - text = ChatColor.AQUA + Quester.prettyItemString(is.getType().name()); + text = ChatColor.AQUA + getName(is); if (is.getDurability() != 0) { text += ChatColor.AQUA + ":" + is.getDurability(); } @@ -178,7 +178,7 @@ public class ItemUtil { if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) { text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.AQUA + " x " + is.getAmount(); } else { - text = ChatColor.AQUA + Quester.prettyItemString(is.getType().name()); + text = ChatColor.AQUA + getName(is); if (is.getDurability() != 0) { text += ChatColor.AQUA + ":" + is.getDurability(); }