mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-12 09:35:26 +02:00
Remove Ess object from FakeServer.
This commit is contained in:
@@ -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());
|
LOGGER.log(Level.INFO, "Constructing new userfile from base player {0}", base.getName());
|
||||||
}
|
}
|
||||||
user = new User(base, this);
|
user = new User(base, this);
|
||||||
|
user.setLastAccountName(base.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import lombok.Delegate;
|
import lombok.Delegate;
|
||||||
import net.ess3.api.IEssentials;
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.conversations.Conversation;
|
import org.bukkit.conversations.Conversation;
|
||||||
@@ -27,7 +26,7 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
public class OfflinePlayer implements Player
|
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 Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||||
private transient World world;
|
private transient World world;
|
||||||
@Delegate(types = org.bukkit.OfflinePlayer.class)
|
@Delegate(types = org.bukkit.OfflinePlayer.class)
|
||||||
@@ -35,18 +34,18 @@ public class OfflinePlayer implements Player
|
|||||||
private boolean allowFlight = false;
|
private boolean allowFlight = false;
|
||||||
private boolean isFlying = 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.server = server;
|
||||||
this.world = ess.getServer().getWorlds().get(0);
|
this.world = server.getWorlds().get(0);
|
||||||
this.base = ess.getServer().getOfflinePlayer(uuid);
|
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.server = server;
|
||||||
this.world = ess.getServer().getWorlds().get(0);
|
this.world = server.getWorlds().get(0);
|
||||||
this.base = ess.getServer().getOfflinePlayer(name);
|
this.base = server.getOfflinePlayer(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -288,7 +287,7 @@ public class OfflinePlayer implements Player
|
|||||||
@Override
|
@Override
|
||||||
public Server getServer()
|
public Server getServer()
|
||||||
{
|
{
|
||||||
return ess == null ? null : ess.getServer();
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getMomentum()
|
public Vector getMomentum()
|
||||||
@@ -903,7 +902,7 @@ public class OfflinePlayer implements Player
|
|||||||
{
|
{
|
||||||
if (!this.base.getName().equalsIgnoreCase(name))
|
if (!this.base.getName().equalsIgnoreCase(name))
|
||||||
{
|
{
|
||||||
this.base = ess.getServer().getOfflinePlayer(name);
|
this.base = server.getOfflinePlayer(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
|||||||
private boolean enderSee = false;
|
private boolean enderSee = false;
|
||||||
private transient long teleportInvulnerabilityTimestamp = 0;
|
private transient long teleportInvulnerabilityTimestamp = 0;
|
||||||
|
|
||||||
User(final Player base, final IEssentials ess)
|
public User(final Player base, final IEssentials ess)
|
||||||
{
|
{
|
||||||
super(base, ess);
|
super(base, ess);
|
||||||
teleport = new Teleport(this, ess);
|
teleport = new Teleport(this, ess);
|
||||||
@@ -225,7 +225,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
|||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
this.base = new OfflinePlayer(base.getUniqueId(), ess);
|
this.base = new OfflinePlayer(base.getUniqueId(), ess.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -206,7 +206,7 @@ public class UserMap extends CacheLoader<UUID, User> implements IConf
|
|||||||
if (userFile.exists())
|
if (userFile.exists())
|
||||||
{
|
{
|
||||||
keys.add(uuid);
|
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!");
|
throw new Exception("User not found!");
|
||||||
|
@@ -33,7 +33,7 @@ public class Commandban extends EssentialsCommand
|
|||||||
catch (PlayerNotFoundException e)
|
catch (PlayerNotFoundException e)
|
||||||
{
|
{
|
||||||
nomatch = true;
|
nomatch = true;
|
||||||
user = ess.getUser(new OfflinePlayer(args[0], ess));
|
user = ess.getUser(new OfflinePlayer(args[0], ess.getServer()));
|
||||||
}
|
}
|
||||||
if (!user.getBase().isOnline())
|
if (!user.getBase().isOnline())
|
||||||
{
|
{
|
||||||
|
@@ -32,7 +32,7 @@ public class Commandmute extends EssentialsCommand
|
|||||||
catch (PlayerNotFoundException e)
|
catch (PlayerNotFoundException e)
|
||||||
{
|
{
|
||||||
nomatch = true;
|
nomatch = true;
|
||||||
user = ess.getUser(new OfflinePlayer(args[0], ess));
|
user = ess.getUser(new OfflinePlayer(args[0], ess.getServer()));
|
||||||
}
|
}
|
||||||
if (!user.getBase().isOnline())
|
if (!user.getBase().isOnline())
|
||||||
{
|
{
|
||||||
|
@@ -34,7 +34,7 @@ public class EconomyTest extends TestCase
|
|||||||
{
|
{
|
||||||
fail("IOException");
|
fail("IOException");
|
||||||
}
|
}
|
||||||
server.addPlayer(new OfflinePlayer(PLAYERNAME, ess));
|
server.addPlayer(new OfflinePlayer(PLAYERNAME, ess.getServer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only one big test, since we use static instances
|
// only one big test, since we use static instances
|
||||||
|
@@ -564,9 +564,9 @@ public class FakeServer implements Server
|
|||||||
players.add(base1);
|
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));
|
player.setLocation(new Location(worlds.get(0), 0, 0, 0, 0, 0));
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ public class StorageTest extends TestCase
|
|||||||
{
|
{
|
||||||
ExecuteTimer ext = new ExecuteTimer();
|
ExecuteTimer ext = new ExecuteTimer();
|
||||||
ext.start();
|
ext.start();
|
||||||
OfflinePlayer base1 = server.createPlayer("testPlayer1", ess);
|
OfflinePlayer base1 = server.createPlayer("testPlayer1");
|
||||||
server.addPlayer(base1);
|
server.addPlayer(base1);
|
||||||
ext.mark("fake user created");
|
ext.mark("fake user created");
|
||||||
UserData user = (UserData)ess.getUser(base1);
|
UserData user = (UserData)ess.getUser(base1);
|
||||||
|
@@ -33,7 +33,7 @@ public class ToggleTest extends TestCase
|
|||||||
{
|
{
|
||||||
fail("IOException");
|
fail("IOException");
|
||||||
}
|
}
|
||||||
base1 = server.createPlayer("testPlayer1", ess);
|
base1 = server.createPlayer("testPlayer1");
|
||||||
server.addPlayer(base1);
|
server.addPlayer(base1);
|
||||||
ess.getUser(base1);
|
ess.getUser(base1);
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ public class UserTest extends TestCase
|
|||||||
{
|
{
|
||||||
fail("IOException");
|
fail("IOException");
|
||||||
}
|
}
|
||||||
base1 = server.createPlayer("testPlayer1", ess);
|
base1 = server.createPlayer("testPlayer1");
|
||||||
server.addPlayer(base1);
|
server.addPlayer(base1);
|
||||||
ess.getUser(base1);
|
ess.getUser(base1);
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ public class UserTest extends TestCase
|
|||||||
|
|
||||||
public void testUpdate()
|
public void testUpdate()
|
||||||
{
|
{
|
||||||
OfflinePlayer base1alt = server.createPlayer(base1.getName(), ess);
|
OfflinePlayer base1alt = server.createPlayer(base1.getName());
|
||||||
assertEquals(base1alt, ess.getUser(base1alt).getBase());
|
assertEquals(base1alt, ess.getUser(base1alt).getBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public class UserTest extends TestCase
|
|||||||
User user = ess.getUser(base1);
|
User user = ess.getUser(base1);
|
||||||
Location loc = base1.getLocation();
|
Location loc = base1.getLocation();
|
||||||
user.setHome("home", loc);
|
user.setHome("home", loc);
|
||||||
OfflinePlayer base2 = server.createPlayer(base1.getName(), ess);
|
OfflinePlayer base2 = server.createPlayer(base1.getName());
|
||||||
User user2 = ess.getUser(base2);
|
User user2 = ess.getUser(base2);
|
||||||
|
|
||||||
Location home = user2.getHome(loc);
|
Location home = user2.getHome(loc);
|
||||||
|
Reference in New Issue
Block a user