split server
This commit is contained in:
parent
b0dc368ef7
commit
3ab017888b
25 changed files with 458 additions and 482 deletions
|
@ -96,6 +96,7 @@ import game.packet.SPacketChunkData;
|
|||
import game.packet.SPacketDestroyEntities;
|
||||
import game.packet.SPacketDisconnect;
|
||||
import game.packet.SPacketKeepAlive;
|
||||
import game.packet.SPacketLoading;
|
||||
import game.packet.SPacketMapChunkBulk;
|
||||
import game.packet.SPacketMessage;
|
||||
import game.packet.SPacketMessage.Type;
|
||||
|
@ -167,7 +168,6 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
private final NetConnection connection;
|
||||
private final Server server;
|
||||
private final String user;
|
||||
private final boolean local;
|
||||
private final IntHashMap<Short> transactions = new IntHashMap();
|
||||
private final List<NBTTagCompound> characters = Lists.newArrayList();
|
||||
|
||||
|
@ -239,7 +239,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
this.user = user;
|
||||
this.server = server;
|
||||
this.connection = connection;
|
||||
this.local = connection.isLocalChannel();
|
||||
// this.local = connection.isLocalChannel();
|
||||
}
|
||||
|
||||
public EntityNPC createPlayer(WorldServer world, String id) {
|
||||
|
@ -274,7 +274,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
this.pingKey = (int)this.lastPingTime;
|
||||
this.sendPacket(new SPacketKeepAlive(this.pingKey));
|
||||
}
|
||||
if(this.local)
|
||||
// if(this.local)
|
||||
|
||||
if(this.respawnTimer > 0) {
|
||||
if(--this.respawnTimer == 0) {
|
||||
|
@ -283,6 +283,18 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
}
|
||||
}
|
||||
|
||||
public void displayLoading(String message) {
|
||||
this.sendPacket(new SPacketLoading(message));
|
||||
}
|
||||
|
||||
public void sendTask(String task, int total) {
|
||||
this.sendPacket(new SPacketLoading(task, total));
|
||||
}
|
||||
|
||||
public void sendProgress(int progress) {
|
||||
this.sendPacket(new SPacketLoading(progress));
|
||||
}
|
||||
|
||||
public void onEntityDeath() {
|
||||
this.entity.sendDeathMessage();
|
||||
|
||||
|
@ -335,16 +347,16 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
return this.user;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return this.local;
|
||||
}
|
||||
// public boolean isLocal() {
|
||||
// return this.local;
|
||||
// }
|
||||
|
||||
public int getLatency() {
|
||||
return this.ping;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return this.admin || this.local;
|
||||
return this.admin; // || this.local;
|
||||
}
|
||||
|
||||
public boolean getAdmin() {
|
||||
|
@ -955,7 +967,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
Iterator<ChunkPos> iterator1 = this.loadedChunks.iterator();
|
||||
List<TileEntity> list1 = Lists.<TileEntity>newArrayList();
|
||||
|
||||
int n = this.local ? 1024 : 10;
|
||||
int n = 10; // TODO: this.local ? 1024 : 10;
|
||||
|
||||
while (iterator1.hasNext() && ((List)list).size() < n)
|
||||
{
|
||||
|
@ -1551,8 +1563,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
public void onDisconnect(String reason)
|
||||
{
|
||||
Log.JNI.info(this.user + " wurde getrennt: " + TextColor.stripCodes(reason));
|
||||
if(!this.local)
|
||||
this.server.sendPacket(new SPacketMessage(String.format("%s hat das Spiel verlassen", this.user), Type.FEED));
|
||||
this.server.sendPacket(new SPacketMessage(String.format("%s hat das Spiel verlassen", this.user), Type.FEED));
|
||||
this.server.removePlayer(this);
|
||||
}
|
||||
|
||||
|
@ -1577,8 +1588,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
chars.add(this.getCharacterInfo(tag));
|
||||
}
|
||||
this.sendPacket(new SPacketCharacterList(this.selected, chars));
|
||||
if(!this.local)
|
||||
this.server.sendPacket(new SPacketMessage(String.format("%s hat das Spiel betreten", this.user), Type.FEED));
|
||||
this.server.sendPacket(new SPacketMessage(String.format("%s hat das Spiel betreten", this.user), Type.FEED));
|
||||
}
|
||||
|
||||
public void sendPacket(final Packet packet)
|
||||
|
@ -2513,7 +2523,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
NetHandler.checkThread(packetIn, this, this.server);
|
||||
|
||||
CPacketAction.Action action = packetIn.getAction();
|
||||
if(action != Action.SET_VIEWDIST && action != Action.SHUTDOWN && (this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_CLASS || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR))) // {
|
||||
if(this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_CLASS || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR)) // {
|
||||
// if(this.local && action == Action.CLOSE_EDITOR)
|
||||
// this.server.setDone();
|
||||
return;
|
||||
|
@ -2544,8 +2554,8 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
world.dimension.getDimensionId());
|
||||
this.entity.setOrigin(origin);
|
||||
Position pos = this.server.getRandomSpawnPosition(origin);
|
||||
if(Config.preloadLocal && this.local && this.server.getPlayers().size() == 1)
|
||||
this.server.preload(world, (int)pos.x, (int)pos.z);
|
||||
if(Config.preload && /* this.local && */ this.server.getPlayers().size() == 1)
|
||||
this.server.preload(world, (int)pos.x, (int)pos.z, this);
|
||||
this.entity.teleport(pos);
|
||||
this.sendPacket(new SPacketCharacterList(this.selected, this.selected, new PlayerCharacter(this.entity.getCustomNameTag(), this.entity.getDescription(), this.entity.getAlignment(), this.entity.worldObj.dimension.getFormattedName(false), this.entity.getPosition(), EntityRegistry.getEntityName(EntityRegistry.getEntityString(this.entity)), this.entity.experienceLevel)));
|
||||
// if(this.local)
|
||||
|
@ -2877,7 +2887,7 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
break;
|
||||
|
||||
case WARP_MODE:
|
||||
if(this.isLocal()) {
|
||||
if(this.isAdmin()) {
|
||||
this.server.schedule(new Runnable() {
|
||||
public void run() {
|
||||
Player.this.server.setTpsTarget(Player.this.server.getTpsTarget() < 10000.0f ? 10000.0f : 20.0f);
|
||||
|
@ -2886,16 +2896,6 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
}
|
||||
break;
|
||||
|
||||
case SET_VIEWDIST:
|
||||
if(this.isLocal())
|
||||
this.server.setVar("viewDistance", "" + packetIn.getAuxData());
|
||||
break;
|
||||
|
||||
case SHUTDOWN:
|
||||
if(this.isLocal())
|
||||
this.server.shutdown();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Ungültige Aktion!");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue