mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-19 19:59:37 +00:00
All events are now an enum and send as a PlayerStatus.
All player updates are now sent as a PlayerStatus.
This commit is contained in:
1 parent
c093287b5c
commit
f6152c589a
6 files changed
+79
-58
No files matched your search
@@ -2,53 +2,59 @@ package mcp.mobius.opis.data.holders.newtypes;
|
||||
|
||||
import mcp.mobius.opis.data.holders.ISerializable;
|
||||
import mcp.mobius.opis.data.holders.basetypes.SerialString;
|
||||
import mcp.mobius.opis.network.enums.PlayerEv;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
|
||||
public class PlayerStatus implements ISerializable {
|
||||
|
||||
CachedString name;
|
||||
boolean status;
|
||||
int x, y, z, dim;
|
||||
|
||||
public PlayerStatus(String name, boolean status, int dim, int x, int y, int z){
|
||||
this.name = new CachedString(name);
|
||||
this.status = status;
|
||||
this.dim = dim;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public PlayerStatus(CachedString name, boolean status, int dim, int x, int y, int z){
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
this.dim = dim;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteArrayDataOutput stream){
|
||||
this.name.writeToStream(stream);
|
||||
stream.writeBoolean(this.status);
|
||||
stream.writeInt(dim);
|
||||
stream.writeInt(x);
|
||||
stream.writeInt(y);
|
||||
stream.writeInt(z);
|
||||
}
|
||||
|
||||
public static PlayerStatus readFromStream(ByteArrayDataInput stream){
|
||||
return new PlayerStatus(
|
||||
CachedString.readFromStream(stream),
|
||||
stream.readBoolean(),
|
||||
stream.readInt(),
|
||||
stream.readInt(),
|
||||
stream.readInt(),
|
||||
stream.readInt()
|
||||
);
|
||||
}
|
||||
public CachedString name;
|
||||
public PlayerEv status;
|
||||
public int x, y, z, dim;
|
||||
public long timestamp;
|
||||
|
||||
public PlayerStatus(String name_, PlayerEv status, int dim, int x, int y, int z){
|
||||
this.name = new CachedString(name_);
|
||||
this.status = status;
|
||||
this.dim = dim;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public PlayerStatus(CachedString name, PlayerEv status, int dim, int x, int y, int z, long timestamp){
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
this.dim = dim;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteArrayDataOutput stream){
|
||||
this.name.writeToStream(stream);
|
||||
stream.writeInt(this.status.ordinal());
|
||||
stream.writeInt(this.dim);
|
||||
stream.writeInt(this.x);
|
||||
stream.writeInt(this.y);
|
||||
stream.writeInt(this.z);
|
||||
stream.writeLong(this.timestamp);
|
||||
}
|
||||
|
||||
public static PlayerStatus readFromStream(ByteArrayDataInput stream){
|
||||
return new PlayerStatus(
|
||||
CachedString.readFromStream(stream),
|
||||
PlayerEv.values()[stream.readInt()],
|
||||
stream.readInt(),
|
||||
stream.readInt(),
|
||||
stream.readInt(),
|
||||
stream.readInt(),
|
||||
stream.readLong()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,11 @@ import mcp.mobius.opis.data.holders.basetypes.CoordinatesChunk;
|
||||
import mcp.mobius.opis.data.holders.newtypes.DataEntity;
|
||||
import mcp.mobius.opis.data.holders.newtypes.DataEntityPerClass;
|
||||
import mcp.mobius.opis.data.holders.newtypes.DataTiming;
|
||||
import mcp.mobius.opis.data.holders.newtypes.PlayerStatus;
|
||||
import mcp.mobius.opis.data.profilers.ProfilerEntityUpdate;
|
||||
import mcp.mobius.opis.helpers.Teleport;
|
||||
import mcp.mobius.opis.network.PacketManager;
|
||||
import mcp.mobius.opis.network.enums.PlayerEv;
|
||||
|
||||
public enum EntityManager {
|
||||
INSTANCE;
|
||||
@@ -268,14 +270,18 @@ public enum EntityManager {
|
||||
return nkilled;
|
||||
}
|
||||
|
||||
public ArrayList<DataEntity> getAllPlayers(){
|
||||
public ArrayList<PlayerStatus> getAllPlayers(){
|
||||
//List players = MinecraftServer.getServerConfigurationManager(MinecraftServer.getServer()).playerEntityList;
|
||||
List players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
|
||||
ArrayList<DataEntity> outList = new ArrayList<DataEntity>();
|
||||
ArrayList<PlayerStatus> outList = new ArrayList<PlayerStatus>();
|
||||
|
||||
for (Object p : players)
|
||||
outList.add(new DataEntity().fill((EntityPlayer) p));
|
||||
for (Object o : players){
|
||||
//outList.add(new DataEntity().fill((EntityPlayer) p));
|
||||
EntityPlayer p = (EntityPlayer) o;
|
||||
outList.add(new PlayerStatus(p.getGameProfile().getName(), PlayerEv.NONE,
|
||||
p.worldObj.provider.dimensionId, (int)p.posX, (int)p.posY, (int)p.posZ));
|
||||
}
|
||||
|
||||
return outList;
|
||||
}
|
||||
|
||||
@@ -88,12 +88,6 @@ public enum OpisServerTickHandler{
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<DataThread> threads = new ArrayList<DataThread>();
|
||||
for (Thread t : Thread.getAllStackTraces().keySet()){
|
||||
threads.add(new DataThread().fill(t));
|
||||
}
|
||||
PacketManager.sendPacketToAllSwing(new NetDataList(Message.LIST_THREADS, threads));
|
||||
|
||||
// Dimension data update.
|
||||
ArrayList<DataDimension> dimData = new ArrayList<DataDimension>();
|
||||
for (int dim : DimensionManager.getIDs()){
|
||||
@@ -113,6 +107,12 @@ public enum OpisServerTickHandler{
|
||||
|
||||
// Two second timer
|
||||
if (timer2000.isDone() && PlayerTracker.INSTANCE.playersSwing.size() > 0){
|
||||
ArrayList<DataThread> threads = new ArrayList<DataThread>();
|
||||
for (Thread t : Thread.getAllStackTraces().keySet()){
|
||||
threads.add(new DataThread().fill(t));
|
||||
}
|
||||
PacketManager.sendPacketToAllSwing(new NetDataList(Message.LIST_THREADS, threads));
|
||||
|
||||
PacketManager.sendPacketToAllSwing(new NetDataList(Message.LIST_PLAYERS, EntityManager.INSTANCE.getAllPlayers()));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import mcp.mobius.opis.gui.overlay.OverlayStatus;
|
||||
import mcp.mobius.opis.network.PacketManager;
|
||||
import mcp.mobius.opis.network.enums.AccessLevel;
|
||||
import mcp.mobius.opis.network.enums.Message;
|
||||
import mcp.mobius.opis.network.enums.PlayerEv;
|
||||
import mcp.mobius.opis.network.packets.server.NetDataValue;
|
||||
import mcp.mobius.opis.network.rcon.RConHandler;
|
||||
import mcp.mobius.opis.network.rcon.server.RConServer;
|
||||
@@ -107,7 +108,7 @@ public enum PlayerTracker{
|
||||
//this.playersOpis.remove(player);
|
||||
this.playersSwing.remove(event.player);
|
||||
PacketManager.sendPacketToAllSwing(new NetDataValue(Message.PLAYER_STATUS_UPDATE,
|
||||
new PlayerStatus(event.player.getGameProfile().getName(), false,
|
||||
new PlayerStatus(event.player.getGameProfile().getName(), PlayerEv.LOGOUT,
|
||||
event.player.worldObj.provider.dimensionId, (int)event.player.posX, (int)event.player.posY, (int)event.player.posZ)));
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ public enum PlayerTracker{
|
||||
|
||||
StringCache.INSTANCE.syncCache((EntityPlayerMP)event.player);
|
||||
PacketManager.sendPacketToAllSwing(new NetDataValue(Message.PLAYER_STATUS_UPDATE,
|
||||
new PlayerStatus(event.player.getGameProfile().getName(), true,
|
||||
new PlayerStatus(event.player.getGameProfile().getName(), PlayerEv.LOGIN,
|
||||
event.player.worldObj.provider.dimensionId, (int)event.player.posX, (int)event.player.posY, (int)event.player.posZ)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package mcp.mobius.opis.network.enums;
|
||||
|
||||
public enum PlayerEv {
|
||||
LOGOUT,
|
||||
LOGIN,
|
||||
NONE;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package mcp.mobius.opis.swing.panels.tracking;
|
||||
|
||||
import mcp.mobius.opis.api.ITabPanel;
|
||||
import mcp.mobius.opis.data.holders.newtypes.DataEntity;
|
||||
import mcp.mobius.opis.data.holders.newtypes.PlayerStatus;
|
||||
import mcp.mobius.opis.network.PacketBase;
|
||||
import mcp.mobius.opis.network.enums.AccessLevel;
|
||||
import mcp.mobius.opis.network.enums.Message;
|
||||
@@ -73,11 +74,11 @@ public class PanelPlayers extends JPanelMsgHandler implements ITabPanel{
|
||||
int row = this.getTable().clearTable(DataEntity.class);
|
||||
|
||||
for (Object o : rawdata.array){
|
||||
DataEntity player = (DataEntity)o;
|
||||
PlayerStatus player = (PlayerStatus)o;
|
||||
model.addRow(new Object[] {
|
||||
player.name,
|
||||
player.pos.dim,
|
||||
String.format("[ %4d %4d %4d ]", player.pos.x, player.pos.y, player.pos.z),
|
||||
player.dim,
|
||||
String.format("[ %4d %4d %4d ]", player.x, player.y, player.z),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user