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() {
|
public void enable() {
|
||||||
super.enable();
|
super.enable();
|
||||||
try {
|
try {
|
||||||
plugin.registerListener(pingCountTimer);
|
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||||
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
plugin.registerListener(pingCountTimer);
|
||||||
|
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||||
|
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||||
|
}
|
||||||
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
} catch (ExceptionInInitializerError | NoClassDefFoundError ignore) {
|
||||||
// Running CraftBukkit
|
// 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
|
//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
|
//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;
|
private static final boolean PING_METHOD_AVAILABLE;
|
||||||
|
|
||||||
@ -196,6 +195,10 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
|
public void onPlayerJoin(PlayerJoinEvent joinEvent) {
|
||||||
Player player = joinEvent.getPlayer();
|
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() {
|
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -203,7 +206,7 @@ public class PingCountTimerBukkit extends AbsRunnable implements Listener {
|
|||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -87,9 +87,12 @@ public class BungeeTaskSystem extends TaskSystem {
|
|||||||
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||||
|
|
||||||
plugin.registerListener(pingCountTimer);
|
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||||
registerTask(pingCountTimer).runTaskTimer(startDelay, PingCountTimerBungee.PING_INTERVAL);
|
plugin.registerListener(pingCountTimer);
|
||||||
|
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||||
|
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||||
|
}
|
||||||
|
|
||||||
registerTask(playersPageRefreshTask)
|
registerTask(playersPageRefreshTask)
|
||||||
.runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
.runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||||
|
@ -52,10 +52,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
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 Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
|
||||||
private final PlanConfig config;
|
private final PlanConfig config;
|
||||||
@ -121,6 +117,10 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
||||||
ProxiedPlayer player = joinEvent.getPlayer();
|
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() {
|
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -128,7 +128,7 @@ public class PingCountTimerBungee extends AbsRunnable implements Listener {
|
|||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -115,6 +115,10 @@ public abstract class SQLDB extends AbstractDatabase {
|
|||||||
transactionExecutor.shutdown();
|
transactionExecutor.shutdown();
|
||||||
try {
|
try {
|
||||||
Long waitMs = config.getOrDefault(TimeSettings.DB_TRANSACTION_FINISH_WAIT_DELAY, TimeUnit.SECONDS.toMillis(20L));
|
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)) {
|
if (!transactionExecutor.awaitTermination(waitMs, TimeUnit.MILLISECONDS)) {
|
||||||
List<Runnable> unfinished = transactionExecutor.shutdownNow();
|
List<Runnable> unfinished = transactionExecutor.shutdownNow();
|
||||||
int unfinishedCount = unfinished.size();
|
int unfinishedCount = unfinished.size();
|
||||||
|
@ -82,9 +82,12 @@ public class SpongeTaskSystem extends ServerTaskSystem {
|
|||||||
public void enable() {
|
public void enable() {
|
||||||
super.enable();
|
super.enable();
|
||||||
|
|
||||||
plugin.registerListener(pingCountTimer);
|
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||||
registerTask(pingCountTimer).runTaskTimer(startDelay, PingCountTimerSponge.PING_INTERVAL);
|
plugin.registerListener(pingCountTimer);
|
||||||
|
long startDelay = TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS);
|
||||||
|
registerTask(pingCountTimer).runTaskTimer(startDelay, 40L);
|
||||||
|
}
|
||||||
|
|
||||||
// +40 ticks / 2 seconds so that update check task runs first.
|
// +40 ticks / 2 seconds so that update check task runs first.
|
||||||
long storeDelay = TimeAmount.toTicks(config.get(TimeSettings.CONFIG_UPDATE_INTERVAL), TimeUnit.MILLISECONDS) + 40;
|
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 {
|
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 Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
|
||||||
private final PlanConfig config;
|
private final PlanConfig config;
|
||||||
@ -117,6 +113,10 @@ public class PingCountTimerSponge extends AbsRunnable {
|
|||||||
@Listener
|
@Listener
|
||||||
public void onPlayerJoin(ClientConnectionEvent.Join joinEvent) {
|
public void onPlayerJoin(ClientConnectionEvent.Join joinEvent) {
|
||||||
Player player = joinEvent.getTargetEntity();
|
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() {
|
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -124,7 +124,7 @@ public class PingCountTimerSponge extends AbsRunnable {
|
|||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
|
@ -87,9 +87,12 @@ public class VelocityTaskSystem extends TaskSystem {
|
|||||||
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
registerTask(networkPageRefreshTask).runTaskTimerAsynchronously(1500, TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||||
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
registerTask(logsFolderCleanTask).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||||
|
|
||||||
plugin.registerListener(pingCountTimer);
|
Long pingDelay = config.get(TimeSettings.PING_SERVER_ENABLE_DELAY);
|
||||||
long startDelay = TimeAmount.toTicks(config.get(TimeSettings.PING_SERVER_ENABLE_DELAY), TimeUnit.MILLISECONDS);
|
if (pingDelay < TimeUnit.HOURS.toMillis(1L)) {
|
||||||
registerTask(pingCountTimer).runTaskTimer(startDelay, PingCountTimerVelocity.PING_INTERVAL);
|
plugin.registerListener(pingCountTimer);
|
||||||
|
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));
|
registerTask(playersPageRefreshTask).runTaskTimerAsynchronously(TimeAmount.toTicks(5L, TimeUnit.MINUTES), TimeAmount.toTicks(5L, TimeUnit.MINUTES));
|
||||||
|
|
||||||
|
@ -53,10 +53,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class PingCountTimerVelocity extends AbsRunnable {
|
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;
|
final Map<UUID, List<DateObj<Integer>>> playerHistory;
|
||||||
|
|
||||||
private final PlanVelocity plugin;
|
private final PlanVelocity plugin;
|
||||||
@ -125,6 +121,10 @@ public class PingCountTimerVelocity extends AbsRunnable {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
public void onPlayerJoin(ServerConnectedEvent joinEvent) {
|
||||||
Player player = joinEvent.getPlayer();
|
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() {
|
runnableFactory.create("Add Player to Ping list", new AbsRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -132,7 +132,7 @@ public class PingCountTimerVelocity extends AbsRunnable {
|
|||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskLater(TimeAmount.toTicks(config.get(TimeSettings.PING_PLAYER_LOGIN_DELAY), TimeUnit.MILLISECONDS));
|
}).runTaskLater(TimeAmount.toTicks(pingDelay, TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
Loading…
Reference in New Issue
Block a user