commands, camera, messages, overlay, ..
This commit is contained in:
parent
75f91dbf4c
commit
d45cd7ec2c
126 changed files with 854 additions and 628 deletions
|
@ -41,9 +41,9 @@ import game.network.IThreadListener;
|
|||
import game.network.LazyLoadBase;
|
||||
import game.network.NetConnection;
|
||||
import game.network.NetHandler.ThreadQuickExitException;
|
||||
import game.network.NetHandlerHandshakeMemory;
|
||||
import game.network.NetHandlerHandshakeTCP;
|
||||
import game.network.NetHandlerPlayServer;
|
||||
import game.network.HandshakeHandlerMemory;
|
||||
import game.network.HandshakeHandlerTCP;
|
||||
import game.network.Player;
|
||||
import game.network.Packet;
|
||||
import game.network.PacketDecoder;
|
||||
import game.network.PacketEncoder;
|
||||
|
@ -99,8 +99,8 @@ public final class Server implements Runnable, IThreadListener {
|
|||
|
||||
private final Thread serverThread;
|
||||
private final List<NetConnection> clients = Collections.<NetConnection>synchronizedList(Lists.<NetConnection>newArrayList());
|
||||
private final List<NetHandlerPlayServer> players = Lists.<NetHandlerPlayServer>newArrayList();
|
||||
private final Map<String, NetHandlerPlayServer> usermap = Maps.<String, NetHandlerPlayServer>newHashMap();
|
||||
private final List<Player> players = Lists.<Player>newArrayList();
|
||||
private final Map<String, Player> usermap = Maps.<String, Player>newHashMap();
|
||||
private final Queue<FutureTask<?>> queue = new ArrayDeque<FutureTask<?>>();
|
||||
private final long[] tickTimes = new long[100];
|
||||
private final Map<Integer, WorldServer> dimensions = Maps.newTreeMap();
|
||||
|
@ -168,7 +168,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
for(int i = 0; i < list.length; ++i) {
|
||||
if(list[i].endsWith(".nbt")) {
|
||||
list[i] = list[i].substring(0, list[i].length() - 4);
|
||||
NetHandlerPlayServer player = this.getPlayer(list[i]);
|
||||
Player player = this.getPlayer(list[i]);
|
||||
if(player != null)
|
||||
list[i] = player.getUser();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
}
|
||||
|
||||
public Position getOfflinePosition(String user) {
|
||||
if(this.debug || !NetHandlerPlayServer.isValidUser(user))
|
||||
if(this.debug || !Player.isValidUser(user))
|
||||
return null;
|
||||
NBTTagCompound tag = null;
|
||||
try {
|
||||
|
@ -532,11 +532,11 @@ public final class Server implements Runnable, IThreadListener {
|
|||
return list;
|
||||
}
|
||||
|
||||
public List<NetHandlerPlayServer> getPlayers() {
|
||||
public List<Player> getPlayers() {
|
||||
return this.players;
|
||||
}
|
||||
|
||||
public NetHandlerPlayServer getPlayer(String user) {
|
||||
public Player getPlayer(String user) {
|
||||
return this.usermap.get(user.toLowerCase());
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
|
||||
public String addPlayer(NetConnection connection, String loginUser, String loginPass) {
|
||||
NBTTagCompound tag = this.readPlayer(loginUser);
|
||||
NetHandlerPlayServer conn = new NetHandlerPlayServer(this, connection, loginUser);
|
||||
Player conn = new Player(this, connection, loginUser);
|
||||
if(tag != null)
|
||||
conn.readFromNBT(tag);
|
||||
if(!connection.isLocalChannel()) {
|
||||
|
@ -699,7 +699,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
this.preparePlayer(player, null);
|
||||
|
||||
for(int i = 0; i < this.players.size(); ++i) {
|
||||
NetHandlerPlayServer other = this.players.get(i);
|
||||
Player other = this.players.get(i);
|
||||
conn.sendPacket(new S38PacketPlayerListItem(false, other));
|
||||
}
|
||||
conn.sendPacket(new SPacketSkin(player.getId(), player.getSkin())); // , player.getModel()));
|
||||
|
@ -714,7 +714,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void removePlayer(NetHandlerPlayServer conn) {
|
||||
public void removePlayer(Player conn) {
|
||||
EntityNPC player = conn.getEntity();
|
||||
player.unmount();
|
||||
this.writePlayer(conn);
|
||||
|
@ -752,7 +752,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
return tag;
|
||||
}
|
||||
|
||||
private void writePlayer(NetHandlerPlayServer conn) {
|
||||
private void writePlayer(Player conn) {
|
||||
if(this.debug)
|
||||
return;
|
||||
try {
|
||||
|
@ -775,7 +775,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void recreatePlayer(NetHandlerPlayServer conn) {
|
||||
public void recreatePlayer(Player conn) {
|
||||
EntityNPC old = conn.getEntity();
|
||||
BlockPos pos = old.getPosition();
|
||||
old.getServerWorld().removePlayerFromTrackers(old);
|
||||
|
@ -830,12 +830,12 @@ public final class Server implements Runnable, IThreadListener {
|
|||
nplayer.setHealth(nplayer.getHealth());
|
||||
conn.sendPlayerAbilities();
|
||||
if(message != null)
|
||||
conn.addFeed(TextColor.DRED + message);
|
||||
conn.addHotbar(TextColor.DRED + message);
|
||||
conn.addFeed(TextColor.RED + "* Bei %d, %d, %d in Dimension %s gestorben", pos.getX(), pos.getY(), pos.getZ(),
|
||||
old.worldObj.dimension.getFormattedName(false));
|
||||
}
|
||||
|
||||
public void swapPlayer(NetHandlerPlayServer conn, NBTTagCompound tag) {
|
||||
public void swapPlayer(Player conn, NBTTagCompound tag) {
|
||||
EntityNPC old = conn.getEntity();
|
||||
old.unmount();
|
||||
NBTTagCompound oldTag = conn.getSelectedCharacter(true);
|
||||
|
@ -939,13 +939,13 @@ public final class Server implements Runnable, IThreadListener {
|
|||
}
|
||||
|
||||
public void sendPacket(Packet packet) {
|
||||
for(NetHandlerPlayServer conn : this.players) {
|
||||
for(Player conn : this.players) {
|
||||
conn.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPacket(Packet packet, int dimension) {
|
||||
for(NetHandlerPlayServer conn : this.players) {
|
||||
for(Player conn : this.players) {
|
||||
if(conn.getEntity() != null && conn.getEntity().worldObj.dimension.getDimensionId() == dimension) {
|
||||
conn.sendPacket(packet);
|
||||
}
|
||||
|
@ -957,7 +957,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
}
|
||||
|
||||
public void sendNearExcept(EntityNPC except, double x, double y, double z, double radius, int dimension, Packet packet) {
|
||||
for(NetHandlerPlayServer conn : this.players) {
|
||||
for(Player conn : this.players) {
|
||||
EntityNPC player = conn.getEntity();
|
||||
if(player != null && player != except && player.worldObj.dimension.getDimensionId() == dimension) {
|
||||
double dx = x - player.posX;
|
||||
|
@ -976,13 +976,13 @@ public final class Server implements Runnable, IThreadListener {
|
|||
if(message) {
|
||||
Log.JNI.info("Speichere Spielerdaten");
|
||||
}
|
||||
for(NetHandlerPlayServer conn : this.players) {
|
||||
for(Player conn : this.players) {
|
||||
this.writePlayer(conn);
|
||||
}
|
||||
// this.saveUsers();
|
||||
}
|
||||
|
||||
private void updateTimeAndWeatherForPlayer(NetHandlerPlayServer conn, WorldServer world) {
|
||||
private void updateTimeAndWeatherForPlayer(Player conn, WorldServer world) {
|
||||
conn.sendPacket(new SPacketTimeUpdate(world.getDayTime()));
|
||||
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.SET_WEATHER, world.getWeather().getID()));
|
||||
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.RAIN_STRENGTH, world.getRainStrength()));
|
||||
|
@ -1018,7 +1018,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
NetConnection manager = new NetConnection();
|
||||
Server.this.clients.add(manager);
|
||||
channel.pipeline().addLast((String)"packet_handler", (ChannelHandler)manager);
|
||||
manager.setNetHandler(new NetHandlerHandshakeTCP(Server.this, manager));
|
||||
manager.setNetHandler(new HandshakeHandlerTCP(Server.this, manager));
|
||||
}
|
||||
}).group(SERVER_NIO_EVENTLOOP.getValue()).localAddress((InetAddress)null, port)).bind().syncUninterruptibly();
|
||||
}
|
||||
|
@ -1033,7 +1033,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
this.localEndpoint = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(LocalServerChannel.class)).childHandler(new ChannelInitializer<Channel>() {
|
||||
protected void initChannel(Channel channel) throws Exception {
|
||||
NetConnection manager = new NetConnection();
|
||||
manager.setNetHandler(new NetHandlerHandshakeMemory(Server.this, manager));
|
||||
manager.setNetHandler(new HandshakeHandlerMemory(Server.this, manager));
|
||||
Server.this.clients.add(manager);
|
||||
channel.pipeline().addLast((String)"packet_handler", (ChannelHandler)manager);
|
||||
}
|
||||
|
@ -1045,7 +1045,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
}
|
||||
|
||||
private void unsetLanEndpoint() {
|
||||
for(NetHandlerPlayServer conn : Lists.newArrayList(this.players)) {
|
||||
for(Player conn : Lists.newArrayList(this.players)) {
|
||||
if(!conn.isLocal())
|
||||
conn.disconnect();
|
||||
}
|
||||
|
@ -1122,7 +1122,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
this.setMessage("Stoppe server");
|
||||
Log.JNI.info("Beende Server");
|
||||
if(this.started)
|
||||
for(NetHandlerPlayServer conn : Lists.newArrayList(this.players)) {
|
||||
for(Player conn : Lists.newArrayList(this.players)) {
|
||||
conn.disconnect();
|
||||
}
|
||||
this.terminateEndpoints(true);
|
||||
|
@ -1157,7 +1157,7 @@ public final class Server implements Runnable, IThreadListener {
|
|||
public void shutdown() {
|
||||
Futures.getUnchecked(this.schedule(new Runnable() {
|
||||
public void run() {
|
||||
for(NetHandlerPlayServer conn : Lists.newArrayList(Server.this.players)) { // = Server.this.getPlayer(Server.this.owner);
|
||||
for(Player conn : Lists.newArrayList(Server.this.players)) { // = Server.this.getPlayer(Server.this.owner);
|
||||
// if(conn != null)
|
||||
if(conn.isLocal())
|
||||
Server.this.removePlayer(conn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue