diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditContainerAbstract.java b/src/com/massivecraft/massivecore/command/editor/CommandEditContainerAbstract.java index 77251e60..18b6bd90 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditContainerAbstract.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditContainerAbstract.java @@ -5,6 +5,7 @@ import java.util.AbstractMap.SimpleImmutableEntry; import org.bukkit.ChatColor; import java.util.Collection; +import java.util.Iterator; import java.util.List; import com.massivecraft.massivecore.MassiveException; @@ -175,25 +176,28 @@ public abstract class CommandEditContainerAbstract extends CommandEditAbst public void addParametersElement(boolean strict) { - Type innerType = this.getValueInnerType(); + Type elementType = this.getValueInnerType(); if (this.isCollection()) { - this.addParameter(innerType, true); + this.addParameter(elementType, true); } else { - Type keyType = innerType.getInnerType(innerType.getIndexUser(0)); - Type valueType = innerType.getInnerType(innerType.getIndexUser(1)); - if (strict) + List userOrder = elementType.getUserOrder(); + for (Iterator iterator = userOrder.iterator(); iterator.hasNext();) { - this.addParameter(keyType); - this.addParameter(valueType, true); - } - else - { - this.addParameter(null, TypeNullable.get(keyType, "any", "all"), keyType.getName(), "any"); - this.addParameter(null, TypeNullable.get(valueType, "any", "all"), valueType.getName(), "any", true); + Integer indexTech = iterator.next(); + Type innerType = elementType.getInnerType(indexTech); + boolean concatFromHere = ! iterator.hasNext(); + if (strict) + { + this.addParameter(innerType, concatFromHere); + } + else + { + this.addParameter(null, TypeNullable.get(innerType, "any", "all"), innerType.getName(), "any", concatFromHere); + } } } } @@ -206,12 +210,21 @@ public abstract class CommandEditContainerAbstract extends CommandEditAbst } else { - Object key = this.readArgAt(this.getValueInnerType().getIndexTech(0)); - Object value = this.readArgAt(this.getValueInnerType().getIndexTech(1)); + Object key = this.readElementInner(0); + Object value = this.readElementInner(1); return new SimpleImmutableEntry(key, value); } } + public Object readElementInner(int indexTech) throws MassiveException + { + Type elementType = this.getValueInnerType(); + Integer indexUser = elementType.getIndexUser(indexTech); + if (indexUser != null) return this.readArgAt(indexUser); + Type innerType = elementType.getInnerType(indexTech); + return innerType.read(sender); + } + // -------------------------------------------- // // ELEMENTS UTIL // -------------------------------------------- // diff --git a/src/com/massivecraft/massivecore/command/type/Type.java b/src/com/massivecraft/massivecore/command/type/Type.java index d54e0f64..1c8958fb 100644 --- a/src/com/massivecraft/massivecore/command/type/Type.java +++ b/src/com/massivecraft/massivecore/command/type/Type.java @@ -38,8 +38,9 @@ public interface Type extends Named public void setUserOrder(List userOrder); public void setUserOrder(Integer... userOrder); - public int getIndexUser(int indexTechy); - public int getIndexTech(int indexUser); + public List getUserOrder(); + public Integer getIndexUser(int indexTechy); + public Integer getIndexTech(int indexUser); // -------------------------------------------- // // WRITE VISUAL COLOR diff --git a/src/com/massivecraft/massivecore/command/type/TypeAbstract.java b/src/com/massivecraft/massivecore/command/type/TypeAbstract.java index 3c33cbad..fcdecb7e 100644 --- a/src/com/massivecraft/massivecore/command/type/TypeAbstract.java +++ b/src/com/massivecraft/massivecore/command/type/TypeAbstract.java @@ -87,17 +87,20 @@ public abstract class TypeAbstract implements Type private List userOrder = null; @Override public void setUserOrder(List userOrder) { this.userOrder = userOrder; } @Override public void setUserOrder(Integer... userOrder) { this.setUserOrder(Arrays.asList(userOrder)); } + @Override public List getUserOrder() { return this.userOrder; } @Override - public int getIndexUser(int indexTechy) + public Integer getIndexUser(int indexTechy) { if (this.userOrder == null) return indexTechy; - return userOrder.get(indexTechy); + Integer ret = this.userOrder.indexOf(indexTechy); + if (ret.equals(-1)) return null; + return ret; } @Override - public int getIndexTech(int indexUser) + public Integer getIndexTech(int indexUser) { if (this.userOrder == null) return indexUser; - return userOrder.indexOf(indexUser); + return this.userOrder.get(indexUser); } // -------------------------------------------- //