From b1d259bf7c0cb67345c0f282d6948aa1ad6b987a Mon Sep 17 00:00:00 2001 From: j502647092 Date: Wed, 29 Apr 2015 12:12:29 +0800 Subject: [PATCH] Remove UUID Check Model... Signed-off-by: j502647092 --- .../me/tft_02/soulbound/util/ItemUtils.java | 59 ------------------- .../me/tft_02/soulbound/util/StringUtils.java | 32 ---------- 2 files changed, 91 deletions(-) diff --git a/src/main/java/com/me/tft_02/soulbound/util/ItemUtils.java b/src/main/java/com/me/tft_02/soulbound/util/ItemUtils.java index b5f1515..b89d1bf 100644 --- a/src/main/java/com/me/tft_02/soulbound/util/ItemUtils.java +++ b/src/main/java/com/me/tft_02/soulbound/util/ItemUtils.java @@ -2,7 +2,6 @@ package com.me.tft_02.soulbound.util; import java.util.ArrayList; import java.util.List; -import java.util.UUID; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -222,69 +221,11 @@ public class ItemUtils { } public static boolean isBindedPlayer(Player player, ItemStack itemStack) { - updateOldLore(player, itemStack); - checkNameChange(player, itemStack); List itemLore = itemStack.getItemMeta().getLore(); return itemLore.contains(player.getName()); } - private static ItemStack updateOldLore(Player player, ItemStack itemStack) { - ItemMeta itemMeta = itemStack.getItemMeta(); - if (itemMeta != null) { - if (!itemMeta.hasLore()) { - return itemStack; - } - } - List itemLore = itemMeta.getLore(); - - if (itemLore.size() - 1 < StringUtils.getIndexOfSoulbound(itemLore) + 2) { - return itemStack; - } - - int indexOfSoulbound = StringUtils.getIndexOfSoulbound(itemLore); - int indexOfUniqueId = indexOfSoulbound + 2; - UUID uuid = null; - - if (itemLore.get(indexOfUniqueId).contains(player.getUniqueId().toString())) { - uuid = UUID.fromString(ChatColor.stripColor(itemLore.get(indexOfUniqueId))); - itemLore.remove(indexOfUniqueId); - } - - if (StringUtils.readUUIDFromLore(itemLore) == null && uuid != null) { - itemLore.set(indexOfSoulbound, Misc.SOULBOUND_TAG + StringUtils.hideUUID(uuid)); - } - - itemMeta.setLore(itemLore); - itemStack.setItemMeta(itemMeta); - return itemStack; - } - - private static ItemStack checkNameChange(Player player, ItemStack itemStack) { - ItemMeta itemMeta = itemStack.getItemMeta(); - List itemLore = itemMeta.getLore(); - - int indexName = StringUtils.getIndexOfSoulbound(itemLore) + 1; - - if (itemLore.size() >= 2 && itemLore.contains(player.getName()) && !Config.getInstance().getShowNameInLore()) { - Soulbound.p.debug("Item lore has a player name but that's disabled in config"); - Soulbound.p.debug("Going to remove what is at indexName " + indexName + " which is: " + itemLore.get(indexName)); - itemLore.remove(indexName); - itemMeta.setLore(itemLore); - itemStack.setItemMeta(itemMeta); - return itemStack; - } - - if (Config.getInstance().getShowNameInLore() && !itemLore.contains(player.getName()) && player.getUniqueId().equals(StringUtils.readUUIDFromLore(itemLore))) { - Soulbound.p.debug("Item lore doesn't have (correct) player name but it should and the UUIDs match"); - itemLore.add(indexName, player.getName()); - } - - itemMeta.setLore(itemLore); - itemStack.setItemMeta(itemMeta); - return itemStack; - } - public static boolean isNormalItem(ItemStack itemStack) { return !itemStack.hasItemMeta() && !itemStack.getItemMeta().hasLore() || ItemUtils.getItemType(itemStack) == ItemType.NORMAL; } diff --git a/src/main/java/com/me/tft_02/soulbound/util/StringUtils.java b/src/main/java/com/me/tft_02/soulbound/util/StringUtils.java index e375dd5..d8bd2e3 100644 --- a/src/main/java/com/me/tft_02/soulbound/util/StringUtils.java +++ b/src/main/java/com/me/tft_02/soulbound/util/StringUtils.java @@ -1,9 +1,6 @@ package com.me.tft_02.soulbound.util; import java.util.List; -import java.util.UUID; - -import org.bukkit.ChatColor; public class StringUtils { @@ -17,33 +14,4 @@ public class StringUtils { } return index; } - - public static UUID readUUIDFromLore(List itemLore) { - int index = getIndexOfSoulbound(itemLore); - - if (index == -1) { - return null; - } - - String line = itemLore.get(index); - line = line.substring(11); - - return readUUID(line); - } - - public static String hideUUID(UUID uuid) { - String string = uuid.toString(); - string = string.replaceAll("-", ChatColor.MAGIC.toString()); - StringBuilder formattedString = new StringBuilder(); - - for (int i = 0; i < string.length(); i++) { - formattedString.append(ChatColor.COLOR_CHAR).append(string.charAt(i)); - } - - return formattedString.toString(); - } - - public static UUID readUUID(String string) { - return UUID.fromString(string.replaceAll(ChatColor.MAGIC.toString(), "-").replaceAll("ยง", "")); - } }