Log current thread, number all connections

This commit is contained in:
Bixilon 2020-08-23 21:56:51 +02:00
parent 04ab1b5254
commit 0d6b38297b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 15 additions and 11 deletions

View File

@ -68,7 +68,6 @@ public class Minosoft {
checkClientToken(); checkClientToken();
Connection c = new Connection(config.getString("debug.host"));
accountList = config.getMojangAccounts(); accountList = config.getMojangAccounts();
if (accountList.size() == 0) { if (accountList.size() == 0) {
/* /*
@ -84,7 +83,7 @@ public class Minosoft {
} else { } else {
Log.mojang("Could not refresh session, you will not be able to join premium servers!"); Log.mojang("Could not refresh session, you will not be able to join premium servers!");
} }
c.setPlayer(new Player(account)); Connection c = new Connection(1, config.getString("debug.host"), new Player(account));
c.resolve(ConnectionReason.CONNECT); // resolve dns address and connect c.resolve(ConnectionReason.CONNECT); // resolve dns address and connect
} }

View File

@ -34,6 +34,8 @@ public class Log {
builder.append("["); builder.append("[");
builder.append(timeFormat.format(System.currentTimeMillis())); builder.append(timeFormat.format(System.currentTimeMillis()));
builder.append("] ["); builder.append("] [");
builder.append(Thread.currentThread().getName());
builder.append("] [");
builder.append(l.name()); builder.append(l.name());
builder.append("] "); builder.append("] ");
if (color != null && Config.colorLog) { if (color != null && Config.colorLog) {
@ -67,7 +69,7 @@ public class Log {
} }
} }
}); });
logThread.setName("Log-Thread"); logThread.setName("Log");
logThread.start(); logThread.start();
} }

View File

@ -45,18 +45,21 @@ public class Connection {
final PacketSender sender; final PacketSender sender;
final ArrayList<ClientboundPacket> handlingQueue; final ArrayList<ClientboundPacket> handlingQueue;
final VelocityHandler velocityHandler = new VelocityHandler(this); final VelocityHandler velocityHandler = new VelocityHandler(this);
final int connectionId;
ServerAddress address; ServerAddress address;
PluginChannelHandler pluginChannelHandler; PluginChannelHandler pluginChannelHandler;
Thread handleThread; Thread handleThread;
Version version = Versions.getLowestVersionSupported(); // default Version version = Versions.getLowestVersionSupported(); // default
final CustomMapping customMapping = new CustomMapping(version); final CustomMapping customMapping = new CustomMapping(version);
Player player; final Player player;
ConnectionState state = ConnectionState.DISCONNECTED; ConnectionState state = ConnectionState.DISCONNECTED;
ConnectionReason reason; ConnectionReason reason;
ConnectionReason nextReason; ConnectionReason nextReason;
ConnectionPing connectionStatusPing; ConnectionPing connectionStatusPing;
public Connection(String hostname) { public Connection(int connectionId, String hostname, Player player) {
this.connectionId = connectionId;
this.player = player;
try { try {
addresses = DNSUtil.getServerAddresses(hostname); addresses = DNSUtil.getServerAddresses(hostname);
} catch (TextParseException e) { } catch (TextParseException e) {
@ -216,10 +219,6 @@ public class Connection {
return player; return player;
} }
public void setPlayer(Player player) {
this.player = player;
}
public void sendPacket(ServerboundPacket p) { public void sendPacket(ServerboundPacket p) {
network.sendPacket(p); network.sendPacket(p);
} }
@ -245,7 +244,7 @@ public class Connection {
} }
} }
}); });
handleThread.setName("Handle-Thread"); handleThread.setName(String.format("%d/Handling", connectionId));
handleThread.start(); handleThread.start();
} }
@ -323,4 +322,8 @@ public class Connection {
public VelocityHandler getVelocityHandler() { public VelocityHandler getVelocityHandler() {
return velocityHandler; return velocityHandler;
} }
public int getConnectionId() {
return connectionId;
}
} }

View File

@ -208,7 +208,7 @@ public class Network {
e.printStackTrace(); e.printStackTrace();
} }
}); });
socketThread.setName("Socket-Thread"); socketThread.setName(String.format("%d/Socket", connection.getConnectionId()));
socketThread.start(); socketThread.start();
} }