issues with permissions "sadface"

Discussion in 'Plugin Development' started by Jeff.Halbert, Jun 15, 2012.

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

    Jeff.Halbert

    for some reason, players with assigned permissions are allowed/not allowed to do what they can/cannot do. BUT if a new player joins the server, and is in the default group, they have access to everything, kinda like an op! weird I know. I doubt it's a PEX issue, and think there must be something wrong with my code. For example:

    If a player has the ChunkProtection.deny permNode, then they shouldn't be able to use any portion of the plugin. If they have ChunkProtection.user, then they should be able to use the plugin. For some reason, in this event (posted below) the person with ChunkProtection.deny will still claim a chunk under protection, even though they do not have the ChunkProtection.user permNode.

    Code:
    public static void onBlockPlace(ChunkProtection plugin, BlockPlaceEvent event) throws SQLException {
           
            String player = event.getPlayer().getName();
            String world = event.getBlock().getWorld().getName();
            int x = event.getBlock().getChunk().getX();
            int z = event.getBlock().getChunk().getZ();
           
            if (sql.checkChunk(plugin, world, x, z)) {
                if (event.getPlayer().hasPermission(log.deny)) {
                    event.setCancelled(true);
                    event.getPlayer().sendMessage(ChatColor.RED + "You cannot build here!");
                } else if (event.getPlayer().hasPermission(log.user)) {
                    if ((sql.isOwner(plugin, player, world, x, z)) || (sql.isMember(plugin, player, world, x, z))) {
                        return;
                    } else if (event.getPlayer().hasPermission(log.mod)) {
                        return;
                    } else {
                        event.setCancelled(true);
                        event.getPlayer().sendMessage(ChatColor.RED + "You cannot build here!");
                    }
                }
            } else {
                if (event.getPlayer().hasPermission(log.user)) {
                    if (event.getBlock().getType() == Material.FENCE) {
                        if (sql.atMaxTokens(plugin, player)) {
                            event.setCancelled(true);
                            event.getPlayer().sendMessage(ChatColor.RED + "You already have the maximum number of allowed protections.");
                        } else {
                            sql.addChunk(plugin, player, world, x, z);
                            sql.addToken(plugin, player);
                            event.getPlayer().sendMessage(ChatColor.GREEN + "You have successfully protected this area!");
                        }
                    }
                }
            }
        }
    what am I doing wrong? (log.deny, log.user are just strings that point to ChunkProtection.deny and ChunkProtection.user respectively)
     
  2. Offline

    IcyRelic

    add "" to it so its "log.user" instead of log.user
     
  3. what is standing inside the plugin.yml?
     
  4. Offline

    Jeff.Halbert

    my plugin.yml goes...
    Code:
    name: ChunkProtection
    version: 1.0
    main: me.GBCsubspec.ChunkProtection.ChunkProtection
    permissions:
        ChunkProtection.user:
            description: Basic permission to allow usage of the ChunkProtection Plugin.
        ChunkProtection.mod:
            description: Allows players to build on ALL areas protected by the ChunkProtection Plugin.
            children:
                ChunkProtection.user: true
        ChunkProtection.admin:
            description: Allows usage of admin commands for the ChunkProtection Plugin.
            children:
                ChunkProtection.user: true
                ChunkProtection.mod: true
            default: op
        ChunkProtection.deny:
            description: Deny all usage of the ChunkProtection Plugin.
    commands:
        cp:
            description: commands for the ChunkProtection plugin.
            usage: /<command> [help] for details.
            permission: ChunkProtection.admin
            permission-message: You do not have permission to use this command!
     
  5. Offline

    chaseoes

    Someone already gave you the solution.

     
  6. Offline

    Jeff.Halbert

    that doesn't work. all it does is make log.user a string that equals "log.user". the actual reference is to my log class, and is a public static String user = "ChunkProtection.user"; so all in all, it's the exact same thing as putting "ChunkProtection.user" in the brackets.

    If I where to take out the log.user and put the actual permission, I still have the same issues :-(

    I'm a RETARD!!!! i just spent the last 2 days re-writing code, testing, re-writing code, testing, re-writing code, testing... etc. and it turns out, all my tests failed because the account that I was testing with was OPed on my test server environment. Oh man, do I feel stupid. sry for waiting everyone's time "sadface" [SOLVED]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  7. Haha, glad you got it sorted anyway.
     
Thread Status:
Not open for further replies.

Share This Page