diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java index 24fcc01f79..1fb887da44 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/ChunkTag.java @@ -73,55 +73,32 @@ public static ChunkTag valueOf(String string) { return valueOf(string, null); } - /** - * Gets a Chunk Object from a string form of x,z,world. - * This is not to be confused with the 'x,y,z,world' of a - * location, which is a finer grain of unit in a WorldTags. - * - * @param string the string or dScript argument String - * @return a ChunkTag, or null if incorrectly formatted - */ @Fetchable("ch") public static ChunkTag valueOf(String string, TagContext context) { if (string == null) { return null; } - string = CoreUtilities.toLowerCase(string).replace("ch@", ""); - - //////// - // Match location formats - - // Get a location to fetch its chunk, return if null String[] parts = string.split(","); - if (parts.length == 3) { - try { - return new ChunkTag(new WorldTag(parts[2]), Integer.parseInt(parts[0]), Integer.parseInt(parts[1])); - } - catch (Exception e) { - if (context == null || context.showErrors()) { - Debug.log("Minor: valueOf ChunkTag returning null: " + "ch@" + string); - } - return null; + if (parts.length != 3) { + if (context == null || context.showErrors()) { + Debug.log("Minor: valueOf ChunkTag unable to handle malformed format: " + "ch@" + string); } - + return null; } - else { + try { + return new ChunkTag(new WorldTag(parts[2]), Integer.parseInt(parts[0]), Integer.parseInt(parts[1])); + } + catch (Exception e) { if (context == null || context.showErrors()) { - Debug.log("Minor: valueOf ChunkTag unable to handle malformed format: " + "ch@" + string); + Debug.log("Minor: valueOf ChunkTag returning null: " + "ch@" + string); } + return null; } - - return null; } public static boolean matches(String string) { - if (CoreUtilities.toLowerCase(string).startsWith("ch@")) { - return true; - } - else { - return false; - } + return valueOf(string, CoreUtilities.noDebugContext) != null; } int chunkX, chunkZ;