TypeCombined separators

This commit is contained in:
BuildTools 2016-02-12 17:20:24 +01:00 committed by Olof Larsson
parent 6fcb04070b
commit 661df11ee7

View File

@ -17,13 +17,21 @@ import com.massivecraft.massivecore.command.type.TypeAbstract;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public abstract class TypeCombined<T> extends TypeAbstract<T> public abstract class TypeCombined<T> extends TypeAbstract<T>
{ {
// -------------------------------------------- //
// CONSTANTS
// -------------------------------------------- //
public static final String SEPARATORS_DEFAULT = ", ";
public static final String SEPARATORS_LENIENT = " .,:-#";
// -------------------------------------------- // // -------------------------------------------- //
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
private Pattern separatorsPattern = null; private Pattern separatorsPattern = null;
public Pattern getSeparatorsPattern() { return this.separatorsPattern; } public Pattern getSeparatorsPattern() { return this.separatorsPattern; }
public void setSeparatorsPattern(Pattern separatorsPattern) { this.separatorsPattern = separatorsPattern; }
private void buildSeparatorsPattern() { this.separatorsPattern = buildSeparatorsPattern(this.separators); } private void buildSeparatorsPattern() { this.separatorsPattern = buildSeparatorsPattern(this.separators); }
private String separators = null; private String separators = null;
@ -72,7 +80,7 @@ public abstract class TypeCombined<T> extends TypeAbstract<T>
public TypeCombined(Type<?>... innerTypes) public TypeCombined(Type<?>... innerTypes)
{ {
this.setInnerTypes(innerTypes); this.setInnerTypes(innerTypes);
this.setSeparators(", "); this.setSeparators(SEPARATORS_DEFAULT);
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -218,7 +226,7 @@ public abstract class TypeCombined<T> extends TypeAbstract<T>
// Fill // Fill
List<String> innerArgs = this.getArgs(arg); List<String> innerArgs = this.getArgs(arg);
if (innerArgs.size() > this.getInnerTypes().size()) throw new MassiveException().addMsg("<b>Too many arguments!"); if (innerArgs.size() > this.getInnerTypes().size()) throw new MassiveException().addMsg("<b>Too many arguments.");
for (int i = 0; i < innerArgs.size(); i++) for (int i = 0; i < innerArgs.size(); i++)
{ {