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
|
* Gets the time that the player specified was last seen switching servers
|
||||||
* @param player The player to check
|
* @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);
|
long getLastServerChange(AdaptedPlayer player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,19 @@ public class EventHandlerImpl implements EventHandler {
|
|||||||
player.hasPermission("ajqueue.queueserver." + to.getName())
|
player.hasPermission("ajqueue.queueserver." + to.getName())
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
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);
|
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;
|
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(
|
if(
|
||||||
!getPlayerQueues(player).contains(to) &&
|
!getPlayerQueues(player).contains(to) &&
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -84,6 +84,13 @@ auto-add-kick-reasons:
|
|||||||
queue-servers:
|
queue-servers:
|
||||||
- 'limbo:lobbys'
|
- '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
|
# 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?
|
# and are kicked from the server with one of the above reasons?
|
||||||
# Note this will do nothing on servers that aren't queue-servers
|
# Note this will do nothing on servers that aren't queue-servers
|
||||||
@@ -382,7 +389,7 @@ debug: false
|
|||||||
|
|
||||||
|
|
||||||
# Don't touch this number please
|
# 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!
|
# 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