1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-16 11:37:30 +02:00

Fixing the Testcases

This commit is contained in:
snowleo
2012-02-05 17:35:47 +01:00
parent 8ab5bad988
commit a60f280a1c
6 changed files with 24 additions and 21 deletions

View File

@@ -269,7 +269,7 @@ public class Teleport implements Runnable, ITeleport
user.acquireReadLock(); user.acquireReadLock();
try try
{ {
teleport(new Target(user.getData().getLastLocation()), chargeFor, TeleportCause.COMMAND); teleport(new Target(user.getData().getLastLocation().getBukkitLocation()), chargeFor, TeleportCause.COMMAND);
} }
finally finally
{ {
@@ -282,7 +282,7 @@ public class Teleport implements Runnable, ITeleport
user.acquireReadLock(); user.acquireReadLock();
try try
{ {
now(new Target(user.getData().getLastLocation()), TeleportCause.COMMAND); now(new Target(user.getData().getLastLocation().getBukkitLocation()), TeleportCause.COMMAND);
} }
finally finally
{ {

View File

@@ -36,9 +36,9 @@ public class Commandsethome extends EssentialsCommand
user.acquireWriteLock(); user.acquireWriteLock();
if (user.getData().getHomes() == null) 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 else
{ {
@@ -73,9 +73,9 @@ public class Commandsethome extends EssentialsCommand
usersHome.acquireWriteLock(); usersHome.acquireWriteLock();
if (usersHome.getData().getHomes() == null) 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(); user.acquireWriteLock();
if (user.getData().getHomes() == null) 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")); user.sendMessage(_("homeSet"));

View File

@@ -190,7 +190,7 @@ public class User extends UserBase implements IUser
acquireWriteLock(); acquireWriteLock();
try try
{ {
getData().setLastLocation(getLocation()); getData().setLastLocation(new com.earth2me.essentials.storage.Location(getLocation()));
} }
finally finally
{ {

View File

@@ -243,13 +243,13 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
acquireWriteLock(); acquireWriteLock();
try try
{ {
Map<String, Location> homes = getData().getHomes(); Map<String, com.earth2me.essentials.storage.Location> homes = getData().getHomes();
if (homes == null) if (homes == null)
{ {
homes = new HashMap<String, Location>(); homes = new HashMap<String, com.earth2me.essentials.storage.Location>();
getData().setHomes(homes); getData().setHomes(homes);
} }
homes.put(Util.sanitizeKey(name), loc); homes.put(Util.sanitizeKey(name), new com.earth2me.essentials.storage.Location(loc));
} }
finally finally
{ {
@@ -417,10 +417,17 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
return null; return null;
} }
ArrayList<Location> worldHomes = new ArrayList<Location>(); 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())) { if (location.getWorldName().equals(loc.getWorld().getName())) {
worldHomes.add(location); try
{
worldHomes.add(location.getBukkitLocation());
}
catch (WorldNotLoadedException ex)
{
continue;
}
} }
} }
if (worldHomes.isEmpty()) { if (worldHomes.isEmpty()) {

View File

@@ -1,13 +1,9 @@
package com.earth2me.essentials.user; package com.earth2me.essentials.user;
import com.earth2me.essentials.storage.ListType; import com.earth2me.essentials.storage.*;
import com.earth2me.essentials.storage.MapKeyType;
import com.earth2me.essentials.storage.MapValueType;
import com.earth2me.essentials.storage.StorageObject;
import java.util.*; import java.util.*;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;

View File

@@ -98,7 +98,7 @@ public class StorageTest extends TestCase
for (int j = 0; j < 10000; j++) 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"); ext.mark("change home 10000 times");
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();