[Resolved]addUserPermission

Discussion in 'Plugin Development' started by DeaGato, Apr 25, 2011.

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

    DeaGato

    How does it work this method?

    Code:
    plugin.Permissions.addUserPermission(String string, String string1, String string2);
     
  2. Offline

    Xaw4

    i'm not sure if that helps you, but
    Code:
    public abstract void addUserPermission(String world, String user, String node);
    is a part of the code for the class PermissionHandler (Permissions is a PermissionHandler?)
     
  3. Offline

    DeaGato

    Good addUserPermissions works perfectly:

    Code:
    if(plugin.Permissions.has(player, "weather.admin.invulnerable")) {
                            World world = player.getWorld();
                            if(plugin.Permissions.has(player, "weather.strike.invulnerable")) {
                                player.sendMessage(ChatColor.GREEN + "Non sei più Invulnerabile!");
                                plugin.Permissions.removeUserPermission(world.getName(), player.getName(), "weather.strike.invulnerable");
                            } else {
                                player.sendMessage(ChatColor.GREEN + "Sei invulnerabile!");
                                plugin.Permissions.addUserPermission(world.getName(), player.getName(), "weather.strike.invulnerable");
                            }
                            plugin.Permissions.saveAll();
                        }
    But when i delete the permission with removeUserPermissions i have this error in permissions file:
    Code:
    users:
        DeaGato:
            permissions: []
     
  4. Offline

    Deathly

    How is that an error? Thats the way it works..

    @DeaGato
     
  5. Offline

    Sammy

    The "[]" is normal, it's the array representation used by the yml file ^^
     
  6. Offline

    DeaGato

    So it don't reload the settings properly. Once It remove the permit it doesn't add more.
     
  7. Offline

    Sammy

    I think that you need to use the reload/update command that comes with permissions
    plugin.Permissions.Update() or plugin.Permissions.reload(), something like that, I don't have an IDE right now
     
  8. Offline

    DeaGato

    Code:
                        if(plugin.Permissions.has(player, "weather.admin.invulnerable")) {
                            if(invPlayer != null) {
                                World world = invPlayer.getWorld();
                                if(plugin.Permissions.has(invPlayer, "weather.strike.invulnerable")) {
                                    player.sendMessage(ChatColor.GREEN + invPlayer.getName() + " non è più invulnerabile!");
                                    invPlayer.sendMessage(ChatColor.RED + player.getName() + " ti ha tolto l'invulnerabilità!");
                                    plugin.Permissions.removeUserPermission(world.getName(), invPlayer.getName(), "weather.strike.invulnerable");
                                } else {
                                    player.sendMessage(ChatColor.GREEN + invPlayer.getName() + " è invulnerabile!");
                                    invPlayer.sendMessage(ChatColor.GREEN + player.getName() + " ti ha reso invulnerabile!");
                                    plugin.Permissions.addUserPermission(world.getName(), invPlayer.getName(), "weather.strike.invulnerable");
                                }
                                plugin.Permissions.saveAll();
                                plugin.Permissions.reload();
                            } else {
                                player.sendMessage(ChatColor.RED + "Il giocatore " + split[1] + " non esiste o non è online!");
                            }
    plugin.Permissions.saveAll();
    plugin.Permissions.reload();

    Resolved - Thanks very much.
     
Thread Status:
Not open for further replies.

Share This Page