Fix Inner --> Inner chain in Type Container and support Mson item visuals.

This commit is contained in:
Olof Larsson 2016-03-09 13:33:23 +01:00
parent 0399041b76
commit f2648656aa
4 changed files with 12 additions and 22 deletions

View File

@ -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<T> implements Type<T>
@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

View File

@ -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<ItemStack>
{
@ -22,10 +24,9 @@ public class TypeItemStack extends TypeAbstract<ItemStack>
// -------------------------------------------- //
@Override
public String getVisualInner(ItemStack value, CommandSender sender)
public Mson getVisualMsonInner(ItemStack value, CommandSender sender)
{
// TODO: Implement
return null;
return Txt.createItemMson(value);
}
@Override

View File

@ -68,7 +68,7 @@ public abstract class TypeContainer<C extends Object, E> extends TypeAbstract<C>
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<C extends Object, E> extends TypeAbstract<C>
for (E element : elements)
{
index++;
String part = Txt.parse("<white>%d <yellow>%s", index, innerType.getVisualInner(element, sender));
String part = Txt.parse("<white>%d <yellow>%s", index, innerType.getVisual(element, sender));
parts.add(part);
}
@ -123,7 +123,7 @@ public abstract class TypeContainer<C extends Object, E> extends TypeAbstract<C>
Type<E> 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<C extends Object, E> extends TypeAbstract<C>
List<E> elements = this.getContainerElementsOrdered(container);
for (E element : elements)
{
String part = innerType.getIdInner(element);
String part = innerType.getId(element);
parts.add(part);
}

View File

@ -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<ItemStack>
{
@ -29,18 +27,6 @@ public class TypeItemStacks extends TypeList<ItemStack>
// OVERRIDE
// -------------------------------------------- //
@Override
public String getVisualInner(List<ItemStack> value, CommandSender sender)
{
// Empty
if (value.isEmpty()) return EMPTY;
// Integer Size
return TypeInteger.get().getVisual(value.size(), sender);
// TODO: Improve
}
@Override
public <O> CommandEditAbstract<O, List<ItemStack>> createEditCommand(EditSettings<O> settings, Property<O, List<ItemStack>> property)
{