Clean-up UUID/blacklist warnings, fixes #251

This commit is contained in:
HappyPikachu 2018-02-17 19:30:35 -05:00
parent 65bc723a13
commit e8a47f910f
3 changed files with 31 additions and 18 deletions

View File

@ -390,9 +390,9 @@ public class Quester {
for (ItemStack e2 : getQuestData(quest).blocksBroken) { for (ItemStack e2 : getQuestData(quest).blocksBroken) {
if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) {
if (e2.getAmount() < e.getAmount()) { 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 { } 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());
} }
} }
} }

View File

@ -2014,17 +2014,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return quester; return quester;
} }
} }
if (quester.loadData() == true) {
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() + "\"");
}
questers.put(id, quester); questers.put(id, quester);
} }
} }

View File

@ -28,8 +28,6 @@ import net.milkbowl.vault.item.Items;
public class ItemUtil { public class ItemUtil {
static Quests plugin;
/** /**
* Will compare stacks by name, amount, data, display name/lore and enchantments * 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.
*
* <p>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) { public static ItemStack readItemStack(String data) {
if (data == null) { if (data == null) {
return null; return null;
@ -94,7 +98,6 @@ public class ItemUtil {
LinkedList<String> lore = new LinkedList<String>(); LinkedList<String> lore = new LinkedList<String>();
for (String arg : args) { for (String arg : args) {
if (arg.startsWith("name-")) { if (arg.startsWith("name-")) {
// Attempt to match item name. Returns null if invalid format
try { try {
stack = new ItemStack(Material.matchMaterial(arg.substring(5))); stack = new ItemStack(Material.matchMaterial(arg.substring(5)));
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
@ -124,6 +127,14 @@ public class ItemUtil {
return stack; return stack;
} }
/**
* Get formatted string from ItemStack. See readItemStack() for reverse function.
*
* <p>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) { public static String serialize(ItemStack is) {
String serial; String serial;
if (is == null) { if (is == null) {
@ -207,6 +218,12 @@ public class ItemUtil {
return text; 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) { public static boolean isItem(ItemStack is) {
if (is == null) if (is == null)
return false; return false;
@ -215,6 +232,12 @@ public class ItemUtil {
return true; 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) { public static boolean isJournal(ItemStack is) {
if (is == null) if (is == null)
return false; return false;