mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-26 11:08:08 +01:00
[#1034] sane handling of large delay options
This commit is contained in:
parent
290cb4d66b
commit
4d261ce6e8
@ -90,9 +90,12 @@ public class BukkitTaskSystem extends ServerTaskSystem {
|
||||
public void enable() {
|
||||
super.enable();
|
||||
try {
|
||||
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||
plugin.registerListener(pingCountTimer);
|
||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
||||
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||
}
|
||||
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
||||
// Running CraftBukkit
|
||||
}
|
||||
|
@ -64,7 +64,6 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
||||
|
||||
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||
public static final int PING_INTERVAL = 2 * 20;
|
||||
|
||||
private static final boolean PING_METHOD_AVAILABLE;
|
||||
|
||||
@ -196,6 +195,10 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
|
||||
Player player = joinEvent.getPlayer();
|
||||
Long pingDelay = config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY);
|
||||
if (pingDelay >= TimeUnit.HOURS.toMillis(2L)) {
|
||||
return;
|
||||
}
|
||||
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -203,7 +206,7 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
||||
addPlayer(player);
|
||||
}
|
||||
}
|
||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
||||
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -87,9 +87,12 @@ public class BungeeTaskSystem extends TaskSystem {
|
||||
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||
|
||||
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||
plugin.registerListener(pingCountTimer);
|
||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, PingCountTimerBungee.PING_INTERVAL);
|
||||
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||
}
|
||||
|
||||
registerTask(playersPageRefreshTask)
|
||||
.runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
|
@ -52,10 +52,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
||||
|
||||
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||
public static final int PING_INTERVAL = 2 * 20;
|
||||
|
||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||
|
||||
private final PlanConfig config;
|
||||
@ -121,6 +117,10 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
||||
ProxiedPlayer player = joinEvent.getPlayer();
|
||||
Long pingDelay = config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY);
|
||||
if (pingDelay >= TimeUnit.HOURS.toMillis(2L)) {
|
||||
return;
|
||||
}
|
||||
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -128,7 +128,7 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
||||
addPlayer(player);
|
||||
}
|
||||
}
|
||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
||||
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -115,6 +115,10 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
transactionExecutor.shutdown();
|
||||
try {
|
||||
Long waitMs = config.getOrDefault(TimeSettings.DB_TRANSACTION_FINISH_WAIT_DELAY, TimeUnit.SECONDS.toMillis(20L));
|
||||
if (waitMs > TimeUnit.MINUTES.toMillis(5L)) {
|
||||
logger.warn(TimeSettings.DB_TRANSACTION_FINISH_WAIT_DELAY.getPath() + " was set to over 5 minutes, using 5 min instead.");
|
||||
waitMs = TimeUnit.MINUTES.toMillis(5L);
|
||||
}
|
||||
if (!transactionExecutor.awaitTermination(waitMs, TimeUnit.MILLISECONDS)) {
|
||||
List<Runnable> unfinished = transactionExecutor.shutdownNow();
|
||||
int unfinishedCount = unfinished.size();
|
||||
|
@ -82,9 +82,12 @@ public class SpongeTaskSystem extends ServerTaskSystem {
|
||||
public void enable() {
|
||||
super.enable();
|
||||
|
||||
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||
plugin.registerListener(pingCountTimer);
|
||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, PingCountTimerSponge.PING_INTERVAL);
|
||||
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||
}
|
||||
|
||||
// +40 ticks / 2 seconds so that update check task runs first.
|
||||
long storeDelay = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS) + 40;
|
||||
|
@ -48,10 +48,6 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class PingCountTimerSponge extends AbsRunnable {
|
||||
|
||||
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||
public static final int PING_INTERVAL = 2 * 20;
|
||||
|
||||
private final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||
|
||||
private final PlanConfig config;
|
||||
@ -117,6 +113,10 @@ public class PingCountTimerSponge extends AbsRunnable {
|
||||
@Listener
|
||||
public void onPlayerJoin(ClientConnectionEvent.Join joinEvent) {
|
||||
Player player = joinEvent.getTargetEntity();
|
||||
Long pingDelay = config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY);
|
||||
if (pingDelay >= TimeUnit.HOURS.toMillis(2L)) {
|
||||
return;
|
||||
}
|
||||
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -124,7 +124,7 @@ public class PingCountTimerSponge extends AbsRunnable {
|
||||
addPlayer(player);
|
||||
}
|
||||
}
|
||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
||||
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@Listener
|
||||
|
@ -87,9 +87,12 @@ public class VelocityTaskSystem extends TaskSystem {
|
||||
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||
|
||||
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||
plugin.registerListener(pingCountTimer);
|
||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, PingCountTimerVelocity.PING_INTERVAL);
|
||||
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||
}
|
||||
|
||||
registerTask(playersPageRefreshTask).runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||
|
||||
|
@ -53,10 +53,6 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class PingCountTimerVelocity extends AbsRunnable {
|
||||
|
||||
//the server is pinging the client every 40 Ticks (2 sec) - so check it then
|
||||
//https://github.com/bergerkiller/CraftSource/blob/master/net.minecraft.server/PlayerConnection.java#L178
|
||||
public static final int PING_INTERVAL = 2 * 20;
|
||||
|
||||
final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||
|
||||
private final PlanVelocity plugin;
|
||||
@ -125,6 +121,10 @@ public class PingCountTimerVelocity extends AbsRunnable {
|
||||
@Subscribe
|
||||
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
||||
Player player = joinEvent.getPlayer();
|
||||
Long pingDelay = config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY);
|
||||
if (pingDelay >= TimeUnit.HOURS.toMillis(2L)) {
|
||||
return;
|
||||
}
|
||||
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -132,7 +132,7 @@ public class PingCountTimerVelocity extends AbsRunnable {
|
||||
addPlayer(player);
|
||||
}
|
||||
}
|
||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
||||
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
Loading…
Reference in New Issue
Block a user