Skip to content

Commit

Permalink
Added plus-level-fallback to allow some leveled permissions on ajQueu…
Browse files Browse the repository at this point in the history
…ePlus to work without a supported permission plugin
  • Loading branch information
ajgeiss0702 committed Oct 21, 2023
1 parent 4a0869c commit 242b4a2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
10 changes: 8 additions & 2 deletions common/src/main/resources/config.yml
Expand Up @@ -350,6 +350,12 @@ include-server-switch-in-cooldown: false
# If ajQueue is pinging your backend servers too often, raise this number
minimum-ping-time: 1.0

# In ajQueuePlus, if your permission plugin isn't yet supported, you can use this workaround to
# be able to use levels 1-10 for priority, or 15, 30, 60, and 120 for stayqueued
# If you want more levels than that, contact aj to add support for your permission plugin if possible.
# Does nothing if you are not on ajQueuePlus, or if you have a supported permission plugin
plus-level-fallback: false

# Should we print some extra stuff to the console that might help aj diagnose some issues?
debug: false

Expand All @@ -364,5 +370,5 @@ debug: false



# Dont touch this number please
config-version: 36
# Don't touch this number please
config-version: 37
Expand Up @@ -5,6 +5,8 @@
import us.ajg0702.queue.api.premium.PermissionHook;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class BuiltInHook implements PermissionHook {
Expand All @@ -26,9 +28,41 @@ public boolean canUse() {

@Override
public List<String> getPermissions(AdaptedPlayer player) {
if(main.getConfig().getBoolean("plus-level-fallback")) {
List<String> hasPermissions = new ArrayList<>();
for (String fallbackPermission : fallbackPermissions) {
if(player.hasPermission(fallbackPermission)) {
hasPermissions.add(fallbackPermission);
}
}
if(!main.getPlatformMethods().getImplementationName().equals("velocity")) {
hasPermissions.addAll(player.getPermissions());
}
return hasPermissions;
}


if(main.getPlatformMethods().getImplementationName().equals("velocity")) {
return new ArrayList<>();
return Collections.emptyList();
}

return player.getPermissions();
}

private final List<String> fallbackPermissions = Arrays.asList(
"ajqueue.priority.1",
"ajqueue.priority.2",
"ajqueue.priority.3",
"ajqueue.priority.4",
"ajqueue.priority.5",
"ajqueue.priority.6",
"ajqueue.priority.7",
"ajqueue.priority.8",
"ajqueue.priority.9",
"ajqueue.priority.10",
"ajqueue.stayqueued.15",
"ajqueue.stayqueued.30",
"ajqueue.stayqueued.60",
"ajqueue.stayqueued.120"
);
}

0 comments on commit 242b4a2

Please sign in to comment.