diff --git a/src/com/massivecraft/massivecore/command/MassiveCommand.java b/src/com/massivecraft/massivecore/command/MassiveCommand.java index 1352fe4c..d6afbb47 100644 --- a/src/com/massivecraft/massivecore/command/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/command/MassiveCommand.java @@ -25,6 +25,7 @@ import com.massivecraft.massivecore.MassivePlugin; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.command.requirement.Requirement; +import com.massivecraft.massivecore.command.requirement.RequirementAbstract; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.type.Type; import com.massivecraft.massivecore.mixin.Mixin; @@ -331,9 +332,9 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand public void addChild(MassiveCommand child, int index) { - if (this.children.isEmpty() && ! (child instanceof HelpCommand)) + if (this.children.isEmpty() && ! (child instanceof MassiveCommandHelp)) { - this.children.add(0, HelpCommand.get()); + this.children.add(0, MassiveCommandHelp.get()); index++; } child.addToChain(this); @@ -718,20 +719,12 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand public boolean isRequirementsMet(CommandSender sender, boolean verboose) { - String error = this.getRequirementsError(sender, verboose); - if (error != null && verboose) Mixin.messageOne(sender, error); - return error == null; + return RequirementAbstract.isRequirementsMet(this.getRequirements(), sender, this, verboose); } public String getRequirementsError(CommandSender sender, boolean verboose) { - for (Requirement requirement : this.getRequirements()) - { - if (requirement.apply(sender, this)) continue; - if ( ! verboose) return ""; - return requirement.createErrorMessage(sender, this); - } - return null; + return RequirementAbstract.getRequirementsError(this.getRequirements(), sender, this, verboose); } // -------------------------------------------- // @@ -943,7 +936,7 @@ public class MassiveCommand implements Active, PluginIdentifiableCommand List chain = new ArrayList(this.getChain()); chain.add(this); - HelpCommand.get().execute(this.sender, this.getArgs(), chain); + MassiveCommandHelp.get().execute(this.sender, this.getArgs(), chain); } // -------------------------------------------- // diff --git a/src/com/massivecraft/massivecore/command/DeprecatedCommand.java b/src/com/massivecraft/massivecore/command/MassiveCommandDeprecated.java similarity index 84% rename from src/com/massivecraft/massivecore/command/DeprecatedCommand.java rename to src/com/massivecraft/massivecore/command/MassiveCommandDeprecated.java index 723a28a7..16d0ed0a 100644 --- a/src/com/massivecraft/massivecore/command/DeprecatedCommand.java +++ b/src/com/massivecraft/massivecore/command/MassiveCommandDeprecated.java @@ -1,6 +1,6 @@ package com.massivecraft.massivecore.command; -public class DeprecatedCommand extends MassiveCommand +public class MassiveCommandDeprecated extends MassiveCommand { // -------------------------------------------- // // FIELDS @@ -12,7 +12,7 @@ public class DeprecatedCommand extends MassiveCommand // CONSTRUCT // -------------------------------------------- // - public DeprecatedCommand(MassiveCommand target, String... aliases) + public MassiveCommandDeprecated(MassiveCommand target, String... aliases) { // Fields this.target = target; diff --git a/src/com/massivecraft/massivecore/command/HelpCommand.java b/src/com/massivecraft/massivecore/command/MassiveCommandHelp.java similarity index 86% rename from src/com/massivecraft/massivecore/command/HelpCommand.java rename to src/com/massivecraft/massivecore/command/MassiveCommandHelp.java index 95fc8d3f..17c2c045 100644 --- a/src/com/massivecraft/massivecore/command/HelpCommand.java +++ b/src/com/massivecraft/massivecore/command/MassiveCommandHelp.java @@ -11,15 +11,15 @@ import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.Txt; -public class HelpCommand extends MassiveCommand +public class MassiveCommandHelp extends MassiveCommand { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - protected static HelpCommand i = new HelpCommand(); - public static HelpCommand get() { return i; } - private HelpCommand() + protected static MassiveCommandHelp i = new MassiveCommandHelp(); + public static MassiveCommandHelp get() { return i; } + private MassiveCommandHelp() { // Aliases this.addAliases("?", "h", "help"); diff --git a/src/com/massivecraft/massivecore/command/MassiveCommandToggle.java b/src/com/massivecraft/massivecore/command/MassiveCommandToggle.java new file mode 100644 index 00000000..43806cc3 --- /dev/null +++ b/src/com/massivecraft/massivecore/command/MassiveCommandToggle.java @@ -0,0 +1,83 @@ +package com.massivecraft.massivecore.command; + +import java.util.List; + +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeBoolean; +import com.massivecraft.massivecore.util.Txt; + +public abstract class MassiveCommandToggle extends MassiveCommand +{ + // -------------------------------------------- // + // FIELD + // -------------------------------------------- // + + protected String info = null; + public String getInfo() { return this.info; } + public void setInfo(String info) { this.info = info; } + public String getInfoSuffix() + { + String info = this.getInfo(); + if (info == null) return ""; + return " " + info; + } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public MassiveCommandToggle() + { + // Parameters + this.addParameter(TypeBoolean.getOn(), "on|off", "toggle"); + } + + // -------------------------------------------- // + // ABSTRACT + // -------------------------------------------- // + + public abstract boolean get(); + + public abstract void set(boolean value); + + // -------------------------------------------- // + // GET NAME + // -------------------------------------------- // + + public String getName() + { + List aliases = this.getAliases(); + return Txt.upperCaseFirst(aliases.get(aliases.size() - 1)); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void perform() throws MassiveException + { + // Args + boolean before = this.get(); + boolean after = this.readArg( ! before); + String afterDesc = TypeBoolean.getOn().getVisual(after, sender); + + // NoChange + if (after == before) + { + String message = Txt.parse("%s is already %s.", this.getName(), afterDesc); + if (after) message += this.getInfoSuffix(); + message(message); + return; + } + + // Apply + set(after); + + // Inform + String message = Txt.parse("%s is now %s.", this.getName(), afterDesc); + if (after) message += this.getInfoSuffix(); + message(message); + } + +} diff --git a/src/com/massivecraft/massivecore/command/VersionCommand.java b/src/com/massivecraft/massivecore/command/MassiveCommandVersion.java similarity index 87% rename from src/com/massivecraft/massivecore/command/VersionCommand.java rename to src/com/massivecraft/massivecore/command/MassiveCommandVersion.java index 6140c3d2..096dae52 100644 --- a/src/com/massivecraft/massivecore/command/VersionCommand.java +++ b/src/com/massivecraft/massivecore/command/MassiveCommandVersion.java @@ -10,7 +10,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.util.Txt; -public class VersionCommand extends MassiveCommand +public class MassiveCommandVersion extends MassiveCommand { // -------------------------------------------- // // CONSTANTS @@ -29,12 +29,12 @@ public class VersionCommand extends MassiveCommand // CONSTRUCT // -------------------------------------------- // - public VersionCommand(Plugin plugin, String permissionName, String... aliases) + public MassiveCommandVersion(Plugin plugin, String permissionName, String... aliases) { this(plugin, permissionName, Arrays.asList(aliases)); } - public VersionCommand(Plugin plugin, String permissionName, Collection aliases) + public MassiveCommandVersion(Plugin plugin, String permissionName, Collection aliases) { this.plugin = plugin; diff --git a/src/com/massivecraft/massivecore/command/massivecore/CmdMassiveCore.java b/src/com/massivecraft/massivecore/command/massivecore/CmdMassiveCore.java index 57dca24e..b4a00034 100644 --- a/src/com/massivecraft/massivecore/command/massivecore/CmdMassiveCore.java +++ b/src/com/massivecraft/massivecore/command/massivecore/CmdMassiveCore.java @@ -6,7 +6,7 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCoreMConf; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.command.MassiveCommand; -import com.massivecraft.massivecore.command.VersionCommand; +import com.massivecraft.massivecore.command.MassiveCommandVersion; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; public class CmdMassiveCore extends MassiveCommand @@ -29,7 +29,7 @@ public class CmdMassiveCore extends MassiveCommand public CmdMassiveCoreHearsound cmdMassiveCoreHearsound = new CmdMassiveCoreHearsound(); public CmdMassiveCoreBuffer cmdMassiveCoreBuffer = new CmdMassiveCoreBuffer(); public CmdMassiveCoreCmdurl cmdMassiveCoreCmdurl = new CmdMassiveCoreCmdurl(); - public VersionCommand cmdMassiveCoreVersion = new VersionCommand(MassiveCore.get(), MassiveCorePerm.VERSION.node, "v", "version"); + public MassiveCommandVersion cmdMassiveCoreVersion = new MassiveCommandVersion(MassiveCore.get(), MassiveCorePerm.VERSION.node, "v", "version"); // -------------------------------------------- // // CONSTRUCT diff --git a/src/com/massivecraft/massivecore/command/requirement/RequirementAbstract.java b/src/com/massivecraft/massivecore/command/requirement/RequirementAbstract.java index 061c68bd..53c7783e 100644 --- a/src/com/massivecraft/massivecore/command/requirement/RequirementAbstract.java +++ b/src/com/massivecraft/massivecore/command/requirement/RequirementAbstract.java @@ -5,11 +5,16 @@ import java.io.Serializable; import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.command.MassiveCommand; +import com.massivecraft.massivecore.mixin.Mixin; public abstract class RequirementAbstract implements Requirement, Serializable { private static final long serialVersionUID = 1L; + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public boolean apply(CommandSender sender) { @@ -28,4 +33,26 @@ public abstract class RequirementAbstract implements Requirement, Serializable return command.getDesc(); } + // -------------------------------------------- // + // BULK + // -------------------------------------------- // + + public static boolean isRequirementsMet(Iterable requirements, CommandSender sender, MassiveCommand command, boolean verboose) + { + String error = getRequirementsError(requirements, sender, command, verboose); + if (error != null && verboose) Mixin.messageOne(sender, error); + return error == null; + } + + public static String getRequirementsError(Iterable requirements, CommandSender sender, MassiveCommand command, boolean verboose) + { + for (Requirement requirement : requirements) + { + if (requirement.apply(sender, command)) continue; + if ( ! verboose) return ""; + return requirement.createErrorMessage(sender, command); + } + return null; + } + } diff --git a/src/com/massivecraft/massivecore/command/type/TypeNameAbstract.java b/src/com/massivecraft/massivecore/command/type/TypeNameAbstract.java new file mode 100644 index 00000000..25988b4b --- /dev/null +++ b/src/com/massivecraft/massivecore/command/type/TypeNameAbstract.java @@ -0,0 +1,62 @@ +package com.massivecraft.massivecore.command.type; + +import java.util.Collection; +import java.util.Collections; + +import org.bukkit.command.CommandSender; + +import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.TypeAbstract; + +public abstract class TypeNameAbstract extends TypeAbstract +{ + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + private final boolean strict; + public boolean isStrict() { return this.strict; } + public boolean isLenient() { return ! this.isStrict(); } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public TypeNameAbstract(boolean strict) + { + this.strict = strict; + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public String read(String arg, CommandSender sender) throws MassiveException + { + if (arg == null) throw new NullPointerException("arg"); + + // Allow changing capitalization of the current name if lenient. + String current = this.getCurrentName(sender); + if (current != null && current.equalsIgnoreCase(arg) && this.isLenient()) return arg; + + if (this.isNameTaken(arg)) throw new MassiveException().addMsg("The name \"%s\" is already in use.",arg); + + return arg; + } + + @Override + public Collection getTabList(CommandSender sender, String arg) + { + return Collections.emptyList(); + } + + // -------------------------------------------- // + // ABSTRACT + // -------------------------------------------- // + + public abstract String getCurrentName(CommandSender sender); + + public abstract boolean isNameTaken(String name); + +} diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorAbstract.java b/src/com/massivecraft/massivecore/comparator/ComparatorAbstract.java index 1f1b0936..1fb6712a 100644 --- a/src/com/massivecraft/massivecore/comparator/ComparatorAbstract.java +++ b/src/com/massivecraft/massivecore/comparator/ComparatorAbstract.java @@ -2,6 +2,9 @@ package com.massivecraft.massivecore.comparator; import java.util.Comparator; +import com.massivecraft.massivecore.Named; +import com.massivecraft.massivecore.Prioritized; +import com.massivecraft.massivecore.store.Entity; import com.massivecraft.massivecore.util.MUtil; public class ComparatorAbstract implements Comparator @@ -35,7 +38,6 @@ public class ComparatorAbstract implements Comparator @Override public int compare(T type1, T type2) { - // Create Integer ret; // Null @@ -44,18 +46,48 @@ public class ComparatorAbstract implements Comparator // Inner ret = this.compareInner(type1, type2); + if (ret != null) return ret; - // Return - return ret; + // Prioritized + if (type1 instanceof Prioritized) + { + Prioritized prioritized1 = (Prioritized)type1; + Prioritized prioritized2 = (Prioritized)type2; + + ret = Integer.compare(prioritized1.getPriority(), prioritized2.getPriority()); + if (ret != null) return ret; + } + + // Named + if (type1 instanceof Named) + { + Named named1 = (Named)type1; + Named named2 = (Named)type2; + + ret = ComparatorNaturalOrder.get().compare(named1.getName(), named2.getName()); + if (ret != null) return ret; + } + + // EntityId + if (type1 instanceof Entity) + { + Entity entity1 = (Entity)type1; + Entity entity2 = (Entity)type2; + ret = MUtil.compare(entity1.getId(), entity2.getId()); + if (ret != null) return ret; + } + + // Identity + return ComparatorIdentity.get().compare(type1, type2); } // -------------------------------------------- // // INNER // -------------------------------------------- // - public int compareInner(T type1, T type2) + public Integer compareInner(T type1, T type2) { - throw new UnsupportedOperationException("not implemented"); + return null; } } diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorAbstractTransformer.java b/src/com/massivecraft/massivecore/comparator/ComparatorAbstractTransformer.java index 9fbed9c6..a3ec2b26 100644 --- a/src/com/massivecraft/massivecore/comparator/ComparatorAbstractTransformer.java +++ b/src/com/massivecraft/massivecore/comparator/ComparatorAbstractTransformer.java @@ -18,7 +18,7 @@ public abstract class ComparatorAbstractTransformer extends ComparatorAbst // -------------------------------------------- // @Override - public int compareInner(T type1, T type2) + public Integer compareInner(T type1, T type2) { X x1 = this.transform(type1); X x2 = this.transform(type2); diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorCaseInsensitive.java b/src/com/massivecraft/massivecore/comparator/ComparatorCaseInsensitive.java index d0ca4314..0d311053 100644 --- a/src/com/massivecraft/massivecore/comparator/ComparatorCaseInsensitive.java +++ b/src/com/massivecraft/massivecore/comparator/ComparatorCaseInsensitive.java @@ -14,7 +14,7 @@ public class ComparatorCaseInsensitive extends ComparatorAbstract // -------------------------------------------- // @Override - public int compareInner(String string1, String string2) + public Integer compareInner(String string1, String string2) { return String.CASE_INSENSITIVE_ORDER.compare(string1, string2); } diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorHashCode.java b/src/com/massivecraft/massivecore/comparator/ComparatorHashCode.java index 9d1f9ce4..7c7c2976 100644 --- a/src/com/massivecraft/massivecore/comparator/ComparatorHashCode.java +++ b/src/com/massivecraft/massivecore/comparator/ComparatorHashCode.java @@ -16,14 +16,9 @@ public class ComparatorHashCode extends ComparatorAbstract // -------------------------------------------- // @Override - public int compareInner(Object object1, Object object2) + public Integer compareInner(Object object1, Object object2) { - int ret; - - ret = Integer.compare(Objects.hashCode(object1), Objects.hashCode(object2)); - if (ret != 0) return ret; - - return ret; + return Integer.compare(Objects.hashCode(object1), Objects.hashCode(object2)); } } diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorIdentity.java b/src/com/massivecraft/massivecore/comparator/ComparatorIdentity.java new file mode 100644 index 00000000..66891908 --- /dev/null +++ b/src/com/massivecraft/massivecore/comparator/ComparatorIdentity.java @@ -0,0 +1,23 @@ +package com.massivecraft.massivecore.comparator; + +public class ComparatorIdentity extends ComparatorAbstract +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static transient ComparatorIdentity i = new ComparatorIdentity(); + public static ComparatorIdentity get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public Integer compareInner(Object object1, Object object2) + { + if (object1 == object2) return 0; + return Integer.compare(System.identityHashCode(object1), System.identityHashCode(object2)); + } + +} diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorIdentityHashCode.java b/src/com/massivecraft/massivecore/comparator/ComparatorIdentityHashCode.java deleted file mode 100644 index 59a01a32..00000000 --- a/src/com/massivecraft/massivecore/comparator/ComparatorIdentityHashCode.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.massivecraft.massivecore.comparator; - -public class ComparatorIdentityHashCode extends ComparatorAbstract -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static transient ComparatorIdentityHashCode i = new ComparatorIdentityHashCode(); - public static ComparatorIdentityHashCode get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public int compareInner(Object object1, Object object2) - { - int ret; - - ret = Integer.compare(System.identityHashCode(object1), System.identityHashCode(object2)); - if (ret != 0) return ret; - - return ret; - } - -} diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorLenient.java b/src/com/massivecraft/massivecore/comparator/ComparatorLenient.java index 3d175764..c1405498 100644 --- a/src/com/massivecraft/massivecore/comparator/ComparatorLenient.java +++ b/src/com/massivecraft/massivecore/comparator/ComparatorLenient.java @@ -29,7 +29,7 @@ public class ComparatorLenient extends ComparatorAbstractWrapper ret = ComparatorHashCode.get().compare(type1, type2); if (ret != 0) return ret; - ret = ComparatorIdentityHashCode.get().compare(type1, type2); + ret = ComparatorIdentity.get().compare(type1, type2); if (ret != 0) return ret; return 1; diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorNaturalOrder.java b/src/com/massivecraft/massivecore/comparator/ComparatorNaturalOrder.java index 8ec3d5df..ab2dd971 100644 --- a/src/com/massivecraft/massivecore/comparator/ComparatorNaturalOrder.java +++ b/src/com/massivecraft/massivecore/comparator/ComparatorNaturalOrder.java @@ -43,7 +43,7 @@ public class ComparatorNaturalOrder extends ComparatorAbstract // -------------------------------------------- // @Override - public int compareInner(Object object1, Object object2) + public Integer compareInner(Object object1, Object object2) { // Martin Pool String a = object1.toString(); diff --git a/src/com/massivecraft/massivecore/comparator/ComparatorPriority.java b/src/com/massivecraft/massivecore/comparator/ComparatorPriority.java index d8838047..7ac79f0e 100644 --- a/src/com/massivecraft/massivecore/comparator/ComparatorPriority.java +++ b/src/com/massivecraft/massivecore/comparator/ComparatorPriority.java @@ -17,7 +17,7 @@ public class ComparatorPriority extends ComparatorAbstract // -------------------------------------------- // @Override - public int compareInner(Prioritized prioritized1, Prioritized prioritized2) + public Integer compareInner(Prioritized prioritized1, Prioritized prioritized2) { // Equals if (prioritized1.equals(prioritized2)) return 0; @@ -35,7 +35,7 @@ public class ComparatorPriority extends ComparatorAbstract } // We should only return 0 if the items actually are equal. - return Integer.compare(prioritized1.hashCode(), prioritized2.hashCode()); + return ComparatorIdentity.get().compare(prioritized1, prioritized2); } } diff --git a/src/com/massivecraft/massivecore/pager/Pager.java b/src/com/massivecraft/massivecore/pager/Pager.java index 9ba76843..8ec3f33d 100644 --- a/src/com/massivecraft/massivecore/pager/Pager.java +++ b/src/com/massivecraft/massivecore/pager/Pager.java @@ -7,6 +7,7 @@ import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.Txt; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -46,6 +47,7 @@ public class Pager protected List args = null; public boolean hasArgs() { return this.args != null; } public Pager setArgs(List args) { this.args = args; return this; } + public Pager setArgs(String... args) { this.setArgs(Arrays.asList(args)); return this; } public List getArgs() { return this.args; } public List getArgsCalc() { diff --git a/src/com/massivecraft/massivecore/store/Coll.java b/src/com/massivecraft/massivecore/store/Coll.java index 43c7e5f2..fc935b38 100644 --- a/src/com/massivecraft/massivecore/store/Coll.java +++ b/src/com/massivecraft/massivecore/store/Coll.java @@ -14,9 +14,12 @@ import java.util.concurrent.ConcurrentSkipListMap; import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCoreMConf; import com.massivecraft.massivecore.MassivePlugin; +import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.comparator.ComparatorNaturalOrder; import com.massivecraft.massivecore.mixin.Mixin; +import com.massivecraft.massivecore.predicate.Predicate; +import com.massivecraft.massivecore.predicate.PredicateEqualsIgnoreCase; import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.xlib.gson.Gson; import com.massivecraft.massivecore.xlib.gson.JsonElement; @@ -1018,5 +1021,33 @@ public class Coll> extends CollAbstract { return name2instance.containsKey(this.getName()); } - + + + // -------------------------------------------- // + // NAME UTILITIES + // -------------------------------------------- // + + public E getByName(String name) + { + if (name == null) throw new NullPointerException("name"); + + Predicate predicate = PredicateEqualsIgnoreCase.get(name); + for (E entity : this.getAll()) + { + if (entity == null) continue; + + if ( ! (entity instanceof Named)) continue; + Named named = (Named)entity; + + if (predicate.apply(named.getName())) return entity; + } + + return null; + } + + public boolean isNameTaken(String str) + { + return this.getByName(str) != null; + } + } diff --git a/src/com/massivecraft/massivecore/util/Txt.java b/src/com/massivecraft/massivecore/util/Txt.java index b79e6561..b50edac9 100644 --- a/src/com/massivecraft/massivecore/util/Txt.java +++ b/src/com/massivecraft/massivecore/util/Txt.java @@ -167,6 +167,7 @@ public class Txt public static String parse(String string) { + if (string == null) return null; StringBuffer ret = new StringBuffer(); Matcher matcher = parsePattern.matcher(string); while (matcher.find()) @@ -198,6 +199,7 @@ public class Txt public static ArrayList wrap(final String string) { + if (string == null) return null; return new ArrayList(Arrays.asList(PATTERN_NEWLINE.split(string))); }