From e8a47f910fe7a328dba45ba27370ea70c7bbabb8 Mon Sep 17 00:00:00 2001 From: HappyPikachu Date: Sat, 17 Feb 2018 19:30:35 -0500 Subject: [PATCH] Clean-up UUID/blacklist warnings, fixes #251 --- .../java/me/blackvein/quests/Quester.java | 4 +-- src/main/java/me/blackvein/quests/Quests.java | 12 +------ .../me/blackvein/quests/util/ItemUtil.java | 33 ++++++++++++++++--- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 0ec1885f7..37a52a5da 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -390,9 +390,9 @@ public class Quester { for (ItemStack e2 : getQuestData(quest).blocksBroken) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getAmount() < e.getAmount()) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "break") + " " + Items.itemByType(e2.getType()).getName() + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "break") + " " + Items.itemByType(e2.getType(), e2.getData().getData()).getName() + ChatColor.GREEN + ": " + e2.getAmount() + "/" + e.getAmount()); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "break") + " " + Items.itemByType(e2.getType()).getName() + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "break") + " " + Items.itemByType(e2.getType(), e2.getData().getData()).getName() + ChatColor.GRAY + ": " + e2.getAmount() + "/" + e.getAmount()); } } } diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 52690cfde..a8931a4c4 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -2014,17 +2014,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener return quester; } } - - if (!questerBlacklist.contains(id.toString())) { - getLogger().log(Level.WARNING, "Quester data for UUID \"" + id.toString() + "\" not stored. Attempting manual data retrieval..."); - } - - if (quester.loadData() == false && !questerBlacklist.contains(id.toString())) { - getLogger().info("Quester not found for UUID \"" + id.toString() + "\". Consider adding them to the Quester blacklist."); - } else { - if (!questerBlacklist.contains(id.toString())) { - getLogger().log(Level.INFO, "Manual data retrieval succeeded for UUID \"" + id.toString() + "\""); - } + if (quester.loadData() == true) { questers.put(id, quester); } } diff --git a/src/main/java/me/blackvein/quests/util/ItemUtil.java b/src/main/java/me/blackvein/quests/util/ItemUtil.java index acb53a563..1ff0f0f52 100644 --- a/src/main/java/me/blackvein/quests/util/ItemUtil.java +++ b/src/main/java/me/blackvein/quests/util/ItemUtil.java @@ -28,8 +28,6 @@ import net.milkbowl.vault.item.Items; public class ItemUtil { - static Quests plugin; - /** * Will compare stacks by name, amount, data, display name/lore and enchantments * @@ -82,8 +80,14 @@ public class ItemUtil { } } - // Formats -> name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore: - // Returns null if invalid format + /** + * Get ItemStack from formatted string. See serialize() for reverse function. + * + *

Supplied format = name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore: + * + * @param data formatted string + * @return ItemStack, or null if invalid format + */ public static ItemStack readItemStack(String data) { if (data == null) { return null; @@ -94,7 +98,6 @@ public class ItemUtil { LinkedList lore = new LinkedList(); for (String arg : args) { if (arg.startsWith("name-")) { - // Attempt to match item name. Returns null if invalid format try { stack = new ItemStack(Material.matchMaterial(arg.substring(5))); } catch (NullPointerException npe) { @@ -124,6 +127,14 @@ public class ItemUtil { return stack; } + /** + * Get formatted string from ItemStack. See readItemStack() for reverse function. + * + *

Returned format = name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore: + * + * @param is ItemStack + * @return formatted string, or null if invalid stack + */ public static String serialize(ItemStack is) { String serial; if (is == null) { @@ -207,6 +218,12 @@ public class ItemUtil { return text; } + /** + * Ensures that an ItemStack if a valid, non-AIR material + * + * @param is ItemStack to check + * @return true if stack is not null or Material.AIR + */ public static boolean isItem(ItemStack is) { if (is == null) return false; @@ -215,6 +232,12 @@ public class ItemUtil { return true; } + /** + * Checks whether an ItemStack is a Quest Journal based on book title + * + * @param is IemsStack to check + * @return true if display name equals colored journal title + */ public static boolean isJournal(ItemStack is) { if (is == null) return false;