added unjoinable priorities
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package us.ajg0702.queue.api.premium;
|
||||
|
||||
import us.ajg0702.queue.api.AjQueueAPI;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.utils.common.Config;
|
||||
|
||||
@SuppressWarnings({"SameReturnValue", "unused"})
|
||||
|
||||
@@ -32,4 +34,34 @@ public interface Logic {
|
||||
* @return the permission getter
|
||||
*/
|
||||
PermissionGetter getPermissionGetter();
|
||||
|
||||
static int getUnJoinablePriorities(QueueServer server, AdaptedPlayer player) {
|
||||
Config config = AjQueueAPI.getInstance().getConfig();
|
||||
int highest = 0;
|
||||
|
||||
int whitelitedPriority = config.getInt("give-whitelisted-players-priority");
|
||||
int bypassPausedPriotity = config.getInt("give-whitelisted-players-priority");
|
||||
int fulljoinPriority = config.getInt("give-whitelisted-players-priority");
|
||||
|
||||
if(whitelitedPriority > 0) {
|
||||
if(server.isWhitelisted() && server.getWhitelistedPlayers().contains(player.getUniqueId())) {
|
||||
highest = whitelitedPriority;
|
||||
}
|
||||
}
|
||||
|
||||
if(bypassPausedPriotity > 0) {
|
||||
if(server.isPaused() && (player.hasPermission("ajqueue.bypasspaused"))) {
|
||||
highest = Math.max(highest, bypassPausedPriotity);
|
||||
}
|
||||
}
|
||||
|
||||
if(fulljoinPriority > 0) {
|
||||
if(server.isFull() && server.canJoinFull(player)) {
|
||||
highest = Math.max(highest, fulljoinPriority);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return highest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.kyori.adventure.title.Title;
|
||||
import us.ajg0702.queue.api.QueueManager;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.premium.Logic;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.common.players.QueuePlayerImpl;
|
||||
@@ -151,6 +152,7 @@ public class QueueManagerImpl implements QueueManager {
|
||||
} else {
|
||||
int priority = player.hasPermission("ajqueue.priority") ||
|
||||
player.hasPermission("ajqueue.serverpriority."+server.getName()) ? 1 : 0;
|
||||
priority = Math.max(priority, Logic.getUnJoinablePriorities(server, player) > 0 ? 1 : 0);
|
||||
int maxOfflineTime = player.hasPermission("ajqueue.stayqueued") ? 60 : 0;
|
||||
queuePlayer = new QueuePlayerImpl(player, server, priority, maxOfflineTime);
|
||||
if(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Dont touch this number please
|
||||
config-version: 30
|
||||
config-version: 31
|
||||
|
||||
|
||||
# This is the main config for ajQueue.
|
||||
@@ -278,6 +278,23 @@ slash-servers: []
|
||||
balancer-types:
|
||||
- "bedwars:minigame"
|
||||
|
||||
# What priority should we give whitelisted players priority when the server is whitelisted?
|
||||
# This will have no effect if the server isnt whitelisted
|
||||
# If you set to 0, this will be disabled
|
||||
# If you have the free version, set it to 1 to enable
|
||||
give-whitelisted-players-priority: 0
|
||||
|
||||
# Should we print some extra stuff to the console that might help diagnose some issues?
|
||||
# What priority should we give players that are able to bypass paused priority when the server is paused?
|
||||
# This will have no effect if the server isnt paused
|
||||
# If you set to 0, this will be disabled
|
||||
# If you have the free version, set it to 1 to enable
|
||||
give-pausedbypass-players-priority: 0
|
||||
|
||||
# What priority should we give players that are able to bypass full servers priority when the server is full?
|
||||
# This will have no effect if the server isnt full
|
||||
# If you set to 0, this will be disabled
|
||||
# If you have the free version, set it to 1 to enable
|
||||
give-fulljoin-players-priority: 0
|
||||
|
||||
# Should we print some extra stuff to the console that might help aj diagnose some issues?
|
||||
debug: false
|
||||
@@ -61,6 +61,7 @@ public class PremiumLogic implements Logic {
|
||||
}
|
||||
|
||||
int highestPriority = Math.max(priority, serverPriority);
|
||||
highestPriority = Math.max(highestPriority, Logic.getUnJoinablePriorities(server, player));
|
||||
|
||||
QueuePlayer queuePlayer = new QueuePlayerImpl(player, server, highestPriority, maxOfflineTime);
|
||||
|
||||
@@ -91,6 +92,7 @@ public class PremiumLogic implements Logic {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(debug) {
|
||||
logger.info("[priority] "+player.getName()+" Cant go infront of anyone" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user