How would I generate permissions on a command? :l

Discussion in 'Plugin Development' started by ShadowWizardMC, Jun 17, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ShadowWizardMC

    Well I am developing a plugin and I would like to know how should I generate permissions on a command so let me give you an example of how it works:
    An OP sets a spawn lets say /setspawn <Number> and the number is 3 how would I make my plugin generate 3 permissions like spawnpoint.1, spawnpoint.2, spawnpoint.3 ?
     
  2. Offline

    cs475x

    ShadowWizardMC Assuming you have a command to go to a spawn point where the syntax is `/spawn <spawn id>`
    Code:java
    1. @Override
    2. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    3. if (command.getName().equalsIgnoreCase("spawn") && args.length >= 1) {
    4. try {
    5. if (sender.hasPermission("spawnpoint." + Integer.parseInt(args[0]))) {
    6. // Teleport player to the spawn point
    7. }
    8. } catch (NumberFormatException e) {
    9. sender.sendMessage(ChatColor.RED + "Number expected, string given");
    10. }
    11. }
    12.  
    13. return true;
    14. }
     
  3. Offline

    ShadowWizardMC

    cs475x Wow I like the idea its the first time ive been intruduced to this but thanks I'll go test it out now.
     
Thread Status:
Not open for further replies.

Share This Page