diff --git a/plugin.yml b/plugin.yml index ae9a03b3..ae602090 100644 --- a/plugin.yml +++ b/plugin.yml @@ -5,6 +5,7 @@ website: ${project.url} description: ${project.description} authors: [Cayorion] load: startup +api-version: 1.13 permissions: # -------------------------------------------- # # THE REAL NODES diff --git a/src/com/massivecraft/massivecore/MassiveCore.java b/src/com/massivecraft/massivecore/MassiveCore.java index 282f8f3b..773f0876 100644 --- a/src/com/massivecraft/massivecore/MassiveCore.java +++ b/src/com/massivecraft/massivecore/MassiveCore.java @@ -6,13 +6,9 @@ import com.google.gson.JsonArray; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import com.google.gson.reflect.TypeToken; import com.massivecraft.massivecore.adapter.AdapterBackstringSet; -import com.massivecraft.massivecore.adapter.AdapterBannerPatterns; import com.massivecraft.massivecore.adapter.AdapterEntityInternalMap; import com.massivecraft.massivecore.adapter.AdapterEntry; -import com.massivecraft.massivecore.adapter.AdapterInventory; -import com.massivecraft.massivecore.adapter.AdapterItemStack; import com.massivecraft.massivecore.adapter.AdapterJsonElement; import com.massivecraft.massivecore.adapter.AdapterMassiveList; import com.massivecraft.massivecore.adapter.AdapterMassiveMap; @@ -22,7 +18,6 @@ import com.massivecraft.massivecore.adapter.AdapterMassiveTreeSet; import com.massivecraft.massivecore.adapter.AdapterModdedEnumType; import com.massivecraft.massivecore.adapter.AdapterMson; import com.massivecraft.massivecore.adapter.AdapterMsonEvent; -import com.massivecraft.massivecore.adapter.AdapterPlayerInventory; import com.massivecraft.massivecore.adapter.AdapterSound; import com.massivecraft.massivecore.adapter.AdapterUUID; import com.massivecraft.massivecore.collections.BackstringSet; @@ -37,21 +32,16 @@ import com.massivecraft.massivecore.collections.MassiveTreeMapDef; import com.massivecraft.massivecore.collections.MassiveTreeSet; import com.massivecraft.massivecore.collections.MassiveTreeSetDef; import com.massivecraft.massivecore.command.type.RegistryType; -import com.massivecraft.massivecore.item.DataBannerPattern; -import com.massivecraft.massivecore.item.DataItemStack; -import com.massivecraft.massivecore.item.WriterItemStack; import com.massivecraft.massivecore.mixin.MixinEvent; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.mson.MsonEvent; import com.massivecraft.massivecore.nms.NmsBasics; -import com.massivecraft.massivecore.nms.NmsItemStackCreate17R4P; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PSAdapter; import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.EntityInternalMap; import com.massivecraft.massivecore.store.ModificationPollerLocal; import com.massivecraft.massivecore.store.ModificationPollerRemote; -import com.massivecraft.massivecore.store.migrator.MigratorUtil; import com.massivecraft.massivecore.util.BoardUtil; import com.massivecraft.massivecore.util.ContainerUtil; import com.massivecraft.massivecore.util.EventUtil; @@ -70,12 +60,8 @@ import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; import org.bukkit.Bukkit; import org.bukkit.Sound; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; import java.lang.reflect.Modifier; -import java.lang.reflect.Type; import java.util.List; import java.util.Map.Entry; import java.util.Random; @@ -156,20 +142,6 @@ public class MassiveCore extends MassivePlugin ret.registerTypeAdapter(Mson.class, AdapterMson.get()); ret.registerTypeAdapter(MsonEvent.class, AdapterMsonEvent.get()); - // Banner Patterns Upgrade Adapter - // NOTE: Must come after the "MassiveContainers" section for priority. - Type typeBannerPatterns = new TypeToken>(){}.getType(); - ret.registerTypeAdapter(typeBannerPatterns, AdapterBannerPatterns.get()); - - // ItemStack - ret.registerTypeAdapter(ItemStack.class, AdapterItemStack.get()); - Class classCraftItemStack = NmsItemStackCreate17R4P.getClassCraftItemStackCatch(); - if (classCraftItemStack != null) ret.registerTypeAdapter(classCraftItemStack, AdapterItemStack.get()); - - // Inventory - ret.registerTypeAdapter(Inventory.class, AdapterInventory.get()); - ret.registerTypeAdapter(PlayerInventory.class, AdapterPlayerInventory.get()); - // Storage ret.registerTypeAdapter(EntityInternalMap.class, AdapterEntityInternalMap.get()); @@ -233,18 +205,11 @@ public class MassiveCore extends MassivePlugin // Setup RegistryType RegistryType.registerAll(); - MigratorUtil.addJsonRepresentation(ItemStack.class, DataItemStack.class); - MigratorUtil.addJsonRepresentation(Inventory.class, null); - MigratorUtil.setTargetVersion(Inventory.class, MigratorUtil.getTargetVersion(DataItemStack.class)); - // Activate this.activateAuto(); // These must be activated after nms this.activate( - - // Writer, - WriterItemStack.class, // Util PlayerUtil.class, diff --git a/src/com/massivecraft/massivecore/PotionEffectWrap.java b/src/com/massivecraft/massivecore/PotionEffectWrap.java deleted file mode 100644 index 607c9476..00000000 --- a/src/com/massivecraft/massivecore/PotionEffectWrap.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.massivecraft.massivecore; - -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.command.editor.annotation.EditorType; -import com.massivecraft.massivecore.command.type.convert.TypeConverterPotionEffectType; -import org.bukkit.entity.LivingEntity; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import java.util.Collection; -import java.util.List; - -/** - * This class wraps the Bukkit PotionEffect class by reimplementing storage of the data. - * The purpose of this class is to allow for serialization using GSON. - * You can not serialize the Bukkit PotionEffect due to some strange GSON bug. - * Also we get the opportunity to add in some nice utility methods. - */ -public class PotionEffectWrap -{ - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - @EditorType(TypeConverterPotionEffectType.class) - protected int id; - public int getId() { return this.id; } - public void setId(int id) { this.id = id; } - - @SuppressWarnings("deprecation") - public void setPotionEffectType(PotionEffectType potionEffectType) { this.setId(potionEffectType.getId());} - @SuppressWarnings("deprecation") - public PotionEffectType getPotionEffectType() { return PotionEffectType.getById(this.getId()); } - - protected int amplifier; - public int getAmplifier() { return this.amplifier; } - public void setAmplifier(int amplifier) { this.amplifier = amplifier; } - - protected int duration; - public int getDuration() { return this.duration; } - public void setDuration(int duration) { this.duration = duration; } - - protected boolean ambient; - public boolean isAmbient() { return this.ambient; } - public void setAmbient(boolean ambient) { this.ambient = ambient; } - - // Since Minecraft 1.8 - protected boolean particles; - public boolean isParticles() { return this.particles; } - public void setParticles(boolean particles) { this.particles = particles; } - // TODO: How to backwards compat? - // TODO: For now we just don't support this 1.8 option... - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public PotionEffectWrap(int id, int amplifier, int duration, boolean ambient, boolean particles) - { - this.id = id; - this.amplifier = amplifier; - this.duration = duration; - this.ambient = ambient; - this.particles = particles; - } - - public PotionEffectWrap() - { - this.id = 0; - this.amplifier = 0; - this.duration = 0; - this.ambient = false; - this.particles = true; - } - - // -------------------------------------------- // - // FROM BUKKIT - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - public static PotionEffectWrap valueOf(PotionEffect potionEffect) - { - return new PotionEffectWrap(potionEffect.getType().getId(), potionEffect.getAmplifier(), potionEffect.getDuration(), potionEffect.isAmbient(), true); - } - - // -------------------------------------------- // - // TO BUKKIT - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - public PotionEffect asPotionEffect() - { - return new PotionEffect(PotionEffectType.getById(id), this.duration, this.amplifier, this.ambient); - } - - public boolean addTo(LivingEntity entity) - { - return entity.addPotionEffect(this.asPotionEffect(), true); - } - - // -------------------------------------------- // - // UTIL - // -------------------------------------------- // - - public static List getEffects(LivingEntity entity) - { - // Create Ret - List ret = new MassiveList<>(); - - // Fill Ret - for (PotionEffect potionEffect : entity.getActivePotionEffects()) - { - ret.add(PotionEffectWrap.valueOf(potionEffect)); - } - - // Return Ret - return ret; - } - - public static void removeEffects(LivingEntity entity) - { - // For each active potion effect ... - for (PotionEffect potionEffect : entity.getActivePotionEffects()) - { - // ... remove that type. - entity.removePotionEffect(potionEffect.getType()); - } - } - - public static void addEffects(LivingEntity entity, Iterable potionEffectWraps) - { - // For each supplied potion effect wrap ... - for (PotionEffectWrap potionEffectWrap : potionEffectWraps) - { - // ... add it to the entity. - potionEffectWrap.addTo(entity); - } - } - - public static void setEffects(LivingEntity entity, Collection potionEffectWraps) - { - // Remove ... - removeEffects(entity); - - // ... then add. - addEffects(entity, potionEffectWraps); - } - - // -------------------------------------------- // - // TO STRING - // -------------------------------------------- // - - public String getListLine() - { - // Create Ret - StringBuilder ret = new StringBuilder(); - - // Type Name (ID) - ret.append(this.getPotionEffectType().getName()); - ret.append(' '); - - // Amplifier - ret.append(this.amplifier); - ret.append(' '); - - // Duration - ret.append(this.duration); - ret.append(' '); - - // Ambient - ret.append(this.ambient); - ret.append(' '); - - // Particles - ret.append(this.particles); - - // Return Ret - return ret.toString(); - } - -} diff --git a/src/com/massivecraft/massivecore/adapter/AdapterBannerPatterns.java b/src/com/massivecraft/massivecore/adapter/AdapterBannerPatterns.java deleted file mode 100644 index e0a9b4c0..00000000 --- a/src/com/massivecraft/massivecore/adapter/AdapterBannerPatterns.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.massivecraft.massivecore.adapter; - -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonNull; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.massivecraft.massivecore.collections.MassiveListDef; -import com.massivecraft.massivecore.item.DataBannerPattern; - -import java.lang.reflect.Type; -import java.util.Iterator; - -public class AdapterBannerPatterns implements JsonDeserializer> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final AdapterBannerPatterns i = new AdapterBannerPatterns(); - public static AdapterBannerPatterns get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - // Default serialization is fine. - // We do however provide a smarter deserialiser. - // This is for the sole purpose of upgrading from the old deprecated database format. - // - // In the old version (around version 2.8.10) we made use of a list with primitives. - // id, color, id, color... - // They were just coming in that order and were not wrapped in some kind of entry. - // - // The data types are the same in the old and new version. - // String, Number, String, Number... - // - // In the new version we do however wrap them in the DataBannerPattern. - - @Override - public MassiveListDef deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - // Create - MassiveListDef ret = new MassiveListDef<>(); - - // Null (Def implementation is never null) - if (json == null) return ret; - if (json.equals(JsonNull.INSTANCE)) return ret; - - // It is an array in both old and new version - JsonArray array = json.getAsJsonArray(); - - // Empty? - if (array.size() == 0) return ret; - - // First element indicates version - JsonElement first = array.get(0); - if (first instanceof JsonObject) - { - // New - for (JsonElement element : array) - { - DataBannerPattern dataBannerPattern = context.deserialize(element, DataBannerPattern.class); - ret.add(dataBannerPattern); - } - } - else - { - // Old aka Upgrade Mode - Iterator iterator = array.iterator(); - while (iterator.hasNext()) - { - DataBannerPattern dataBannerPattern = new DataBannerPattern(); - - JsonElement idElement = iterator.next(); - String id = idElement.getAsString(); - dataBannerPattern.setId(id); - - JsonElement colorElement = iterator.next(); - Integer color = colorElement.getAsInt(); - dataBannerPattern.setColor(color); - - ret.add(dataBannerPattern); - } - } - - return ret; - } - -} diff --git a/src/com/massivecraft/massivecore/adapter/AdapterInventory.java b/src/com/massivecraft/massivecore/adapter/AdapterInventory.java deleted file mode 100644 index df8ef673..00000000 --- a/src/com/massivecraft/massivecore/adapter/AdapterInventory.java +++ /dev/null @@ -1,276 +0,0 @@ -package com.massivecraft.massivecore.adapter; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.massivecraft.massivecore.MassiveCore; -import com.massivecraft.massivecore.item.DataItemStack; -import com.massivecraft.massivecore.mixin.MixinInventory; -import com.massivecraft.massivecore.store.migrator.MigratorUtil; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; - -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.Map.Entry; - -/** - * This is my Gson adapter for Inventories. - * It handles all inventories as CraftInventoryCustom "Chest"s with size of your choice - * except for PlayerInventory which it handles pretty darn well! - */ -public class AdapterInventory implements JsonDeserializer, JsonSerializer -{ - // -------------------------------------------- // - // CONSTANTS - // -------------------------------------------- // - - public static final int SIZE_PLAYER_STORAGE = 36; - public static final int INDEX_PLAYER_STORAGE_FROM = 0; - public static final int INDEX_PLAYER_STORAGE_TO = SIZE_PLAYER_STORAGE - 1; - - public static final int INDEX_PLAYER_SHIELD = 40; - - // -------------------------------------------- // - // FIELD NAME CONSTANTS - // -------------------------------------------- // - - public static final String SIZE = "size"; - - public static final String PLAYER = "player"; - - public static final String HELMET = "helmet"; - public static final String CHESTPLATE = "chestplate"; - public static final String LEGGINGS = "leggings"; - public static final String BOOTS = "boots"; - public static final String SHIELD = "shield"; - - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final AdapterInventory i = new AdapterInventory(); - public static AdapterInventory get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public JsonElement serialize(Inventory src, Type typeOfSrc, JsonSerializationContext context) - { - return toJson(src); - } - - @Override - public Inventory deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - return fromJson(json); - } - - // -------------------------------------------- // - // IMPLEMENTATION - // -------------------------------------------- // - - public static JsonElement toJson(Inventory src) - { - // The return value is this object: - JsonObject jsonInventory = new JsonObject(); - - // These variables are used in loops and repetitive logic. - ItemStack itemStack = null; - JsonElement jsonItemStack = null; - String index = null; - - // Every inventory has a content part. - ItemStack[] itemStacks = src.getContents(); - - if (src instanceof PlayerInventory) - { - // Add the size "player" - jsonInventory.addProperty(SIZE, PLAYER); - - // Cast to PlayerInventory - PlayerInventory psrc = (PlayerInventory)src; - - // Helmet - itemStack = psrc.getHelmet(); - if (itemStack != null) - { - jsonItemStack = MassiveCore.gson.toJsonTree(itemStack, ItemStack.class); - jsonInventory.add(HELMET, jsonItemStack); - } - - // Chestplate - itemStack = psrc.getChestplate(); - if (itemStack != null) - { - jsonItemStack = MassiveCore.gson.toJsonTree(itemStack, ItemStack.class); - jsonInventory.add(CHESTPLATE, jsonItemStack); - } - - // Leggings - itemStack = psrc.getLeggings(); - if (itemStack != null) - { - jsonItemStack = MassiveCore.gson.toJsonTree(itemStack, ItemStack.class); - jsonInventory.add(LEGGINGS, jsonItemStack); - } - - // Boots - itemStack = psrc.getBoots(); - if (itemStack != null) - { - jsonItemStack = MassiveCore.gson.toJsonTree(itemStack, ItemStack.class); - jsonInventory.add(BOOTS, jsonItemStack); - } - - // Shield (Minecraft 1.9) - itemStack = null; - if (INDEX_PLAYER_SHIELD < itemStacks.length) itemStack = itemStacks[INDEX_PLAYER_SHIELD]; - if (itemStack != null) - { - jsonItemStack = MassiveCore.gson.toJsonTree(itemStack, ItemStack.class); - jsonInventory.add(SHIELD, jsonItemStack); - } - - // Storage Range (Minecraft 1.9) - itemStacks = range(itemStacks, INDEX_PLAYER_STORAGE_FROM, INDEX_PLAYER_STORAGE_TO); - } - else - { - // Add the size *length* - jsonInventory.addProperty(SIZE, itemStacks.length); - } - - // Add the content at the end since we like to have it at the bottom of return json. - for (Entry entry : DataItemStack.fromBukkitContents(itemStacks).entrySet()) - { - index = String.valueOf(entry.getKey()); - jsonItemStack = MassiveCore.gson.toJsonTree(entry.getValue()); - jsonInventory.add(index, jsonItemStack); - } - - // Add version - int version = MigratorUtil.getTargetVersion(DataItemStack.class); - jsonInventory.addProperty(MigratorUtil.VERSION_FIELD_NAME, version); - - return jsonInventory; - } - - public static Inventory fromJson(JsonElement json) - { - // If must be an object! - if ( ! json.isJsonObject()) return null; - JsonObject jsonInventory = json.getAsJsonObject(); - - // The return value - Inventory ret = null; - - // These variables are used in loops and repetitive logic. - ItemStack itemStack = null; - JsonElement jsonItemStack = null; - - // There must be a size entry! - if ( ! jsonInventory.has(SIZE)) return null; - - JsonPrimitive jsonSize = jsonInventory.get(SIZE).getAsJsonPrimitive(); - int size = 0; - - // What size/type is it? - if (jsonSize.isString() && jsonSize.getAsString().equals(PLAYER)) - { - // We use 36 here since it's the size of the player inventory (without armor) - size = SIZE_PLAYER_STORAGE; - - // This is a PlayerInventory - ret = MixinInventory.get().createPlayerInventory(); - PlayerInventory pret = (PlayerInventory)ret; - - // Helmet - if (jsonInventory.has(HELMET)) - { - itemStack = getItemStack(jsonInventory, HELMET); - pret.setHelmet(itemStack); - } - - // Chestplate - if (jsonInventory.has(CHESTPLATE)) - { - itemStack = getItemStack(jsonInventory, CHESTPLATE); - pret.setChestplate(itemStack); - } - - // Leggings - if (jsonInventory.has(LEGGINGS)) - { - jsonItemStack = jsonInventory.get(LEGGINGS); - itemStack = MassiveCore.gson.fromJson(jsonItemStack, ItemStack.class); - pret.setLeggings(itemStack); - } - - // Boots - if (jsonInventory.has(BOOTS)) - { - itemStack = getItemStack(jsonInventory, BOOTS); - pret.setBoots(itemStack); - } - - // Shield (Minecraft 1.9) - if (jsonInventory.has(SHIELD) && INDEX_PLAYER_SHIELD < pret.getSize()) - { - itemStack = getItemStack(jsonInventory, SHIELD); - pret.setItem(INDEX_PLAYER_SHIELD, itemStack); - } - } - else - { - // A custom size were specified - size = jsonSize.getAsInt(); - - // This is a "Custom" Inventory (content only). - ret = MixinInventory.get().createInventory(null, size, ""); - } - - // Now process content - for (int i = 0; i < size; i++) - { - String stackIdx = String.valueOf(i); - itemStack = getItemStack(jsonInventory, stackIdx); - if (itemStack == null) continue; - ret.setItem(i, itemStack); - } - - return ret; - } - - private static ItemStack getItemStack(JsonObject jsonInventory, String idx) - { - // Get jsonItemStack - JsonElement jsonItemStack = jsonInventory.get(idx); - if (jsonItemStack == null) return null; - - ItemStack ret = MassiveCore.gson.fromJson(jsonItemStack, ItemStack.class); - return ret; - } - - // -------------------------------------------- // - // UTIL - // -------------------------------------------- // - - // This is a modified copyOfRange implementation. - // Both boundaries are inclusive. - // It returns the original when possible. - public static T[] range(T[] original, int from, int to) - { - if (from == 0 && to == original.length - 1) return original; - return Arrays.copyOfRange(original, from, to + 1); - } - -} diff --git a/src/com/massivecraft/massivecore/adapter/AdapterItemStack.java b/src/com/massivecraft/massivecore/adapter/AdapterItemStack.java deleted file mode 100644 index 442e5f63..00000000 --- a/src/com/massivecraft/massivecore/adapter/AdapterItemStack.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.massivecraft.massivecore.adapter; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.massivecraft.massivecore.item.DataItemStack; -import org.bukkit.inventory.ItemStack; - -import java.lang.reflect.Type; - -/** - * This is a GSON serializer/deserializer for the Bukkit ItemStack. Why not use - * the built in Bukkit serializer/deserializer? I would have loved to do that :) - * but sadly that one is YAML centric and cannot be used with json in a good - * way. This serializer requires manual updating to work but produces clean - * json. See the file itemstackformat.txt for more info. - */ -public class AdapterItemStack implements JsonDeserializer, JsonSerializer -{ - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static final AdapterItemStack i = new AdapterItemStack(); - public static AdapterItemStack get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) - { - DataItemStack dataItemStack = new DataItemStack(src); - return context.serialize(dataItemStack); - } - - @Override - public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - DataItemStack dataItemStack = context.deserialize(json, DataItemStack.class); - return dataItemStack.toBukkit(); - } - -} diff --git a/src/com/massivecraft/massivecore/adapter/AdapterPlayerInventory.java b/src/com/massivecraft/massivecore/adapter/AdapterPlayerInventory.java deleted file mode 100644 index 1fa70859..00000000 --- a/src/com/massivecraft/massivecore/adapter/AdapterPlayerInventory.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.massivecraft.massivecore.adapter; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import org.bukkit.inventory.PlayerInventory; - -import java.lang.reflect.Type; - -public class AdapterPlayerInventory implements JsonDeserializer, JsonSerializer -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final AdapterPlayerInventory i = new AdapterPlayerInventory(); - public static AdapterPlayerInventory get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public JsonElement serialize(PlayerInventory src, Type typeOfSrc, JsonSerializationContext context) - { - return AdapterInventory.toJson(src); - } - - @Override - public PlayerInventory deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - return (PlayerInventory) AdapterInventory.fromJson(json); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/RegistryType.java b/src/com/massivecraft/massivecore/command/type/RegistryType.java index 894e1532..1525e6b7 100644 --- a/src/com/massivecraft/massivecore/command/type/RegistryType.java +++ b/src/com/massivecraft/massivecore/command/type/RegistryType.java @@ -7,10 +7,7 @@ import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.collections.WorldExceptionSet; import com.massivecraft.massivecore.command.editor.annotation.EditorType; import com.massivecraft.massivecore.command.editor.annotation.EditorTypeInner; -import com.massivecraft.massivecore.command.type.combined.TypeDataBannerPattern; -import com.massivecraft.massivecore.command.type.combined.TypeDataPotionEffect; import com.massivecraft.massivecore.command.type.combined.TypeEntry; -import com.massivecraft.massivecore.command.type.combined.TypePotionEffectWrap; import com.massivecraft.massivecore.command.type.combined.TypeSoundEffect; import com.massivecraft.massivecore.command.type.container.TypeBackstringSet; import com.massivecraft.massivecore.command.type.container.TypeExceptionSet; @@ -275,10 +272,7 @@ public class RegistryType // -------------------------------------------- // // DEFAULTS // -------------------------------------------- // - // NOTE: As of 2016-05-17 about 15% of all servers are still using 1.7.x. - // With this in mind there are some try catch clauses. - // We catch NoClassDefFoundError and silently move along on those servers. - + public static void registerAll() { // Primitive @@ -319,44 +313,10 @@ public class RegistryType register(TypeOcelotType.get()); register(TypeParticleEffect.get()); register(TypeSpawnReason.get()); - - // 1.7 Compat - try - { - register(TypeRabbitType.get()); - } - catch (Throwable t) - { - - } - - try - { - register(TypeDamageModifier.get()); - } - catch (Throwable t) - { - - } - - try - { - register(TypeLlamaColor.get()); - } - catch (Throwable t) - { - - } - - try - { - register(TypeParrotVariant.get()); - } - catch (Throwable t) - { - - } - + register(TypeRabbitType.get()); + register(TypeDamageModifier.get()); + register(TypeLlamaColor.get()); + register(TypeParrotVariant.get()); register(TypeSkeletonType.get()); register(TypeSound.get()); register(TypeVillagerProfession.get()); @@ -366,16 +326,10 @@ public class RegistryType register(TypeDestination.get()); register(TypeItemStack.get()); - register(TypeDataBannerPattern.get()); - register(TypeDataPotionEffect.get()); - register(TypeDataFireworkEffect.get()); - register(TypeDataItemStack.get()); - register(TypePermission.get()); register(TypePotionEffectType.get()); register(TypePS.get()); register(TypeWorld.get()); - register(TypePotionEffectWrap.get()); register(TypeSoundEffect.get()); // Sender diff --git a/src/com/massivecraft/massivecore/command/type/TypeDataFireworkEffect.java b/src/com/massivecraft/massivecore/command/type/TypeDataFireworkEffect.java deleted file mode 100644 index 65566b21..00000000 --- a/src/com/massivecraft/massivecore/command/type/TypeDataFireworkEffect.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.massivecraft.massivecore.command.type; - -import com.massivecraft.massivecore.command.type.primitive.TypeObject; -import com.massivecraft.massivecore.item.DataFireworkEffect; - -public class TypeDataFireworkEffect extends TypeObject -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeDataFireworkEffect i = new TypeDataFireworkEffect(); - public static TypeDataFireworkEffect get() { return i; } - public TypeDataFireworkEffect() - { - super(DataFireworkEffect.class); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/TypeDataItemStack.java b/src/com/massivecraft/massivecore/command/type/TypeDataItemStack.java deleted file mode 100644 index af822051..00000000 --- a/src/com/massivecraft/massivecore/command/type/TypeDataItemStack.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.massivecraft.massivecore.command.type; - -import com.massivecraft.massivecore.command.type.primitive.TypeObject; -import com.massivecraft.massivecore.item.DataItemStack; -import org.bukkit.command.CommandSender; -import org.bukkit.inventory.ItemStack; - -public class TypeDataItemStack extends TypeTransformer -{ - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static final TypeDataItemStack i = new TypeDataItemStack(); - public static TypeDataItemStack get() { return i; } - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public TypeDataItemStack(Type typeInner) - { - super(typeInner, TypeObject.get(DataItemStack.class)); - } - - public TypeDataItemStack() - { - this(TypeItemStack.get()); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public DataItemStack innerToOuter(ItemStack inner, CommandSender sender) - { - return DataItemStack.fromBukkit(inner); - } - - @Override - public ItemStack outerToInner(DataItemStack outer) - { - return DataItemStack.toBukkit(outer); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/TypeEnchantment.java b/src/com/massivecraft/massivecore/command/type/TypeEnchantment.java index 789cff5a..cc2a372b 100644 --- a/src/com/massivecraft/massivecore/command/type/TypeEnchantment.java +++ b/src/com/massivecraft/massivecore/command/type/TypeEnchantment.java @@ -2,14 +2,11 @@ package com.massivecraft.massivecore.command.type; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveMap; -import com.massivecraft.massivecore.collections.MassiveSet; -import com.massivecraft.massivecore.util.Txt; import org.bukkit.ChatColor; import org.bukkit.enchantments.Enchantment; import java.util.List; import java.util.Map; -import java.util.Set; public class TypeEnchantment extends TypeAbstractChoice { @@ -70,18 +67,15 @@ public class TypeEnchantment extends TypeAbstractChoice // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // - - @SuppressWarnings("deprecation") + @Override public String getNameInner(Enchantment enchantment) { - String rawname = enchantment.getName(); - List rawnames = ID_TO_RAWNAMES.get(enchantment.getId()); - if (rawnames != null) rawname = rawnames.get(0); - return Txt.getNicedEnumString(rawname); + return enchantment.getKey().getNamespace(); } - - @SuppressWarnings("deprecation") + + // TODO: this needs to be changed, so all the expected names work + /* @Override public Set getNamesInner(Enchantment enchantment) { @@ -100,13 +94,12 @@ public class TypeEnchantment extends TypeAbstractChoice // Return return ret; - } - - @SuppressWarnings("deprecation") + }*/ + @Override public String getIdInner(Enchantment enchantment) { - return String.valueOf(enchantment.getId()); + return enchantment.getKey().toString(); } } diff --git a/src/com/massivecraft/massivecore/command/type/TypeMaterialId.java b/src/com/massivecraft/massivecore/command/type/TypeMaterialId.java deleted file mode 100644 index a3d86f42..00000000 --- a/src/com/massivecraft/massivecore/command/type/TypeMaterialId.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.massivecraft.massivecore.command.type; - -import com.massivecraft.massivecore.command.type.enumeration.TypeMaterial; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; -import org.bukkit.Material; -import org.bukkit.command.CommandSender; - -@SuppressWarnings("deprecation") -public class TypeMaterialId extends TypeTransformer -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeMaterialId i = new TypeMaterialId(); - public static TypeMaterialId get() { return i; } - - public TypeMaterialId() - { - super(TypeMaterial.get(), TypeInteger.get()); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - - @Override - public Integer innerToOuter(Material inner, CommandSender sender) - { - if (inner == null) return null; - return inner.getId(); - } - - @Override - public Material outerToInner(Integer outer) - { - if (outer == null) return null; - return Material.getMaterial(outer); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/combined/TypeDataBannerPattern.java b/src/com/massivecraft/massivecore/command/type/combined/TypeDataBannerPattern.java deleted file mode 100644 index a19d1eaa..00000000 --- a/src/com/massivecraft/massivecore/command/type/combined/TypeDataBannerPattern.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.massivecraft.massivecore.command.type.combined; - -import com.massivecraft.massivecore.item.DataBannerPattern; - -public class TypeDataBannerPattern extends TypeCombined -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeDataBannerPattern i = new TypeDataBannerPattern(); - public static TypeDataBannerPattern get() { return i; } - - public TypeDataBannerPattern() - { - super(DataBannerPattern.class); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/combined/TypeDataPotionEffect.java b/src/com/massivecraft/massivecore/command/type/combined/TypeDataPotionEffect.java deleted file mode 100644 index c4f0926f..00000000 --- a/src/com/massivecraft/massivecore/command/type/combined/TypeDataPotionEffect.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.command.type.combined; - -import com.massivecraft.massivecore.item.DataPotionEffect; - -public class TypeDataPotionEffect extends TypeCombined -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeDataPotionEffect i = new TypeDataPotionEffect(); - public static TypeDataPotionEffect get() { return i; } - public TypeDataPotionEffect() - { - super(DataPotionEffect.class); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/combined/TypePotionEffectWrap.java b/src/com/massivecraft/massivecore/command/type/combined/TypePotionEffectWrap.java deleted file mode 100644 index b8033d19..00000000 --- a/src/com/massivecraft/massivecore/command/type/combined/TypePotionEffectWrap.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.massivecraft.massivecore.command.type.combined; - -import com.massivecraft.massivecore.PotionEffectWrap; - -public class TypePotionEffectWrap extends TypeCombined -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypePotionEffectWrap i = new TypePotionEffectWrap(); - public static TypePotionEffectWrap get() { return i; } - - public TypePotionEffectWrap() - { - super(PotionEffectWrap.class); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverter.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverter.java deleted file mode 100644 index 36230475..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverter.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.Type; -import com.massivecraft.massivecore.command.type.TypeTransformer; -import com.massivecraft.massivecore.item.Converter; -import org.bukkit.command.CommandSender; - -public class TypeConverter extends TypeTransformer -{ - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private final Converter a2b; - public Converter getA2b() { return this.a2b; } - - private final Converter b2a; - public Converter getB2a() { return this.b2a; } - - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - public TypeConverter(Type typeA, Type typeB, Converter a2b, Converter b2a) - { - super(typeA, typeB); - this.a2b = a2b; - this.b2a = b2a; - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - - @Override - public B innerToOuter(A inner, CommandSender sender) - { - return this.getA2b().convert(inner); - } - - @Override - public A outerToInner(B outer) - { - return this.getB2a().convert(outer); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterBannerPatternType.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverterBannerPatternType.java deleted file mode 100644 index 61f4d30f..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterBannerPatternType.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.Type; -import com.massivecraft.massivecore.command.type.enumeration.TypePatternType; -import com.massivecraft.massivecore.command.type.primitive.TypeString; -import com.massivecraft.massivecore.item.Converter; -import com.massivecraft.massivecore.item.ConverterFromBannerPatternType; -import com.massivecraft.massivecore.item.ConverterToBannerPatternType; - -// Minecraft 1.7 Compatibility -public class TypeConverterBannerPatternType extends TypeConverter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeConverterBannerPatternType i = null; - @SuppressWarnings("unchecked") - public static TypeConverterBannerPatternType get() - { - if (i == null) i = new TypeConverterBannerPatternType<>(TypePatternType.get(), ConverterFromBannerPatternType.get(), ConverterToBannerPatternType.get()); - return (TypeConverterBannerPatternType) i; - } - - public TypeConverterBannerPatternType(Type typeA, Converter a2b, Converter b2a) - { - super(typeA, TypeString.get(), a2b, b2a); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterColor.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverterColor.java deleted file mode 100644 index 096bbcb2..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterColor.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.TypeColor; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; -import com.massivecraft.massivecore.item.ConverterFromColor; -import com.massivecraft.massivecore.item.ConverterToColor; -import org.bukkit.Color; - -public class TypeConverterColor extends TypeConverter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeConverterColor i = new TypeConverterColor(); - public static TypeConverterColor get() { return i; } - - public TypeConverterColor() - { - super(TypeColor.get(), TypeInteger.get(), ConverterFromColor.get(), ConverterToColor.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterDyeColor.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverterDyeColor.java deleted file mode 100644 index 12d68d2d..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterDyeColor.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.enumeration.TypeDyeColor; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; -import com.massivecraft.massivecore.item.ConverterFromDyeColor; -import com.massivecraft.massivecore.item.ConverterToDyeColor; -import org.bukkit.DyeColor; - -public class TypeConverterDyeColor extends TypeConverter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeConverterDyeColor i = new TypeConverterDyeColor(); - public static TypeConverterDyeColor get() { return i; } - - public TypeConverterDyeColor() - { - super(TypeDyeColor.get(), TypeInteger.get(), ConverterFromDyeColor.get(), ConverterToDyeColor.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterEnchant.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverterEnchant.java deleted file mode 100644 index 490f7285..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterEnchant.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.TypeEnchantment; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; -import com.massivecraft.massivecore.item.ConverterFromEnchant; -import com.massivecraft.massivecore.item.ConverterToEnchant; -import org.bukkit.enchantments.Enchantment; - -public class TypeConverterEnchant extends TypeConverter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeConverterEnchant i = new TypeConverterEnchant(); - public static TypeConverterEnchant get() { return i; } - - public TypeConverterEnchant() - { - super(TypeEnchantment.get(), TypeInteger.get(), ConverterFromEnchant.get(), ConverterToEnchant.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterFireworkEffectType.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverterFireworkEffectType.java deleted file mode 100644 index 4dba10f3..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterFireworkEffectType.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.enumeration.TypeFireworkEffectType; -import com.massivecraft.massivecore.command.type.primitive.TypeString; -import com.massivecraft.massivecore.item.ConverterFromFireworkEffectType; -import com.massivecraft.massivecore.item.ConverterToFireworkEffectType; -import org.bukkit.FireworkEffect.Type; - -public class TypeConverterFireworkEffectType extends TypeConverter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeConverterFireworkEffectType i = new TypeConverterFireworkEffectType(); - public static TypeConverterFireworkEffectType get() { return i; } - - public TypeConverterFireworkEffectType() - { - super(TypeFireworkEffectType.get(), TypeString.get(), ConverterFromFireworkEffectType.get(), ConverterToFireworkEffectType.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterItemFlag.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverterItemFlag.java deleted file mode 100644 index 2c422719..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterItemFlag.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.enumeration.TypeItemFlag; -import com.massivecraft.massivecore.command.type.primitive.TypeString; -import com.massivecraft.massivecore.item.ConverterFromItemFlag; -import com.massivecraft.massivecore.item.ConverterToItemFlag; -import org.bukkit.inventory.ItemFlag; - -public class TypeConverterItemFlag extends TypeConverter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeConverterItemFlag i = new TypeConverterItemFlag(); - public static TypeConverterItemFlag get() { return i; } - - public TypeConverterItemFlag() - { - super(TypeItemFlag.get(), TypeString.get(), ConverterFromItemFlag.get(), ConverterToItemFlag.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterPotionEffectType.java b/src/com/massivecraft/massivecore/command/type/convert/TypeConverterPotionEffectType.java deleted file mode 100644 index 4080ecf0..00000000 --- a/src/com/massivecraft/massivecore/command/type/convert/TypeConverterPotionEffectType.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.massivecraft.massivecore.command.type.convert; - -import com.massivecraft.massivecore.command.type.TypePotionEffectType; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; -import com.massivecraft.massivecore.item.ConverterFromPotionEffectType; -import com.massivecraft.massivecore.item.ConverterToPotionEffectType; -import org.bukkit.potion.PotionEffectType; - -public class TypeConverterPotionEffectType extends TypeConverter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TypeConverterPotionEffectType i = new TypeConverterPotionEffectType(); - public static TypeConverterPotionEffectType get() { return i; } - - public TypeConverterPotionEffectType() - { - super(TypePotionEffectType.get(), TypeInteger.get(), ConverterFromPotionEffectType.get(), ConverterToPotionEffectType.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/entity/migrator/MigratorDataItemStack001StringId.java b/src/com/massivecraft/massivecore/entity/migrator/MigratorDataItemStack001StringId.java deleted file mode 100644 index 13fce7ab..00000000 --- a/src/com/massivecraft/massivecore/entity/migrator/MigratorDataItemStack001StringId.java +++ /dev/null @@ -1,522 +0,0 @@ -package com.massivecraft.massivecore.entity.migrator; - -import com.google.common.collect.ImmutableMap; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.massivecraft.massivecore.collections.MassiveMap; -import com.massivecraft.massivecore.item.DataItemStack; -import com.massivecraft.massivecore.store.migrator.MigratorRoot; - -import java.util.Map; - -public class MigratorDataItemStack001StringId extends MigratorRoot -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static MigratorDataItemStack001StringId i = new MigratorDataItemStack001StringId(); - public static MigratorDataItemStack001StringId get() { return i; } - private MigratorDataItemStack001StringId() - { - super(DataItemStack.class); - } - - // -------------------------------------------- // - // CONVERSION - // -------------------------------------------- // - - @Override - public void migrateInner(JsonObject json) - { - // Get the id - JsonElement id = json.get("id"); - if (id == null || id.isJsonNull()) return; - - // The id is either a number or string, always a JsonPrimitive - JsonPrimitive primitive = id.getAsJsonPrimitive(); - - // Only convert if number - if (!primitive.isNumber()) return; - int typeId = primitive.getAsInt(); - String name = id2name.get(typeId); - if (name == null) throw new RuntimeException(String.valueOf(typeId)); - JsonElement newValue = new JsonPrimitive(name); - json.add("id", newValue); - } - - private static final Map id2name; - - static - { - Map map = new MassiveMap<>(); - - map.put(0, "AIR"); - map.put(1, "STONE"); - map.put(2, "GRASS"); - map.put(3, "DIRT"); - map.put(4, "COBBLESTONE"); - map.put(5, "WOOD"); - map.put(6, "SAPLING"); - map.put(7, "BEDROCK"); - map.put(8, "WATER"); - map.put(9, "STATIONARY_WATER"); - map.put(10, "LAVA"); - map.put(11, "STATIONARY_LAVA"); - map.put(12, "SAND"); - map.put(13, "GRAVEL"); - map.put(14, "GOLD_ORE"); - map.put(15, "IRON_ORE"); - map.put(16, "COAL_ORE"); - map.put(17, "LOG"); - map.put(18, "LEAVES"); - map.put(19, "SPONGE"); - map.put(20, "GLASS"); - map.put(21, "LAPIS_ORE"); - map.put(22, "LAPIS_BLOCK"); - map.put(23, "DISPENSER"); - map.put(24, "SANDSTONE"); - map.put(25, "NOTE_BLOCK"); - map.put(26, "BED_BLOCK"); - map.put(27, "POWERED_RAIL"); - map.put(28, "DETECTOR_RAIL"); - map.put(29, "PISTON_STICKY_BASE"); - map.put(30, "WEB"); - map.put(31, "LONG_GRASS"); - map.put(32, "DEAD_BUSH"); - map.put(33, "PISTON_BASE"); - map.put(34, "PISTON_EXTENSION"); - map.put(35, "WOOL"); - map.put(36, "PISTON_MOVING_PIECE"); - map.put(37, "YELLOW_FLOWER"); - map.put(38, "RED_ROSE"); - map.put(39, "BROWN_MUSHROOM"); - map.put(40, "RED_MUSHROOM"); - map.put(41, "GOLD_BLOCK"); - map.put(42, "IRON_BLOCK"); - map.put(43, "DOUBLE_STEP"); - map.put(44, "STEP"); - map.put(45, "BRICK"); - map.put(46, "TNT"); - map.put(47, "BOOKSHELF"); - map.put(48, "MOSSY_COBBLESTONE"); - map.put(49, "OBSIDIAN"); - map.put(50, "TORCH"); - map.put(51, "FIRE"); - map.put(52, "MOB_SPAWNER"); - map.put(53, "WOOD_STAIRS"); - map.put(54, "CHEST"); - map.put(55, "REDSTONE_WIRE"); - map.put(56, "DIAMOND_ORE"); - map.put(57, "DIAMOND_BLOCK"); - map.put(58, "WORKBENCH"); - map.put(59, "CROPS"); - map.put(60, "SOIL"); - map.put(61, "FURNACE"); - map.put(62, "BURNING_FURNACE"); - map.put(63, "SIGN_POST"); - map.put(64, "WOODEN_DOOR"); - map.put(65, "LADDER"); - map.put(66, "RAILS"); - map.put(67, "COBBLESTONE_STAIRS"); - map.put(68, "WALL_SIGN"); - map.put(69, "LEVER"); - map.put(70, "STONE_PLATE"); - map.put(71, "IRON_DOOR_BLOCK"); - map.put(72, "WOOD_PLATE"); - map.put(73, "REDSTONE_ORE"); - map.put(74, "GLOWING_REDSTONE_ORE"); - map.put(75, "REDSTONE_TORCH_OFF"); - map.put(76, "REDSTONE_TORCH_ON"); - map.put(77, "STONE_BUTTON"); - map.put(78, "SNOW"); - map.put(79, "ICE"); - map.put(80, "SNOW_BLOCK"); - map.put(81, "CACTUS"); - map.put(82, "CLAY"); - map.put(83, "SUGAR_CANE_BLOCK"); - map.put(84, "JUKEBOX"); - map.put(85, "FENCE"); - map.put(86, "PUMPKIN"); - map.put(87, "NETHERRACK"); - map.put(88, "SOUL_SAND"); - map.put(89, "GLOWSTONE"); - map.put(90, "PORTAL"); - map.put(91, "JACK_O_LANTERN"); - map.put(92, "CAKE_BLOCK"); - map.put(93, "DIODE_BLOCK_OFF"); - map.put(94, "DIODE_BLOCK_ON"); - map.put(95, "STAINED_GLASS"); - map.put(96, "TRAP_DOOR"); - map.put(97, "MONSTER_EGGS"); - map.put(98, "SMOOTH_BRICK"); - map.put(99, "HUGE_MUSHROOM_1"); - map.put(100, "HUGE_MUSHROOM_2"); - map.put(101, "IRON_FENCE"); - map.put(102, "THIN_GLASS"); - map.put(103, "MELON_BLOCK"); - map.put(104, "PUMPKIN_STEM"); - map.put(105, "MELON_STEM"); - map.put(106, "VINE"); - map.put(107, "FENCE_GATE"); - map.put(108, "BRICK_STAIRS"); - map.put(109, "SMOOTH_STAIRS"); - map.put(110, "MYCEL"); - map.put(111, "WATER_LILY"); - map.put(112, "NETHER_BRICK"); - map.put(113, "NETHER_FENCE"); - map.put(114, "NETHER_BRICK_STAIRS"); - map.put(115, "NETHER_WARTS"); - map.put(116, "ENCHANTMENT_TABLE"); - map.put(117, "BREWING_STAND"); - map.put(118, "CAULDRON"); - map.put(119, "ENDER_PORTAL"); - map.put(120, "ENDER_PORTAL_FRAME"); - map.put(121, "ENDER_STONE"); - map.put(122, "DRAGON_EGG"); - map.put(123, "REDSTONE_LAMP_OFF"); - map.put(124, "REDSTONE_LAMP_ON"); - map.put(125, "WOOD_DOUBLE_STEP"); - map.put(126, "WOOD_STEP"); - map.put(127, "COCOA"); - map.put(128, "SANDSTONE_STAIRS"); - map.put(129, "EMERALD_ORE"); - map.put(130, "ENDER_CHEST"); - map.put(131, "TRIPWIRE_HOOK"); - map.put(132, "TRIPWIRE"); - map.put(133, "EMERALD_BLOCK"); - map.put(134, "SPRUCE_WOOD_STAIRS"); - map.put(135, "BIRCH_WOOD_STAIRS"); - map.put(136, "JUNGLE_WOOD_STAIRS"); - map.put(137, "COMMAND"); - map.put(138, "BEACON"); - map.put(139, "COBBLE_WALL"); - map.put(140, "FLOWER_POT"); - map.put(141, "CARROT"); - map.put(142, "POTATO"); - map.put(143, "WOOD_BUTTON"); - map.put(144, "SKULL"); - map.put(145, "ANVIL"); - map.put(146, "TRAPPED_CHEST"); - map.put(147, "GOLD_PLATE"); - map.put(148, "IRON_PLATE"); - map.put(149, "REDSTONE_COMPARATOR_OFF"); - map.put(150, "REDSTONE_COMPARATOR_ON"); - map.put(151, "DAYLIGHT_DETECTOR"); - map.put(152, "REDSTONE_BLOCK"); - map.put(153, "QUARTZ_ORE"); - map.put(154, "HOPPER"); - map.put(155, "QUARTZ_BLOCK"); - map.put(156, "QUARTZ_STAIRS"); - map.put(157, "ACTIVATOR_RAIL"); - map.put(158, "DROPPER"); - map.put(159, "STAINED_CLAY"); - map.put(160, "STAINED_GLASS_PANE"); - map.put(161, "LEAVES_2"); - map.put(162, "LOG_2"); - map.put(163, "ACACIA_STAIRS"); - map.put(164, "DARK_OAK_STAIRS"); - map.put(165, "SLIME_BLOCK"); - map.put(166, "BARRIER"); - map.put(167, "IRON_TRAPDOOR"); - map.put(168, "PRISMARINE"); - map.put(169, "SEA_LANTERN"); - map.put(170, "HAY_BLOCK"); - map.put(171, "CARPET"); - map.put(172, "HARD_CLAY"); - map.put(173, "COAL_BLOCK"); - map.put(174, "PACKED_ICE"); - map.put(175, "DOUBLE_PLANT"); - map.put(176, "STANDING_BANNER"); - map.put(177, "WALL_BANNER"); - map.put(178, "DAYLIGHT_DETECTOR_INVERTED"); - map.put(179, "RED_SANDSTONE"); - map.put(180, "RED_SANDSTONE_STAIRS"); - map.put(181, "DOUBLE_STONE_SLAB2"); - map.put(182, "STONE_SLAB2"); - map.put(183, "SPRUCE_FENCE_GATE"); - map.put(184, "BIRCH_FENCE_GATE"); - map.put(185, "JUNGLE_FENCE_GATE"); - map.put(186, "DARK_OAK_FENCE_GATE"); - map.put(187, "ACACIA_FENCE_GATE"); - map.put(188, "SPRUCE_FENCE"); - map.put(189, "BIRCH_FENCE"); - map.put(190, "JUNGLE_FENCE"); - map.put(191, "DARK_OAK_FENCE"); - map.put(192, "ACACIA_FENCE"); - map.put(193, "SPRUCE_DOOR"); - map.put(194, "BIRCH_DOOR"); - map.put(195, "JUNGLE_DOOR"); - map.put(196, "ACACIA_DOOR"); - map.put(197, "DARK_OAK_DOOR"); - map.put(198, "END_ROD"); - map.put(199, "CHORUS_PLANT"); - map.put(200, "CHORUS_FLOWER"); - map.put(201, "PURPUR_BLOCK"); - map.put(202, "PURPUR_PILLAR"); - map.put(203, "PURPUR_STAIRS"); - map.put(204, "PURPUR_DOUBLE_SLAB"); - map.put(205, "PURPUR_SLAB"); - map.put(206, "END_BRICKS"); - map.put(207, "BEETROOT_BLOCK"); - map.put(208, "GRASS_PATH"); - map.put(209, "END_GATEWAY"); - map.put(210, "COMMAND_REPEATING"); - map.put(211, "COMMAND_CHAIN"); - map.put(212, "FROSTED_ICE"); - map.put(213, "MAGMA"); - map.put(214, "NETHER_WART_BLOCK"); - map.put(215, "RED_NETHER_BRICK"); - map.put(216, "BONE_BLOCK"); - map.put(217, "STRUCTURE_VOID"); - map.put(218, "OBSERVER"); - map.put(219, "WHITE_SHULKER_BOX"); - map.put(220, "ORANGE_SHULKER_BOX"); - map.put(221, "MAGENTA_SHULKER_BOX"); - map.put(222, "LIGHT_BLUE_SHULKER_BOX"); - map.put(223, "YELLOW_SHULKER_BOX"); - map.put(224, "LIME_SHULKER_BOX"); - map.put(225, "PINK_SHULKER_BOX"); - map.put(226, "GRAY_SHULKER_BOX"); - map.put(227, "SILVER_SHULKER_BOX"); - map.put(228, "CYAN_SHULKER_BOX"); - map.put(229, "PURPLE_SHULKER_BOX"); - map.put(230, "BLUE_SHULKER_BOX"); - map.put(231, "BROWN_SHULKER_BOX"); - map.put(232, "GREEN_SHULKER_BOX"); - map.put(233, "RED_SHULKER_BOX"); - map.put(234, "BLACK_SHULKER_BOX"); - map.put(235, "WHITE_GLAZED_TERRACOTTA"); - map.put(236, "ORANGE_GLAZED_TERRACOTTA"); - map.put(237, "MAGENTA_GLAZED_TERRACOTTA"); - map.put(238, "LIGHT_BLUE_GLAZED_TERRACOTTA"); - map.put(239, "YELLOW_GLAZED_TERRACOTTA"); - map.put(240, "LIME_GLAZED_TERRACOTTA"); - map.put(241, "PINK_GLAZED_TERRACOTTA"); - map.put(242, "GRAY_GLAZED_TERRACOTTA"); - map.put(243, "SILVER_GLAZED_TERRACOTTA"); - map.put(244, "CYAN_GLAZED_TERRACOTTA"); - map.put(245, "PURPLE_GLAZED_TERRACOTTA"); - map.put(246, "BLUE_GLAZED_TERRACOTTA"); - map.put(247, "BROWN_GLAZED_TERRACOTTA"); - map.put(248, "GREEN_GLAZED_TERRACOTTA"); - map.put(249, "RED_GLAZED_TERRACOTTA"); - map.put(250, "BLACK_GLAZED_TERRACOTTA"); - map.put(251, "CONCRETE"); - map.put(252, "CONCRETE_POWDER"); - map.put(255, "STRUCTURE_BLOCK"); - map.put(256, "IRON_SPADE"); - map.put(257, "IRON_PICKAXE"); - map.put(258, "IRON_AXE"); - map.put(259, "FLINT_AND_STEEL"); - map.put(260, "APPLE"); - map.put(261, "BOW"); - map.put(262, "ARROW"); - map.put(263, "COAL"); - map.put(264, "DIAMOND"); - map.put(265, "IRON_INGOT"); - map.put(266, "GOLD_INGOT"); - map.put(267, "IRON_SWORD"); - map.put(268, "WOOD_SWORD"); - map.put(269, "WOOD_SPADE"); - map.put(270, "WOOD_PICKAXE"); - map.put(271, "WOOD_AXE"); - map.put(272, "STONE_SWORD"); - map.put(273, "STONE_SPADE"); - map.put(274, "STONE_PICKAXE"); - map.put(275, "STONE_AXE"); - map.put(276, "DIAMOND_SWORD"); - map.put(277, "DIAMOND_SPADE"); - map.put(278, "DIAMOND_PICKAXE"); - map.put(279, "DIAMOND_AXE"); - map.put(280, "STICK"); - map.put(281, "BOWL"); - map.put(282, "MUSHROOM_SOUP"); - map.put(283, "GOLD_SWORD"); - map.put(284, "GOLD_SPADE"); - map.put(285, "GOLD_PICKAXE"); - map.put(286, "GOLD_AXE"); - map.put(287, "STRING"); - map.put(288, "FEATHER"); - map.put(289, "SULPHUR"); - map.put(290, "WOOD_HOE"); - map.put(291, "STONE_HOE"); - map.put(292, "IRON_HOE"); - map.put(293, "DIAMOND_HOE"); - map.put(294, "GOLD_HOE"); - map.put(295, "SEEDS"); - map.put(296, "WHEAT"); - map.put(297, "BREAD"); - map.put(298, "LEATHER_HELMET"); - map.put(299, "LEATHER_CHESTPLATE"); - map.put(300, "LEATHER_LEGGINGS"); - map.put(301, "LEATHER_BOOTS"); - map.put(302, "CHAINMAIL_HELMET"); - map.put(303, "CHAINMAIL_CHESTPLATE"); - map.put(304, "CHAINMAIL_LEGGINGS"); - map.put(305, "CHAINMAIL_BOOTS"); - map.put(306, "IRON_HELMET"); - map.put(307, "IRON_CHESTPLATE"); - map.put(308, "IRON_LEGGINGS"); - map.put(309, "IRON_BOOTS"); - map.put(310, "DIAMOND_HELMET"); - map.put(311, "DIAMOND_CHESTPLATE"); - map.put(312, "DIAMOND_LEGGINGS"); - map.put(313, "DIAMOND_BOOTS"); - map.put(314, "GOLD_HELMET"); - map.put(315, "GOLD_CHESTPLATE"); - map.put(316, "GOLD_LEGGINGS"); - map.put(317, "GOLD_BOOTS"); - map.put(318, "FLINT"); - map.put(319, "PORK"); - map.put(320, "GRILLED_PORK"); - map.put(321, "PAINTING"); - map.put(322, "GOLDEN_APPLE"); - map.put(323, "SIGN"); - map.put(324, "WOOD_DOOR"); - map.put(325, "BUCKET"); - map.put(326, "WATER_BUCKET"); - map.put(327, "LAVA_BUCKET"); - map.put(328, "MINECART"); - map.put(329, "SADDLE"); - map.put(330, "IRON_DOOR"); - map.put(331, "REDSTONE"); - map.put(332, "SNOW_BALL"); - map.put(333, "BOAT"); - map.put(334, "LEATHER"); - map.put(335, "MILK_BUCKET"); - map.put(336, "CLAY_BRICK"); - map.put(337, "CLAY_BALL"); - map.put(338, "SUGAR_CANE"); - map.put(339, "PAPER"); - map.put(340, "BOOK"); - map.put(341, "SLIME_BALL"); - map.put(342, "STORAGE_MINECART"); - map.put(343, "POWERED_MINECART"); - map.put(344, "EGG"); - map.put(345, "COMPASS"); - map.put(346, "FISHING_ROD"); - map.put(347, "WATCH"); - map.put(348, "GLOWSTONE_DUST"); - map.put(349, "RAW_FISH"); - map.put(350, "COOKED_FISH"); - map.put(351, "INK_SACK"); - map.put(352, "BONE"); - map.put(353, "SUGAR"); - map.put(354, "CAKE"); - map.put(355, "BED"); - map.put(356, "DIODE"); - map.put(357, "COOKIE"); - map.put(358, "MAP"); - map.put(359, "SHEARS"); - map.put(360, "MELON"); - map.put(361, "PUMPKIN_SEEDS"); - map.put(362, "MELON_SEEDS"); - map.put(363, "RAW_BEEF"); - map.put(364, "COOKED_BEEF"); - map.put(365, "RAW_CHICKEN"); - map.put(366, "COOKED_CHICKEN"); - map.put(367, "ROTTEN_FLESH"); - map.put(368, "ENDER_PEARL"); - map.put(369, "BLAZE_ROD"); - map.put(370, "GHAST_TEAR"); - map.put(371, "GOLD_NUGGET"); - map.put(372, "NETHER_STALK"); - map.put(373, "POTION"); - map.put(374, "GLASS_BOTTLE"); - map.put(375, "SPIDER_EYE"); - map.put(376, "FERMENTED_SPIDER_EYE"); - map.put(377, "BLAZE_POWDER"); - map.put(378, "MAGMA_CREAM"); - map.put(379, "BREWING_STAND_ITEM"); - map.put(380, "CAULDRON_ITEM"); - map.put(381, "EYE_OF_ENDER"); - map.put(382, "SPECKLED_MELON"); - map.put(383, "MONSTER_EGG"); - map.put(384, "EXP_BOTTLE"); - map.put(385, "FIREBALL"); - map.put(386, "BOOK_AND_QUILL"); - map.put(387, "WRITTEN_BOOK"); - map.put(388, "EMERALD"); - map.put(389, "ITEM_FRAME"); - map.put(390, "FLOWER_POT_ITEM"); - map.put(391, "CARROT_ITEM"); - map.put(392, "POTATO_ITEM"); - map.put(393, "BAKED_POTATO"); - map.put(394, "POISONOUS_POTATO"); - map.put(395, "EMPTY_MAP"); - map.put(396, "GOLDEN_CARROT"); - map.put(397, "SKULL_ITEM"); - map.put(398, "CARROT_STICK"); - map.put(399, "NETHER_STAR"); - map.put(400, "PUMPKIN_PIE"); - map.put(401, "FIREWORK"); - map.put(402, "FIREWORK_CHARGE"); - map.put(403, "ENCHANTED_BOOK"); - map.put(404, "REDSTONE_COMPARATOR"); - map.put(405, "NETHER_BRICK_ITEM"); - map.put(406, "QUARTZ"); - map.put(407, "EXPLOSIVE_MINECART"); - map.put(408, "HOPPER_MINECART"); - map.put(409, "PRISMARINE_SHARD"); - map.put(410, "PRISMARINE_CRYSTALS"); - map.put(411, "RABBIT"); - map.put(412, "COOKED_RABBIT"); - map.put(413, "RABBIT_STEW"); - map.put(414, "RABBIT_FOOT"); - map.put(415, "RABBIT_HIDE"); - map.put(416, "ARMOR_STAND"); - map.put(417, "IRON_BARDING"); - map.put(418, "GOLD_BARDING"); - map.put(419, "DIAMOND_BARDING"); - map.put(420, "LEASH"); - map.put(421, "NAME_TAG"); - map.put(422, "COMMAND_MINECART"); - map.put(423, "MUTTON"); - map.put(424, "COOKED_MUTTON"); - map.put(425, "BANNER"); - map.put(426, "END_CRYSTAL"); - map.put(427, "SPRUCE_DOOR_ITEM"); - map.put(428, "BIRCH_DOOR_ITEM"); - map.put(429, "JUNGLE_DOOR_ITEM"); - map.put(430, "ACACIA_DOOR_ITEM"); - map.put(431, "DARK_OAK_DOOR_ITEM"); - map.put(432, "CHORUS_FRUIT"); - map.put(433, "CHORUS_FRUIT_POPPED"); - map.put(434, "BEETROOT"); - map.put(435, "BEETROOT_SEEDS"); - map.put(436, "BEETROOT_SOUP"); - map.put(437, "DRAGONS_BREATH"); - map.put(438, "SPLASH_POTION"); - map.put(439, "SPECTRAL_ARROW"); - map.put(440, "TIPPED_ARROW"); - map.put(441, "LINGERING_POTION"); - map.put(442, "SHIELD"); - map.put(443, "ELYTRA"); - map.put(444, "BOAT_SPRUCE"); - map.put(445, "BOAT_BIRCH"); - map.put(446, "BOAT_JUNGLE"); - map.put(447, "BOAT_ACACIA"); - map.put(448, "BOAT_DARK_OAK"); - map.put(449, "TOTEM"); - map.put(450, "SHULKER_SHELL"); - map.put(452, "IRON_NUGGET"); - map.put(453, "KNOWLEDGE_BOOK"); - map.put(2256, "GOLD_RECORD"); - map.put(2257, "GREEN_RECORD"); - map.put(2258, "RECORD_3"); - map.put(2259, "RECORD_4"); - map.put(2260, "RECORD_5"); - map.put(2261, "RECORD_6"); - map.put(2262, "RECORD_7"); - map.put(2263, "RECORD_8"); - map.put(2264, "RECORD_9"); - map.put(2265, "RECORD_10"); - map.put(2266, "RECORD_11"); - map.put(2267, "RECORD_12"); - - id2name = ImmutableMap.copyOf(map); - } - -} diff --git a/src/com/massivecraft/massivecore/entity/migrator/MigratorInventory001StringId.java b/src/com/massivecraft/massivecore/entity/migrator/MigratorInventory001StringId.java deleted file mode 100644 index 87c9fccf..00000000 --- a/src/com/massivecraft/massivecore/entity/migrator/MigratorInventory001StringId.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.massivecraft.massivecore.entity.migrator; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.massivecraft.massivecore.adapter.AdapterInventory; -import com.massivecraft.massivecore.item.DataItemStack; -import com.massivecraft.massivecore.store.migrator.MigratorRoot; -import com.massivecraft.massivecore.store.migrator.MigratorUtil; -import com.massivecraft.massivecore.util.MUtil; -import org.apache.commons.lang.StringUtils; -import org.bukkit.inventory.Inventory; - -import java.util.Map.Entry; -import java.util.Set; - -public class MigratorInventory001StringId extends MigratorRoot -{ - // -------------------------------------------- // - // CONSTANTS - // -------------------------------------------- // - - public static final Set NAMES_EXTRA_FIELDS = MUtil.set( - AdapterInventory.HELMET, - AdapterInventory.CHESTPLATE, - AdapterInventory.LEGGINGS, - AdapterInventory.BOOTS, - AdapterInventory.SHIELD - ); - - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static MigratorInventory001StringId i = new MigratorInventory001StringId(); - public static MigratorInventory001StringId get() { return i; } - private MigratorInventory001StringId() - { - super(Inventory.class); - } - - // -------------------------------------------- // - // CONVERSION - // -------------------------------------------- // - - @Override - public void migrateInner(JsonObject json) - { - for (Entry entry : json.entrySet()) - { - String name = entry.getKey(); - boolean updateable = NAMES_EXTRA_FIELDS.contains(name) || StringUtils.isNumeric(name); - - if (!updateable) continue; - - updateField(json, name); - } - } - - public void updateField(JsonObject json, String name) - { - JsonElement element = json.get(name); - if (element == null) return; - if (!element.isJsonObject()) return; - JsonObject object = element.getAsJsonObject(); - MigratorUtil.migrate(DataItemStack.class, object); - } - -} diff --git a/src/com/massivecraft/massivecore/item/Converter.java b/src/com/massivecraft/massivecore/item/Converter.java deleted file mode 100644 index cf402e97..00000000 --- a/src/com/massivecraft/massivecore/item/Converter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.massivecraft.massivecore.item; - -public abstract class Converter -{ - // -------------------------------------------- // - // ABSTRACT - // -------------------------------------------- // - - public abstract Y convert(X x); - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterDefault.java b/src/com/massivecraft/massivecore/item/ConverterDefault.java deleted file mode 100644 index 3eee2e15..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterDefault.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -public class ConverterDefault extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterDefault i = new ConverterDefault<>(); - @SuppressWarnings("unchecked") - public static ConverterDefault get() { return (ConverterDefault) i; } - @SuppressWarnings("unchecked") - public static ConverterDefault get(Class cx, Class cy) { return (ConverterDefault) i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @SuppressWarnings("unchecked") - @Override - public Y convert(X x) - { - return (Y)x; - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromBannerPattern.java b/src/com/massivecraft/massivecore/item/ConverterFromBannerPattern.java deleted file mode 100644 index 73fddf7f..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromBannerPattern.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.banner.Pattern; - -public class ConverterFromBannerPattern extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromBannerPattern i = new ConverterFromBannerPattern(); - public static ConverterFromBannerPattern get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public DataBannerPattern convert(Pattern x) - { - if (x == null) return null; - return new DataBannerPattern(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromBannerPatternType.java b/src/com/massivecraft/massivecore/item/ConverterFromBannerPatternType.java deleted file mode 100644 index b9393519..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromBannerPatternType.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.banner.PatternType; - -public class ConverterFromBannerPatternType extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromBannerPatternType i = new ConverterFromBannerPatternType(); - public static ConverterFromBannerPatternType get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public String convert(PatternType x) - { - if (x == null) return null; - return x.getIdentifier(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromBannerPatterns.java b/src/com/massivecraft/massivecore/item/ConverterFromBannerPatterns.java deleted file mode 100644 index e2de4a79..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromBannerPatterns.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.banner.Pattern; - -public class ConverterFromBannerPatterns extends ConverterList -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromBannerPatterns i = new ConverterFromBannerPatterns(); - public static ConverterFromBannerPatterns get() { return i; } - public ConverterFromBannerPatterns() - { - super(ConverterFromBannerPattern.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromColor.java b/src/com/massivecraft/massivecore/item/ConverterFromColor.java deleted file mode 100644 index f200513f..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromColor.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; - -public class ConverterFromColor extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromColor i = new ConverterFromColor(); - public static ConverterFromColor get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Integer convert(Color x) - { - if (x == null) return null; - return x.asRGB(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromColors.java b/src/com/massivecraft/massivecore/item/ConverterFromColors.java deleted file mode 100644 index f2e9ef37..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromColors.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; - -public class ConverterFromColors extends ConverterList -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromColors i = new ConverterFromColors(); - public static ConverterFromColors get() { return i; } - public ConverterFromColors() - { - super(ConverterFromColor.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromDyeColor.java b/src/com/massivecraft/massivecore/item/ConverterFromDyeColor.java deleted file mode 100644 index c9226115..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromDyeColor.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.DyeColor; - -public class ConverterFromDyeColor extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromDyeColor i = new ConverterFromDyeColor(); - public static ConverterFromDyeColor get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - @Override - public Integer convert(DyeColor x) - { - if (x == null) return null; - return Integer.valueOf(x.getDyeData()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromEnchant.java b/src/com/massivecraft/massivecore/item/ConverterFromEnchant.java deleted file mode 100644 index ff0ae0a9..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromEnchant.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.enchantments.Enchantment; - -public class ConverterFromEnchant extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromEnchant i = new ConverterFromEnchant(); - public static ConverterFromEnchant get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - @Override - public Integer convert(Enchantment x) - { - if (x == null) return null; - return x.getId(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromEnchants.java b/src/com/massivecraft/massivecore/item/ConverterFromEnchants.java deleted file mode 100644 index d25bdc04..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromEnchants.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.enchantments.Enchantment; - -public class ConverterFromEnchants extends ConverterMap -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromEnchants i = new ConverterFromEnchants(); - public static ConverterFromEnchants get() { return i; } - public ConverterFromEnchants() - { - super(ConverterFromEnchant.get(), ConverterDefault.get(Integer.class, Integer.class)); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffect.java b/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffect.java deleted file mode 100644 index d0da4713..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffect.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; - -public class ConverterFromFireworkEffect extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromFireworkEffect i = new ConverterFromFireworkEffect(); - public static ConverterFromFireworkEffect get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public DataFireworkEffect convert(FireworkEffect x) - { - if (x == null) return null; - return new DataFireworkEffect(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffectType.java b/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffectType.java deleted file mode 100644 index b270d0f9..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffectType.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect.Type; - -public class ConverterFromFireworkEffectType extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromFireworkEffectType i = new ConverterFromFireworkEffectType(); - public static ConverterFromFireworkEffectType get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public String convert(Type x) - { - if (x == null) return null; - return x.name(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffects.java b/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffects.java deleted file mode 100644 index 7c9c7c84..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromFireworkEffects.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; - -public class ConverterFromFireworkEffects extends ConverterList -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromFireworkEffects i = new ConverterFromFireworkEffects(); - public static ConverterFromFireworkEffects get() { return i; } - public ConverterFromFireworkEffects() - { - super(ConverterFromFireworkEffect.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromInventoryContents.java b/src/com/massivecraft/massivecore/item/ConverterFromInventoryContents.java deleted file mode 100644 index 4377d65d..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromInventoryContents.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; - -import java.util.Map; - -public class ConverterFromInventoryContents extends Converter> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromInventoryContents i = new ConverterFromInventoryContents(); - public static ConverterFromInventoryContents get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Map convert(ItemStack[] x) - { - if (x == null) return null; - return DataItemStack.fromBukkitContents(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromItemFlag.java b/src/com/massivecraft/massivecore/item/ConverterFromItemFlag.java deleted file mode 100644 index da06bade..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromItemFlag.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemFlag; - -public class ConverterFromItemFlag extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromItemFlag i = new ConverterFromItemFlag(); - public static ConverterFromItemFlag get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public String convert(ItemFlag x) - { - if (x == null) return null; - return x.name(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromItemFlags.java b/src/com/massivecraft/massivecore/item/ConverterFromItemFlags.java deleted file mode 100644 index 2ebd2661..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromItemFlags.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemFlag; - -public class ConverterFromItemFlags extends ConverterSet -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromItemFlags i = new ConverterFromItemFlags(); - public static ConverterFromItemFlags get() { return i; } - public ConverterFromItemFlags() - { - super(ConverterFromItemFlag.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromMaterial.java b/src/com/massivecraft/massivecore/item/ConverterFromMaterial.java deleted file mode 100644 index 7cfce8ec..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromMaterial.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; - -public class ConverterFromMaterial extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromMaterial i = new ConverterFromMaterial(); - public static ConverterFromMaterial get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public String convert(Material x) - { - if (x == null) return null; - return x.name(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromPotionEffect.java b/src/com/massivecraft/massivecore/item/ConverterFromPotionEffect.java deleted file mode 100644 index d5c7063b..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromPotionEffect.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class ConverterFromPotionEffect extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromPotionEffect i = new ConverterFromPotionEffect(); - public static ConverterFromPotionEffect get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public DataPotionEffect convert(PotionEffect x) - { - if (x == null) return null; - return new DataPotionEffect(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromPotionEffectType.java b/src/com/massivecraft/massivecore/item/ConverterFromPotionEffectType.java deleted file mode 100644 index 1b009e53..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromPotionEffectType.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffectType; - -public class ConverterFromPotionEffectType extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromPotionEffectType i = new ConverterFromPotionEffectType(); - public static ConverterFromPotionEffectType get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - @Override - public Integer convert(PotionEffectType x) - { - if (x == null) return null; - return x.getId(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterFromPotionEffects.java b/src/com/massivecraft/massivecore/item/ConverterFromPotionEffects.java deleted file mode 100644 index 1afd0fb1..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterFromPotionEffects.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class ConverterFromPotionEffects extends ConverterList -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterFromPotionEffects i = new ConverterFromPotionEffects(); - public static ConverterFromPotionEffects get() { return i; } - public ConverterFromPotionEffects() - { - super(ConverterFromPotionEffect.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterList.java b/src/com/massivecraft/massivecore/item/ConverterList.java deleted file mode 100644 index a3b2a841..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterList.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.collections.MassiveList; - -import java.util.List; - -public class ConverterList extends Converter, List> -{ - // -------------------------------------------- // - // FIELD - // -------------------------------------------- // - - private final Converter converterElement; - public Converter getConverterElement() { return this.converterElement; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - public ConverterList(Converter converterElement) - { - this.converterElement = converterElement; - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public List convert(Iterable exs) - { - // Null - if (exs == null) return null; - - // Create - List eys = new MassiveList<>(); - - // Fill - for (EX ex : exs) - { - EY ey = null; - try - { - ey = this.getConverterElement().convert(ex); - } - catch (Throwable t) - { - t.printStackTrace(); - continue; - } - - eys.add(ey); - } - - // Return - return eys; - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterListImmutable.java b/src/com/massivecraft/massivecore/item/ConverterListImmutable.java deleted file mode 100644 index a88cf4c1..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterListImmutable.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; - -public class ConverterListImmutable extends Converter, ImmutableList> -{ - // -------------------------------------------- // - // FIELD - // -------------------------------------------- // - - private final Converter converterElement; - public Converter getConverterElement() { return this.converterElement; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - public ConverterListImmutable(Converter converterElement) - { - this.converterElement = converterElement; - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public ImmutableList convert(Iterable exs) - { - // Null - if (exs == null) return null; - - // Create - Builder eys = ImmutableList.builder(); - - // Fill - for (EX ex : exs) - { - EY ey = null; - try - { - ey = this.getConverterElement().convert(ex); - } - catch (Throwable t) - { - t.printStackTrace(); - continue; - } - - eys.add(ey); - } - - // Return - return eys.build(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterMap.java b/src/com/massivecraft/massivecore/item/ConverterMap.java deleted file mode 100644 index e5e07524..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterMap.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.collections.MassiveMap; - -import java.util.Map; -import java.util.Map.Entry; - -public class ConverterMap extends Converter, Map> -{ - // -------------------------------------------- // - // FIELD - // -------------------------------------------- // - - private final Converter converterKey; - public Converter getConverterKey() { return this.converterKey; } - - private final Converter converterValue; - public Converter getConverterValue() { return this.converterValue; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - public ConverterMap(Converter converterKey, Converter converterValue) - { - this.converterKey = converterKey; - this.converterValue = converterValue; - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Map convert(Map mapx) - { - // Null - if (mapx == null) return null; - - // Create - Map mapy = new MassiveMap<>(); - - // Fill - for (Entry entry : mapx.entrySet()) - { - KY ky = null; - KX kx = entry.getKey(); - try - { - ky = this.getConverterKey().convert(kx); - } - catch (Throwable t) - { - t.printStackTrace(); - continue; - } - - VY vy = null; - VX vx = entry.getValue(); - try - { - vy = this.getConverterValue().convert(vx); - } - catch (Throwable t) - { - t.printStackTrace(); - continue; - } - - mapy.put(ky, vy); - } - - // Return - return mapy; - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterSet.java b/src/com/massivecraft/massivecore/item/ConverterSet.java deleted file mode 100644 index a3a1956d..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterSet.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.collections.MassiveSet; - -import java.util.Set; - -public class ConverterSet extends Converter, Set> -{ - // -------------------------------------------- // - // FIELD - // -------------------------------------------- // - - private final Converter converterElement; - public Converter getConverterElement() { return this.converterElement; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - public ConverterSet(Converter converterElement) - { - this.converterElement = converterElement; - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Set convert(Iterable exs) - { - // Null - if (exs == null) return null; - - // Create - Set eys = new MassiveSet<>(); - - // Fill - for (EX ex : exs) - { - EY ey = null; - try - { - ey = this.getConverterElement().convert(ex); - } - catch (Throwable t) - { - t.printStackTrace(); - continue; - } - - eys.add(ey); - } - - // Return - return eys; - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToBannerPattern.java b/src/com/massivecraft/massivecore/item/ConverterToBannerPattern.java deleted file mode 100644 index 573a8438..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToBannerPattern.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.banner.Pattern; - -public class ConverterToBannerPattern extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToBannerPattern i = new ConverterToBannerPattern(); - public static ConverterToBannerPattern get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Pattern convert(DataBannerPattern x) - { - if (x == null) return null; - return x.toBukkit(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToBannerPatternType.java b/src/com/massivecraft/massivecore/item/ConverterToBannerPatternType.java deleted file mode 100644 index 2784b94e..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToBannerPatternType.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.banner.PatternType; - -public class ConverterToBannerPatternType extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToBannerPatternType i = new ConverterToBannerPatternType(); - public static ConverterToBannerPatternType get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public PatternType convert(String x) - { - if (x == null) return null; - return PatternType.getByIdentifier(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToBannerPatterns.java b/src/com/massivecraft/massivecore/item/ConverterToBannerPatterns.java deleted file mode 100644 index e77c1183..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToBannerPatterns.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.banner.Pattern; - -public class ConverterToBannerPatterns extends ConverterList -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToBannerPatterns i = new ConverterToBannerPatterns(); - public static ConverterToBannerPatterns get() { return i; } - public ConverterToBannerPatterns() - { - super(ConverterToBannerPattern.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToColor.java b/src/com/massivecraft/massivecore/item/ConverterToColor.java deleted file mode 100644 index 6bf836a7..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToColor.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; - -public class ConverterToColor extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToColor i = new ConverterToColor(); - public static ConverterToColor get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Color convert(Integer x) - { - if (x == null) return null; - return Color.fromRGB(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToColors.java b/src/com/massivecraft/massivecore/item/ConverterToColors.java deleted file mode 100644 index d5de6c54..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToColors.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; - -public class ConverterToColors extends ConverterListImmutable -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToColors i = new ConverterToColors(); - public static ConverterToColors get() { return i; } - public ConverterToColors() - { - super(ConverterToColor.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToDyeColor.java b/src/com/massivecraft/massivecore/item/ConverterToDyeColor.java deleted file mode 100644 index 3b1b53e5..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToDyeColor.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.DyeColor; - -public class ConverterToDyeColor extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToDyeColor i = new ConverterToDyeColor(); - public static ConverterToDyeColor get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - @Override - public DyeColor convert(Integer x) - { - if (x == null) return null; - return DyeColor.getByDyeData(x.byteValue()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToEnchant.java b/src/com/massivecraft/massivecore/item/ConverterToEnchant.java deleted file mode 100644 index 15251779..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToEnchant.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.enchantments.Enchantment; - -public class ConverterToEnchant extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToEnchant i = new ConverterToEnchant(); - public static ConverterToEnchant get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - @Override - public Enchantment convert(Integer x) - { - if (x == null) return null; - return Enchantment.getById(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToEnchants.java b/src/com/massivecraft/massivecore/item/ConverterToEnchants.java deleted file mode 100644 index bda2c327..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToEnchants.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.enchantments.Enchantment; - -public class ConverterToEnchants extends ConverterMap -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToEnchants i = new ConverterToEnchants(); - public static ConverterToEnchants get() { return i; } - public ConverterToEnchants() - { - super(ConverterToEnchant.get(), ConverterDefault.get(Integer.class, Integer.class)); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToFireworkEffect.java b/src/com/massivecraft/massivecore/item/ConverterToFireworkEffect.java deleted file mode 100644 index 8c65325a..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToFireworkEffect.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; - -public class ConverterToFireworkEffect extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToFireworkEffect i = new ConverterToFireworkEffect(); - public static ConverterToFireworkEffect get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public FireworkEffect convert(DataFireworkEffect x) - { - if (x == null) return null; - return x.toBukkit(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToFireworkEffectType.java b/src/com/massivecraft/massivecore/item/ConverterToFireworkEffectType.java deleted file mode 100644 index 2538768b..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToFireworkEffectType.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect.Type; - -public class ConverterToFireworkEffectType extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToFireworkEffectType i = new ConverterToFireworkEffectType(); - public static ConverterToFireworkEffectType get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Type convert(String x) - { - if (x == null) return null; - return Type.valueOf(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToFireworkEffects.java b/src/com/massivecraft/massivecore/item/ConverterToFireworkEffects.java deleted file mode 100644 index fb1480c0..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToFireworkEffects.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; - -public class ConverterToFireworkEffects extends ConverterList -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToFireworkEffects i = new ConverterToFireworkEffects(); - public static ConverterToFireworkEffects get() { return i; } - public ConverterToFireworkEffects() - { - super(ConverterToFireworkEffect.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToInventoryContents.java b/src/com/massivecraft/massivecore/item/ConverterToInventoryContents.java deleted file mode 100644 index 4fe1965d..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToInventoryContents.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; - -import java.util.Map; - -public class ConverterToInventoryContents extends Converter, ItemStack[]> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToInventoryContents i = new ConverterToInventoryContents(); - public static ConverterToInventoryContents get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public ItemStack[] convert(Map x) - { - if (x == null) return null; - return DataItemStack.toBukkitContents(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToItemFlag.java b/src/com/massivecraft/massivecore/item/ConverterToItemFlag.java deleted file mode 100644 index 7f523ec1..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToItemFlag.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemFlag; - -public class ConverterToItemFlag extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToItemFlag i = new ConverterToItemFlag(); - public static ConverterToItemFlag get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public ItemFlag convert(String x) - { - if (x == null) return null; - return ItemFlag.valueOf(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToItemFlags.java b/src/com/massivecraft/massivecore/item/ConverterToItemFlags.java deleted file mode 100644 index 237e45e7..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToItemFlags.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemFlag; - -public class ConverterToItemFlags extends ConverterSet -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToItemFlags i = new ConverterToItemFlags(); - public static ConverterToItemFlags get() { return i; } - public ConverterToItemFlags() - { - super(ConverterToItemFlag.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToMaterial.java b/src/com/massivecraft/massivecore/item/ConverterToMaterial.java deleted file mode 100644 index e4e098fa..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToMaterial.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; - -public class ConverterToMaterial extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToMaterial i = new ConverterToMaterial(); - public static ConverterToMaterial get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Material convert(String x) - { - if (x == null) return null; - Material ret = Material.getMaterial(x); - if (ret == null) throw new NullPointerException(x); - return ret; - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToPotionEffect.java b/src/com/massivecraft/massivecore/item/ConverterToPotionEffect.java deleted file mode 100644 index dbca6a9c..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToPotionEffect.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class ConverterToPotionEffect extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToPotionEffect i = new ConverterToPotionEffect(); - public static ConverterToPotionEffect get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public PotionEffect convert(DataPotionEffect x) - { - if (x == null) return null; - return x.toBukkit(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToPotionEffectType.java b/src/com/massivecraft/massivecore/item/ConverterToPotionEffectType.java deleted file mode 100644 index 8d80d87f..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToPotionEffectType.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffectType; - -public class ConverterToPotionEffectType extends Converter -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToPotionEffectType i = new ConverterToPotionEffectType(); - public static ConverterToPotionEffectType get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - @Override - public PotionEffectType convert(Integer x) - { - if (x == null) return null; - return PotionEffectType.getById(x); - } - -} diff --git a/src/com/massivecraft/massivecore/item/ConverterToPotionEffects.java b/src/com/massivecraft/massivecore/item/ConverterToPotionEffects.java deleted file mode 100644 index 6ef30250..00000000 --- a/src/com/massivecraft/massivecore/item/ConverterToPotionEffects.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class ConverterToPotionEffects extends ConverterList -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final ConverterToPotionEffects i = new ConverterToPotionEffects(); - public static ConverterToPotionEffects get() { return i; } - public ConverterToPotionEffects() - { - super(ConverterToPotionEffect.get()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/DataBannerPattern.java b/src/com/massivecraft/massivecore/item/DataBannerPattern.java deleted file mode 100644 index 641b2c64..00000000 --- a/src/com/massivecraft/massivecore/item/DataBannerPattern.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.command.editor.annotation.EditorMethods; -import com.massivecraft.massivecore.command.editor.annotation.EditorType; -import com.massivecraft.massivecore.command.type.convert.TypeConverterBannerPatternType; -import com.massivecraft.massivecore.command.type.convert.TypeConverterDyeColor; -import com.massivecraft.massivecore.comparator.ComparatorSmart; -import com.massivecraft.massivecore.util.MUtil; -import org.bukkit.block.banner.Pattern; - -import java.util.Objects; - -import static com.massivecraft.massivecore.item.DataItemStack.get; -import static com.massivecraft.massivecore.item.DataItemStack.set; - -@EditorMethods(true) -public class DataBannerPattern implements Comparable -{ - // -------------------------------------------- // - // DEFAULTS - // -------------------------------------------- // - - public static final transient String DEFAULT_ID = null; - public static final transient Integer DEFAULT_COLOR = null; - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - @EditorType(TypeConverterBannerPatternType.class) - private String id = null; - public String getId() { return get(this.id, DEFAULT_ID); } - public DataBannerPattern setId(String id) { this.id = set(id, DEFAULT_ID); return this; } - - @EditorType(TypeConverterDyeColor.class) - private Integer color = null; - public Integer getColor() { return get(this.color, DEFAULT_COLOR); } - public DataBannerPattern setColor(Integer color) { this.color = set(color, DEFAULT_ID); return this; } - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public DataBannerPattern() - { - - } - - // Minecraft 1.7 Compatibility - public DataBannerPattern(Object pattern) - { - if ( ! (pattern instanceof Pattern)) throw new IllegalArgumentException("pattern"); - this.write((Pattern)pattern, false); - } - - // -------------------------------------------- // - // WRITE - // -------------------------------------------- // - - // Minecraft 1.7 Compatibility - public void write(Object pattern, boolean a2b) - { - if ( ! (pattern instanceof Pattern)) throw new IllegalArgumentException("pattern"); - WriterBannerPattern.get().write(this, (Pattern)pattern, a2b); - } - - // -------------------------------------------- // - // TO BUKKIT - // -------------------------------------------- // - - // Minecraft 1.7 Compatibility - @SuppressWarnings("unchecked") - public T toBukkit() - { - // Create - Pattern ret = WriterBannerPattern.get().createOB(); - - // Fill - this.write(ret, true); - - // Return - return (T) ret; - } - - // -------------------------------------------- // - // COMPARE & EQUALS & HASHCODE - // -------------------------------------------- // - - @Override - public int compareTo(DataBannerPattern that) - { - return ComparatorSmart.get().compare( - this.getId(), that.getId(), - this.getColor(), that.getColor() - ); - } - - // TODO: Use compare instead to avoid bugs? - @Override - public boolean equals(Object object) - { - if ( ! (object instanceof DataBannerPattern)) return false; - DataBannerPattern that = (DataBannerPattern)object; - - return MUtil.equals( - this.getId(), that.getId(), - this.getColor(), that.getColor() - ); - } - - @Override - public int hashCode() - { - return Objects.hash( - this.getId(), - this.getColor() - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/DataFireworkEffect.java b/src/com/massivecraft/massivecore/item/DataFireworkEffect.java deleted file mode 100644 index df8a84c2..00000000 --- a/src/com/massivecraft/massivecore/item/DataFireworkEffect.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.google.gson.annotations.SerializedName; -import com.massivecraft.massivecore.collections.MassiveListDef; -import com.massivecraft.massivecore.command.editor.annotation.EditorMethods; -import com.massivecraft.massivecore.command.editor.annotation.EditorType; -import com.massivecraft.massivecore.command.editor.annotation.EditorTypeInner; -import com.massivecraft.massivecore.command.type.convert.TypeConverterColor; -import com.massivecraft.massivecore.command.type.convert.TypeConverterFireworkEffectType; -import com.massivecraft.massivecore.comparator.ComparatorSmart; -import com.massivecraft.massivecore.util.MUtil; -import org.bukkit.FireworkEffect; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import static com.massivecraft.massivecore.item.DataItemStack.get; -import static com.massivecraft.massivecore.item.DataItemStack.set; - -@EditorMethods(true) -public class DataFireworkEffect implements Comparable -{ - // -------------------------------------------- // - // DEFAULTS - // -------------------------------------------- // - - public static final transient Boolean DEFAULT_FLICKER = false; - public static final transient Boolean DEFAULT_TRAIL = false; - public static final transient List DEFAULT_COLORS = Collections.emptyList(); - public static final transient List DEFAULT_FADE_COLORS = Collections.emptyList(); - public static final transient String DEFAULT_TYPE = "BALL_LARGE"; - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - // According to Bukkit the colors are indeed lists with explicit order. - // I have not researched if that is true. For now I am assuming it is. - - private Boolean flicker = null; - public boolean hasFlicker() { return get(this.flicker, DEFAULT_FLICKER); } - public DataFireworkEffect setFlicker(boolean flicker) { this.flicker = set(flicker, DEFAULT_FLICKER); return this; } - - private Boolean trail = null; - public boolean hasTrail() { return get(this.trail, DEFAULT_TRAIL); } - public DataFireworkEffect setTrail(boolean trail) { this.trail = set(trail, DEFAULT_TRAIL); return this; } - - @EditorTypeInner(TypeConverterColor.class) - private MassiveListDef colors = null; - public List getColors() { return get(this.colors, DEFAULT_COLORS); } - public DataFireworkEffect setColors(List colors) { this.colors = set(colors, DEFAULT_COLORS); return this; } - - @EditorTypeInner(TypeConverterColor.class) - @SerializedName("fade-colors") - private MassiveListDef fadeColors = null; - public List getFadeColors() { return get(this.fadeColors, DEFAULT_FADE_COLORS); } - public DataFireworkEffect setFadeColors(List fadeColors) { this.fadeColors = set(fadeColors, DEFAULT_FADE_COLORS); return this; } - - @EditorType(TypeConverterFireworkEffectType.class) - private String type = null; - public String getType() { return get(this.type, DEFAULT_TYPE); } - public DataFireworkEffect setType(String type) { this.type = set(type, DEFAULT_TYPE); return this; } - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public DataFireworkEffect() - { - - } - - public DataFireworkEffect(FireworkEffect fireworkEffect) - { - this.write(fireworkEffect, false); - } - - // -------------------------------------------- // - // WRITE - // -------------------------------------------- // - - public void write(FireworkEffect fireworkEffect, boolean a2b) - { - WriterFireworkEffect.get().write(this, fireworkEffect, a2b); - } - - // -------------------------------------------- // - // TO BUKKIT - // -------------------------------------------- // - - public FireworkEffect toBukkit() - { - // Create - FireworkEffect ret = WriterFireworkEffect.get().createOB(); - - // Fill - this.write(ret, true); - - // Return - return ret; - } - - // -------------------------------------------- // - // COMPARE & EQUALS & HASHCODE - // -------------------------------------------- // - - @Override - public int compareTo(DataFireworkEffect that) - { - return ComparatorSmart.get().compare( - this.hasFlicker(), that.hasFlicker(), - this.hasTrail(), that.hasTrail(), - this.getColors(), that.getColors(), - this.getColors(), that.getColors(), - this.getFadeColors(), that.getFadeColors(), - this.getType(), that.getType() - ); - } - - // TODO: Use compare instead to avoid bugs? - @Override - public boolean equals(Object object) - { - if ( ! (object instanceof DataFireworkEffect)) return false; - DataFireworkEffect that = (DataFireworkEffect)object; - - return MUtil.equals( - this.hasFlicker(), that.hasFlicker(), - this.hasTrail(), that.hasTrail(), - this.getColors(), that.getColors(), - this.getColors(), that.getColors(), - this.getFadeColors(), that.getFadeColors(), - this.getType(), that.getType() - ); - } - - @Override - public int hashCode() - { - return Objects.hash( - this.hasFlicker(), - this.hasTrail(), - this.getColors(), - this.getColors(), - this.getFadeColors(), - this.getType() - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/DataItemStack.java b/src/com/massivecraft/massivecore/item/DataItemStack.java deleted file mode 100644 index f01a1363..00000000 --- a/src/com/massivecraft/massivecore/item/DataItemStack.java +++ /dev/null @@ -1,685 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.google.gson.annotations.SerializedName; -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.collections.MassiveListDef; -import com.massivecraft.massivecore.collections.MassiveMap; -import com.massivecraft.massivecore.collections.MassiveTreeMapDef; -import com.massivecraft.massivecore.collections.MassiveTreeSetDef; -import com.massivecraft.massivecore.command.editor.annotation.EditorEditable; -import com.massivecraft.massivecore.command.editor.annotation.EditorMethods; -import com.massivecraft.massivecore.command.editor.annotation.EditorType; -import com.massivecraft.massivecore.command.editor.annotation.EditorTypeInner; -import com.massivecraft.massivecore.command.editor.annotation.EditorVisible; -import com.massivecraft.massivecore.command.type.TypeMaterialId; -import com.massivecraft.massivecore.command.type.convert.TypeConverterColor; -import com.massivecraft.massivecore.command.type.convert.TypeConverterDyeColor; -import com.massivecraft.massivecore.command.type.convert.TypeConverterEnchant; -import com.massivecraft.massivecore.command.type.convert.TypeConverterItemFlag; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; -import com.massivecraft.massivecore.command.type.primitive.TypeStringParsed; -import com.massivecraft.massivecore.comparator.ComparatorSmart; -import com.massivecraft.massivecore.util.InventoryUtil; -import com.massivecraft.massivecore.util.MUtil; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; - -/** - * This class makes use of primitives, collections and maps only. - * All Bukkit specific enumerations and classes are avoided. - * That means this class itself is compatible with all Bukkit server versions. - * - * We also make sure to only initialize variables with null as value. - * Null means "default" and this way we save database space as well as CPU power on class construction. - * - * This class acts as a safe intermediary for database storage. - * It is mainly used by the ItemStackAdapter and InventoryAdapter. - * It can also be used directly, for example in maps, since it provides a stable equals and hash code method (as opposed to Bukkit). - */ -@EditorMethods(true) -public class DataItemStack implements Comparable -{ - // -------------------------------------------- // - // DEFAULTS - // -------------------------------------------- // - // The default values are used in the logic of both getters and setters. - // For that reason they are immutable. - // - // We avoid null in all locations except where Bukkit makes use of null. - // Since Bukkit doesn't NPE evade much we save ourselves a lot of trouble that way. - // Especially note how all collections default to empty immutables instead of null. - - public static final transient String DEFAULT_ID = Material.AIR.name(); - public static final transient Integer DEFAULT_COUNT = 1; - public static final transient Integer DEFAULT_DAMAGE = 0; - public static final transient String DEFAULT_NAME = null; - public static final transient List DEFAULT_LORE = Collections.emptyList(); - public static final transient Map DEFAULT_ENCHANTS = Collections.emptyMap(); - public static final transient Integer DEFAULT_REPAIRCOST = 0; - public static final transient String DEFAULT_TITLE = null; - public static final transient String DEFAULT_AUTHOR = null; - public static final transient List DEFAULT_PAGES = Collections.emptyList(); - public static final transient Integer DEFAULT_COLOR = Bukkit.getItemFactory().getDefaultLeatherColor().asRGB(); - public static final transient Boolean DEFAULT_SCALING = false; - public static final transient List DEFAULT_POTION_EFFECTS = Collections.emptyList(); - public static final transient String DEFAULT_SKULL = null; - public static final transient DataFireworkEffect DEFAULT_FIREWORK_EFFECT = null; - public static final transient List DEFAULT_FIREWORK_EFFECTS = Collections.emptyList(); - public static final transient Integer DEFAULT_FIREWORK_FLIGHT = 0; - public static final transient Map DEFAULT_STORED_ENCHANTS = Collections.emptyMap(); - public static final transient Boolean DEFAULT_UNBREAKABLE = false; - public static final transient Set DEFAULT_FLAGS = Collections.emptySet(); - public static final transient Integer DEFAULT_BANNER_BASE = null; - public static final transient List DEFAULT_BANNER_PATTERNS = Collections.emptyList(); - public static final transient String DEFAULT_POTION = "water"; - public static final transient Map DEFAULT_INVENTORY = Collections.emptyMap(); - public static final transient Integer DEFAULT_POTION_COLOR = null; - public static final transient Integer DEFAULT_MAP_COLOR = null; - - // -------------------------------------------- // - // FIELDS > VERSION - // -------------------------------------------- // - - @EditorEditable(false) - @EditorVisible(false) - private int version = 1; - - // -------------------------------------------- // - // FIELDS > BASIC - // -------------------------------------------- // - - @EditorType(value = TypeMaterialId.class) - private String id = null; - public String getId() { return get(this.id, DEFAULT_ID); } - public DataItemStack setId(String id) { this.id = set(id, DEFAULT_ID); return this; } - - private Integer count = null; - public int getCount() { return get(this.count, DEFAULT_COUNT); } - public DataItemStack setCount(int count) { this.count = set(count, DEFAULT_COUNT); return this; } - - private Integer damage = null; - public int getDamage() { return get(this.damage, DEFAULT_DAMAGE); } - public DataItemStack setDamage(int damage) { this.damage = set(damage, DEFAULT_DAMAGE); return this; } - - // -------------------------------------------- // - // FIELDS > UNSPECIFIC - // -------------------------------------------- // - - @EditorType(TypeStringParsed.class) - private String name = null; - public String getName() { return get(this.name, DEFAULT_NAME); } - public DataItemStack setName(String name) { this.name = set(name, DEFAULT_NAME); return this; } - - @EditorTypeInner(TypeStringParsed.class) - private MassiveListDef lore = null; - public List getLore() { return get(this.lore, DEFAULT_LORE); } - public DataItemStack setLore(List lore) { this.lore = set(lore, DEFAULT_LORE); return this; } - - // The Bukkit ItemMeta#getEnchants() is not sorted by the enchant id. - // There may be some sort of custom sorting order, I'm not sure. - // We are however enforcing sorting by the enchant id ourselves to be sure. - @EditorTypeInner({TypeConverterEnchant.class, TypeInteger.class}) - private MassiveTreeMapDef enchants = null; - public Map getEnchants() { return get(this.enchants, DEFAULT_ENCHANTS); } - public DataItemStack setEnchants(Map enchants) { this.enchants = set(enchants, DEFAULT_ENCHANTS); return this; } - - private Integer repaircost = null; - public int getRepaircost() { return get(this.repaircost, DEFAULT_REPAIRCOST); } - public DataItemStack setRepaircost(int repaircost) { this.repaircost = set(repaircost, DEFAULT_REPAIRCOST); return this; } - - // -------------------------------------------- // - // FIELDS > BOOK - // -------------------------------------------- // - - @EditorType(TypeStringParsed.class) - private String title = null; - public String getTitle() { return get(this.title, DEFAULT_TITLE); } - public DataItemStack setTitle(String title) { this.title = set(title, DEFAULT_TITLE); return this; } - - private String author = null; - public String getAuthor() { return get(this.author, DEFAULT_AUTHOR); } - public DataItemStack setAuthor(String author) { this.author = set(author, DEFAULT_AUTHOR); return this; } - - @EditorTypeInner(TypeStringParsed.class) - private MassiveListDef pages = null; - public List getPages() { return get(this.pages, DEFAULT_PAGES); } - public DataItemStack setPages(Collection pages) { this.pages = set(pages, DEFAULT_PAGES); return this; } - - // -------------------------------------------- // - // FIELDS > LEATHER ARMOR - // -------------------------------------------- // - - @EditorType(TypeConverterColor.class) - private Integer color = null; - public Integer getColor() { return get(this.color, DEFAULT_COLOR); } - public DataItemStack setColor(int color) { this.color = set(color, DEFAULT_COLOR); return this; } - - // -------------------------------------------- // - // FIELDS > MAP - // -------------------------------------------- // - - private Boolean scaling = null; - public boolean isScaling() { return get(this.scaling, DEFAULT_SCALING); } - public DataItemStack setScaling(boolean scaling) { this.scaling = set(scaling, DEFAULT_SCALING); return this; } - - // -------------------------------------------- // - // FIELDS > POTION EFFECTS - // -------------------------------------------- // - - // TODO: Sorting? - @SerializedName("potion-effects") - private MassiveListDef potionEffects = null; - public List getPotionEffects() { return get(this.potionEffects, DEFAULT_POTION_EFFECTS); } - public DataItemStack setPotionEffects(List potionEffects) { this.potionEffects = set(potionEffects, DEFAULT_POTION_EFFECTS); return this; } - - // -------------------------------------------- // - // FIELDS > SKULL - // -------------------------------------------- // - - private String skull = null; - public String getSkull() { return get(this.skull, DEFAULT_SKULL); } - public DataItemStack setSkull(String skull) { this.skull = set(skull, DEFAULT_SKULL); return this; } - - // -------------------------------------------- // - // FIELDS > FIREWORK EFFECT - // -------------------------------------------- // - - @SerializedName("firework-effect") - private DataFireworkEffect fireworkEffect = null; - public DataFireworkEffect getFireworkEffect() { return get(this.fireworkEffect, DEFAULT_FIREWORK_EFFECT); } - public DataItemStack setFireworkEffect(DataFireworkEffect fireworkEffect) { this.fireworkEffect = set(fireworkEffect, DEFAULT_FIREWORK_EFFECT); return this; } - - // -------------------------------------------- // - // FIELDS > FIREWORK - // -------------------------------------------- // - - // TODO: Sorting? - @SerializedName("firework-effects") - private MassiveListDef fireworkEffects = null; - public List getFireworkEffects() { return get(this.fireworkEffects, DEFAULT_FIREWORK_EFFECTS); } - public DataItemStack setFireworkEffects(List fireworkEffects) { this.fireworkEffects = set(fireworkEffects, DEFAULT_FIREWORK_EFFECTS); return this; } - - // NOTE: Did not have a default specified. - @SerializedName("firework-flight") - private Integer fireworkFlight = null; - public int getFireworkFlight() { return get(this.fireworkFlight, DEFAULT_FIREWORK_FLIGHT); } - public DataItemStack setFireworkFlight(int fireworkFlight) { this.fireworkFlight = set(fireworkFlight, DEFAULT_FIREWORK_FLIGHT); return this; } - - // -------------------------------------------- // - // FIELDS > STORED ENCHANTS - // -------------------------------------------- // - - @EditorTypeInner({TypeConverterEnchant.class, TypeInteger.class}) - @SerializedName("stored-enchants") - private MassiveTreeMapDef storedEnchants = null; - public Map getStoredEnchants() { return get(this.storedEnchants, DEFAULT_STORED_ENCHANTS); } - public DataItemStack setStoredEnchants(Map storedEnchants) { this.storedEnchants = set(storedEnchants, DEFAULT_STORED_ENCHANTS); return this; } - - // -------------------------------------------- // - // FIELDS > UNBREAKABLE - // -------------------------------------------- // - // SINCE: 1.8 - - private Boolean unbreakable = null; - public boolean isUnbreakable() { return get(this.unbreakable, DEFAULT_UNBREAKABLE); } - public DataItemStack setUnbreakable(boolean unbreakable) { this.unbreakable = set(unbreakable, DEFAULT_UNBREAKABLE); return this; } - - // -------------------------------------------- // - // FIELDS > FLAGS - // -------------------------------------------- // - // SINCE: 1.8 - - @EditorTypeInner(TypeConverterItemFlag.class) - private MassiveTreeSetDef flags = null; - public Set getFlags() { return get(this.flags, DEFAULT_FLAGS); } - public DataItemStack setFlags(Set flags) { this.flags = set(flags, DEFAULT_FLAGS); return this; } - - // -------------------------------------------- // - // FIELDS > BANNER BASE - // -------------------------------------------- // - // SINCE: 1.8 - // The integer is the dye color byte representation. - // Is actually nullable in Bukkit. - - @EditorType(TypeConverterDyeColor.class) - @SerializedName("banner-base") - private Integer bannerBase = null; - public Integer getBannerBase() { return get(this.bannerBase, DEFAULT_BANNER_BASE); } - public DataItemStack setBannerBase(Integer bannerBase) { this.bannerBase = set(bannerBase, DEFAULT_BANNER_BASE); return this; } - - // -------------------------------------------- // - // FIELDS > BANNER PATTERNS - // -------------------------------------------- // - // SINCE: 1.8 - // This should really be a list and not a set. - // The order matters and is explicitly assigned. - - @SerializedName("banner") - private MassiveListDef bannerPatterns = null; - public List getBannerPatterns() { return get(this.bannerPatterns, DEFAULT_BANNER_PATTERNS); } - public DataItemStack setBannerPatterns(List bannerPatterns) { this.bannerPatterns = set(bannerPatterns, DEFAULT_BANNER_PATTERNS); return this;} - - // -------------------------------------------- // - // FIELDS > POTION - // -------------------------------------------- // - // SINCE: 1.9 - - private String potion = null; - public String getPotion() { return get(this.potion, DEFAULT_POTION); } - public DataItemStack setPotion(String potion) { this.potion = set(potion, DEFAULT_POTION); return this; } - - // -------------------------------------------- // - // FIELDS > INVENTORY - // -------------------------------------------- // - // SINCE: 1.8 - - @EditorVisible(false) - private Map inventory = null; - public Map getInventory() { return get(this.inventory, DEFAULT_INVENTORY); } - public DataItemStack setInventory(Map inventory) { this.inventory = set(inventory, DEFAULT_INVENTORY); return this; } - - // -------------------------------------------- // - // FIELDS > POTION COLOR - // -------------------------------------------- // - // SINCE: 1.11 - - @EditorType(TypeConverterColor.class) - private Integer potionColor = null; - public Integer getPotionColor() { return get(this.potionColor, DEFAULT_POTION_COLOR); } - public DataItemStack setPotionColor(Integer potionColor) { this.potionColor = set(potionColor, DEFAULT_POTION_COLOR); return this; } - - // -------------------------------------------- // - // FIELDS > MAP COLOR - // -------------------------------------------- // - // Since 1.11 - - @EditorType(TypeConverterColor.class) - private Integer mapColor = null; - public Integer getMapColor() { return get(this.mapColor, DEFAULT_MAP_COLOR); } - public DataItemStack setMapColor(Integer mapColor) { this.mapColor = set(mapColor, DEFAULT_MAP_COLOR); return this; } - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public DataItemStack() - { - - } - - public DataItemStack(ItemStack itemStack) - { - this.write(itemStack, false); - } - - // -------------------------------------------- // - // WRITE - // -------------------------------------------- // - - public void write(ItemStack itemStack, boolean a2b) - { - WriterItemStack.get().write(this, itemStack, a2b); - } - - // -------------------------------------------- // - // CONVERT ONE - // -------------------------------------------- // - - public static DataItemStack fromBukkit(ItemStack itemStack) - { - if (itemStack == null) return null; - return new DataItemStack(itemStack); - } - - public ItemStack toBukkit() - { - // Create - ItemStack ret = WriterItemStack.get().createOB(); - - // Fill - this.write(ret, true); - - // Return - return ret; - } - - public static ItemStack toBukkit(DataItemStack dataItemStack) - { - if (dataItemStack == null) return null; - return dataItemStack.toBukkit(); - } - - // -------------------------------------------- // - // CONVERT MANY - // -------------------------------------------- // - - public static void fromBukkit(Iterable itemStacks, Collection dataItemStacks) - { - for (ItemStack itemStack : itemStacks) - { - dataItemStacks.add(fromBukkit(itemStack)); - } - } - - public static List fromBukkit(Iterable itemStacks) - { - // Create - List ret = new MassiveList<>(); - - // Fill - fromBukkit(itemStacks, ret); - - // Return - return ret; - } - - public static void fromBukkitKeys(Map itemStacks, Map dataItemStacks) - { - for (Entry entry : itemStacks.entrySet()) - { - dataItemStacks.put(fromBukkit(entry.getKey()), entry.getValue()); - } - } - - public static Map fromBukkitKeys(Map itemStacks) - { - // Create - Map ret = new MassiveMap<>(); - - // Fill - fromBukkitKeys(itemStacks, ret); - - // Return - return ret; - } - - public static void fromBukkitValues(Map itemStacks, Map dataItemStacks) - { - for (Entry entry : itemStacks.entrySet()) - { - dataItemStacks.put(entry.getKey(), fromBukkit(entry.getValue())); - } - } - - public static Map fromBukkitValues(Map itemStacks) - { - // Create - Map ret = new MassiveMap<>(); - - // Fill - fromBukkitValues(itemStacks, ret); - - // Return - return ret; - } - - public static Map fromBukkitContents(ItemStack[] contents) - { - // Catch NullEmpty - if (contents == null || contents.length == 0) return null; - - // Create - Map ret = new MassiveMap<>(); - - // Fill - for (int i = 0; i < contents.length; i++) - { - ItemStack itemStack = contents[i]; - if (InventoryUtil.isNothing(itemStack)) continue; - - ret.put(i, DataItemStack.fromBukkit(itemStack)); - } - - // Return - return ret; - } - - public static ItemStack[] toBukkitContents(Map contents) - { - // Catch NullEmpty - if (contents == null || contents.isEmpty()) return null; - - // Create - int max = Collections.max(contents.keySet()); - ItemStack[] ret = new ItemStack[max+1]; - - // Fill - for (Entry entry: contents.entrySet()) - { - int index = entry.getKey(); - DataItemStack item = entry.getValue(); - ret[index] = item.toBukkit(); - } - - // Return - return ret; - } - - // -------------------------------------------- // - // UTILITY - // -------------------------------------------- // - - public static boolean isSomething(DataItemStack dataItemStack) - { - if (dataItemStack == null) return false; - if (dataItemStack.getId().equals(DEFAULT_ID)) return false; - // In Minecraft 1.9 zero quantity is a thing. - return true; - } - - public static boolean isNothing(DataItemStack dataItemStack) - { - return ! isSomething(dataItemStack); - } - - // -------------------------------------------- // - // COMPARE & EQUALS & HASHCODE - // -------------------------------------------- // - - @Override - public int compareTo(DataItemStack that) - { - return ComparatorSmart.get().compare( - this.getId(), that.getId(), - this.getCount(), that.getCount(), - this.getDamage(), that.getDamage(), - this.getName(), that.getName(), - this.getLore(), that.getLore(), - this.getEnchants(), that.getEnchants(), - this.getRepaircost(), that.getRepaircost(), - this.getTitle(), that.getTitle(), - this.getAuthor(), that.getAuthor(), - this.getPages(), that.getPages(), - this.getColor(), that.getColor(), - this.isScaling(), that.isScaling(), - this.getPotionEffects(), that.getPotionEffects(), - this.getSkull(), that.getSkull(), - this.getFireworkEffect(), that.getFireworkEffect(), - this.getFireworkEffects(), that.getFireworkEffects(), - this.getFireworkFlight(), that.getFireworkFlight(), - this.getStoredEnchants(), that.getStoredEnchants(), - this.isUnbreakable(), that.isUnbreakable(), - this.getFlags(), that.getFlags(), - this.getBannerBase(), that.getBannerBase(), - this.getBannerPatterns(), that.getBannerPatterns(), - this.getPotion(), that.getPotion(), - this.getInventory(), that.getInventory(), - this.getPotionColor(), that.getPotionColor(), - this.getMapColor(), that.getMapColor() - ); - } - - @Override - public boolean equals(Object object) - { - if ( ! (object instanceof DataItemStack)) return false; - DataItemStack that = (DataItemStack)object; - return MUtil.equals( - this.getId(), that.getId(), - this.getCount(), that.getCount(), - this.getDamage(), that.getDamage(), - this.getName(), that.getName(), - this.getLore(), that.getLore(), - this.getEnchants(), that.getEnchants(), - this.getRepaircost(), that.getRepaircost(), - this.getTitle(), that.getTitle(), - this.getAuthor(), that.getAuthor(), - this.getPages(), that.getPages(), - this.getColor(), that.getColor(), - this.isScaling(), that.isScaling(), - this.getPotionEffects(), that.getPotionEffects(), - this.getSkull(), that.getSkull(), - this.getFireworkEffect(), that.getFireworkEffect(), - this.getFireworkEffects(), that.getFireworkEffects(), - this.getFireworkFlight(), that.getFireworkFlight(), - this.getStoredEnchants(), that.getStoredEnchants(), - this.isUnbreakable(), that.isUnbreakable(), - this.getFlags(), that.getFlags(), - this.getBannerBase(), that.getBannerBase(), - this.getBannerPatterns(), that.getBannerPatterns(), - this.getPotion(), that.getPotion(), - this.getInventory(), that.getInventory(), - this.getPotionColor(), that.getPotionColor(), - this.getMapColor(), that.getMapColor() - ); - } - - public boolean equalsItem(ItemStack item) - { - if (item == null) return false; - DataItemStack that = DataItemStack.fromBukkit(item); - return this.equals(that); - } - - public boolean isSimilar(DataItemStack that) - { - // A copy of the equals logic above. However we comment out: - // * Count - // * Repaircost - return MUtil.equals( - this.getId(), that.getId(), - // this.getCount(), that.getCount(), - this.getDamage(), that.getDamage(), - this.getName(), that.getName(), - this.getLore(), that.getLore(), - this.getEnchants(), that.getEnchants(), - // this.getRepaircost(), that.getRepaircost(), - this.getTitle(), that.getTitle(), - this.getAuthor(), that.getAuthor(), - this.getPages(), that.getPages(), - this.getColor(), that.getColor(), - this.isScaling(), that.isScaling(), - this.getPotionEffects(), that.getPotionEffects(), - this.getSkull(), that.getSkull(), - this.getFireworkEffect(), that.getFireworkEffect(), - this.getFireworkEffects(), that.getFireworkEffects(), - this.getFireworkFlight(), that.getFireworkFlight(), - this.getStoredEnchants(), that.getStoredEnchants(), - this.isUnbreakable(), that.isUnbreakable(), - this.getFlags(), that.getFlags(), - this.getBannerBase(), that.getBannerBase(), - this.getBannerPatterns(), that.getBannerPatterns(), - this.getPotion(), that.getPotion(), - this.getInventory(), that.getInventory(), - this.getPotionColor(), that.getPotionColor(), - this.getMapColor(), that.getMapColor() - ); - } - - public boolean isSimilarItem(ItemStack item) - { - if (item == null) return false; - DataItemStack that = DataItemStack.fromBukkit(item); - return this.isSimilar(that); - } - - @Override - public int hashCode() - { - return Objects.hash( - this.getId(), - this.getCount(), - this.getDamage(), - this.getName(), - this.getLore(), - this.getEnchants(), - this.getRepaircost(), - this.getTitle(), - this.getAuthor(), - this.getPages(), - this.getColor(), - this.isScaling(), - this.getPotionEffects(), - this.getSkull(), - this.getFireworkEffect(), - this.getFireworkEffects(), - this.getFireworkFlight(), - this.getStoredEnchants(), - this.isUnbreakable(), - this.getFlags(), - this.getBannerBase(), - this.getBannerPatterns(), - this.getPotion(), - this.getInventory(), - this.getPotionColor(), - this.getMapColor() - ); - } - - // -------------------------------------------- // - // GET & SET & NOTHING - // -------------------------------------------- // - - // We treat null and empty collections the same. - public static boolean isNothing(Object object) - { - if (object == null) return true; - if (object instanceof Collection) return ((Collection)object).isEmpty(); - if (object instanceof Map) return ((Map)object).isEmpty(); - return false; - } - - // Return the value unless the value is nothing then return standard instead. - public static T get(T value, T standard) - { - if (isNothing(value)) return standard; - return value; - } - - // Return the value unless the value is nothing or standard then return null instead. - // Perform shallow copy on supported collections. - @SuppressWarnings("unchecked") - public static R set(T value, T standard) - { - if (isNothing(value)) return null; - if (value.equals(standard)) return null; - - if (value instanceof List) - { - List list = (List)value; - return (R) new MassiveListDef<>(list); - } - else if (value instanceof Set) - { - Set set = (Set)value; - return (R) new MassiveTreeSetDef<>(ComparatorSmart.get(), set); - } - else if (value instanceof Map) - { - Map map = (Map)value; - return (R) new MassiveTreeMapDef<>(ComparatorSmart.get(), map); - } - - return (R) value; - } - -} diff --git a/src/com/massivecraft/massivecore/item/DataPotionEffect.java b/src/com/massivecraft/massivecore/item/DataPotionEffect.java deleted file mode 100644 index ded9cb0a..00000000 --- a/src/com/massivecraft/massivecore/item/DataPotionEffect.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.command.editor.annotation.EditorMethods; -import com.massivecraft.massivecore.command.editor.annotation.EditorType; -import com.massivecraft.massivecore.command.type.convert.TypeConverterColor; -import com.massivecraft.massivecore.command.type.convert.TypeConverterPotionEffectType; -import com.massivecraft.massivecore.comparator.ComparatorSmart; -import com.massivecraft.massivecore.util.MUtil; -import org.bukkit.potion.PotionEffect; - -import java.util.Objects; - -import static com.massivecraft.massivecore.item.DataItemStack.get; -import static com.massivecraft.massivecore.item.DataItemStack.set; - -@EditorMethods(true) -public class DataPotionEffect implements Comparable -{ - // -------------------------------------------- // - // DEFAULTS - // -------------------------------------------- // - - public static final transient Integer DEFAULT_ID = null; - public static final transient Integer DEFAULT_DURATION = 20 * 3 * 60; - public static final transient Integer DEFAULT_AMPLIFIER = 0; - public static final transient Boolean DEFAULT_AMBIENT = false; - public static final transient Boolean DEFAULT_PARTICLES = true; - public static final transient Integer DEFAULT_COLOR = null; - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - @EditorType(value = TypeConverterPotionEffectType.class) - private Integer id = null; - public Integer getId() { return get(this.id, DEFAULT_ID); } - public DataPotionEffect setId(Integer id) { this.id = set(id, DEFAULT_ID); return this; } - - private Integer duration = null; - public int getDuration() { return get(this.duration, DEFAULT_DURATION); } - public DataPotionEffect setDuration(int duration) { this.duration = set(duration, DEFAULT_DURATION); return this; } - - private Integer amplifier = null; - public int getAmplifier() { return get(this.amplifier, DEFAULT_AMPLIFIER); } - public DataPotionEffect setAmplifier(int amplifier) { this.amplifier = set(amplifier, DEFAULT_AMPLIFIER); return this; } - - private Boolean ambient = null; - public boolean isAmbient() { return get(this.ambient, DEFAULT_AMBIENT); } - public DataPotionEffect setAmbient(boolean ambient) { this.ambient = set(ambient, DEFAULT_AMBIENT); return this; } - - // SINCE: 1.8 - private Boolean particles = null; - public boolean isParticles() { return get(this.particles, DEFAULT_PARTICLES); } - public DataPotionEffect setParticles(boolean particles) { this.particles = set(particles, DEFAULT_PARTICLES); return this; } - - // SINCE: 1.9 - @EditorType(TypeConverterColor.class) - private Integer color = null; - public Integer getColor() { return get(this.color, DEFAULT_COLOR); } - public DataPotionEffect setColor(Integer color) { this.color = set(color, DEFAULT_COLOR); return this; } - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public DataPotionEffect() - { - - } - - public DataPotionEffect(PotionEffect potionEffect) - { - this.write(potionEffect, false); - } - - // -------------------------------------------- // - // WRITE - // -------------------------------------------- // - - public void write(PotionEffect potionEffect, boolean a2b) - { - WriterPotionEffect.get().write(this, potionEffect, a2b); - } - - // -------------------------------------------- // - // TO BUKKIT - // -------------------------------------------- // - - public PotionEffect toBukkit() - { - // Create - PotionEffect ret = WriterPotionEffect.get().createOB(); - - // Fill - this.write(ret, true); - - // Return - return ret; - } - - // -------------------------------------------- // - // COMPARE & EQUALS & HASHCODE - // -------------------------------------------- // - - @Override - public int compareTo(DataPotionEffect that) - { - return ComparatorSmart.get().compare( - this.getId(), that.getId(), - this.getDuration(), that.getDuration(), - this.getAmplifier(), that.getAmplifier(), - this.isAmbient(), that.isAmbient(), - this.isParticles(), that.isParticles(), - this.getColor(), that.getColor() - ); - } - - // TODO: Use compare instead to avoid bugs? - @Override - public boolean equals(Object object) - { - if ( ! (object instanceof DataPotionEffect)) return false; - DataPotionEffect that = (DataPotionEffect)object; - - return MUtil.equals( - this.getId(), that.getId(), - this.getDuration(), that.getDuration(), - this.getAmplifier(), that.getAmplifier(), - this.isAmbient(), that.isAmbient(), - this.isParticles(), that.isParticles(), - this.getColor(), that.getColor() - ); - } - - @Override - public int hashCode() - { - return Objects.hash( - this.getId(), - this.getDuration(), - this.getAmplifier(), - this.isAmbient(), - this.isParticles(), - this.getColor() - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/PotionUtil.java b/src/com/massivecraft/massivecore/item/PotionUtil.java deleted file mode 100644 index 4f788c71..00000000 --- a/src/com/massivecraft/massivecore/item/PotionUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.google.common.collect.BiMap; -import com.google.common.collect.ImmutableBiMap; -import org.bukkit.potion.Potion; -import org.bukkit.potion.PotionData; -import org.bukkit.potion.PotionType; - -@SuppressWarnings("deprecation") -public class PotionUtil -{ - public static PotionData toPotionData(int damage) - { - try - { - Potion potion = Potion.fromDamage(damage); - PotionType type = potion.getType(); - boolean extended = potion.hasExtendedDuration(); - boolean upgraded = (potion.getLevel() >= 2); - - // This section serves two purposes: - // 1. Avoid slow exceptions over for invalid damage values. - // 2. Lenient upgrade to Minecraft 1.9. Keep what we can. - // If a potion was both upgraded and extended we keep the upgraded and remove the extended. - if (type == null) return null; - if (extended && ! type.isExtendable()) return null; - if (upgraded && ! type.isUpgradeable()) return null; - if (upgraded && extended) extended = false; - - return new PotionData(type, extended, upgraded); - } - catch (Exception e) - { - return null; - } - } - - public static PotionData toPotionData(String potionString) - { - if (potionString == null) return null; - return POTION_ID_TO_DATA.get(potionString); - } - - public static String toPotionString(PotionData potionData) - { - if (potionData == null) return null; - return POTION_ID_TO_DATA.inverse().get(potionData); - } - - private static final BiMap POTION_ID_TO_DATA = ImmutableBiMap.builder() - // REGULAR - .put("empty", new PotionData(PotionType.UNCRAFTABLE, false, false)) - .put("water", new PotionData(PotionType.WATER, false, false)) - .put("mundane", new PotionData(PotionType.MUNDANE, false, false)) - .put("thick", new PotionData(PotionType.THICK, false, false)) - .put("awkward", new PotionData(PotionType.AWKWARD, false, false)) - .put("night_vision", new PotionData(PotionType.NIGHT_VISION, false, false)) - .put("invisibility", new PotionData(PotionType.INVISIBILITY, false, false)) - .put("leaping", new PotionData(PotionType.JUMP, false, false)) - .put("fire_resistance", new PotionData(PotionType.FIRE_RESISTANCE, false, false)) - .put("swiftness", new PotionData(PotionType.SPEED, false, false)) - .put("slowness", new PotionData(PotionType.SLOWNESS, false, false)) - .put("water_breathing", new PotionData(PotionType.WATER_BREATHING, false, false)) - .put("healing", new PotionData(PotionType.INSTANT_HEAL, false, false)) - .put("harming", new PotionData(PotionType.INSTANT_DAMAGE, false, false)) - .put("poison", new PotionData(PotionType.POISON, false, false)) - .put("regeneration", new PotionData(PotionType.REGEN, false, false)) - .put("strength", new PotionData(PotionType.STRENGTH, false, false)) - .put("weakness", new PotionData(PotionType.WEAKNESS, false, false)) - .put("luck", new PotionData(PotionType.LUCK, false, false)) - - // UPGRADABLE - .put("strong_leaping", new PotionData(PotionType.JUMP, false, true)) - .put("strong_swiftness", new PotionData(PotionType.SPEED, false, true)) - .put("strong_healing", new PotionData(PotionType.INSTANT_HEAL, false, true)) - .put("strong_harming", new PotionData(PotionType.INSTANT_DAMAGE, false, true)) - .put("strong_poison", new PotionData(PotionType.POISON, false, true)) - .put("strong_regeneration", new PotionData(PotionType.REGEN, false, true)) - .put("strong_strength", new PotionData(PotionType.STRENGTH, false, true)) - - // EXTENDABLE - .put("long_night_vision", new PotionData(PotionType.NIGHT_VISION, true, false)) - .put("long_invisibility", new PotionData(PotionType.INVISIBILITY, true, false)) - .put("long_leaping", new PotionData(PotionType.JUMP, true, false)) - .put("long_fire_resistance", new PotionData(PotionType.FIRE_RESISTANCE, true, false)) - .put("long_swiftness", new PotionData(PotionType.SPEED, true, false)) - .put("long_slowness", new PotionData(PotionType.SLOWNESS, true, false)) - .put("long_water_breathing", new PotionData(PotionType.WATER_BREATHING, true, false)) - .put("long_poison", new PotionData(PotionType.POISON, true, false)) - .put("long_regeneration", new PotionData(PotionType.REGEN, true, false)) - .put("long_strength", new PotionData(PotionType.STRENGTH, true, false)) - .put("long_weakness", new PotionData(PotionType.WEAKNESS, true, false)) - - // BUILD - .build(); - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstract.java b/src/com/massivecraft/massivecore/item/WriterAbstract.java deleted file mode 100644 index 2425cb21..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstract.java +++ /dev/null @@ -1,329 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.Engine; -import com.massivecraft.massivecore.MassiveCoreMConf; -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.command.type.primitive.TypeBooleanOn; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.ReflectionUtil; -import com.massivecraft.massivecore.util.Txt; - -import java.util.Arrays; -import java.util.List; - -// A = What we are writing from. -// B = What we are writing to. -// -// O = The base object. Not yet morphed into specific class. -// C = The specific class object. Often the same as O but at times very different. -// F = The field class. Used for field writing. -// -// D = The data class. Used for sending arbitrary data along. -// -// TIP: Simply set to Object if you are not using a certain generic. -// -public abstract class WriterAbstract extends Engine -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstract(Class classCA, Class classCB) - { - this.classCA = classCA; - this.classCB = classCB; - } - - // -------------------------------------------- // - // WRITERS - // -------------------------------------------- // - // Writer have dependencies and child writers. - - // A dependency is another writer that must be successfully activated for this writer to function. - // For that reason the dependencies are activated just after the setup logic. - // Examples would be WriterPotionEffect and WriterFireworkEffect. - // They are implicitly required for some ItemStack field writers. - private List> dependencyClasses = new MassiveList<>(); - public List> getDependencyClasses() { return this.dependencyClasses; } - public void addDependencyClasses(Class... dependencyClasses) { this.getDependencyClasses().addAll(Arrays.asList(dependencyClasses)); } - - // This is the writer classes scheduled to be used at setup. - // We do not yet know if they are compatible with this Minecraft version. - // All, some or none of them may fail. - private List> writerClasses = new MassiveList<>(); - public List> getWriterClasses() { return this.writerClasses; } - public void addWriterClasses(Class... writerClasses) { this.getWriterClasses().addAll(Arrays.asList(writerClasses)); } - - // These are the actually functional child writers. - // This list should only contain writers that passed the setup routine. - private List> writers = new MassiveList<>(); - public List> getWriters() { return this.writers; } - - // Here is the logic to perform the dependency and child writer setup. - public void setupDependencies() - { - for (Class dependencyClass : this.getDependencyClasses()) - { - this.setupWriter(dependencyClass, false); - } - } - - public void setupWriters() - { - for (Class writerClass : this.getWriterClasses()) - { - this.setupWriter(writerClass, true); - } - } - - @SuppressWarnings("unchecked") - public void setupWriter(Class writerClass, boolean add) - { - try - { - WriterAbstract writer = ReflectionUtil.getSingletonInstance(writerClass); - - if ( ! writer.isActive()) writer.setActive(this.getActivePlugin()); - - if (add) this.getWriters().add((WriterAbstract)writer); - } - catch (Throwable t) - { - this.reportSuccess(false, writerClass.getSimpleName(), t); - } - } - - public void reportSuccess(boolean success) - { - this.reportSuccess(success, this.getClass().getSimpleName()); - } - - public void reportSuccess(boolean success, String name) - { - this.reportSuccess(success, name, null); - } - - public void reportSuccess(boolean success, String name, Throwable t) - { - if ( ! MassiveCoreMConf.get().debugEnabled) return; - - // Create - List messages = new MassiveList<>(); - - // Fill - String message; - - // Main - message = Txt.parse("%s %s", name, TypeBooleanOn.get().getVisual(success)); - messages.add(message); - - // Throwable - if (t != null) - { - message = Txt.parse("### %s %s", t.getClass().getSimpleName(), t.getMessage()); - messages.add(message); - for (String s : MUtil.getStackTraceStrings(Arrays.asList(t.getStackTrace()), true)) - { - message = Txt.parse("--> %s", s); - messages.add(message); - } - } - - // Send - for (String s : messages) - { - this.getActivePlugin().log(s); - } - } - - // -------------------------------------------- // - // ACTIVE - // -------------------------------------------- // - - @Override - public void setActive(boolean active) - { - if (active) - { - // Setup Self - this.setupSelf(); - - // Setup Dependencies - this.setupDependencies(); - - // Report This Success - this.reportSuccess(true); - - // Setup Writers - this.setupWriters(); - } - - super.setActive(active); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - public OA createOA() - { - return null; - } - - public OB createOB() - { - return null; - } - - // -------------------------------------------- // - // CLASSES - // -------------------------------------------- // - - private final Class classCA; - public Class getClassCA() { return this.classCA; } - - private final Class classCB; - public Class getClassCB() { return this.classCB; } - - // -------------------------------------------- // - // MORPH - // -------------------------------------------- // - // Per default the morph is just a secure cast. - // If the morph fails it means the writer was not applicable. - // In those cases we don't want a crash. - // We rather silently continue. - - @SuppressWarnings("unchecked") - public CA morphA(OA oa) - { - if (this.getClassCA() != null && ! this.getClassCA().isAssignableFrom(oa.getClass())) return null; - return (CA)oa; - } - - @SuppressWarnings("unchecked") - public CB morphB(OB ob) - { - if (this.getClassCB() != null && ! this.getClassCB().isAssignableFrom(ob.getClass())) return null; - return (CB)ob; - } - - // -------------------------------------------- // - // SETUP - // -------------------------------------------- // - - public void setupSelf() - { - // Create O - OA oa = this.createOA(); - OB ob = this.createOB(); - - // Demand O - if (oa == null) throw new NullPointerException("Couldn't Create OA"); - if (ob == null) throw new NullPointerException("Couldn't Create OB"); - - // Morph - CA ca = this.morphA(oa); - CB cb = this.morphB(ob); - - // Demand C - if (ca == null) throw new NullPointerException("Couldn't Create CA"); - if (cb == null) throw new NullPointerException("Couldn't Create CB"); - - // Write (to provoke extra much) - this.write(oa, ob, true); - this.write(oa, ob, false); - } - - // -------------------------------------------- // - // WRITE - // -------------------------------------------- // - - public void write(OA oa, OB ob, boolean a2b) - { - this.write(oa, ob, null, a2b); - } - - public void write(OA oa, OB ob, D d, boolean a2b) - { - // if ( ! this.isActive()) throw new IllegalStateException("not active " + this.getClass().getName()); - - if (oa == null) throw new NullPointerException("oa"); - if (ob == null) throw new NullPointerException("ob"); - - CA ca = this.morphA(oa); - if (ca == null) return; - - CB cb = this.morphB(ob); - if (cb == null) return; - - this.writeInner(oa, ob, ca, cb, d, a2b); - } - - public void writeInner(OA oa, OB ob, CA ca, CB cb, D d, boolean a2b) - { - for (WriterAbstract writer : this.getWriters()) - { - writer.write(ca, cb, d, a2b); - } - - if (a2b) - { - FA fa = getA(ca, d); - FB fb = toB(fa); - setB(cb, fb, d); - } - else - { - FB fb = getB(cb, d); - FA fa = toA(fb); - setA(ca, fa, d); - } - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - public FA getA(CA ca, D d) - { - return null; - } - - public void setA(CA ca, FA fa, D d) - { - - } - - public FB getB(CB cb, D d) - { - return null; - } - - public void setB(CB cb, FB fb, D d) - { - - } - - // -------------------------------------------- // - // CONVERT - // -------------------------------------------- // - - private Converter converterTo = ConverterDefault.get(); - public Converter getConverterTo() { return this.converterTo; } - public void setConverterTo(Converter converterTo) { this.converterTo = converterTo; } - - private Converter converterFrom = ConverterDefault.get(); - public Converter getConverterFrom() { return this.converterFrom; } - public void setConverterFrom(Converter converterFrom) { this.converterFrom = converterFrom; } - - public FA toA(FB fb) - { - return this.getConverterFrom().convert(fb); - } - - public FB toB(FA fa) - { - return this.getConverterTo().convert(fa); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractBannerPattern.java b/src/com/massivecraft/massivecore/item/WriterAbstractBannerPattern.java deleted file mode 100644 index 24014aa9..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractBannerPattern.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.DyeColor; -import org.bukkit.block.banner.Pattern; -import org.bukkit.block.banner.PatternType; - - -public abstract class WriterAbstractBannerPattern extends WriterAbstractReflect -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractBannerPattern(String fieldName) - { - super(Pattern.class, fieldName); - } - - public WriterAbstractBannerPattern() - { - this(null); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public DataBannerPattern createOA() - { - return new DataBannerPattern(); - } - - @Override - public Pattern createOB() - { - return new Pattern(DyeColor.WHITE, PatternType.BASE); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractFireworkEffect.java b/src/com/massivecraft/massivecore/item/WriterAbstractFireworkEffect.java deleted file mode 100644 index 4e40c9a6..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractFireworkEffect.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; -import org.bukkit.FireworkEffect; - - -public abstract class WriterAbstractFireworkEffect extends WriterAbstractReflect -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractFireworkEffect(String fieldName) - { - super(FireworkEffect.class, fieldName); - } - - public WriterAbstractFireworkEffect() - { - this(null); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public DataFireworkEffect createOA() - { - return new DataFireworkEffect(); - } - - @Override - public FireworkEffect createOB() - { - return FireworkEffect.builder().withColor(Color.GREEN).build(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStack.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStack.java deleted file mode 100644 index c5e7267b..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemStack.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.nms.NmsItemStackCreate; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public abstract class WriterAbstractItemStack extends WriterAbstract -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractItemStack(Class classCB) - { - super(DataItemStack.class, classCB); - } - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private Material material = Material.STONE; - public Material getMaterial() { return this.material; } - public void setMaterial(Material material) { this.material = material; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public DataItemStack createOA() - { - return new DataItemStack(); - } - - @SuppressWarnings("unchecked") - @Override - public OB createOB() - { - return (OB) this.createItemStack(); - } - - // -------------------------------------------- // - // CREATE INNER - // -------------------------------------------- // - - public ItemStack createItemStack() - { - ItemStack ret = NmsItemStackCreate.get().create(); - ret.setType(this.getMaterial()); - return ret; - } - - // -------------------------------------------- // - // CREATE & WRITE - // -------------------------------------------- // - // We some times need to access the ItemStack even at deeper levels of writing. - // With that in mind we pass it along in the data generic. - - @Override - public void writeInner(DataItemStack oa, OB ob, DataItemStack ca, CB cb, ItemStack d, boolean a2b) - { - // Ensure there is an ItemStack data. Create if necessary (used by setup method). - if (d == null) d = (ItemStack)((ob instanceof ItemStack) ? ob : this.createItemStack()); - super.writeInner(oa, ob, ca, cb, d, a2b); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackField.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackField.java deleted file mode 100644 index 0a4e6fed..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackField.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; - -public abstract class WriterAbstractItemStackField extends WriterAbstractItemStack -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractItemStackField() - { - super(ItemStack.class); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMeta.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMeta.java deleted file mode 100644 index 26513074..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMeta.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.Banner; -import org.bukkit.block.BlockState; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.ItemMeta; - -public abstract class WriterAbstractItemStackMeta extends WriterAbstractItemStack -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractItemStackMeta(Class classCB) - { - super(classCB); - } - - // -------------------------------------------- // - // CREATE INNER - // -------------------------------------------- // - - public ItemMeta createItemMeta() - { - return createItemMeta(this.createItemStack()); - } - - public static ItemMeta createItemMeta(ItemStack itemStack) - { - return itemStack.getItemMeta(); - } - - // -------------------------------------------- // - // BANNER - // -------------------------------------------- // - - public static Banner getBanner(BlockStateMeta meta, boolean creative) - { - // Null - if (meta == null) return null; - - // Creative - if (!meta.hasBlockState() && !creative) return null; - - // Try - try - { - BlockState ret = meta.getBlockState(); - if ( ! (ret instanceof Banner)) return null; - return (Banner)ret; - } - catch (Exception e) - { - // Catch errors such as: throw new IllegalStateException("Missing blockState for " + material); - return null; - } - } - - public static void setBanner(BlockStateMeta meta, Banner banner) - { - // Null - if (meta == null) return; - if (banner == null) return; - - // Dodge Update NPE - if (banner.getBaseColor() == null) return; - - // Update with Force without Physics - banner.update(true, false); - - // Apply - meta.setBlockState(banner); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaField.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaField.java deleted file mode 100644 index 17b069dd..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaField.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.meta.ItemMeta; - -public abstract class WriterAbstractItemStackMetaField extends WriterAbstractItemStackMeta -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractItemStackMetaField(Class classCB) - { - super(classCB); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public ItemMeta createOB() - { - return this.createItemMeta(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaMorph.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaMorph.java deleted file mode 100644 index 62635a9b..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaMorph.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public abstract class WriterAbstractItemStackMetaMorph extends WriterAbstractItemStackMeta -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractItemStackMetaMorph() - { - super(ItemMeta.class); - } - - // -------------------------------------------- // - // MORPH - // -------------------------------------------- // - - @Override - public ItemMeta morphB(ItemStack ob) - { - return createItemMeta(ob); - } - - // -------------------------------------------- // - // WRITE - // -------------------------------------------- // - - @Override - public void writeInner(DataItemStack oa, ItemStack ob, DataItemStack ca, ItemMeta cb, ItemStack d, boolean a2b) - { - super.writeInner(oa, ob, ca, cb, d, a2b); - - // Write Back - if (a2b) ob.setItemMeta(cb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractPotionEffect.java b/src/com/massivecraft/massivecore/item/WriterAbstractPotionEffect.java deleted file mode 100644 index 62c31c51..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractPotionEffect.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public abstract class WriterAbstractPotionEffect extends WriterAbstractReflect -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractPotionEffect(String fieldName) - { - super(PotionEffect.class, fieldName); - } - - public WriterAbstractPotionEffect() - { - this(null); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public DataPotionEffect createOA() - { - return new DataPotionEffect(); - } - - @Override - public PotionEffect createOB() - { - return new PotionEffect(PotionEffectType.SPEED, 1, 1); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractReflect.java b/src/com/massivecraft/massivecore/item/WriterAbstractReflect.java deleted file mode 100644 index d13b47f3..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractReflect.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.util.ReflectionUtil; - -import java.lang.reflect.Field; - -public abstract class WriterAbstractReflect extends WriterAbstract -{ - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private final Field field; - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public WriterAbstractReflect(Class clazz, String fieldName) - { - super(null, null); - this.field = (fieldName == null ? null : ReflectionUtil.getField(clazz, fieldName)); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public void setB(CB cb, FB fb, Object d) - { - if (this.field == null) return; - ReflectionUtil.setField(this.field, cb, fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterBannerPattern.java b/src/com/massivecraft/massivecore/item/WriterBannerPattern.java deleted file mode 100644 index 00cd039b..00000000 --- a/src/com/massivecraft/massivecore/item/WriterBannerPattern.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.massivecraft.massivecore.item; - -public class WriterBannerPattern extends WriterAbstractBannerPattern -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterBannerPattern i = new WriterBannerPattern(); - public static WriterBannerPattern get() { return i; } - public WriterBannerPattern() - { - this.addWriterClasses( - WriterBannerPatternId.class, - WriterBannerPatternColor.class - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterBannerPatternColor.java b/src/com/massivecraft/massivecore/item/WriterBannerPatternColor.java deleted file mode 100644 index 4911b299..00000000 --- a/src/com/massivecraft/massivecore/item/WriterBannerPatternColor.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.DyeColor; -import org.bukkit.block.banner.Pattern; - -public class WriterBannerPatternColor extends WriterAbstractBannerPattern -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterBannerPatternColor i = new WriterBannerPatternColor(); - public static WriterBannerPatternColor get() { return i; } - public WriterBannerPatternColor() - { - super("color"); - this.setConverterTo(ConverterToDyeColor.get()); - this.setConverterFrom(ConverterFromDyeColor.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataBannerPattern ca, Object d) - { - return ca.getColor(); - } - - @Override - public void setA(DataBannerPattern ca, Integer fa, Object d) - { - ca.setColor(fa); - } - - @Override - public DyeColor getB(Pattern cb, Object d) - { - return cb.getColor(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterBannerPatternId.java b/src/com/massivecraft/massivecore/item/WriterBannerPatternId.java deleted file mode 100644 index 81c5fe27..00000000 --- a/src/com/massivecraft/massivecore/item/WriterBannerPatternId.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.block.banner.Pattern; -import org.bukkit.block.banner.PatternType; - -public class WriterBannerPatternId extends WriterAbstractBannerPattern -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterBannerPatternId i = new WriterBannerPatternId(); - public static WriterBannerPatternId get() { return i; } - public WriterBannerPatternId() - { - super("pattern"); - this.setConverterTo(ConverterToBannerPatternType.get()); - this.setConverterFrom(ConverterFromBannerPatternType.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public String getA(DataBannerPattern ca, Object d) - { - return ca.getId(); - } - - @Override - public void setA(DataBannerPattern ca, String fa, Object d) - { - ca.setId(fa); - } - - @Override - public PatternType getB(Pattern cb, Object d) - { - return cb.getPattern(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterFireworkEffect.java b/src/com/massivecraft/massivecore/item/WriterFireworkEffect.java deleted file mode 100644 index 9d335fb2..00000000 --- a/src/com/massivecraft/massivecore/item/WriterFireworkEffect.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.massivecraft.massivecore.item; - -public class WriterFireworkEffect extends WriterAbstractFireworkEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterFireworkEffect i = new WriterFireworkEffect(); - public static WriterFireworkEffect get() { return i; } - public WriterFireworkEffect() - { - this.addWriterClasses( - WriterFireworkEffectFlicker.class, - WriterFireworkEffectTrail.class, - WriterFireworkEffectColors.class, - WriterFireworkEffectFadeColors.class, - WriterFireworkEffectType.class - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterFireworkEffectColors.java b/src/com/massivecraft/massivecore/item/WriterFireworkEffectColors.java deleted file mode 100644 index bc6dbd79..00000000 --- a/src/com/massivecraft/massivecore/item/WriterFireworkEffectColors.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.google.common.collect.ImmutableList; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; - -import java.util.List; - -public class WriterFireworkEffectColors extends WriterAbstractFireworkEffect, ImmutableList> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterFireworkEffectColors i = new WriterFireworkEffectColors(); - public static WriterFireworkEffectColors get() { return i; } - public WriterFireworkEffectColors() - { - super("colors"); - this.setConverterTo(ConverterToColors.get()); - this.setConverterFrom(ConverterFromColors.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataFireworkEffect ca, Object d) - { - return ca.getColors(); - } - - @Override - public void setA(DataFireworkEffect ca, List fa, Object d) - { - ca.setColors(fa); - } - - @Override - public ImmutableList getB(FireworkEffect cb, Object d) - { - return (ImmutableList) cb.getColors(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterFireworkEffectFadeColors.java b/src/com/massivecraft/massivecore/item/WriterFireworkEffectFadeColors.java deleted file mode 100644 index cd33a7b9..00000000 --- a/src/com/massivecraft/massivecore/item/WriterFireworkEffectFadeColors.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.google.common.collect.ImmutableList; -import org.bukkit.Color; -import org.bukkit.FireworkEffect; - -import java.util.List; - -public class WriterFireworkEffectFadeColors extends WriterAbstractFireworkEffect, ImmutableList> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterFireworkEffectFadeColors i = new WriterFireworkEffectFadeColors(); - public static WriterFireworkEffectFadeColors get() { return i; } - public WriterFireworkEffectFadeColors() - { - super("fadeColors"); - this.setConverterTo(ConverterToColors.get()); - this.setConverterFrom(ConverterFromColors.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataFireworkEffect ca, Object d) - { - return ca.getFadeColors(); - } - - @Override - public void setA(DataFireworkEffect ca, List fa, Object d) - { - ca.setFadeColors(fa); - } - - @Override - public ImmutableList getB(FireworkEffect cb, Object d) - { - return (ImmutableList) cb.getFadeColors(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterFireworkEffectFlicker.java b/src/com/massivecraft/massivecore/item/WriterFireworkEffectFlicker.java deleted file mode 100644 index 9f2979a2..00000000 --- a/src/com/massivecraft/massivecore/item/WriterFireworkEffectFlicker.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; - -public class WriterFireworkEffectFlicker extends WriterAbstractFireworkEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterFireworkEffectFlicker i = new WriterFireworkEffectFlicker(); - public static WriterFireworkEffectFlicker get() { return i; } - public WriterFireworkEffectFlicker() - { - super("flicker"); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Boolean getA(DataFireworkEffect ca, Object d) - { - return ca.hasFlicker(); - } - - @Override - public void setA(DataFireworkEffect ca, Boolean fa, Object d) - { - ca.setFlicker(fa); - } - - @Override - public Boolean getB(FireworkEffect cb, Object d) - { - return cb.hasFlicker(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterFireworkEffectTrail.java b/src/com/massivecraft/massivecore/item/WriterFireworkEffectTrail.java deleted file mode 100644 index b9d320e5..00000000 --- a/src/com/massivecraft/massivecore/item/WriterFireworkEffectTrail.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; - -public class WriterFireworkEffectTrail extends WriterAbstractFireworkEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterFireworkEffectTrail i = new WriterFireworkEffectTrail(); - public static WriterFireworkEffectTrail get() { return i; } - public WriterFireworkEffectTrail() - { - super("trail"); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Boolean getA(DataFireworkEffect ca, Object d) - { - return ca.hasTrail(); - } - - @Override - public void setA(DataFireworkEffect ca, Boolean fa, Object d) - { - ca.setTrail(fa); - } - - @Override - public Boolean getB(FireworkEffect cb, Object d) - { - return cb.hasTrail(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterFireworkEffectType.java b/src/com/massivecraft/massivecore/item/WriterFireworkEffectType.java deleted file mode 100644 index 7b813bdb..00000000 --- a/src/com/massivecraft/massivecore/item/WriterFireworkEffectType.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; -import org.bukkit.FireworkEffect.Type; - -public class WriterFireworkEffectType extends WriterAbstractFireworkEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterFireworkEffectType i = new WriterFireworkEffectType(); - public static WriterFireworkEffectType get() { return i; } - public WriterFireworkEffectType() - { - super("type"); - this.setConverterTo(ConverterToFireworkEffectType.get()); - this.setConverterFrom(ConverterFromFireworkEffectType.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public String getA(DataFireworkEffect ca, Object d) - { - return ca.getType(); - } - - @Override - public void setA(DataFireworkEffect ca, String fa, Object d) - { - ca.setType(fa); - } - - @Override - public Type getB(FireworkEffect cb, Object d) - { - return cb.getType(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStack.java b/src/com/massivecraft/massivecore/item/WriterItemStack.java deleted file mode 100644 index 3c6d68a7..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStack.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.massivecraft.massivecore.item; - -public class WriterItemStack extends WriterAbstractItemStackField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStack i = new WriterItemStack(); - public static WriterItemStack get() { return i; } - public WriterItemStack() - { - this.addWriterClasses( - // BASIC - WriterItemStackId.class, - WriterItemStackCount.class, - WriterItemStackDamage.class, - - // META - WriterItemStackMeta.class - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackCount.java b/src/com/massivecraft/massivecore/item/WriterItemStackCount.java deleted file mode 100644 index 4a177595..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackCount.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; - -public class WriterItemStackCount extends WriterAbstractItemStackField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackCount i = new WriterItemStackCount(); - public static WriterItemStackCount get() { return i; } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getCount(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setCount(fa); - } - - @Override - public Integer getB(ItemStack cb, ItemStack d) - { - return cb.getAmount(); - } - - @Override - public void setB(ItemStack cb, Integer fb, ItemStack d) - { - cb.setAmount(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackDamage.java b/src/com/massivecraft/massivecore/item/WriterItemStackDamage.java deleted file mode 100644 index f7ea38ad..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackDamage.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; - -public class WriterItemStackDamage extends WriterAbstractItemStackField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackDamage i = new WriterItemStackDamage(); - public static WriterItemStackDamage get() { return i; } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getDamage(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setDamage(fa); - } - - @Override - public Integer getB(ItemStack cb, ItemStack d) - { - return Integer.valueOf(cb.getDurability()); - } - - @Override - public void setB(ItemStack cb, Integer fb, ItemStack d) - { - cb.setDurability(fb.shortValue()); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackId.java b/src/com/massivecraft/massivecore/item/WriterItemStackId.java deleted file mode 100644 index 129c049d..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackId.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class WriterItemStackId extends WriterAbstractItemStackField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackId i = new WriterItemStackId(); - public static WriterItemStackId get() { return i; } - public WriterItemStackId() - { - this.setConverterTo(ConverterToMaterial.get()); - this.setConverterFrom(ConverterFromMaterial.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public String getA(DataItemStack ca, ItemStack d) - { - return ca.getId(); - } - - @Override - public void setA(DataItemStack ca, String fa, ItemStack d) - { - ca.setId(fa); - } - - @Override - public Material getB(ItemStack cb, ItemStack d) - { - return cb.getType(); - } - - @Override - public void setB(ItemStack cb, Material fb, ItemStack d) - { - cb.setType(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMeta.java b/src/com/massivecraft/massivecore/item/WriterItemStackMeta.java deleted file mode 100644 index c6f4be05..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMeta.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.massivecraft.massivecore.item; - -public class WriterItemStackMeta extends WriterAbstractItemStackMetaMorph -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMeta i = new WriterItemStackMeta(); - public static WriterItemStackMeta get() { return i; } - public WriterItemStackMeta() - { - this.addWriterClasses( - // UNSPECIFIC - WriterItemStackMetaName.class, - WriterItemStackMetaLore.class, - WriterItemStackMetaEnchants.class, - WriterItemStackMetaRepaircost.class, - - // BOOK - WriterItemStackMetaTitle.class, - WriterItemStackMetaAuthor.class, - WriterItemStackMetaPages.class, - - // LEATHER ARMOR - WriterItemStackMetaColor.class, - - // MAP - WriterItemStackMetaScaling.class, - WriterItemStackMetaMapColor.class, - - // POTION EFFECTS - WriterItemStackMetaPotionEffects.class, - - // SKULL - WriterItemStackMetaSkull.class, - - // FIREWORK EFFECT - WriterItemStackMetaFireworkEffect.class, - - // FIREWORK - WriterItemStackMetaFireworkEffects.class, - WriterItemStackMetaFireworkFlight.class, - - // STORED ENCHANTS - WriterItemStackMetaStoredEnchants.class, - - // UNBREAKABLE - WriterItemStackMetaUnbreakable.class, - - // FLAGS - WriterItemStackMetaFlags.class, - - // BANNER - WriterItemStackMetaBannerBase.class, - WriterItemStackMetaBannerPatterns.class, - - // SHIELD - WriterItemStackMetaShieldBase.class, - WriterItemStackMetaShieldPatterns.class, - - // POTION - WriterItemStackMetaPotion.class, - WriterItemStackMetaPotionColor.class, - - // INVENTORY - WriterItemStackMetaInventory.class - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaAuthor.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaAuthor.java deleted file mode 100644 index 5f454842..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaAuthor.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; - -public class WriterItemStackMetaAuthor extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaAuthor i = new WriterItemStackMetaAuthor(); - public static WriterItemStackMetaAuthor get() { return i; } - - public WriterItemStackMetaAuthor() - { - super(BookMeta.class); - this.setMaterial(Material.WRITTEN_BOOK); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public String getA(DataItemStack ca, ItemStack d) - { - return ca.getAuthor(); - } - - @Override - public void setA(DataItemStack ca, String fa, ItemStack d) - { - ca.setAuthor(fa); - } - - @Override - public String getB(BookMeta cb, ItemStack d) - { - return cb.getAuthor(); - } - - @Override - public void setB(BookMeta cb, String fb, ItemStack d) - { - cb.setAuthor(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerBase.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerBase.java deleted file mode 100644 index 20893e9d..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerBase.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; - -public class WriterItemStackMetaBannerBase extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaBannerBase i = new WriterItemStackMetaBannerBase(); - public static WriterItemStackMetaBannerBase get() { return i; } - public WriterItemStackMetaBannerBase() - { - super(BannerMeta.class); - this.setMaterial(Material.BANNER); - this.setConverterTo(ConverterToDyeColor.get()); - this.setConverterFrom(ConverterFromDyeColor.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getBannerBase(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setBannerBase(fa); - } - - @Override - public DyeColor getB(BannerMeta cb, ItemStack d) - { - return cb.getBaseColor(); - } - - @Override - public void setB(BannerMeta cb, DyeColor fb, ItemStack d) - { - cb.setBaseColor(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerPatterns.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerPatterns.java deleted file mode 100644 index 803fb49f..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerPatterns.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.block.banner.Pattern; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BannerMeta; - -import java.util.List; - -public class WriterItemStackMetaBannerPatterns extends WriterAbstractItemStackMetaField, List> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaBannerPatterns i = new WriterItemStackMetaBannerPatterns(); - public static WriterItemStackMetaBannerPatterns get() { return i; } - public WriterItemStackMetaBannerPatterns() - { - super(BannerMeta.class); - this.setMaterial(Material.BANNER); - this.setConverterTo(ConverterToBannerPatterns.get()); - this.setConverterFrom(ConverterFromBannerPatterns.get()); - this.addDependencyClasses( - WriterBannerPattern.class - ); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataItemStack ca, ItemStack d) - { - return ca.getBannerPatterns(); - } - - @Override - public void setA(DataItemStack ca, List fa, ItemStack d) - { - ca.setBannerPatterns(fa); - } - - @Override - public List getB(BannerMeta cb, ItemStack d) - { - return cb.getPatterns(); - } - - @Override - public void setB(BannerMeta cb, List fb, ItemStack d) - { - cb.setPatterns(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaColor.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaColor.java deleted file mode 100644 index 5cda58ca..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaColor.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; - -public class WriterItemStackMetaColor extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaColor i = new WriterItemStackMetaColor(); - public static WriterItemStackMetaColor get() { return i; } - - public WriterItemStackMetaColor() - { - super(LeatherArmorMeta.class); - this.setMaterial(Material.LEATHER_HELMET); - this.setConverterTo(ConverterToColor.get()); - this.setConverterFrom(ConverterFromColor.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getColor(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setColor(fa); - } - - @Override - public Color getB(LeatherArmorMeta cb, ItemStack d) - { - return cb.getColor(); - } - - @Override - public void setB(LeatherArmorMeta cb, Color fb, ItemStack d) - { - cb.setColor(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaEnchants.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaEnchants.java deleted file mode 100644 index f1260dcf..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaEnchants.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.Map; -import java.util.Map.Entry; - -public class WriterItemStackMetaEnchants extends WriterAbstractItemStackMetaField, Map> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaEnchants i = new WriterItemStackMetaEnchants(); - public static WriterItemStackMetaEnchants get() { return i; } - public WriterItemStackMetaEnchants() - { - super(ItemMeta.class); - this.setConverterTo(ConverterToEnchants.get()); - this.setConverterFrom(ConverterFromEnchants.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Map getA(DataItemStack ca, ItemStack d) - { - return ca.getEnchants(); - } - - @Override - public void setA(DataItemStack ca, Map fa, ItemStack d) - { - ca.setEnchants(fa); - } - - @Override - public Map getB(ItemMeta cb, ItemStack d) - { - return cb.getEnchants(); - } - - @Override - public void setB(ItemMeta cb, Map fb, ItemStack d) - { - for (Entry entry : fb.entrySet()) - { - cb.addEnchant(entry.getKey(), entry.getValue(), true); - } - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffect.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffect.java deleted file mode 100644 index 358c49f9..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffect.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.FireworkEffectMeta; - -public class WriterItemStackMetaFireworkEffect extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaFireworkEffect i = new WriterItemStackMetaFireworkEffect(); - public static WriterItemStackMetaFireworkEffect get() { return i; } - public WriterItemStackMetaFireworkEffect() - { - super(FireworkEffectMeta.class); - this.setMaterial(Material.FIREWORK_CHARGE); - this.setConverterTo(ConverterToFireworkEffect.get()); - this.setConverterFrom(ConverterFromFireworkEffect.get()); - this.addDependencyClasses( - WriterFireworkEffect.class - ); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public DataFireworkEffect getA(DataItemStack ca, ItemStack d) - { - return ca.getFireworkEffect(); - } - - @Override - public void setA(DataItemStack ca, DataFireworkEffect fa, ItemStack d) - { - ca.setFireworkEffect(fa); - } - - @Override - public FireworkEffect getB(FireworkEffectMeta cb, ItemStack d) - { - return cb.getEffect(); - } - - @Override - public void setB(FireworkEffectMeta cb, FireworkEffect fb, ItemStack d) - { - cb.setEffect(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffects.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffects.java deleted file mode 100644 index 94229a2c..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffects.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.FireworkEffect; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.FireworkMeta; - -import java.util.List; - -public class WriterItemStackMetaFireworkEffects extends WriterAbstractItemStackMetaField, List> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaFireworkEffects i = new WriterItemStackMetaFireworkEffects(); - public static WriterItemStackMetaFireworkEffects get() { return i; } - public WriterItemStackMetaFireworkEffects() - { - super(FireworkMeta.class); - this.setMaterial(Material.FIREWORK); - this.setConverterTo(ConverterToFireworkEffects.get()); - this.setConverterFrom(ConverterFromFireworkEffects.get()); - this.addDependencyClasses( - WriterFireworkEffect.class - ); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataItemStack ca, ItemStack d) - { - return ca.getFireworkEffects(); - } - - @Override - public void setA(DataItemStack ca, List fa, ItemStack d) - { - ca.setFireworkEffects(fa); - } - - @Override - public List getB(FireworkMeta cb, ItemStack d) - { - return cb.getEffects(); - } - - @Override - public void setB(FireworkMeta cb, List fb, ItemStack d) - { - cb.addEffects(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkFlight.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkFlight.java deleted file mode 100644 index 24cae3ba..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkFlight.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.FireworkMeta; - -public class WriterItemStackMetaFireworkFlight extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaFireworkFlight i = new WriterItemStackMetaFireworkFlight(); - public static WriterItemStackMetaFireworkFlight get() { return i; } - public WriterItemStackMetaFireworkFlight() - { - super(FireworkMeta.class); - this.setMaterial(Material.FIREWORK); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getFireworkFlight(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setFireworkFlight(fa); - } - - @Override - public Integer getB(FireworkMeta cb, ItemStack d) - { - return cb.getPower(); - } - - @Override - public void setB(FireworkMeta cb, Integer fb, ItemStack d) - { - fb = Math.min(fb, 127); - fb = Math.max(fb, 0); - - cb.setPower(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFlags.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFlags.java deleted file mode 100644 index cdd19e19..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFlags.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.Set; - -public class WriterItemStackMetaFlags extends WriterAbstractItemStackMetaField, Set> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaFlags i = new WriterItemStackMetaFlags(); - public static WriterItemStackMetaFlags get() { return i; } - public WriterItemStackMetaFlags() - { - super(ItemMeta.class); - this.setConverterTo(ConverterToItemFlags.get()); - this.setConverterFrom(ConverterFromItemFlags.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Set getA(DataItemStack ca, ItemStack d) - { - return ca.getFlags(); - } - - @Override - public void setA(DataItemStack ca, Set fa, ItemStack d) - { - ca.setFlags(fa); - } - - @Override - public Set getB(ItemMeta cb, ItemStack d) - { - return cb.getItemFlags(); - } - - @Override - public void setB(ItemMeta cb, Set fb, ItemStack d) - { - cb.addItemFlags(fb.toArray(new ItemFlag[0])); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaInventory.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaInventory.java deleted file mode 100644 index f8401e1b..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaInventory.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.util.InventoryUtil; -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BlockStateMeta; - -import java.util.Map; - -// NOTE: We take ItemStack[] (inventory contents) instead of Inventories to accommodate the different sizes of inventories better. -// It is not possible to create an inventory with less then 9 slots, but hoppers or brewing stands only have 5. -// By using arrays, we avoid huge efforts to retain inventory order, because that happens relatively naturally. -public class WriterItemStackMetaInventory extends WriterAbstractItemStackMetaField, ItemStack[]> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaInventory i = new WriterItemStackMetaInventory(); - public static WriterItemStackMetaInventory get() { return i; } - public WriterItemStackMetaInventory() - { - super(BlockStateMeta.class); - this.setMaterial(Material.CHEST); - this.setConverterTo(ConverterToInventoryContents.get()); - this.setConverterFrom(ConverterFromInventoryContents.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Map getA(DataItemStack ca, ItemStack d) - { - return ca.getInventory(); - } - - @Override - public void setA(DataItemStack ca, Map fa, ItemStack d) - { - ca.setInventory(fa); - } - - @Override - public ItemStack[] getB(BlockStateMeta cb, ItemStack d) - { - // Null - if (cb == null) return null; - - // Creative - if (!cb.hasBlockState()) return null; - - // Try - try - { - BlockState ret = cb.getBlockState(); - if (!(ret instanceof InventoryHolder)) return null; - return ((InventoryHolder) ret).getInventory().getContents(); - } - catch (Exception e) - { - // Catch errors such as: throw new IllegalStateException("Missing blockState for " + material); - return null; - } - } - - @Override - public void setB(BlockStateMeta blockStateMeta, ItemStack[] storedInventory, ItemStack d) - { - // Null - if (blockStateMeta == null) return; - if (storedInventory == null || storedInventory.length == 0) return; - - // Try - BlockState ret; - Inventory inventory; - - try - { - ret = blockStateMeta.getBlockState(); - if (!(ret instanceof InventoryHolder)) return; - inventory = ((InventoryHolder)ret).getInventory(); - } - catch (Exception e) - { - // Catch errors such as: throw new IllegalStateException("Missing blockState for " + material); - return; - } - - // Apply - InventoryUtil.setContentsAll(inventory, storedInventory); - - // Set - blockStateMeta.setBlockState(ret); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaLore.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaLore.java deleted file mode 100644 index 49460ed9..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaLore.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.List; - -public class WriterItemStackMetaLore extends WriterAbstractItemStackMetaField, List> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaLore i = new WriterItemStackMetaLore(); - public static WriterItemStackMetaLore get() { return i; } - public WriterItemStackMetaLore() - { - super(ItemMeta.class); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataItemStack ca, ItemStack d) - { - return ca.getLore(); - } - - @Override - public void setA(DataItemStack ca, List fa, ItemStack d) - { - ca.setLore(fa); - } - - @Override - public List getB(ItemMeta cb, ItemStack d) - { - return cb.getLore(); - } - - @Override - public void setB(ItemMeta cb, List fb, ItemStack d) - { - cb.setLore(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaMapColor.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaMapColor.java deleted file mode 100644 index 24b4c638..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaMapColor.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.MapMeta; - -public class WriterItemStackMetaMapColor extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaMapColor i = new WriterItemStackMetaMapColor(); - public static WriterItemStackMetaMapColor get() { return i; } - - public WriterItemStackMetaMapColor() - { - super(MapMeta.class); - this.setMaterial(Material.MAP); - this.setConverterTo(ConverterToColor.get()); - this.setConverterFrom(ConverterFromColor.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getMapColor(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setMapColor(fa); - } - - @Override - public Color getB(MapMeta cb, ItemStack d) - { - return cb.getColor(); - } - - @Override - public void setB(MapMeta cb, Color fb, ItemStack d) - { - cb.setColor(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaName.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaName.java deleted file mode 100644 index fa1e7ec4..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaName.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public class WriterItemStackMetaName extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaName i = new WriterItemStackMetaName(); - public static WriterItemStackMetaName get() { return i; } - public WriterItemStackMetaName() - { - super(ItemMeta.class); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public String getA(DataItemStack ca, ItemStack d) - { - return ca.getName(); - } - - @Override - public void setA(DataItemStack ca, String fa, ItemStack d) - { - ca.setName(fa); - } - - @Override - public String getB(ItemMeta cb, ItemStack d) - { - return cb.getDisplayName(); - } - - @Override - public void setB(ItemMeta cb, String fb, ItemStack d) - { - cb.setDisplayName(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPages.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPages.java deleted file mode 100644 index c5673068..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPages.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; - -import java.util.List; - -public class WriterItemStackMetaPages extends WriterAbstractItemStackMetaField, List> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaPages i = new WriterItemStackMetaPages(); - public static WriterItemStackMetaPages get() { return i; } - public WriterItemStackMetaPages() - { - super(BookMeta.class); - this.setMaterial(Material.WRITTEN_BOOK); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataItemStack ca, ItemStack d) - { - return ca.getPages(); - } - - @Override - public void setA(DataItemStack ca, List fa, ItemStack d) - { - ca.setPages(fa); - } - - @Override - public List getB(BookMeta cb, ItemStack d) - { - return cb.getPages(); - } - - @Override - public void setB(BookMeta cb, List fb, ItemStack d) - { - cb.setPages(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotion.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotion.java deleted file mode 100644 index 14f1cdd3..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotion.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; - -public class WriterItemStackMetaPotion extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaPotion i = new WriterItemStackMetaPotion(); - public static WriterItemStackMetaPotion get() { return i; } - public WriterItemStackMetaPotion() - { - super(PotionMeta.class); - this.setMaterial(Material.POTION); - } - - // -------------------------------------------- // - // WRITE - // -------------------------------------------- // - // Due to the complexity of the upgrade mechanic we override writeInner. - // - // There are two interesting data points. - // 1. The old item damage. - // 2. The new item potion. - // These two data points exists in both our implementation and in Bukkit. - // - // Serialization is simple. - // We just assume everything is properly upgraded and save accordingly. - // - // The hard part is deserialization (writing to Bukkit). - // - // In Minecraft 1.8 the damage value was used to store the potion effects. - // In Minecraft 1.9 the damage value is no longer used and the potion effect is stored by string instead. - // - // Sticking to the damage value for serialization is not feasible. - // Minecraft 1.9 adds new potion effects that did not exist in Minecraft 1.8 such as LUCK. - // - // Thus we upgrade the database from damage values to the new potion string where possible. - // Invalid old damage values that does not make any sense are left as is. - // - // TODO: As Ulumulu1510 indicated the material must be changed for throwable/splash potions. - // TODO: That must be implemented for a 100% proper upgrading experience. - - @Override - public void writeInner(DataItemStack oa, ItemMeta ob, DataItemStack ca, PotionMeta cb, ItemStack d, boolean a2b) - { - if (a2b) - { - // DESERIALIZE - - // Create - PotionData potionData = null; - - // Fill > Old - int damage = ca.getDamage(); - if (damage != DataItemStack.DEFAULT_DAMAGE) - { - potionData = PotionUtil.toPotionData(damage); - if (potionData != null) - { - d.setDurability((short)0); - } - } - - // Fill > New / Default - if (potionData == null) - { - String potionString = ca.getPotion(); - potionData = PotionUtil.toPotionData(potionString); - } - - // Set - cb.setBasePotionData(potionData); - } - else - { - // SERIALIZE - PotionData potionData = cb.getBasePotionData(); - String potionString = PotionUtil.toPotionString(potionData); - ca.setPotion(potionString); - } - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionColor.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionColor.java deleted file mode 100644 index b37ab53a..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionColor.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.PotionMeta; - -public class WriterItemStackMetaPotionColor extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaPotionColor i = new WriterItemStackMetaPotionColor(); - public static WriterItemStackMetaPotionColor get() { return i; } - - public WriterItemStackMetaPotionColor() - { - super(PotionMeta.class); - this.setMaterial(Material.POTION); - this.setConverterTo(ConverterToColor.get()); - this.setConverterFrom(ConverterFromColor.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getPotionColor(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setPotionColor(fa); - } - - @Override - public Color getB(PotionMeta cb, ItemStack d) - { - return cb.getColor(); - } - - @Override - public void setB(PotionMeta cb, Color fb, ItemStack d) - { - cb.setColor(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionEffects.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionEffects.java deleted file mode 100644 index 73abed9b..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionEffects.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionEffect; - -import java.util.List; - -public class WriterItemStackMetaPotionEffects extends WriterAbstractItemStackMetaField, List> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaPotionEffects i = new WriterItemStackMetaPotionEffects(); - public static WriterItemStackMetaPotionEffects get() { return i; } - - public WriterItemStackMetaPotionEffects() - { - super(PotionMeta.class); - this.setMaterial(Material.POTION); - this.setConverterTo(ConverterToPotionEffects.get()); - this.setConverterFrom(ConverterFromPotionEffects.get()); - this.addDependencyClasses( - WriterPotionEffect.class - ); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataItemStack ca, ItemStack d) - { - return ca.getPotionEffects(); - } - - @Override - public void setA(DataItemStack ca, List fa, ItemStack d) - { - ca.setPotionEffects(fa); - } - - @Override - public List getB(PotionMeta cb, ItemStack d) - { - return cb.getCustomEffects(); - } - - @Override - public void setB(PotionMeta cb, List fb, ItemStack d) - { - for (PotionEffect potionEffect : fb) - { - cb.addCustomEffect(potionEffect, false); - } - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaRepaircost.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaRepaircost.java deleted file mode 100644 index 8e556ad2..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaRepaircost.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.Repairable; - -public class WriterItemStackMetaRepaircost extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaRepaircost i = new WriterItemStackMetaRepaircost(); - public static WriterItemStackMetaRepaircost get() { return i; } - public WriterItemStackMetaRepaircost() - { - super(Repairable.class); - this.setMaterial(Material.IRON_CHESTPLATE); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getRepaircost(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setRepaircost(fa); - } - - @Override - public Integer getB(Repairable cb, ItemStack d) - { - return cb.getRepairCost(); - } - - @Override - public void setB(Repairable cb, Integer fb, ItemStack d) - { - cb.setRepairCost(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaScaling.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaScaling.java deleted file mode 100644 index 0c1141f1..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaScaling.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.MapMeta; - -public class WriterItemStackMetaScaling extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaScaling i = new WriterItemStackMetaScaling(); - public static WriterItemStackMetaScaling get() { return i; } - public WriterItemStackMetaScaling() - { - super(MapMeta.class); - this.setMaterial(Material.MAP); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Boolean getA(DataItemStack ca, ItemStack d) - { - return ca.isScaling(); - } - - @Override - public void setA(DataItemStack ca, Boolean fa, ItemStack d) - { - ca.setScaling(fa); - } - - @Override - public Boolean getB(MapMeta cb, ItemStack d) - { - return cb.isScaling(); - } - - @Override - public void setB(MapMeta cb, Boolean fb, ItemStack d) - { - cb.setScaling(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaShieldBase.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaShieldBase.java deleted file mode 100644 index a4964353..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaShieldBase.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.block.Banner; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BlockStateMeta; - -public class WriterItemStackMetaShieldBase extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaShieldBase i = new WriterItemStackMetaShieldBase(); - public static WriterItemStackMetaShieldBase get() { return i; } - public WriterItemStackMetaShieldBase() - { - super(BlockStateMeta.class); - this.setMaterial(Material.SHIELD); - this.setConverterTo(ConverterToDyeColor.get()); - this.setConverterFrom(ConverterFromDyeColor.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataItemStack ca, ItemStack d) - { - return ca.getBannerBase(); - } - - @Override - public void setA(DataItemStack ca, Integer fa, ItemStack d) - { - ca.setBannerBase(fa); - } - - @Override - public DyeColor getB(BlockStateMeta cb, ItemStack d) - { - // Get - boolean creative = false; - Banner banner = getBanner(cb, creative); - if (banner == null) return null; - - // Return - return banner.getBaseColor(); - } - - @Override - public void setB(BlockStateMeta cb, DyeColor fb, ItemStack d) - { - // Get - boolean creative = (fb != null); - Banner banner = getBanner(cb, creative); - if (banner == null) return; - - // Change - banner.setBaseColor(fb); - - // Set - setBanner(cb, banner); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaShieldPatterns.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaShieldPatterns.java deleted file mode 100644 index 6ce064dc..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaShieldPatterns.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.collections.MassiveList; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.block.Banner; -import org.bukkit.block.banner.Pattern; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BlockStateMeta; - -import java.util.List; - -public class WriterItemStackMetaShieldPatterns extends WriterAbstractItemStackMetaField, List> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaShieldPatterns i = new WriterItemStackMetaShieldPatterns(); - public static WriterItemStackMetaShieldPatterns get() { return i; } - - public WriterItemStackMetaShieldPatterns() - { - super(BlockStateMeta.class); - this.setMaterial(Material.SHIELD); - this.setConverterTo(ConverterToBannerPatterns.get()); - this.setConverterFrom(ConverterFromBannerPatterns.get()); - this.addDependencyClasses( - WriterBannerPattern.class - ); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public List getA(DataItemStack ca, ItemStack d) - { - return ca.getBannerPatterns(); - } - - @Override - public void setA(DataItemStack ca, List fa, ItemStack d) - { - ca.setBannerPatterns(fa); - } - - @Override - public List getB(BlockStateMeta cb, ItemStack d) - { - // Get - boolean creative = false; - Banner banner = getBanner(cb, creative); - if (banner == null) return null; - - // Return - try { - return banner.getPatterns(); - } catch (NullPointerException e) { - return new MassiveList<>(); - } - } - - @Override - public void setB(BlockStateMeta cb, List fb, ItemStack d) - { - // Get - boolean creative = (fb != null && !fb.isEmpty()); - Banner banner = getBanner(cb, creative); - if (banner == null) return; - - // Change - banner.setPatterns(fb); - - // Ensure Base - if (banner.getBaseColor() == null && !banner.getPatterns().isEmpty()) - { - banner.setBaseColor(DyeColor.BLACK); - } - - // Set - setBanner(cb, banner); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull.java deleted file mode 100644 index 48491250..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.massivecraft.massivecore.item; - -import com.massivecraft.massivecore.Couple; -import com.massivecraft.massivecore.nms.NmsSkullMeta; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - -import java.util.UUID; - -public class WriterItemStackMetaSkull extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaSkull i = new WriterItemStackMetaSkull(); - public static WriterItemStackMetaSkull get() { return i; } - public WriterItemStackMetaSkull() - { - super(SkullMeta.class); - this.setMaterial(Material.SKULL_ITEM); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public String getA(DataItemStack ca, ItemStack d) - { - return ca.getSkull(); - } - - @Override - public void setA(DataItemStack ca, String fa, ItemStack d) - { - if (fa != null) fa = fa.toLowerCase(); - ca.setSkull(fa); - } - - @Override - public String getB(SkullMeta cb, ItemStack d) - { - return cb.getOwner(); - } - - @Override - public void setB(SkullMeta cb, String fb, ItemStack d) - { - String name = fb; - UUID id = null; - - NmsSkullMeta nms = NmsSkullMeta.get(); - - Couple resolved = nms.resolve(name, id); - name = resolved.getFirst(); - id = resolved.getSecond(); - - if (name != null || id != null) - { - nms.set(cb, name, id); - } - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaStoredEnchants.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaStoredEnchants.java deleted file mode 100644 index ac55fc86..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaStoredEnchants.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.EnchantmentStorageMeta; - -import java.util.Map; -import java.util.Map.Entry; - -public class WriterItemStackMetaStoredEnchants extends WriterAbstractItemStackMetaField, Map> -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaStoredEnchants i = new WriterItemStackMetaStoredEnchants(); - public static WriterItemStackMetaStoredEnchants get() { return i; } - public WriterItemStackMetaStoredEnchants() - { - super(EnchantmentStorageMeta.class); - this.setMaterial(Material.ENCHANTED_BOOK); - this.setConverterTo(ConverterToEnchants.get()); - this.setConverterFrom(ConverterFromEnchants.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Map getA(DataItemStack ca, ItemStack d) - { - return ca.getStoredEnchants(); - } - - @Override - public void setA(DataItemStack ca, Map fa, ItemStack d) - { - ca.setStoredEnchants(fa); - } - - @Override - public Map getB(EnchantmentStorageMeta cb, ItemStack d) - { - return cb.getStoredEnchants(); - } - - @Override - public void setB(EnchantmentStorageMeta cb, Map fb, ItemStack d) - { - for (Entry entry : fb.entrySet()) - { - cb.addStoredEnchant(entry.getKey(), entry.getValue(), true); - } - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaTitle.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaTitle.java deleted file mode 100644 index 986500b8..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaTitle.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BookMeta; - -public class WriterItemStackMetaTitle extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaTitle i = new WriterItemStackMetaTitle(); - public static WriterItemStackMetaTitle get() { return i; } - public WriterItemStackMetaTitle() - { - super(BookMeta.class); - this.setMaterial(Material.WRITTEN_BOOK); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public String getA(DataItemStack ca, ItemStack d) - { - return ca.getTitle(); - } - - @Override - public void setA(DataItemStack ca, String fa, ItemStack d) - { - ca.setTitle(fa); - } - - @Override - public String getB(BookMeta cb, ItemStack d) - { - return cb.getTitle(); - } - - @Override - public void setB(BookMeta cb, String fb, ItemStack d) - { - cb.setTitle(fb); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaUnbreakable.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaUnbreakable.java deleted file mode 100644 index e0319590..00000000 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaUnbreakable.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public class WriterItemStackMetaUnbreakable extends WriterAbstractItemStackMetaField -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterItemStackMetaUnbreakable i = new WriterItemStackMetaUnbreakable(); - public static WriterItemStackMetaUnbreakable get() { return i; } - public WriterItemStackMetaUnbreakable() - { - super(ItemMeta.class); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Boolean getA(DataItemStack ca, ItemStack d) - { - return ca.isUnbreakable(); - } - - @Override - public void setA(DataItemStack ca, Boolean fa, ItemStack d) - { - ca.setUnbreakable(fa); - } - - @Override - public Boolean getB(ItemMeta cb, ItemStack d) - { - try { - return cb.spigot().isUnbreakable(); - } catch (UnsupportedOperationException ignored) { - return false; - } - } - - @Override - public void setB(ItemMeta cb, Boolean fb, ItemStack d) - { - try { - cb.spigot().setUnbreakable(fb); - } catch (UnsupportedOperationException ignored) { - // ignored - } - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterPotionEffect.java b/src/com/massivecraft/massivecore/item/WriterPotionEffect.java deleted file mode 100644 index adadd206..00000000 --- a/src/com/massivecraft/massivecore/item/WriterPotionEffect.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.massivecraft.massivecore.item; - -public class WriterPotionEffect extends WriterAbstractPotionEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterPotionEffect i = new WriterPotionEffect(); - public static WriterPotionEffect get() { return i; } - public WriterPotionEffect() - { - this.addWriterClasses( - WriterPotionEffectId.class, - WriterPotionEffectDuraction.class, - WriterPotionEffectAmplifier.class, - WriterPotionEffectAmbient.class, - WriterPotionEffectParticles.class, - WriterPotionEffectColor.class - ); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterPotionEffectAmbient.java b/src/com/massivecraft/massivecore/item/WriterPotionEffectAmbient.java deleted file mode 100644 index 1c437d3c..00000000 --- a/src/com/massivecraft/massivecore/item/WriterPotionEffectAmbient.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class WriterPotionEffectAmbient extends WriterAbstractPotionEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterPotionEffectAmbient i = new WriterPotionEffectAmbient(); - public static WriterPotionEffectAmbient get() { return i; } - public WriterPotionEffectAmbient() - { - super("ambient"); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Boolean getA(DataPotionEffect ca, Object d) - { - return ca.isAmbient(); - } - - @Override - public void setA(DataPotionEffect ca, Boolean fa, Object d) - { - ca.setAmbient(fa); - } - - @Override - public Boolean getB(PotionEffect cb, Object d) - { - return cb.isAmbient(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterPotionEffectAmplifier.java b/src/com/massivecraft/massivecore/item/WriterPotionEffectAmplifier.java deleted file mode 100644 index 5e9ed5be..00000000 --- a/src/com/massivecraft/massivecore/item/WriterPotionEffectAmplifier.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class WriterPotionEffectAmplifier extends WriterAbstractPotionEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterPotionEffectAmplifier i = new WriterPotionEffectAmplifier(); - public static WriterPotionEffectAmplifier get() { return i; } - public WriterPotionEffectAmplifier() - { - super("amplifier"); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataPotionEffect ca, Object d) - { - return ca.getAmplifier(); - } - - @Override - public void setA(DataPotionEffect ca, Integer fa, Object d) - { - ca.setAmplifier(fa); - } - - @Override - public Integer getB(PotionEffect cb, Object d) - { - return cb.getAmplifier(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterPotionEffectColor.java b/src/com/massivecraft/massivecore/item/WriterPotionEffectColor.java deleted file mode 100644 index 9a5becf3..00000000 --- a/src/com/massivecraft/massivecore/item/WriterPotionEffectColor.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Color; -import org.bukkit.potion.PotionEffect; - -public class WriterPotionEffectColor extends WriterAbstractPotionEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterPotionEffectColor i = new WriterPotionEffectColor(); - public static WriterPotionEffectColor get() { return i; } - public WriterPotionEffectColor() - { - super("color"); - this.setConverterTo(ConverterToColor.get()); - this.setConverterFrom(ConverterFromColor.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataPotionEffect ca, Object d) - { - return ca.getColor(); - } - - @Override - public void setA(DataPotionEffect ca, Integer fa, Object d) - { - ca.setColor(fa); - } - - @Override - public Color getB(PotionEffect cb, Object d) - { - return cb.getColor(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterPotionEffectDuraction.java b/src/com/massivecraft/massivecore/item/WriterPotionEffectDuraction.java deleted file mode 100644 index 4e31fe71..00000000 --- a/src/com/massivecraft/massivecore/item/WriterPotionEffectDuraction.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class WriterPotionEffectDuraction extends WriterAbstractPotionEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterPotionEffectDuraction i = new WriterPotionEffectDuraction(); - public static WriterPotionEffectDuraction get() { return i; } - public WriterPotionEffectDuraction() - { - super("duration"); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataPotionEffect ca, Object d) - { - return ca.getDuration(); - } - - @Override - public void setA(DataPotionEffect ca, Integer fa, Object d) - { - ca.setDuration(fa); - } - - @Override - public Integer getB(PotionEffect cb, Object d) - { - return cb.getDuration(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterPotionEffectId.java b/src/com/massivecraft/massivecore/item/WriterPotionEffectId.java deleted file mode 100644 index e32fd5ee..00000000 --- a/src/com/massivecraft/massivecore/item/WriterPotionEffectId.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class WriterPotionEffectId extends WriterAbstractPotionEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterPotionEffectId i = new WriterPotionEffectId(); - public static WriterPotionEffectId get() { return i; } - public WriterPotionEffectId() - { - super("type"); - this.setConverterTo(ConverterToPotionEffectType.get()); - this.setConverterFrom(ConverterFromPotionEffectType.get()); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Integer getA(DataPotionEffect ca, Object d) - { - return ca.getId(); - } - - @Override - public void setA(DataPotionEffect ca, Integer fa, Object d) - { - ca.setId(fa); - } - - @Override - public PotionEffectType getB(PotionEffect cb, Object d) - { - return cb.getType(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterPotionEffectParticles.java b/src/com/massivecraft/massivecore/item/WriterPotionEffectParticles.java deleted file mode 100644 index a17a6ac9..00000000 --- a/src/com/massivecraft/massivecore/item/WriterPotionEffectParticles.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.potion.PotionEffect; - -public class WriterPotionEffectParticles extends WriterAbstractPotionEffect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static final WriterPotionEffectParticles i = new WriterPotionEffectParticles(); - public static WriterPotionEffectParticles get() { return i; } - public WriterPotionEffectParticles() - { - super("particles"); - } - - // -------------------------------------------- // - // ACCESS - // -------------------------------------------- // - - @Override - public Boolean getA(DataPotionEffect ca, Object d) - { - return ca.isParticles(); - } - - @Override - public void setA(DataPotionEffect ca, Boolean fa, Object d) - { - ca.setParticles(fa); - } - - @Override - public Boolean getB(PotionEffect cb, Object d) - { - return cb.hasParticles(); - } - -} diff --git a/src/com/massivecraft/massivecore/nms/NmsItemStackCreate.java b/src/com/massivecraft/massivecore/nms/NmsItemStackCreate.java deleted file mode 100644 index 3d665862..00000000 --- a/src/com/massivecraft/massivecore/nms/NmsItemStackCreate.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.massivecraft.massivecore.nms; - -import com.massivecraft.massivecore.mixin.Mixin; -import org.bukkit.inventory.ItemStack; - -public class NmsItemStackCreate extends Mixin -{ - // -------------------------------------------- // - // DEFAULT - // -------------------------------------------- // - - private static NmsItemStackCreate d = new NmsItemStackCreate().setAlternatives( - NmsItemStackCreate17R4P.class, - NmsItemStackCreateFallback.class - ); - - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static NmsItemStackCreate i = d; - public static NmsItemStackCreate get() { return i; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - public ItemStack create() - { - throw notImplemented(); - } - -} diff --git a/src/com/massivecraft/massivecore/nms/NmsItemStackCreate17R4P.java b/src/com/massivecraft/massivecore/nms/NmsItemStackCreate17R4P.java deleted file mode 100644 index 7a0b0641..00000000 --- a/src/com/massivecraft/massivecore/nms/NmsItemStackCreate17R4P.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.massivecraft.massivecore.nms; - -import com.massivecraft.massivecore.particleeffect.ReflectionUtils.PackageType; -import com.massivecraft.massivecore.util.ReflectionUtil; -import org.bukkit.inventory.ItemStack; - -import java.lang.reflect.Constructor; - -public class NmsItemStackCreate17R4P extends NmsItemStackCreate -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static NmsItemStackCreate17R4P i = new NmsItemStackCreate17R4P(); - public static NmsItemStackCreate17R4P get () { return i; } - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - // net.minecraft.server.ItemStack - private Class classNmsItemStack; - - // org.bukkit.craftbukkit.inventory.CraftItemStack - private Class classCraftItemStack; - - // org.bukkit.craftbukkit.inventory.CraftItemStack(net.minecraft.server.ItemStack) - private Constructor constructorCraftItemStack; - - // -------------------------------------------- // - // SETUP - // -------------------------------------------- // - - @Override - public void setup() throws Throwable - { - this.classNmsItemStack = getClassCraftItemStack(); - this.classCraftItemStack = PackageType.CRAFTBUKKIT_INVENTORY.getClass("CraftItemStack"); - this.constructorCraftItemStack = ReflectionUtil.getConstructor(this.classCraftItemStack, this.classNmsItemStack); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public ItemStack create() - { - return ReflectionUtil.invokeConstructor(this.constructorCraftItemStack, (Object)null); - } - - // -------------------------------------------- // - // UTIL - // -------------------------------------------- // - - public static Class getClassCraftItemStack() throws ClassNotFoundException - { - if (ServerType.get() == ServerType.FORGE) - { - return PackageType.MINECRAFT_ITEM.getClass("ItemStack"); - } - else - { - return PackageType.MINECRAFT_SERVER.getClass("ItemStack"); - } - } - - public static Class getClassCraftItemStackCatch() - { - try - { - return getClassCraftItemStack(); - } - catch (Throwable t) - { - return null; - } - } - -} diff --git a/src/com/massivecraft/massivecore/nms/NmsItemStackCreateFallback.java b/src/com/massivecraft/massivecore/nms/NmsItemStackCreateFallback.java deleted file mode 100644 index 1129dd83..00000000 --- a/src/com/massivecraft/massivecore/nms/NmsItemStackCreateFallback.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.massivecraft.massivecore.nms; - -import org.bukkit.inventory.ItemStack; - -public class NmsItemStackCreateFallback extends NmsItemStackCreate -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static NmsItemStackCreateFallback i = new NmsItemStackCreateFallback(); - public static NmsItemStackCreateFallback get () { return i; } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @SuppressWarnings("deprecation") - @Override - public ItemStack create() - { - return new ItemStack(0); - } - -} diff --git a/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java b/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java index 07bd1ebf..2693c19f 100644 --- a/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java +++ b/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java @@ -500,7 +500,7 @@ public enum ParticleEffect { */ private static boolean isWater(Location location) { Material material = location.getBlock().getType(); - return material == Material.WATER || material == Material.STATIONARY_WATER; + return material == Material.WATER || material == Material.WATER; } /** @@ -1358,7 +1358,6 @@ public enum ParticleEffect { * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 * @param data Data of the effect * @throws IllegalArgumentException If the speed is lower than 0 - * @see #ParticleEffect(ParticleEffect, float, float, float, float, int, boolean, ParticleData) */ public ParticlePacket(ParticleEffect effect, Vector direction, float speed, boolean longDistance, ParticleData data) throws IllegalArgumentException { this(effect, (float) direction.getX(), (float) direction.getY(), (float) direction.getZ(), speed, 0, longDistance, data); @@ -1370,7 +1369,6 @@ public enum ParticleEffect { * @param effect Particle effect * @param color Color of the particle * @param longDistance Indicates whether the maximum distance is increased from 256 to 65536 - * @see #ParticleEffect(ParticleEffect, float, float, float, float, int, boolean, ParticleData) */ public ParticlePacket(ParticleEffect effect, ParticleColor color, boolean longDistance) { this(effect, color.getValueX(), color.getValueY(), color.getValueZ(), 1, 0, longDistance, null); diff --git a/src/com/massivecraft/massivecore/test/TestTypeEnchantment.java b/src/com/massivecraft/massivecore/test/TestTypeEnchantment.java deleted file mode 100644 index 4ba8d6ec..00000000 --- a/src/com/massivecraft/massivecore/test/TestTypeEnchantment.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.massivecraft.massivecore.test; - -import com.massivecraft.massivecore.collections.MassiveList; -import com.massivecraft.massivecore.command.type.TypeEnchantment; -import com.massivecraft.massivecore.util.Txt; -import org.bukkit.enchantments.Enchantment; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -public class TestTypeEnchantment extends Test -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static TestTypeEnchantment i = new TestTypeEnchantment(); - public static TestTypeEnchantment get() { return i; } - - // -------------------------------------------- // - // TEST - // -------------------------------------------- // - - @Override - public void test() - { - final List enchantments = new MassiveList<>(Arrays.asList(Enchantment.values())); - - for (Iterator iterator = enchantments.iterator(); iterator.hasNext();) - { - Enchantment enchantment = iterator.next(); - if (TypeEnchantment.ID_TO_RAWNAMES.containsKey(enchantment.getId())) - { - iterator.remove(); - } - } - - for (Enchantment enchantment : enchantments) - { - String issue = Txt.parse("The enchantment %s (%d) lacks nicename in TypeEnchantment.", enchantment.getName(), enchantment.getId()); - this.addIssue(issue); - } - - } -} diff --git a/src/com/massivecraft/massivecore/util/InventoryUtil.java b/src/com/massivecraft/massivecore/util/InventoryUtil.java index fce7272e..462351b0 100644 --- a/src/com/massivecraft/massivecore/util/InventoryUtil.java +++ b/src/com/massivecraft/massivecore/util/InventoryUtil.java @@ -5,7 +5,6 @@ import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.comparator.ComparatorComparable; import com.massivecraft.massivecore.comparator.ComparatorEntryValue; import com.massivecraft.massivecore.event.EventMassiveCoreLorePriority; -import com.massivecraft.massivecore.item.DataItemStack; import com.massivecraft.massivecore.mixin.MixinInventory; import com.massivecraft.massivecore.predicate.Predicate; import com.massivecraft.massivecore.predicate.PredicateStringStartsWith; @@ -23,8 +22,8 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.material.MaterialData; import java.util.AbstractMap.SimpleEntry; import java.util.Arrays; @@ -913,43 +912,12 @@ public class InventoryUtil { // Check Null if (isNothing(itemStack)) return; - - // Check Repairable - Material material = itemStack.getType(); - if ( ! isRepairable(material)) return; - - // Repair - itemStack.setDurability((short) 0); - } - - public static boolean isRepairable(Material material) - { - // Blocks are never repairable. - // Only items take damage in Minecraft. - if (material.isBlock()) return false; - - // This list was created by checking for the "B" notation on: - // http://minecraft.gamepedia.com/Data_values - if (material == Material.COAL) return false; - if (material == Material.GOLDEN_APPLE) return false; - if (material == Material.RAW_FISH) return false; - if (material == Material.COOKED_FISH) return false; - if (material == Material.INK_SACK) return false; - if (material == Material.MAP) return false; - if (material == Material.POTION) return false; - if (material == Material.MONSTER_EGG) return false; - if (material == Material.SKULL_ITEM) return false; - - // This lines actually catches most of the specific lines above. - // However we add this in anyways for future compatibility. - if ( ! material.getData().equals(MaterialData.class)) return false; - - // We may also not repair things that can not take any damage. - // NOTE: MaxDurability should be renamed to MaxDamage. - if (material.getMaxDurability() == 0) return false; - - // Otherwise repairable - return true; + + ItemMeta meta = getMeta(itemStack); + if (meta == null) return; + + if (!(meta instanceof Damageable)) return; + Damageable damageable = (Damageable) meta; } public static boolean isPotion(ItemStack itemStack) @@ -1024,10 +992,8 @@ public class InventoryUtil { if (isNothing(one)) return isNothing(two); if (isNothing(two)) return false; - - DataItemStack dataOne = DataItemStack.fromBukkit(one); - DataItemStack dataTwo = DataItemStack.fromBukkit(two); - return dataOne.equals(dataTwo); + + return one.equals(two); } public static boolean equals(ItemStack[] one, ItemStack[] two) diff --git a/src/com/massivecraft/massivecore/util/MUtil.java b/src/com/massivecraft/massivecore/util/MUtil.java index 70492599..d277892c 100644 --- a/src/com/massivecraft/massivecore/util/MUtil.java +++ b/src/com/massivecraft/massivecore/util/MUtil.java @@ -1102,16 +1102,22 @@ public class MUtil Material.BREAD, Material.COOKED_BEEF, Material.COOKED_CHICKEN, - Material.COOKED_FISH, + Material.COOKED_COD, + Material.COOKED_MUTTON, + Material.COOKED_PORKCHOP, + Material.COOKED_RABBIT, + Material.COOKED_SALMON, Material.COOKIE, - Material.GRILLED_PORK, Material.GOLDEN_APPLE, Material.MELON, - Material.MUSHROOM_SOUP, - Material.PORK, - Material.RAW_BEEF, - Material.RAW_CHICKEN, - Material.RAW_FISH, + Material.MUSHROOM_STEW, + Material.PORKCHOP, + Material.BEEF, + Material.CHICKEN, + Material.COD, + Material.SALMON, + Material.PUFFERFISH, + Material.TROPICAL_FISH, Material.ROTTEN_FLESH, Material.SPIDER_EYE )); @@ -1138,10 +1144,10 @@ public class MUtil // Sword public static Set SWORD_MATERIALS = EnumSet.of( - Material.WOOD_SWORD, + Material.WOODEN_SWORD, Material.STONE_SWORD, Material.IRON_SWORD, - Material.GOLD_SWORD, + Material.GOLDEN_SWORD, Material.DIAMOND_SWORD ); @@ -1178,10 +1184,10 @@ public class MUtil // Axe public static Set AXE_MATERIALS = EnumSet.of( - Material.WOOD_AXE, + Material.WOODEN_AXE, Material.STONE_AXE, Material.IRON_AXE, - Material.GOLD_AXE, + Material.GOLDEN_AXE, Material.DIAMOND_AXE ); @@ -1250,10 +1256,10 @@ public class MUtil // Pickaxe public static Set PICKAXE_MATERIALS = EnumSet.of( - Material.WOOD_PICKAXE, + Material.WOODEN_PICKAXE, Material.STONE_PICKAXE, Material.IRON_PICKAXE, - Material.GOLD_PICKAXE, + Material.GOLDEN_PICKAXE, Material.DIAMOND_PICKAXE ); @@ -1284,11 +1290,11 @@ public class MUtil // Spade public static Set SPADE_MATERIALS = EnumSet.of( - Material.WOOD_SPADE, - Material.STONE_SPADE, - Material.IRON_SPADE, - Material.GOLD_SPADE, - Material.DIAMOND_SPADE + Material.WOODEN_SHOVEL, + Material.IRON_SHOVEL, + Material.IRON_SHOVEL, + Material.GOLDEN_SHOVEL, + Material.DIAMOND_SHOVEL ); public static boolean isSpade(Material material) @@ -1327,9 +1333,9 @@ public class MUtil Material ret = null; - if (action == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CAKE_BLOCK) + if (action == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CAKE) { - ret = Material.CAKE_BLOCK; + ret = Material.CAKE; } else if (FOOD_MATERIALS.contains(event.getMaterial())) { diff --git a/src/com/massivecraft/massivecore/util/SignUtil.java b/src/com/massivecraft/massivecore/util/SignUtil.java index 2ffce837..518fe7c2 100644 --- a/src/com/massivecraft/massivecore/util/SignUtil.java +++ b/src/com/massivecraft/massivecore/util/SignUtil.java @@ -244,7 +244,6 @@ public class SignUtil if (material == null) throw new NullPointerException("material"); if (material == Material.SIGN) return true; - if (material == Material.SIGN_POST) return true; if (material == Material.WALL_SIGN) return true; return false;