From bf76b77cf6c2f991d2be9c9b3b5624256bc87cb2 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sun, 22 Jan 2012 14:21:18 -0700 Subject: [PATCH] Add New api methods, Write location format better Closes #411 --- .../com/onarandombox/MultiverseCore/MVWorld.java | 8 ++++++++ .../onarandombox/MultiverseCore/MultiverseCore.java | 2 +- .../MultiverseCore/api/MultiverseWorld.java | 12 ++++++++++++ .../MultiverseCore/utils/LocationManipulation.java | 6 +++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java index 74c2fad0..0a264726 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java @@ -628,6 +628,14 @@ public class MVWorld implements MultiverseWorld { return this.name; } + /** + * {@inheritDoc} + */ + @Override + public String getPermissibleName() { + return this.name.toLowerCase(); + } + /** * {@inheritDoc} */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index e10965ae..164dcf06 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -64,7 +64,7 @@ import java.util.logging.Logger; * The implementation of the Multiverse-{@link Core}. */ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { - private static final int PROTOCOL = 11; + private static final int PROTOCOL = 12; // Global Multiverse config variable, states whether or not // Multiverse should stop other plugins from teleporting players // to worlds. diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java index 1b2cca3f..fb473ce8 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java @@ -145,6 +145,18 @@ public interface MultiverseWorld { */ String getName(); + /** + * Gets the lowercased name of the world. This method is required, since the permissables + * lowercase all permissions when recalculating. + *

+ * Note: This also means if a user has worlds named: world and WORLD, that they can both + * exist, and both be teleported to independently, but their permissions **cannot** be + * uniqueified at this time. See bug report #. + * + * @return The lowercased name of the world. + */ + String getPermissibleName(); + /** * Gets the alias of this world. *

diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/LocationManipulation.java b/src/main/java/com/onarandombox/MultiverseCore/utils/LocationManipulation.java index 132ff259..0c605309 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/LocationManipulation.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/LocationManipulation.java @@ -17,6 +17,7 @@ import org.bukkit.util.Vector; import java.text.DecimalFormat; import java.util.Collections; import java.util.HashMap; +import java.util.Locale; import java.util.Map; /** @@ -57,7 +58,10 @@ public class LocationManipulation { if (location == null) { return ""; } - return String.format("%s:%.2f,%.2f,%.2f:%.2f:%.2f", location.getWorld().getName(), + // We set the locale to ENGLISH here so we always save with the format: + // world:1.2,5.4,3.6:1.8:21.3 + // Otherwise we blow up when parsing! + return String.format(Locale.ENGLISH, "%s:%.2f,%.2f,%.2f:%.2f:%.2f", location.getWorld().getName(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); }