diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemMeta.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemMeta.java deleted file mode 100644 index 7af12dfb..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemMeta.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.inventory.meta.ItemMeta; - -public abstract class WriterAbstractItemMeta extends WriterAbstractMeta -{ - -} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStack.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStack.java index 2589a229..ff2052bc 100644 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemStack.java +++ b/src/com/massivecraft/massivecore/item/WriterAbstractItemStack.java @@ -1,11 +1,8 @@ package com.massivecraft.massivecore.item; -import org.bukkit.inventory.ItemStack; - import com.massivecraft.massivecore.nms.NmsItemStack; - -public abstract class WriterAbstractItemStack extends WriterAbstract +public abstract class WriterAbstractItemStack extends WriterAbstract { // -------------------------------------------- // // CREATE @@ -17,10 +14,11 @@ public abstract class WriterAbstractItemStack extends WriterAbstract extends WriterAbstractItemStack +{ + +} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMeta.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMeta.java index a43f8d7a..f68b2a1a 100644 --- a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMeta.java +++ b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMeta.java @@ -1,31 +1,35 @@ package com.massivecraft.massivecore.item; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -public abstract class WriterAbstractItemStackMeta extends WriterAbstractMeta -{ +public abstract class WriterAbstractItemStackMeta extends WriterAbstractItemStack +{ // -------------------------------------------- // - // MORPH + // FIELDS // -------------------------------------------- // - @Override - public ItemMeta morphB(ItemStack ob) + private Material material = Material.STONE; + public Material getMaterial() { return this.material; } + @SuppressWarnings("unchecked") + public void setMaterial(Material material) { - return ob.getItemMeta(); + this.material = material; + CB cb = this.createB(); + this.setClassB((Class) cb.getClass()); } // -------------------------------------------- // - // WRITE + // CREATE // -------------------------------------------- // - + + @SuppressWarnings("unchecked") @Override - public void writeInner(DataItemStack oa, ItemStack ob, DataItemStack ca, ItemMeta cb, boolean a2b) + public CB createB() { - super.writeInner(oa, ob, ca, cb, a2b); - - // Write back the meta - if (a2b) ob.setItemMeta(cb); + ItemStack itemStack = (ItemStack) super.createB(); + itemStack.setType(this.getMaterial()); + return (CB) itemStack.getItemMeta(); } } diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaField.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaField.java new file mode 100644 index 00000000..b245bd95 --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaField.java @@ -0,0 +1,8 @@ +package com.massivecraft.massivecore.item; + +import org.bukkit.inventory.meta.ItemMeta; + +public abstract class WriterAbstractItemStackMetaField extends WriterAbstractItemStackMeta +{ + +} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaMorph.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaMorph.java new file mode 100644 index 00000000..15e1c07c --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaMorph.java @@ -0,0 +1,31 @@ +package com.massivecraft.massivecore.item; + +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public abstract class WriterAbstractItemStackMetaMorph extends WriterAbstractItemStackMeta +{ + // -------------------------------------------- // + // MORPH + // -------------------------------------------- // + + @Override + public ItemMeta morphB(ItemStack ob) + { + return ob.getItemMeta(); + } + + // -------------------------------------------- // + // WRITE + // -------------------------------------------- // + + @Override + public void writeInner(DataItemStack oa, ItemStack ob, DataItemStack ca, ItemMeta cb, boolean a2b) + { + super.writeInner(oa, ob, ca, cb, a2b); + + // Write Back + if (a2b) ob.setItemMeta(cb); + } + +} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaState.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaState.java new file mode 100644 index 00000000..1ee57afa --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaState.java @@ -0,0 +1,19 @@ +package com.massivecraft.massivecore.item; + +import org.bukkit.inventory.meta.BlockStateMeta; + +public abstract class WriterAbstractItemStackMetaState extends WriterAbstractItemStackMeta +{ + // -------------------------------------------- // + // CREATE + // -------------------------------------------- // + + @SuppressWarnings("unchecked") + @Override + public CB createB() + { + BlockStateMeta blockStateMeta = (BlockStateMeta) super.createB(); + return (CB) blockStateMeta.getBlockState(); + } + +} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaStateField.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaStateField.java new file mode 100644 index 00000000..e04ff9b4 --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaStateField.java @@ -0,0 +1,8 @@ +package com.massivecraft.massivecore.item; + +import org.bukkit.block.BlockState; + +public abstract class WriterAbstractItemStackMetaStateField extends WriterAbstractItemStackMetaState +{ + +} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaStateMorph.java b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaStateMorph.java new file mode 100644 index 00000000..74c2e8b7 --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterAbstractItemStackMetaStateMorph.java @@ -0,0 +1,37 @@ +package com.massivecraft.massivecore.item; + +import org.bukkit.block.BlockState; +import org.bukkit.inventory.meta.BlockStateMeta; +import org.bukkit.inventory.meta.ItemMeta; + +public abstract class WriterAbstractItemStackMetaStateMorph extends WriterAbstractItemStackMetaState +{ + // -------------------------------------------- // + // MORPH + // -------------------------------------------- // + + @Override + public BlockState morphB(ItemMeta ob) + { + BlockStateMeta state = (BlockStateMeta)ob; + return state.getBlockState(); + } + + // -------------------------------------------- // + // WRITE + // -------------------------------------------- // + + @Override + public void writeInner(DataItemStack oa, ItemMeta ob, DataItemStack ca, BlockState cb, boolean a2b) + { + super.writeInner(oa, ob, ca, cb, a2b); + + // Write Back + if (a2b) + { + BlockStateMeta blockStateMeta = (BlockStateMeta)ob; + blockStateMeta.setBlockState(cb); + } + } + +} diff --git a/src/com/massivecraft/massivecore/item/WriterAbstractMeta.java b/src/com/massivecraft/massivecore/item/WriterAbstractMeta.java deleted file mode 100644 index a87ea351..00000000 --- a/src/com/massivecraft/massivecore/item/WriterAbstractMeta.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.massivecraft.massivecore.item; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import com.massivecraft.massivecore.nms.NmsItemStack; - -public abstract class WriterAbstractMeta extends WriterAbstract -{ - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private Material material = Material.STONE; - public Material getMaterial() { return this.material; } - @SuppressWarnings("unchecked") - public void setMaterial(Material material) - { - this.material = material; - CB cb = this.createB(); - this.setClassB((Class) cb.getClass()); - } - - // -------------------------------------------- // - // CREATE - // -------------------------------------------- // - - @Override - public DataItemStack createA() - { - return new DataItemStack(); - } - - @SuppressWarnings("unchecked") - @Override - public CB createB() - { - ItemStack itemStack = NmsItemStack.get().createItemStack(); - itemStack.setType(this.getMaterial()); - return (CB) itemStack.getItemMeta(); - } - -} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStack.java b/src/com/massivecraft/massivecore/item/WriterItemStack.java index ca784de7..9a62c518 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStack.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStack.java @@ -1,6 +1,6 @@ package com.massivecraft.massivecore.item; -public class WriterItemStack extends WriterAbstractItemStack +public class WriterItemStack extends WriterAbstractItemStackField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackCount.java b/src/com/massivecraft/massivecore/item/WriterItemStackCount.java index 1994326a..dfa230c6 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackCount.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackCount.java @@ -2,7 +2,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.inventory.ItemStack; -public class WriterItemStackCount extends WriterAbstractItemStack +public class WriterItemStackCount extends WriterAbstractItemStackField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackDamage.java b/src/com/massivecraft/massivecore/item/WriterItemStackDamage.java index a89b90c6..f4d8883f 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackDamage.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackDamage.java @@ -2,7 +2,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.inventory.ItemStack; -public class WriterItemStackDamage extends WriterAbstractItemStack +public class WriterItemStackDamage extends WriterAbstractItemStackField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackId.java b/src/com/massivecraft/massivecore/item/WriterItemStackId.java index d09af003..9ea8d4d5 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackId.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackId.java @@ -2,7 +2,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.inventory.ItemStack; -public class WriterItemStackId extends WriterAbstractItemStack +public class WriterItemStackId extends WriterAbstractItemStackField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMeta.java b/src/com/massivecraft/massivecore/item/WriterItemStackMeta.java index 47d41f33..d1ba90a6 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMeta.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMeta.java @@ -1,6 +1,6 @@ package com.massivecraft.massivecore.item; -public class WriterItemStackMeta extends WriterAbstractItemStackMeta +public class WriterItemStackMeta extends WriterAbstractItemStackMetaMorph { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -60,17 +60,15 @@ public class WriterItemStackMeta extends WriterAbstractItemStackMeta +public class WriterItemStackMetaAuthor extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerBase.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerBase.java index dd10a7a8..994cd1ed 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerBase.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaBannerBase.java @@ -4,7 +4,7 @@ import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.inventory.meta.BannerMeta; -public class WriterItemStackMetaBannerBase extends WriterAbstractItemMeta +public class WriterItemStackMetaBannerBase extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -15,6 +15,8 @@ public class WriterItemStackMetaBannerBase extends WriterAbstractItemMeta, List> +public class WriterItemStackMetaBannerPatterns extends WriterAbstractItemStackMetaField, List> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaColor.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaColor.java index dbc1ca0d..13416fe8 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaColor.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaColor.java @@ -4,7 +4,7 @@ import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.inventory.meta.LeatherArmorMeta; -public class WriterItemStackMetaColor extends WriterAbstractItemMeta +public class WriterItemStackMetaColor extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaEnchants.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaEnchants.java index 5816ccf6..64e2a339 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaEnchants.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaEnchants.java @@ -6,7 +6,7 @@ import java.util.Map.Entry; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.meta.ItemMeta; -public class WriterItemStackMetaEnchants extends WriterAbstractItemMeta, Map> +public class WriterItemStackMetaEnchants extends WriterAbstractItemStackMetaField, Map> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffect.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffect.java index bb9d1e2b..3554037e 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffect.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffect.java @@ -4,7 +4,7 @@ import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.inventory.meta.FireworkEffectMeta; -public class WriterItemStackMetaFireworkEffect extends WriterAbstractItemMeta +public class WriterItemStackMetaFireworkEffect extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffects.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffects.java index 6919e43c..3364a27f 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffects.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkEffects.java @@ -6,7 +6,7 @@ import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.inventory.meta.FireworkMeta; -public class WriterItemStackMetaFireworkEffects extends WriterAbstractItemMeta, List> +public class WriterItemStackMetaFireworkEffects extends WriterAbstractItemStackMetaField, List> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkFlight.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkFlight.java index f9243429..5b30834d 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkFlight.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFireworkFlight.java @@ -3,7 +3,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.Material; import org.bukkit.inventory.meta.FireworkMeta; -public class WriterItemStackMetaFireworkFlight extends WriterAbstractItemMeta +public class WriterItemStackMetaFireworkFlight extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFlags.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFlags.java index 6f9441fd..0e8f8f3d 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaFlags.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaFlags.java @@ -5,7 +5,7 @@ import java.util.Set; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.ItemMeta; -public class WriterItemStackMetaFlags extends WriterAbstractItemMeta, Set> +public class WriterItemStackMetaFlags extends WriterAbstractItemStackMetaField, Set> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaLore.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaLore.java index 8dcba2ef..033dd137 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaLore.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaLore.java @@ -4,7 +4,7 @@ import java.util.List; import org.bukkit.inventory.meta.ItemMeta; -public class WriterItemStackMetaLore extends WriterAbstractItemMeta, List> +public class WriterItemStackMetaLore extends WriterAbstractItemStackMetaField, List> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaName.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaName.java index bc4d8bb2..413a6b41 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaName.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaName.java @@ -2,7 +2,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.inventory.meta.ItemMeta; -public class WriterItemStackMetaName extends WriterAbstractItemMeta +public class WriterItemStackMetaName extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPages.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPages.java index c245cc05..95e8b6f7 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPages.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPages.java @@ -5,7 +5,7 @@ import java.util.List; import org.bukkit.Material; import org.bukkit.inventory.meta.BookMeta; -public class WriterItemStackMetaPages extends WriterAbstractItemMeta, List> +public class WriterItemStackMetaPages extends WriterAbstractItemStackMetaField, List> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionEffects.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionEffects.java index 9f75c291..d771d829 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionEffects.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaPotionEffects.java @@ -6,7 +6,7 @@ import org.bukkit.Material; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffect; -public class WriterItemStackMetaPotionEffects extends WriterAbstractItemMeta, List> +public class WriterItemStackMetaPotionEffects extends WriterAbstractItemStackMetaField, List> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaRepaircost.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaRepaircost.java index 85a60d65..8c00ea3c 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaRepaircost.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaRepaircost.java @@ -3,7 +3,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.Material; import org.bukkit.inventory.meta.Repairable; -public class WriterItemStackMetaRepaircost extends WriterAbstractItemMeta +public class WriterItemStackMetaRepaircost extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaScaling.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaScaling.java index 9fba0bd7..e606a132 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaScaling.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaScaling.java @@ -3,7 +3,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.Material; import org.bukkit.inventory.meta.MapMeta; -public class WriterItemStackMetaScaling extends WriterAbstractItemMeta +public class WriterItemStackMetaScaling extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull17.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull17.java index b575a411..ce0cfe9e 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull17.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull17.java @@ -3,7 +3,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.Material; import org.bukkit.inventory.meta.SkullMeta; -public class WriterItemStackMetaSkull17 extends WriterAbstractItemMeta +public class WriterItemStackMetaSkull17 extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull18.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull18.java index 19ed7b7e..1535ae82 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull18.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaSkull18.java @@ -8,7 +8,7 @@ import org.bukkit.inventory.meta.SkullMeta; import com.massivecraft.massivecore.Couple; import com.massivecraft.massivecore.nms.NmsHead; -public class WriterItemStackMetaSkull18 extends WriterAbstractItemMeta +public class WriterItemStackMetaSkull18 extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaState.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaState.java new file mode 100644 index 00000000..525d96dd --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaState.java @@ -0,0 +1,29 @@ +package com.massivecraft.massivecore.item; + +public class WriterItemStackMetaState extends WriterAbstractItemStackMetaStateMorph +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static final WriterItemStackMetaState i = new WriterItemStackMetaState(); + public static WriterItemStackMetaState get() { return i; } + + // -------------------------------------------- // + // ACTIVE + // -------------------------------------------- // + + @Override + public void setActiveInner(boolean active) + { + if ( ! active) return; + this.clearWriters(); + + this.addWriters( + // SHIELD + WriterItemStackMetaStateShieldBase.class, + WriterItemStackMetaStateShieldPatterns.class + ); + } + +} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaStateShieldBase.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaStateShieldBase.java new file mode 100644 index 00000000..fb57d8c0 --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaStateShieldBase.java @@ -0,0 +1,50 @@ +package com.massivecraft.massivecore.item; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.block.Banner; + +public class WriterItemStackMetaStateShieldBase extends WriterAbstractItemStackMetaStateField +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static final WriterItemStackMetaStateShieldBase i = new WriterItemStackMetaStateShieldBase(); + public static WriterItemStackMetaStateShieldBase get() { return i; } + public WriterItemStackMetaStateShieldBase() + { + this.setMaterial(Material.SHIELD); + this.setConverterTo(ConverterToDyeColor.get()); + this.setConverterFrom(ConverterFromDyeColor.get()); + } + + // -------------------------------------------- // + // ACCESS + // -------------------------------------------- // + + @Override + public Integer getA(DataItemStack ca) + { + return ca.getBannerBase(); + } + + @Override + public void setA(DataItemStack ca, Integer fa) + { + ca.setBannerBase(fa); + } + + @Override + public DyeColor getB(Banner cb) + { + return cb.getBaseColor(); + } + + @Override + public void setB(Banner cb, DyeColor fb) + { + cb.setBaseColor(fb); + } + +} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaStateShieldPatterns.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaStateShieldPatterns.java new file mode 100644 index 00000000..86b8d3b5 --- /dev/null +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaStateShieldPatterns.java @@ -0,0 +1,51 @@ +package com.massivecraft.massivecore.item; + +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.block.Banner; +import org.bukkit.block.banner.Pattern; + +public class WriterItemStackMetaStateShieldPatterns extends WriterAbstractItemStackMetaStateField, List> +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static final WriterItemStackMetaStateShieldPatterns i = new WriterItemStackMetaStateShieldPatterns(); + public static WriterItemStackMetaStateShieldPatterns get() { return i; } + { + this.setMaterial(Material.SHIELD); + this.setConverterTo(ConverterToBannerPatterns.get()); + this.setConverterFrom(ConverterFromBannerPatterns.get()); + } + + // -------------------------------------------- // + // ACCESS + // -------------------------------------------- // + + @Override + public List getA(DataItemStack ca) + { + return ca.getBannerPatterns(); + } + + @Override + public void setA(DataItemStack ca, List fa) + { + ca.setBannerPatterns(fa); + } + + @Override + public List getB(Banner cb) + { + return cb.getPatterns(); + } + + @Override + public void setB(Banner cb, List fb) + { + cb.setPatterns(fb); + } + +} diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaStoredEnchants.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaStoredEnchants.java index 8e59e2da..442832c7 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaStoredEnchants.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaStoredEnchants.java @@ -7,7 +7,7 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.meta.EnchantmentStorageMeta; -public class WriterItemStackMetaStoredEnchants extends WriterAbstractItemMeta, Map> +public class WriterItemStackMetaStoredEnchants extends WriterAbstractItemStackMetaField, Map> { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaTitle.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaTitle.java index 2d5cb586..6e901af3 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaTitle.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaTitle.java @@ -3,7 +3,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.Material; import org.bukkit.inventory.meta.BookMeta; -public class WriterItemStackMetaTitle extends WriterAbstractItemMeta +public class WriterItemStackMetaTitle extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT diff --git a/src/com/massivecraft/massivecore/item/WriterItemStackMetaUnbreakable.java b/src/com/massivecraft/massivecore/item/WriterItemStackMetaUnbreakable.java index b61e0614..e30c7227 100644 --- a/src/com/massivecraft/massivecore/item/WriterItemStackMetaUnbreakable.java +++ b/src/com/massivecraft/massivecore/item/WriterItemStackMetaUnbreakable.java @@ -2,7 +2,7 @@ package com.massivecraft.massivecore.item; import org.bukkit.inventory.meta.ItemMeta; -public class WriterItemStackMetaUnbreakable extends WriterAbstractItemMeta +public class WriterItemStackMetaUnbreakable extends WriterAbstractItemStackMetaField { // -------------------------------------------- // // INSTANCE & CONSTRUCT