Move players info update to slack service w/ config changes
This commit is contained in:
@@ -170,19 +170,19 @@ public class AkarinGlobalConfig {
|
||||
legacyWorldTimings = getBoolean("alternative.legacy-world-timings-required", false);
|
||||
}
|
||||
|
||||
public static int timeUpdateInterval;
|
||||
public static long timeUpdateInterval;
|
||||
private static void timeUpdateInterval() {
|
||||
timeUpdateInterval = getSeconds(getString("core.world-time-update-interval", "1s"));
|
||||
timeUpdateInterval = getSeconds(getString("core.tick-rate.world-time-update-interval", "1s")) * 10;
|
||||
}
|
||||
|
||||
public static int keepAliveSendInterval;
|
||||
public static long keepAliveSendInterval;
|
||||
private static void keepAliveSendInterval() {
|
||||
keepAliveSendInterval = getSeconds(getString("core.keep-alive-packet-send-interval", "15s"));
|
||||
keepAliveSendInterval = getSeconds(getString("core.tick-rate.keep-alive-packet-send-interval", "15s")) * 1000;
|
||||
}
|
||||
|
||||
public static int keepAliveTimeout;
|
||||
public static long keepAliveTimeout;
|
||||
private static void keepAliveTimeout() {
|
||||
keepAliveTimeout = getSeconds(getString("core.keep-alive-response-timeout", "30s"));
|
||||
keepAliveTimeout = getSeconds(getString("core.keep-alive-response-timeout", "30s")) * 1000;
|
||||
}
|
||||
|
||||
public static int asyncLightingThreads;
|
||||
@@ -289,4 +289,9 @@ public class AkarinGlobalConfig {
|
||||
private static void primaryThreadPriority() {
|
||||
primaryThreadPriority = getInt("core.primary-thread-priority", 7);
|
||||
}
|
||||
|
||||
public static long playersInfoUpdateInterval;
|
||||
private static void playersInfoUpdateInterval() {
|
||||
playersInfoUpdateInterval = getSeconds(getString("core.tick-rate.players-info-update-interval", "30s")) * 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package io.akarin.server.core;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import io.akarin.api.internal.Akari;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EnumDifficulty;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PacketPlayOutKeepAlive;
|
||||
import net.minecraft.server.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.PacketPlayOutUpdateTime;
|
||||
import net.minecraft.server.PlayerConnection;
|
||||
import net.minecraft.server.WorldServer;
|
||||
@@ -26,7 +30,11 @@ public class AkarinSlackScheduler extends Thread {
|
||||
private static final AkarinSlackScheduler instance = new AkarinSlackScheduler();
|
||||
}
|
||||
|
||||
/*
|
||||
* Timers
|
||||
*/
|
||||
private long updateTime;
|
||||
private long resendPlayersInfo;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -34,7 +42,7 @@ public class AkarinSlackScheduler extends Thread {
|
||||
|
||||
while (server.isRunning()) {
|
||||
// Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
if (++updateTime >= AkarinGlobalConfig.timeUpdateInterval * 10) {
|
||||
if (++updateTime >= AkarinGlobalConfig.timeUpdateInterval) {
|
||||
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
|
||||
}
|
||||
@@ -49,14 +57,14 @@ public class AkarinSlackScheduler extends Thread {
|
||||
long elapsedTime = currentTime - conn.getLastPing();
|
||||
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
|
||||
if (!conn.processedDisconnect && elapsedTime >= AkarinGlobalConfig.keepAliveTimeout) { // check keepalive limit, don't fire if already disconnected
|
||||
Akari.callbackQueue.add(() -> {
|
||||
Akari.logger.warn("{} was kicked due to keepalive timeout!", conn.player.getName()); // more info
|
||||
conn.disconnect("disconnect.timeout");
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (elapsedTime >= AkarinGlobalConfig.keepAliveSendInterval * 1000L) { // 15 seconds default
|
||||
if (elapsedTime >= AkarinGlobalConfig.keepAliveSendInterval) { // 15 seconds default
|
||||
conn.setPendingPing(true);
|
||||
conn.setLastPing(currentTime);
|
||||
conn.setKeepAliveID(currentTime);
|
||||
@@ -71,6 +79,18 @@ public class AkarinSlackScheduler extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
if (++resendPlayersInfo > AkarinGlobalConfig.playersInfoUpdateInterval) {
|
||||
for (EntityPlayer target : server.getPlayerList().players) {
|
||||
target.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(server.getPlayerList().players, new Predicate<EntityPlayer>() {
|
||||
@Override
|
||||
public boolean apply(EntityPlayer input) {
|
||||
return target.getBukkitEntity().canSee(input.getBukkitEntity());
|
||||
}
|
||||
})));
|
||||
}
|
||||
resendPlayersInfo = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
@@ -193,10 +193,6 @@ public abstract class MixinMinecraftServer {
|
||||
this.an().c();
|
||||
MinecraftTimings.connectionTimer.stopTiming();
|
||||
|
||||
MinecraftTimings.playerListTimer.startTiming();
|
||||
this.v.tick();
|
||||
MinecraftTimings.playerListTimer.stopTiming();
|
||||
|
||||
MinecraftTimings.commandFunctionsTimer.startTiming();
|
||||
this.aL().e();
|
||||
MinecraftTimings.commandFunctionsTimer.stopTiming();
|
||||
|
||||
1940
sources/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
Normal file
1940
sources/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user