loops

Discussion in 'Plugin Development' started by TerroDoor, Sep 4, 2019.

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

    TerroDoor

    I am trying to solve this for a while, confusing myself more everytime.

    i have a custom inv with nothing in it, when the player interacts with an item i can open the gui. I am trying to go through all of the players permissions and only add items based on permissions the player has.
     
  2. Online

    timtower Administrator Administrator Moderator

    @TerroDoor Check if the player has a permission instead.
     
  3. Offline

    TerroDoor

    Code:
    
            ItemStack pvp = new ItemStack(Material.DIAMOND_SWORD);
    
            if (p.getInventory().getItemInMainHand().getType() == Material.BOOK) {
                if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                   
                    if (p.hasPermission("tkits.pvp")) {
                       
                        kitinv.setItem(0, pvp);
                   
                    } else {
                       
                        return;
                    }
               
               
                p.openInventory(kitinv);
                return;
               
                } else {
                   
                    return;
                }
            }
            return;
        }
    }
    
    
    @timtower is there a faster way to go through all the perms? or would an else if statement fit this better
     
  4. Online

    timtower Administrator Administrator Moderator

    @TerroDoor hasPermission is as fast as it will get probably, with this you at least have a set order.
     
Thread Status:
Not open for further replies.

Share This Page