Fixes time update
This commit is contained in:
@@ -30,43 +30,45 @@ public class AkarinSlackScheduler extends Thread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
MinecraftServer server = MinecraftServer.getServer();
|
MinecraftServer server = MinecraftServer.getServer();
|
||||||
|
|
||||||
// Send time updates to everyone, it will get the right time from the world the player is in.
|
while (server.isRunning()) {
|
||||||
if (++updateTime == AkarinGlobalConfig.timeUpdateInterval * 10) {
|
// Send time updates to everyone, it will get the right time from the world the player is in.
|
||||||
|
if (++updateTime >= AkarinGlobalConfig.timeUpdateInterval * 10) {
|
||||||
|
for (EntityPlayer player : server.getPlayerList().players) {
|
||||||
|
player.playerConnection.sendPacket(new PacketPlayOutUpdateTime(player.world.getTime(), player.getPlayerTime(), player.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
|
||||||
|
}
|
||||||
|
updateTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (EntityPlayer player : server.getPlayerList().players) {
|
for (EntityPlayer player : server.getPlayerList().players) {
|
||||||
player.playerConnection.sendPacket(new PacketPlayOutUpdateTime(player.world.getTime(), player.getPlayerTime(), player.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
|
PlayerConnection conn = player.playerConnection;
|
||||||
}
|
// Paper - give clients a longer time to respond to pings as per pre 1.12.2 timings
|
||||||
updateTime = 0;
|
// This should effectively place the keepalive handling back to "as it was" before 1.12.2
|
||||||
}
|
long currentTime = System.nanoTime() / 1000000L;
|
||||||
|
long elapsedTime = currentTime - conn.getLastPing();
|
||||||
for (EntityPlayer player : server.getPlayerList().players) {
|
if (conn.isPendingPing()) {
|
||||||
PlayerConnection conn = player.playerConnection;
|
// We're pending a ping from the client
|
||||||
// Paper - give clients a longer time to respond to pings as per pre 1.12.2 timings
|
if (!conn.processedDisconnect && elapsedTime >= AkarinGlobalConfig.keepAliveTimeout * 1000L) { // check keepalive limit, don't fire if already disconnected
|
||||||
// This should effectively place the keepalive handling back to "as it was" before 1.12.2
|
Akari.callbackQueue.add(() -> {
|
||||||
long currentTime = System.nanoTime() / 1000000L;
|
Akari.logger.warn("{} was kicked due to keepalive timeout!", conn.player.getName()); // more info
|
||||||
long elapsedTime = currentTime - conn.getLastPing();
|
conn.disconnect("disconnect.timeout");
|
||||||
if (conn.isPendingPing()) {
|
});
|
||||||
// We're pending a ping from the client
|
}
|
||||||
if (!conn.processedDisconnect && elapsedTime >= AkarinGlobalConfig.keepAliveTimeout * 1000L) { // check keepalive limit, don't fire if already disconnected
|
} else {
|
||||||
Akari.callbackQueue.add(() -> {
|
if (elapsedTime >= AkarinGlobalConfig.keepAliveSendInterval * 1000L) { // 15 seconds default
|
||||||
Akari.logger.warn("{} was kicked due to keepalive timeout!", conn.player.getName()); // more info
|
conn.setPendingPing(true);
|
||||||
conn.disconnect("disconnect.timeout");
|
conn.setLastPing(currentTime);
|
||||||
});
|
conn.setKeepAliveID(currentTime);
|
||||||
}
|
conn.sendPacket(new PacketPlayOutKeepAlive(conn.getKeepAliveID()));
|
||||||
} else {
|
}
|
||||||
if (elapsedTime >= AkarinGlobalConfig.keepAliveSendInterval * 1000L) { // 15 seconds default
|
|
||||||
conn.setPendingPing(true);
|
|
||||||
conn.setLastPing(currentTime);
|
|
||||||
conn.setKeepAliveID(currentTime);
|
|
||||||
conn.sendPacket(new PacketPlayOutKeepAlive(conn.getKeepAliveID()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
try {
|
Thread.sleep(100);
|
||||||
Thread.sleep(100);
|
} catch (InterruptedException ex) {
|
||||||
} catch (InterruptedException ex) {
|
Akari.logger.warn("Slack scheduler thread was interrupted unexpectly!");
|
||||||
Akari.logger.warn("Slack scheduler thread was interrupted unexpectly!");
|
ex.printStackTrace();
|
||||||
ex.printStackTrace();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user