added optional permission for appliance commands

This commit is contained in:
MineTec committed 2026-10-14 17:04:06 +02:00
1 parent 86ae261c60
commit 675d87f6e9
3 files changed
+15

No files matched your search

@@ -139,6 +139,7 @@ public abstract class Appliance {
PluginCommand command = this.createPluginCommand(name, plugin);
command.setExecutor(executor);
command.setTabCompleter(executor);
if(executor.permission() != null) command.setPermission(executor.permission());
plugin.getServer().getCommandMap().register(plugin.getName(), command);
} catch(Exception e) {
throw new RuntimeException(String.format("Failed to register command '%s'", name), e);
@@ -30,6 +30,14 @@ public abstract class ApplianceCommand<T extends Appliance> extends CachedApplia
this.errorMessage = errorMessage;
}
/**
* Permission needed to see and run the command. Paper leaves the command out of the command tree
* of players without it, so for them it does not exist. Null means everyone.
*/
public @Nullable String permission() {
return null;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
try {
+6
View File
@@ -17,6 +17,12 @@ database:
loginLog:
retentionMonths: 16
banEvasion:
windowDays: 14
rejectionWindowHours: 24
banCacheMinutes: 5
retentionMonths: 16
worldMuseum:
uuid:
connect-server-name: worldmuseum