diff --git a/MMOItems-API/pom.xml b/MMOItems-API/pom.xml index efc011b4..09783456 100644 --- a/MMOItems-API/pom.xml +++ b/MMOItems-API/pom.xml @@ -173,7 +173,7 @@ io.lumine Mythic-Dist - 5.6.0-SNAPSHOT + 5.7.1 provided true diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java index 6b4f74c7..b8353165 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java @@ -18,7 +18,7 @@ import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.manager.TypeManager; import net.Indyuce.mmoitems.stat.type.ItemStat; -import org.apache.commons.lang.Validate; +import net.Indyuce.mmoitems.util.MMOUtils; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -148,7 +148,7 @@ public void load(@NotNull ConfigurationSection config) { postLoadAction.cacheConfig(config); name = config.getString("name", name); - item = read(config.getString("display", item == null ? Material.STONE.toString() : item.getType().toString())); + item = MMOUtils.readIcon(config.getString("display", item == null ? Material.STONE.toString() : item.getType().toString())); (unidentifiedTemplate = new UnidentifiedItem(this)).update(config.getConfigurationSection("unident-item")); loreFormat = config.getString("LoreFormat", (parent != null ? parent.loreFormat : null)); attackCooldownKey = config.getString("attack-cooldown-key", "default"); @@ -286,14 +286,6 @@ public UnidentifiedItem getUnidentifiedTemplate() { return unidentifiedTemplate; } - private ItemStack read(String str) { - Validate.notNull(str, "Input must not be null"); - - String[] split = str.split(":"); - Material material = Material.valueOf(split[0]); - return split.length > 1 ? MythicLib.plugin.getVersion().getWrapper().textureItem(material, Integer.parseInt(split[1])) : new ItemStack(material); - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/inventory/MMOItemPlayerIngredient.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/inventory/MMOItemPlayerIngredient.java index d0521010..06cb32a1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/inventory/MMOItemPlayerIngredient.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/crafting/ingredient/inventory/MMOItemPlayerIngredient.java @@ -1,7 +1,7 @@ package net.Indyuce.mmoitems.api.crafting.ingredient.inventory; -import com.google.gson.JsonParser; import io.lumine.mythic.lib.api.item.NBTItem; +import io.lumine.mythic.lib.gson.JsonParser; public class MMOItemPlayerIngredient extends PlayerIngredient { diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/util/DurabilityItem.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/util/DurabilityItem.java index 78aa3050..73fd2443 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/util/DurabilityItem.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/util/DurabilityItem.java @@ -1,11 +1,11 @@ package net.Indyuce.mmoitems.api.interaction.util; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import io.lumine.mythic.lib.version.VEnchantment; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.api.event.item.CustomDurabilityDamage; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/ItemStackBuilder.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/ItemStackBuilder.java index 4012a478..7788a7ed 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/ItemStackBuilder.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/build/ItemStackBuilder.java @@ -1,9 +1,9 @@ package net.Indyuce.mmoitems.api.item.build; -import com.google.gson.JsonArray; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; +import io.lumine.mythic.lib.gson.JsonArray; import io.lumine.mythic.lib.util.AdventureUtils; import io.lumine.mythic.lib.version.VersionUtils; import net.Indyuce.mmoitems.ItemStats; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/ConfigItem.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/ConfigItem.java index 0c2cc4df..65095edf 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/ConfigItem.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/ConfigItem.java @@ -19,8 +19,10 @@ import java.util.List; import java.util.stream.Collectors; +// TODO Refactor this mess public class ConfigItem { private final String id; + @Deprecated private final ItemStack icon; // updated when the plugin reloads @@ -28,6 +30,7 @@ public class ConfigItem { private List lore; // generated + @Deprecated private ItemStack item; public ConfigItem(String id, Material material) { @@ -44,8 +47,8 @@ public ConfigItem(String id, Material material, String name, String... lore) { this.lore = Arrays.asList(lore); } - /* - * used as util to load an item stack from a config + /** + * Used as util to load an item stack from a config */ public ConfigItem(ConfigurationSection config) { Validate.notNull(config, "Config cannot be null"); @@ -65,11 +68,13 @@ public String getId() { return id; } + @Deprecated public void setup(ConfigurationSection config) { config.set("name", getName()); config.set("lore", getLore()); } + @Deprecated public void update(ConfigurationSection config) { Validate.notNull(config, "Config cannot be null"); @@ -128,10 +133,12 @@ public boolean hasLore() { return lore != null; } + @Deprecated public ItemStack getItem() { return item; } + @Deprecated public ItemStack getNewItem() { return item.clone(); } @@ -144,11 +151,11 @@ protected void setLore(List lore) { this.lore = lore; } + @Deprecated protected void setItem(ItemStack item) { this.item = item; } - /** * Unidentified items are ruined when, using a custom resourcepack, they get the material and * custom model data of what they should be, making them not really unidentified.... this will @@ -159,11 +166,13 @@ protected void setItem(ItemStack item) { * @author Gunging * @see #setModel(Integer) */ + @Deprecated protected void setMaterial(@Nullable Material mat) { material = mat; } @Nullable + @Deprecated protected Material material = null; /** @@ -176,10 +185,12 @@ protected void setMaterial(@Nullable Material mat) { * @author Gunging * @see #setMaterial(Material) */ + @Deprecated protected void setModel(@Nullable Integer cmd) { customModelData = cmd; } @Nullable + @Deprecated protected Integer customModelData = null; } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/IdentifiedItem.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/IdentifiedItem.java index 3bbe8a1b..e97071a8 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/IdentifiedItem.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/IdentifiedItem.java @@ -1,56 +1,58 @@ package net.Indyuce.mmoitems.api.item.util.identify; -import java.io.ByteArrayInputStream; -import java.io.IOException; - +import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem; import org.bukkit.inventory.ItemStack; import org.bukkit.util.io.BukkitObjectInputStream; +import org.jetbrains.annotations.NotNull; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; -import io.lumine.mythic.lib.api.item.NBTItem; +import java.io.ByteArrayInputStream; +import java.io.IOException; public class IdentifiedItem { - private final NBTItem item; - - public IdentifiedItem(NBTItem item) { - this.item = item; - } - - /* - * the identified item is stored in an item NBTTag, identifying the item - * basically replaces the item for the one saved in the NBT - */ - public ItemStack identify() { - return deserialize(item.getString("MMOITEMS_UNIDENTIFIED_ITEM")); - } - - private ItemStack deserialize(String data) { - try { - ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); - BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); - ItemStack stack = (ItemStack) dataInput.readObject(); - dataInput.close(); - - /* - * For some reason, unidentified items keep having slightly different NBT tags - * than items generated from mob drops or the GUI, I suppose it has to do with - * the serialization-deserialization, It seems to get fixed when rebuilding - * the item stack though. - * - * Its annoying because it prevents stacking. - */ - NBTItem toRebuild = NBTItem.get(stack); - if (toRebuild.hasType()) { - - // Rebuild - LiveMMOItem rebuilt = new LiveMMOItem(stack); - return rebuilt.newBuilder().build(); } - - return stack; - } catch (ClassNotFoundException | IOException e) { - e.printStackTrace(); - return null; - } - } + private final NBTItem item; + + public IdentifiedItem(NBTItem item) { + this.item = item; + } + + /** + * The identified item is stored in an item NBTTag, identifying the + * item basically replaces the item for the one saved in the NBT + */ + @NotNull + public ItemStack identify() { + return deserialize(item.getString("MMOITEMS_UNIDENTIFIED_ITEM")); + } + + @NotNull + private ItemStack deserialize(String stringInput) { + try { + ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(stringInput)); + BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); + ItemStack stack = (ItemStack) dataInput.readObject(); + dataInput.close(); + + /* + * For some reason, unidentified items keep having slightly different NBT tags + * than items generated from mob drops or the GUI, I suppose it has to do with + * the serialization-deserialization, It seems to get fixed when rebuilding + * the item stack though. + * + * Its annoying because it prevents stacking. + */ + NBTItem toRebuild = NBTItem.get(stack); + if (toRebuild.hasType()) { + + // Rebuild + LiveMMOItem rebuilt = new LiveMMOItem(stack); + return rebuilt.newBuilder().build(); + } + + return stack; + } catch (ClassNotFoundException | IOException exception) { + throw new RuntimeException(exception); + } + } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/UnidentifiedItem.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/UnidentifiedItem.java index 9160a251..a2875807 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/UnidentifiedItem.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/item/util/identify/UnidentifiedItem.java @@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.util.io.BukkitObjectOutputStream; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; @@ -23,11 +24,17 @@ public class UnidentifiedItem extends ConfigItem { public UnidentifiedItem(Type type) { + // Default options super("unidentified", type.getItem().getType()); - setName("#prefix#Unidentified " + type.getName()); - setLore(Arrays.asList("&7This item is unidentified. I must", "&7find a way to identify it!", "{tier}", "{tier}&8Item Info:", - "{range}&8- &7Lvl Range: &e#range#", "{tier}&8- &7Item Tier: #prefix##tier#")); + setLore(Arrays.asList( + "&7This item is unidentified. I must", + "&7find a way to identify it!", + "{tier}", + "{tier}&8Item Info:", + "{range}&8- &7Lvl Range: &e#range#", + "{tier}&8- &7Item Tier: #prefix##tier#" + )); } public ItemBuilder newBuilder(NBTItem item) { @@ -86,27 +93,27 @@ public ItemStack build() { // Apply changes to item item.getItem().setAmount(1); - ItemStack unidentified = MythicLib.plugin.getVersion().getWrapper().copyTexture(item) - .addTag(new ItemTag("MMOITEMS_UNIDENTIFIED_ITEM", serialize(item.toItem()))).toItem(); + + // Save serialized item inside of NBT + final ItemStack unidentified = NBTItem.get(new ItemStack(material != null ? material : item.getItem().getType())) + .addTag(new ItemTag("MMOITEMS_UNIDENTIFIED_ITEM", serialize(item.getItem()))) + .toItem(); + + final ItemMeta meta = unidentified.getItemMeta(); + if (customModelData != null) meta.setCustomModelData(customModelData); + else if (item.getItem().hasItemMeta() && item.getItem().getItemMeta().hasCustomModelData()) + meta.setCustomModelData(item.getItem().getItemMeta().getCustomModelData()); unidentified.setAmount(amount); - ItemMeta meta = unidentified.getItemMeta(); meta.addItemFlags(ItemFlag.values()); meta.setUnbreakable(true); AdventureUtils.setDisplayName(meta, name); AdventureUtils.setLore(meta, lore); - if (customModelData != null) { - meta.setCustomModelData(customModelData); - } unidentified.setItemMeta(meta); - // Has model? - if (material != null && material.isItem()) { - unidentified.setType(material); - } - return unidentified; } + @NotNull private String serialize(ItemStack item) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); @@ -114,9 +121,8 @@ private String serialize(ItemStack item) { dataOutput.writeObject(item); dataOutput.close(); return Base64Coder.encodeLines(outputStream.toByteArray()); - } catch (Exception e) { - e.printStackTrace(); - return null; + } catch (Exception exception) { + throw new RuntimeException(exception); } } } diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java index 26fc807a..1dbead19 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Abilities.java @@ -1,11 +1,11 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.*; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.*; import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility; import net.Indyuce.mmoitems.MMOItems; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java index 28ac2aab..fd6ab5a1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowParticles.java @@ -1,12 +1,12 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import io.lumine.mythic.lib.version.VParticle; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java index f22bc1d9..6c78dcdb 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ArrowPotionEffects.java @@ -1,12 +1,12 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonArray; +import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java index d3520d6d..2d252b34 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CanDeskin.java @@ -1,10 +1,10 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonObject; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.util.SmartGive; +import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.Type; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java index 94f3be11..e49d52fd 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Commands.java @@ -1,9 +1,9 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.*; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.*; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java index 7650bb6e..b5cdc771 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleIds.java @@ -1,11 +1,11 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonArray; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonArray; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java index d24b7158..319b7ca6 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleMaterials.java @@ -1,11 +1,11 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonArray; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonArray; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java index a96a2d2d..6fa219bb 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/CompatibleTypes.java @@ -1,11 +1,11 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonArray; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonArray; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java index afdac64a..17450686 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Effects.java @@ -1,12 +1,12 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.*; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider; +import io.lumine.mythic.lib.gson.*; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java index 6f547595..0c8469a3 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GemSockets.java @@ -1,12 +1,12 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonArray; +import io.lumine.mythic.lib.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java index 4126784e..c2ab6332 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/GrantedPermissions.java @@ -1,34 +1,25 @@ package net.Indyuce.mmoitems.stat; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; - -import com.google.gson.JsonArray; -import com.google.gson.JsonParser; - +import io.lumine.mythic.lib.MythicLib; +import io.lumine.mythic.lib.api.util.AltChar; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; -import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; -import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.data.StringListData; -import net.Indyuce.mmoitems.stat.data.random.RandomStatData; -import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.StringListStat; -import io.lumine.mythic.lib.MythicLib; -import io.lumine.mythic.lib.api.item.ItemTag; -import io.lumine.mythic.lib.api.util.AltChar; +import org.apache.commons.lang.Validate; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + public class GrantedPermissions extends StringListStat implements GemStoneStat { public GrantedPermissions() { super("GRANTED_PERMISSIONS", Material.NAME_TAG, "授予的权限", diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java index 6534d240..249ff25a 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ItemParticles.java @@ -1,11 +1,11 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import io.lumine.mythic.lib.version.VParticle; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java index 5fcdde59..7c5cf2bd 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/NBTTags.java @@ -1,28 +1,26 @@ package net.Indyuce.mmoitems.stat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; - -import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; - -import com.google.gson.JsonArray; - +import io.lumine.mythic.lib.api.item.ItemTag; +import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonArray; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.stat.data.StringListData; import net.Indyuce.mmoitems.stat.type.StringListStat; -import io.lumine.mythic.lib.api.item.ItemTag; -import io.lumine.mythic.lib.api.util.AltChar; +import org.apache.commons.lang.Validate; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + public class NBTTags extends StringListStat { public NBTTags() { super("CUSTOM_NBT", Material.NAME_TAG, "NBT 标签", new String[] { "自定义 NBT 标签" }, new String[0]); diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java index 74aae919..c2cc160c 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/PermanentEffects.java @@ -1,28 +1,15 @@ package net.Indyuce.mmoitems.stat; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.UtilityMethods; +import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; -import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.potion.PotionEffectType; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - +import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonElement; +import io.lumine.mythic.lib.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; @@ -34,11 +21,22 @@ import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData; import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ItemStat; -import io.lumine.mythic.lib.api.item.ItemTag; -import io.lumine.mythic.lib.api.util.AltChar; +import net.Indyuce.mmoitems.util.MMOUtils; +import org.apache.commons.lang.Validate; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Set; + /** * This class has not been updated for the item generation update!!! The potion * amplifier and duration are not numeric formulas but flat values.... TODO diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java index bb4015fd..28b39fd1 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/ProjectileParticles.java @@ -1,12 +1,12 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java index 3aa0f327..486c3e07 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/Soulbound.java @@ -1,10 +1,10 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java index 073c707f..0ba643b9 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/UpgradeStat.java @@ -1,14 +1,13 @@ package net.Indyuce.mmoitems.stat; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.JsonParser; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.event.item.UpgradeItemEvent; import net.Indyuce.mmoitems.api.interaction.Consumable; @@ -25,6 +24,7 @@ import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.ItemStat; +import net.Indyuce.mmoitems.util.MMOUtils; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java index 77b9b994..b6aced99 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java @@ -1,19 +1,19 @@ package net.Indyuce.mmoitems.stat.data; -import com.google.gson.JsonObject; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.UtilityMethods; +import io.lumine.mythic.lib.gson.JsonObject; import io.lumine.mythic.lib.player.cooldown.CooldownInfo; import io.lumine.mythic.lib.skill.Skill; import io.lumine.mythic.lib.skill.SkillMetadata; import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.skill.trigger.TriggerType; import net.Indyuce.mmoitems.MMOItems; -import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.skill.RegisteredSkill; +import net.Indyuce.mmoitems.util.MMOUtils; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java index b07cb767..000a5a71 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ArrowParticlesData.java @@ -1,6 +1,6 @@ package net.Indyuce.mmoitems.stat.data; -import com.google.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java index 0870486a..b4fdfcd0 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemSocketsData.java @@ -1,8 +1,8 @@ package net.Indyuce.mmoitems.stat.data; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import io.lumine.mythic.lib.api.util.ui.SilentNumbers; +import io.lumine.mythic.lib.gson.JsonArray; +import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemstoneData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemstoneData.java index 6ae12a1c..eef1af2f 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemstoneData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/GemstoneData.java @@ -1,12 +1,12 @@ package net.Indyuce.mmoitems.stat.data; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonElement; +import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmoitems.ItemStats; -import net.Indyuce.mmoitems.util.MMOUtils; import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem; import net.Indyuce.mmoitems.stat.GemUpgradeScaling; import net.Indyuce.mmoitems.stat.type.ItemStat; +import net.Indyuce.mmoitems.util.MMOUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ParticleData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ParticleData.java index 84a8a634..e396494e 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ParticleData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/ParticleData.java @@ -1,19 +1,7 @@ package net.Indyuce.mmoitems.stat.data; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - +import io.lumine.mythic.lib.gson.JsonObject; import io.lumine.mythic.lib.version.VParticle; -import net.Indyuce.mmoitems.util.MMOUtils; -import org.apache.commons.lang.Validate; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.Particle; -import org.bukkit.configuration.ConfigurationSection; - -import com.google.gson.JsonObject; - import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.api.player.PlayerData; @@ -21,6 +9,16 @@ import net.Indyuce.mmoitems.particle.api.ParticleType; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.StatData; +import net.Indyuce.mmoitems.util.MMOUtils; +import org.apache.commons.lang.Validate; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.configuration.ConfigurationSection; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; public class ParticleData implements StatData, RandomStatData { private final ParticleType type; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java index 9492e2ae..10603eaa 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/SoulboundData.java @@ -1,6 +1,6 @@ package net.Indyuce.mmoitems.stat.data; -import com.google.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmoitems.stat.data.type.StatData; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java index 5d04ca67..18ce48fa 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/StringListData.java @@ -1,7 +1,7 @@ package net.Indyuce.mmoitems.stat.data; -import com.google.gson.JsonArray; import io.lumine.mythic.lib.api.util.ui.SilentNumbers; +import io.lumine.mythic.lib.gson.JsonArray; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.stat.data.random.RandomStatData; import net.Indyuce.mmoitems.stat.data.type.Mergeable; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java index 71d7a15f..08f416f5 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/data/UpgradeData.java @@ -1,6 +1,6 @@ package net.Indyuce.mmoitems.stat.data; -import com.google.gson.JsonObject; +import io.lumine.mythic.lib.gson.JsonObject; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.UpgradeTemplate; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringListStat.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringListStat.java index 5ef0ed8b..c9ececee 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringListStat.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/stat/type/StringListStat.java @@ -1,12 +1,12 @@ package net.Indyuce.mmoitems.stat.type; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonSyntaxException; import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.util.AltChar; +import io.lumine.mythic.lib.gson.Gson; +import io.lumine.mythic.lib.gson.JsonArray; +import io.lumine.mythic.lib.gson.JsonSyntaxException; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java index 5c21f6df..7a2b6c59 100644 --- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java +++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/util/MMOUtils.java @@ -11,6 +11,7 @@ import io.lumine.mythic.lib.version.VPotionEffectType; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.api.Type; +import org.apache.commons.lang.Validate; import org.bukkit.*; import org.bukkit.attribute.Attribute; import org.bukkit.enchantments.Enchantment; @@ -21,6 +22,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; @@ -38,6 +40,22 @@ public static boolean isColorable(@NotNull Particle particle) { return particle.getDataType() == Particle.DustOptions.class; } + + @NotNull + public static ItemStack readIcon(@NotNull String stringInput) { + Validate.notNull(stringInput, "Input must not be null"); + final String[] split = stringInput.split(":"); + + final ItemStack stack = new ItemStack(Material.valueOf(UtilityMethods.enumName(split[0]))); + if (split.length > 1) { + final ItemMeta meta = stack.getItemMeta(); + meta.setCustomModelData(Integer.parseInt(split[1])); + stack.setItemMeta(meta); + } + + return stack; + } + @BackwardsCompatibility(version = "1.21") public static double getForce(@NotNull EntityShootBowEvent event) { final double force = event.getForce(); @@ -456,10 +474,4 @@ public static List getNearbyChunkEntities(Location loc) { return entities; } - - public static ItemStack readIcon(String string) throws IllegalArgumentException { - String[] split = string.split(":"); - Material material = Material.valueOf(split[0].toUpperCase().replace("-", "_").replace(" ", "_")); - return split.length > 1 ? MythicLib.plugin.getVersion().getWrapper().textureItem(material, Integer.parseInt(split[1])) : new ItemStack(material); - } }