Add option to delay queue-servers by up to 3 seconds
This commit is contained in:
@@ -6,7 +6,7 @@ public interface ServerTimeManager {
|
||||
/**
|
||||
* Gets the time that the player specified was last seen switching servers
|
||||
* @param player The player to check
|
||||
* @return The time that they last switched servers, in miliseconds since midnight, January 1, 1970, UTC
|
||||
* @return The time that they last switched servers, in milliseconds since midnight, January 1, 1970, UTC
|
||||
*/
|
||||
long getLastServerChange(AdaptedPlayer player);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,19 @@ public class EventHandlerImpl implements EventHandler {
|
||||
player.hasPermission("ajqueue.queueserver." + to.getName())
|
||||
)
|
||||
) {
|
||||
main.getQueueManager().addToQueue(player, to);
|
||||
int delay = Math.min(main.getConfig().getInt("queue-server-delay"), 3000);
|
||||
Runnable task = () -> {
|
||||
if(to.getServers().contains(player.getCurrentServer())) return;
|
||||
main.getQueueManager().addToQueue(player, to);
|
||||
};
|
||||
|
||||
Debug.info("Delaying queue-server by " + delay);
|
||||
|
||||
if(delay > 0) {
|
||||
main.getTaskManager().executor.schedule(task, delay, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,6 +470,11 @@ public class QueueManagerImpl implements QueueManager {
|
||||
}
|
||||
return;
|
||||
}
|
||||
long lastSwitch = main.getServerTimeManager().getLastServerChange(player);
|
||||
int delay = Math.min(Math.max(main.getConfig().getInt("queue-server-delay"), 0), 3000);
|
||||
if(System.currentTimeMillis() - lastSwitch > delay + 1000 || !player.getCurrentServer().equals(from)) {
|
||||
return;
|
||||
}
|
||||
if(
|
||||
!getPlayerQueues(player).contains(to) &&
|
||||
(
|
||||
|
||||
@@ -84,6 +84,13 @@ auto-add-kick-reasons:
|
||||
queue-servers:
|
||||
- 'limbo:lobbys'
|
||||
|
||||
# How much should we delay queueing players in queue servers?
|
||||
# You should only use this if you have issues with the instant sending.
|
||||
# Set to 0 or any negative number to disable
|
||||
# In milliseconds. Maximum value is 3000 (3 seconds)
|
||||
# Default: 0
|
||||
queue-server-delay: 0
|
||||
|
||||
# Should we completely kick the user from the server if they are in a queue-server
|
||||
# and are kicked from the server with one of the above reasons?
|
||||
# Note this will do nothing on servers that aren't queue-servers
|
||||
@@ -382,7 +389,7 @@ debug: false
|
||||
|
||||
|
||||
# Don't touch this number please
|
||||
config-version: 43
|
||||
config-version: 44
|
||||
|
||||
|
||||
# This is ONLY here so that they can be moved to messages.yml. Please edit these in messages.yml!
|
||||
|
||||
Reference in New Issue
Block a user