Remove Ess object from FakeServer.

This commit is contained in:
KHobbits 2014-04-14 00:03:07 +01:00
parent 9e9409da1e
commit cd38aeb544
11 changed files with 25 additions and 25 deletions

View file

@ -680,6 +680,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials
LOGGER.log(Level.INFO, "Constructing new userfile from base player {0}", base.getName());
}
user = new User(base, this);
user.setLastAccountName(base.getName());
}
else
{

View file

@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n.tl;
import java.net.InetSocketAddress;
import java.util.*;
import lombok.Delegate;
import net.ess3.api.IEssentials;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.conversations.Conversation;
@ -27,7 +26,7 @@ import org.bukkit.util.Vector;
public class OfflinePlayer implements Player
{
private final transient IEssentials ess;
private final transient Server server;
private transient Location location = new Location(null, 0, 0, 0, 0, 0);
private transient World world;
@Delegate(types = org.bukkit.OfflinePlayer.class)
@ -35,18 +34,18 @@ public class OfflinePlayer implements Player
private boolean allowFlight = false;
private boolean isFlying = false;
public OfflinePlayer(final UUID uuid, final IEssentials ess)
public OfflinePlayer(final UUID uuid, final Server server)
{
this.ess = ess;
this.world = ess.getServer().getWorlds().get(0);
this.base = ess.getServer().getOfflinePlayer(uuid);
this.server = server;
this.world = server.getWorlds().get(0);
this.base = server.getOfflinePlayer(uuid);
}
public OfflinePlayer(final String name, final IEssentials ess)
public OfflinePlayer(final String name, final Server server)
{
this.ess = ess;
this.world = ess.getServer().getWorlds().get(0);
this.base = ess.getServer().getOfflinePlayer(name);
this.server = server;
this.world = server.getWorlds().get(0);
this.base = server.getOfflinePlayer(name);
}
@Override
@ -288,7 +287,7 @@ public class OfflinePlayer implements Player
@Override
public Server getServer()
{
return ess == null ? null : ess.getServer();
return server;
}
public Vector getMomentum()
@ -903,7 +902,7 @@ public class OfflinePlayer implements Player
{
if (!this.base.getName().equalsIgnoreCase(name))
{
this.base = ess.getServer().getOfflinePlayer(name);
this.base = server.getOfflinePlayer(name);
}
}

View file

@ -45,7 +45,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
private boolean enderSee = false;
private transient long teleportInvulnerabilityTimestamp = 0;
User(final Player base, final IEssentials ess)
public User(final Player base, final IEssentials ess)
{
super(base, ess);
teleport = new Teleport(this, ess);
@ -225,7 +225,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
public void dispose()
{
this.base = new OfflinePlayer(base.getUniqueId(), ess);
this.base = new OfflinePlayer(base.getUniqueId(), ess.getServer());
}
@Override

View file

@ -206,7 +206,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
if (userFile.exists())
{
keys.add(uuid);
return new User(new OfflinePlayer(uuid, ess), ess);
return new User(new OfflinePlayer(uuid, ess.getServer()), ess);
}
throw new Exception("User not found!");

View file

@ -33,7 +33,7 @@ public class Commandban extends EssentialsCommand
catch (PlayerNotFoundException e)
{
nomatch = true;
user = ess.getUser(new OfflinePlayer(args[0], ess));
user = ess.getUser(new OfflinePlayer(args[0], ess.getServer()));
}
if (!user.getBase().isOnline())
{

View file

@ -32,7 +32,7 @@ public class Commandmute extends EssentialsCommand
catch (PlayerNotFoundException e)
{
nomatch = true;
user = ess.getUser(new OfflinePlayer(args[0], ess));
user = ess.getUser(new OfflinePlayer(args[0], ess.getServer()));
}
if (!user.getBase().isOnline())
{

View file

@ -34,7 +34,7 @@ public class EconomyTest extends TestCase
{
fail("IOException");
}
server.addPlayer(new OfflinePlayer(PLAYERNAME, ess));
server.addPlayer(new OfflinePlayer(PLAYERNAME, ess.getServer()));
}
// only one big test, since we use static instances

View file

@ -564,9 +564,9 @@ public class FakeServer implements Server
players.add(base1);
}
public OfflinePlayer createPlayer(String name, IEssentials ess)
public OfflinePlayer createPlayer(String name)
{
OfflinePlayer player = new OfflinePlayer(name, ess);
OfflinePlayer player = new OfflinePlayer(name, this);
player.setLocation(new Location(worlds.get(0), 0, 0, 0, 0, 0));
return player;
}

View file

@ -39,7 +39,7 @@ public class StorageTest extends TestCase
{
ExecuteTimer ext = new ExecuteTimer();
ext.start();
OfflinePlayer base1 = server.createPlayer("testPlayer1", ess);
OfflinePlayer base1 = server.createPlayer("testPlayer1");
server.addPlayer(base1);
ext.mark("fake user created");
UserData user = (UserData)ess.getUser(base1);

View file

@ -33,7 +33,7 @@ public class ToggleTest extends TestCase
{
fail("IOException");
}
base1 = server.createPlayer("testPlayer1", ess);
base1 = server.createPlayer("testPlayer1");
server.addPlayer(base1);
ess.getUser(base1);
}

View file

@ -33,7 +33,7 @@ public class UserTest extends TestCase
{
fail("IOException");
}
base1 = server.createPlayer("testPlayer1", ess);
base1 = server.createPlayer("testPlayer1");
server.addPlayer(base1);
ess.getUser(base1);
}
@ -45,7 +45,7 @@ public class UserTest extends TestCase
public void testUpdate()
{
OfflinePlayer base1alt = server.createPlayer(base1.getName(), ess);
OfflinePlayer base1alt = server.createPlayer(base1.getName());
assertEquals(base1alt, ess.getUser(base1alt).getBase());
}
@ -54,7 +54,7 @@ public class UserTest extends TestCase
User user = ess.getUser(base1);
Location loc = base1.getLocation();
user.setHome("home", loc);
OfflinePlayer base2 = server.createPlayer(base1.getName(), ess);
OfflinePlayer base2 = server.createPlayer(base1.getName());
User user2 = ess.getUser(base2);
Location home = user2.getHome(loc);