diff options
author | snowleo <schneeleo@gmail.com> | 2012-02-05 17:35:47 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2012-02-05 17:35:47 +0100 |
commit | a60f280a1c286d6c553fac3e2e4aaf82dd21fd34 (patch) | |
tree | aae4265c10a013357f8a47d6a1bba351c8568306 | |
parent | 8ab5bad988f7ad9c8a1fafd504cf108f3ec84cc3 (diff) | |
download | Essentials-a60f280a1c286d6c553fac3e2e4aaf82dd21fd34.tar Essentials-a60f280a1c286d6c553fac3e2e4aaf82dd21fd34.tar.gz Essentials-a60f280a1c286d6c553fac3e2e4aaf82dd21fd34.tar.lz Essentials-a60f280a1c286d6c553fac3e2e4aaf82dd21fd34.tar.xz Essentials-a60f280a1c286d6c553fac3e2e4aaf82dd21fd34.zip |
Fixing the Testcases
6 files changed, 24 insertions, 21 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index 78844d7b1..971b11ba5 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -269,7 +269,7 @@ public class Teleport implements Runnable, ITeleport user.acquireReadLock(); try { - teleport(new Target(user.getData().getLastLocation()), chargeFor, TeleportCause.COMMAND); + teleport(new Target(user.getData().getLastLocation().getBukkitLocation()), chargeFor, TeleportCause.COMMAND); } finally { @@ -282,7 +282,7 @@ public class Teleport implements Runnable, ITeleport user.acquireReadLock(); try { - now(new Target(user.getData().getLastLocation()), TeleportCause.COMMAND); + now(new Target(user.getData().getLastLocation().getBukkitLocation()), TeleportCause.COMMAND); } finally { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java index f2cf9d762..18693dd99 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java @@ -36,9 +36,9 @@ public class Commandsethome extends EssentialsCommand user.acquireWriteLock(); if (user.getData().getHomes() == null) { - user.getData().setHomes(new HashMap<String, Location>()); + user.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.Location>()); } - user.getData().getHomes().put(args[0].toLowerCase(Locale.ENGLISH), user.getLocation()); + user.getData().getHomes().put(args[0].toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(user.getLocation())); } else { @@ -73,9 +73,9 @@ public class Commandsethome extends EssentialsCommand usersHome.acquireWriteLock(); if (usersHome.getData().getHomes() == null) { - usersHome.getData().setHomes(new HashMap<String, Location>()); + usersHome.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.Location>()); } - usersHome.getData().getHomes().put(name, user.getLocation()); + usersHome.getData().getHomes().put(name, new com.earth2me.essentials.storage.Location(user.getLocation())); } } } @@ -84,9 +84,9 @@ public class Commandsethome extends EssentialsCommand user.acquireWriteLock(); if (user.getData().getHomes() == null) { - user.getData().setHomes(new HashMap<String, Location>()); + user.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.Location>()); } - user.getData().getHomes().put("home", user.getLocation()); + user.getData().getHomes().put("home", new com.earth2me.essentials.storage.Location(user.getLocation())); } user.sendMessage(_("homeSet")); diff --git a/Essentials/src/com/earth2me/essentials/user/User.java b/Essentials/src/com/earth2me/essentials/user/User.java index 1f64b0b05..ecd71f34d 100644 --- a/Essentials/src/com/earth2me/essentials/user/User.java +++ b/Essentials/src/com/earth2me/essentials/user/User.java @@ -190,7 +190,7 @@ public class User extends UserBase implements IUser acquireWriteLock(); try { - getData().setLastLocation(getLocation()); + getData().setLastLocation(new com.earth2me.essentials.storage.Location(getLocation())); } finally { diff --git a/Essentials/src/com/earth2me/essentials/user/UserBase.java b/Essentials/src/com/earth2me/essentials/user/UserBase.java index f913796c2..ac2197b33 100644 --- a/Essentials/src/com/earth2me/essentials/user/UserBase.java +++ b/Essentials/src/com/earth2me/essentials/user/UserBase.java @@ -243,13 +243,13 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem acquireWriteLock(); try { - Map<String, Location> homes = getData().getHomes(); + Map<String, com.earth2me.essentials.storage.Location> homes = getData().getHomes(); if (homes == null) { - homes = new HashMap<String, Location>(); + homes = new HashMap<String, com.earth2me.essentials.storage.Location>(); getData().setHomes(homes); } - homes.put(Util.sanitizeKey(name), loc); + homes.put(Util.sanitizeKey(name), new com.earth2me.essentials.storage.Location(loc)); } finally { @@ -417,10 +417,17 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem return null; } ArrayList<Location> worldHomes = new ArrayList<Location>(); - for (Location location : getData().getHomes().values()) + for (com.earth2me.essentials.storage.Location location : getData().getHomes().values()) { - if (location.getWorld().equals(loc.getWorld())) { - worldHomes.add(location); + if (location.getWorldName().equals(loc.getWorld().getName())) { + try + { + worldHomes.add(location.getBukkitLocation()); + } + catch (WorldNotLoadedException ex) + { + continue; + } } } if (worldHomes.isEmpty()) { diff --git a/Essentials/src/com/earth2me/essentials/user/UserData.java b/Essentials/src/com/earth2me/essentials/user/UserData.java index 7a11f5f9d..d61d21a49 100644 --- a/Essentials/src/com/earth2me/essentials/user/UserData.java +++ b/Essentials/src/com/earth2me/essentials/user/UserData.java @@ -1,13 +1,9 @@ package com.earth2me.essentials.user; -import com.earth2me.essentials.storage.ListType; -import com.earth2me.essentials.storage.MapKeyType; -import com.earth2me.essentials.storage.MapValueType; -import com.earth2me.essentials.storage.StorageObject; +import com.earth2me.essentials.storage.*; import java.util.*; import lombok.Data; import lombok.EqualsAndHashCode; -import org.bukkit.Location; import org.bukkit.Material; diff --git a/Essentials/test/com/earth2me/essentials/StorageTest.java b/Essentials/test/com/earth2me/essentials/StorageTest.java index a04c6b34f..21dc51b55 100644 --- a/Essentials/test/com/earth2me/essentials/StorageTest.java +++ b/Essentials/test/com/earth2me/essentials/StorageTest.java @@ -98,7 +98,7 @@ public class StorageTest extends TestCase for (int j = 0; j < 10000; j++) { - userdata.getHomes().put("home", new Location(world, j, j, j)); + userdata.getHomes().put("home", new com.earth2me.essentials.storage.Location(new Location(world, j, j, j))); } ext.mark("change home 10000 times"); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); |