Fix kyori, add permissionlist command, fix luckperms getting wrong context
This commit is contained in:
@@ -6,7 +6,7 @@ plugins {
|
||||
group = "us.ajg0702.queue.api"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://repo.ajg0702.us") }
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package us.ajg0702.queue.api;
|
||||
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.utils.common.Config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface LogicGetter {
|
||||
Logic constructLogic();
|
||||
AliasManager constructAliasManager(Config config);
|
||||
List<String> getPermissions(AdaptedPlayer player);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public interface IBaseCommand {
|
||||
|
||||
String getPermission();
|
||||
|
||||
boolean showInTabComplete();
|
||||
|
||||
Messages getMessages();
|
||||
|
||||
void addSubCommand(ISubCommand subCommand);
|
||||
|
||||
@@ -6,7 +6,7 @@ plugins {
|
||||
group = "us.ajg0702.queue.common"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.ajg0702.us") }
|
||||
}
|
||||
|
||||
@@ -31,6 +31,11 @@ public class BaseCommand implements IBaseCommand {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInTabComplete() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return null;
|
||||
|
||||
@@ -27,6 +27,11 @@ public class ISP extends SubCommand {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInTabComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return null;
|
||||
|
||||
@@ -27,6 +27,7 @@ public class ManageCommand extends BaseCommand {
|
||||
addSubCommand(new ISP(main));
|
||||
addSubCommand(new QueueList(main));
|
||||
addSubCommand(new Send(main));
|
||||
addSubCommand(new PermissionList(main));
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +88,7 @@ public class ManageCommand extends BaseCommand {
|
||||
}
|
||||
List<String> commands = new ArrayList<>();
|
||||
for(ISubCommand subCommand : subCommands) {
|
||||
if(!subCommand.showInTabComplete()) continue;
|
||||
commands.add(subCommand.getName());
|
||||
commands.addAll(subCommand.getAliases());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package us.ajg0702.queue.commands.commands.manage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.commands.SubCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class PermissionList extends SubCommand {
|
||||
|
||||
final QueueMain main;
|
||||
public PermissionList(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "permissionlist";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInTabComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
List<String> permissions = main.getLogicGetter().getPermissions(main.getPlatformMethods().senderToPlayer(sender));
|
||||
if(permissions == null) {
|
||||
sender.sendMessage(Component.text("no permission handler"));
|
||||
return;
|
||||
}
|
||||
permissions.forEach(s -> {
|
||||
if(!s.toLowerCase(Locale.ROOT).contains("ajqueue")) return;
|
||||
sender.sendMessage(Component.text(s));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,11 @@ public class Tasks extends SubCommand {
|
||||
return "ajqueue.manage.tasks";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInTabComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
|
||||
@@ -75,6 +75,10 @@ public class QueueMain {
|
||||
return queueManager;
|
||||
}
|
||||
|
||||
private final LogicGetter logicGetter;
|
||||
public LogicGetter getLogicGetter() {
|
||||
return logicGetter;
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
taskManager.shutdown();
|
||||
@@ -86,6 +90,8 @@ public class QueueMain {
|
||||
|
||||
public QueueMain(QueueLogger logger, PlatformMethods platformMethods, File dataFolder) {
|
||||
|
||||
logicGetter = new LogicGetterImpl();
|
||||
|
||||
if(instance != null) {
|
||||
try {
|
||||
throw new Exception("ajQueue QueueMain is being initialized when there is already one! Still initializing it, but this can cause issues.");
|
||||
@@ -114,8 +120,8 @@ public class QueueMain {
|
||||
|
||||
queueManager = new QueueManagerImpl(this);
|
||||
|
||||
logic = new LogicGetterImpl().constructLogic();
|
||||
aliasManager = new LogicGetterImpl().constructAliasManager(config);
|
||||
logic = logicGetter.constructLogic();
|
||||
aliasManager = logicGetter.constructAliasManager(config);
|
||||
|
||||
taskManager.rescheduleTasks();
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@ package us.ajg0702.queue.logic;
|
||||
|
||||
import us.ajg0702.queue.api.AliasManager;
|
||||
import us.ajg0702.queue.api.Logic;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.utils.common.Config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LogicGetterImpl implements us.ajg0702.queue.api.LogicGetter {
|
||||
|
||||
@Override
|
||||
@@ -15,4 +18,9 @@ public class LogicGetterImpl implements us.ajg0702.queue.api.LogicGetter {
|
||||
public AliasManager constructAliasManager(Config config) {
|
||||
return new FreeAliasManager(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPermissions(AdaptedPlayer player) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
group = "us.ajg0702.queue"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.ajg0702.us") }
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
|
||||
|
||||
@@ -6,7 +6,7 @@ plugins {
|
||||
group = "us.ajg0702.queue.platforms.bungeecord"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.ajg0702.us") }
|
||||
maven { url = uri("https://nexus.velocitypowered.com/repository/maven-public/") }
|
||||
@@ -17,9 +17,9 @@ dependencies {
|
||||
compileOnly("com.google.guava:guava:30.1.1-jre")
|
||||
compileOnly("us.ajg0702:ajUtils:1.1.7")
|
||||
|
||||
compileOnly("net.md-5:bungeecord-api:1.14-SNAPSHOT")
|
||||
compileOnly("net.md-5:bungeecord-api:1.16-R0.4")
|
||||
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT")
|
||||
|
||||
implementation("net.kyori:adventure-platform-bungeecord:4.0.0-SNAPSHOT")
|
||||
compileOnly("net.kyori:adventure-text-serializer-plain:4.0.0-SNAPSHOT")
|
||||
|
||||
+3
-3
@@ -36,6 +36,8 @@ public class BungeeQueue extends Plugin implements Listener {
|
||||
QueueLogger logger = new BungeeLogger(getLogger());
|
||||
File dataFolder = getDataFolder();
|
||||
|
||||
adventure = BungeeAudiences.create(this);
|
||||
|
||||
main = new QueueMain(
|
||||
logger,
|
||||
new BungeeMethods(this, getProxy(), logger),
|
||||
@@ -59,15 +61,13 @@ public class BungeeQueue extends Plugin implements Listener {
|
||||
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
|
||||
adventure = BungeeAudiences.create(this);
|
||||
|
||||
}
|
||||
|
||||
private static BungeeAudiences adventure;
|
||||
|
||||
public static @NonNull BungeeAudiences adventure() {
|
||||
if(adventure == null) {
|
||||
throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled");
|
||||
throw new IllegalStateException("Cannot retrieve audience provider. Not loaded yet.");
|
||||
}
|
||||
return adventure;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ plugins {
|
||||
group = "us.ajg0702.queue.platforms.velocity"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.ajg0702.us") }
|
||||
maven { url = uri("https://nexus.velocitypowered.com/repository/maven-public/") }
|
||||
@@ -19,7 +19,7 @@ dependencies {
|
||||
|
||||
compileOnly("com.velocitypowered:velocity-api:3.0.0")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.0.0")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT")
|
||||
|
||||
implementation(project(":common"))
|
||||
implementation(project(":api"))
|
||||
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
group = "us.ajg0702.queue"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.ajg0702.us") }
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
|
||||
|
||||
@@ -3,17 +3,32 @@ package us.ajg0702.queue.logic;
|
||||
import us.ajg0702.queue.api.AliasManager;
|
||||
import us.ajg0702.queue.api.Logic;
|
||||
import us.ajg0702.queue.api.LogicGetter;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.queue.logic.permissions.PermissionGetter;
|
||||
import us.ajg0702.utils.common.Config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LogicGetterImpl implements LogicGetter {
|
||||
PremiumLogic logic;
|
||||
|
||||
@Override
|
||||
public Logic constructLogic() {
|
||||
return new PremiumLogic(QueueMain.getInstance());
|
||||
if(logic == null) {
|
||||
logic = new PremiumLogic(QueueMain.getInstance());
|
||||
}
|
||||
return logic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AliasManager constructAliasManager(Config config) {
|
||||
return new PremiumAliasManager(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPermissions(AdaptedPlayer player) {
|
||||
if(logic == null) return null;
|
||||
return logic.getPermissionGetter().getSelected().getPermissions(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ import us.ajg0702.queue.logic.permissions.PermissionGetter;
|
||||
|
||||
public class PremiumLogic implements Logic {
|
||||
|
||||
public PermissionGetter getPermissionGetter() {
|
||||
return permissionGetter;
|
||||
}
|
||||
|
||||
private final PermissionGetter permissionGetter;
|
||||
public PremiumLogic(QueueMain main) {
|
||||
permissionGetter = new PermissionGetter(main);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class LuckPermsHook implements PermissionHook {
|
||||
User user = api.getUserManager().getUser(player.getUniqueId());
|
||||
|
||||
assert user != null;
|
||||
SortedSet<Node> nodes = user.resolveDistinctInheritedNodes(QueryOptions.defaultContextualOptions());
|
||||
SortedSet<Node> nodes = user.resolveDistinctInheritedNodes(QueryOptions.nonContextual());
|
||||
|
||||
List<String> perms = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ plugins {
|
||||
group = "us.ajg0702.queue.spigot"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") }
|
||||
|
||||
Reference in New Issue
Block a user