From f2648656aaefec0e49c267c47e2023301b63f92d Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 9 Mar 2016 13:33:23 +0100 Subject: [PATCH] Fix Inner --> Inner chain in Type Container and support Mson item visuals. --- .../massivecore/command/type/TypeAbstract.java | 5 ++++- .../massivecore/command/type/TypeItemStack.java | 7 ++++--- .../command/type/container/TypeContainer.java | 8 ++++---- .../command/type/container/TypeItemStacks.java | 14 -------------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/com/massivecraft/massivecore/command/type/TypeAbstract.java b/src/com/massivecraft/massivecore/command/type/TypeAbstract.java index 16cde7c8..3c33cbad 100644 --- a/src/com/massivecraft/massivecore/command/type/TypeAbstract.java +++ b/src/com/massivecraft/massivecore/command/type/TypeAbstract.java @@ -26,6 +26,7 @@ import com.massivecraft.massivecore.comparator.ComparatorHashCode; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.store.SenderEntity; import com.massivecraft.massivecore.util.ContainerUtil; +import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.ReflectionUtil; import com.massivecraft.massivecore.util.Txt; @@ -141,7 +142,9 @@ public abstract class TypeAbstract implements Type @Override public Mson getVisualMsonInner(T value, CommandSender sender) { - return Mson.fromParsedMessage(this.getVisualInner(value, sender)); + String visualInner = this.getVisualInner(value, sender); + if (visualInner == null) MUtil.stackTraceDebug("visualInner null for + " + value); + return Mson.fromParsedMessage(visualInner); } @Override diff --git a/src/com/massivecraft/massivecore/command/type/TypeItemStack.java b/src/com/massivecraft/massivecore/command/type/TypeItemStack.java index 7e3105dc..0495a4f9 100644 --- a/src/com/massivecraft/massivecore/command/type/TypeItemStack.java +++ b/src/com/massivecraft/massivecore/command/type/TypeItemStack.java @@ -7,6 +7,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.mson.Mson; +import com.massivecraft.massivecore.util.Txt; public class TypeItemStack extends TypeAbstract { @@ -22,10 +24,9 @@ public class TypeItemStack extends TypeAbstract // -------------------------------------------- // @Override - public String getVisualInner(ItemStack value, CommandSender sender) + public Mson getVisualMsonInner(ItemStack value, CommandSender sender) { - // TODO: Implement - return null; + return Txt.createItemMson(value); } @Override diff --git a/src/com/massivecraft/massivecore/command/type/container/TypeContainer.java b/src/com/massivecraft/massivecore/command/type/container/TypeContainer.java index 2659c00c..858d8218 100644 --- a/src/com/massivecraft/massivecore/command/type/container/TypeContainer.java +++ b/src/com/massivecraft/massivecore/command/type/container/TypeContainer.java @@ -68,7 +68,7 @@ public abstract class TypeContainer extends TypeAbstract Mson part = Mson.mson( Mson.mson(String.valueOf(index)).color(ChatColor.WHITE), " ", - innerType.getVisualMsonInner(element, sender) + innerType.getVisualMson(element, sender) ); parts.add(part); } @@ -97,7 +97,7 @@ public abstract class TypeContainer extends TypeAbstract for (E element : elements) { index++; - String part = Txt.parse("%d %s", index, innerType.getVisualInner(element, sender)); + String part = Txt.parse("%d %s", index, innerType.getVisual(element, sender)); parts.add(part); } @@ -123,7 +123,7 @@ public abstract class TypeContainer extends TypeAbstract Type innerType = this.getInnerType(); for (E element : elements) { - String part = innerType.getNameInner(element); + String part = innerType.getName(element); parts.add(part); } @@ -149,7 +149,7 @@ public abstract class TypeContainer extends TypeAbstract List elements = this.getContainerElementsOrdered(container); for (E element : elements) { - String part = innerType.getIdInner(element); + String part = innerType.getId(element); parts.add(part); } diff --git a/src/com/massivecraft/massivecore/command/type/container/TypeItemStacks.java b/src/com/massivecraft/massivecore/command/type/container/TypeItemStacks.java index b0053451..ad5024dd 100644 --- a/src/com/massivecraft/massivecore/command/type/container/TypeItemStacks.java +++ b/src/com/massivecraft/massivecore/command/type/container/TypeItemStacks.java @@ -2,7 +2,6 @@ package com.massivecraft.massivecore.command.type.container; import java.util.List; -import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; import com.massivecraft.massivecore.command.editor.CommandEditAbstract; @@ -10,7 +9,6 @@ import com.massivecraft.massivecore.command.editor.CommandEditItemStacks; import com.massivecraft.massivecore.command.editor.EditSettings; import com.massivecraft.massivecore.command.editor.Property; import com.massivecraft.massivecore.command.type.TypeItemStack; -import com.massivecraft.massivecore.command.type.primitive.TypeInteger; public class TypeItemStacks extends TypeList { @@ -29,18 +27,6 @@ public class TypeItemStacks extends TypeList // OVERRIDE // -------------------------------------------- // - @Override - public String getVisualInner(List value, CommandSender sender) - { - // Empty - if (value.isEmpty()) return EMPTY; - - // Integer Size - return TypeInteger.get().getVisual(value.size(), sender); - - // TODO: Improve - } - @Override public CommandEditAbstract> createEditCommand(EditSettings settings, Property> property) {