Perm changes
This commit is contained in:
parent
aec9682b2a
commit
4132a33037
3 changed files with 13 additions and 1 deletions
|
@ -54,7 +54,7 @@ public abstract class Command2<TC extends ICommand2, TP extends Command2Sender>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main permission which allows using this command (individual access can be still granted with "thorpe.command.X").
|
* The main permission which allows using this command (individual access can be still granted with "thorpe.command.X").
|
||||||
* Used to be "tbmc.admin"
|
* Used to be "tbmc.admin". The {@link #MOD_GROUP} is provided to use with this.
|
||||||
*/
|
*/
|
||||||
String permGroup() default ""; //TODO
|
String permGroup() default ""; //TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package buttondevteam.lib.chat;
|
||||||
|
|
||||||
import buttondevteam.core.MainPlugin;
|
import buttondevteam.core.MainPlugin;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@ -9,12 +12,15 @@ public class Command2MC extends Command2<ICommand2MC, Command2MCSender> {
|
||||||
@Override
|
@Override
|
||||||
public void registerCommand(ICommand2MC command) {
|
public void registerCommand(ICommand2MC command) {
|
||||||
super.registerCommand(command, '/');
|
super.registerCommand(command, '/');
|
||||||
|
Bukkit.getPluginManager().addPermission(new Permission("thorpe.command." + command.getCommandPath().replace(' ', '.'),
|
||||||
|
modOnly(command) ? PermissionDefault.OP : PermissionDefault.TRUE)); //Allow commands by default, unless it's mod only - TODO: Test
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(Command2MCSender sender, ICommand2MC command) {
|
public boolean hasPermission(Command2MCSender sender, ICommand2MC command) {
|
||||||
return modOnly(command)
|
return modOnly(command)
|
||||||
? MainPlugin.permission.has(sender.getSender(), "tbmc.admin") //TODO: Change when groups are implemented
|
? MainPlugin.permission.has(sender.getSender(), "tbmc.admin") //TODO: Change when groups are implemented
|
||||||
|
//: MainPlugin.permission.has(sender.getSender(), permGroup()) - TODO: Check for subcommands (permGroup)
|
||||||
: MainPlugin.permission.has(sender.getSender(), "thorpe.command." + command.getCommandPath().replace(' ', '.'));
|
: MainPlugin.permission.has(sender.getSender(), "thorpe.command." + command.getCommandPath().replace(' ', '.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,4 +44,10 @@ public @interface CommandClass {
|
||||||
* @return The help text
|
* @return The help text
|
||||||
*/
|
*/
|
||||||
String[] helpText() default {};
|
String[] helpText() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main permission which allows using this command (individual access can be still granted with "thorpe.command.X").
|
||||||
|
* Used to be "tbmc.admin"
|
||||||
|
*/
|
||||||
|
String permGroup() default ""; //TODO: A single annotation instead of these two
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue