Removed unneeded legacy conversion

This commit is contained in:
Auxilor
2021-11-08 12:07:15 +00:00
parent 0ab15d5012
commit 5e4ac571e3
2 changed files with 0 additions and 47 deletions

View File

@@ -113,8 +113,6 @@ public class TalismanChecks {
return null;
}
TalismanUtils.convertFromLegacy(item);
ItemMeta meta = item.getItemMeta();
if (meta == null) {

View File

@@ -79,49 +79,4 @@ public class TalismanUtils {
public static void clearTalismanMaterials() {
TALISMAN_MATERIALS.clear();
}
/**
* Update legacy talisman to 3.0.0 talisman.
*
* @param itemStack The Talisman ItemStack.
*/
public static void convertFromLegacy(@NotNull final ItemStack itemStack) {
ItemMeta meta = itemStack.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
NamespacedKey talismanKey = container.getKeys().stream().filter(namespacedKey -> namespacedKey.getNamespace().equals("talismans")).findFirst().orElse(null);
if (talismanKey == null) {
return;
}
String key = talismanKey.getKey();
int level;
if (key.endsWith("_talisman")) {
level = 1;
} else if (key.endsWith("_ring")) {
level = 2;
} else if (key.endsWith("_relic")) {
level = 3;
} else if (key.endsWith("_fossil")) {
level = 4;
} else {
return;
}
String newKey = key.replace("_talisman", "")
.replace("_ring", "")
.replace("_relic", "")
.replace("_fossil", "");
container.remove(talismanKey);
NamespacedKey newTalismanKey = TalismansPlugin.getInstance().getNamespacedKeyFactory().create(newKey);
container.set(newTalismanKey, PersistentDataType.INTEGER, level);
itemStack.setItemMeta(meta);
}
}