Only allow if player has permission.

Discussion in 'Plugin Development' started by SneakyBruh, Sep 29, 2017.

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

    SneakyBruh

    For my kitpvp plugin i am making a GUI that lists all kits. These kits will only be accessible by level. How do i make it if players don't have permission fortis.rank.2 and so on the glass for the ranks will turn back and if they do have the permission it will turn green and allow them?
     
  2. Offline

    FireBuster12

    Code:
    If(p.haspermission("whateveryouwant"){

    //if player has permission whateveryouwant
    } else{
    P.sendmessage("dont have permission");
    Return true;
    }
     
  3. Offline

    SneakyBruh

    Yes i already know but would that still apply to changing a glass pane to either black (no permission) or green (has permission)
     
  4. Online

    timtower Administrator Administrator Moderator

    @SneakyBruh if(has){item.data = green}else{item.data = black}
     
  5. Offline

    VictoryShot

    I would use this method.
    Code:
    boolean statement ? true result : false result;
    In your terms
    Code:
            ItemStack is = new ItemStack(Material.STAINED_GLASS_PANE);
            Colorable color = (Colorable) is.getData();
            color.setColor(p.hasPermission("your.permission") ? DyeColor.LIME : DyeColor.GRAY);
     
  6. Offline

    SneakyBruh

    Line: 52
    Colorablecolor=(Colorable)is.getData();
    Error:
    https://pastebin.com/JJWNmfTc
     
    Last edited: Sep 29, 2017
  7. Offline

    Minesuchtiiii

    Check the permissions before opening the inventory for him. Then according to the permissions he has set some glass planes black, and some green.
     
  8. Offline

    SneakyBruh

    I can't seem to do it!!!!!
    Code:
        ItemStackrod=newItemStack(Material.STAINED_CLAY,1);
    
            ItemMeta rodmeta = rod.getItemMeta();
    
            rodmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&',"&b&lRod God"));
    
            rodmeta.setLore(Arrays.asList(ChatColor.AQUA+"Get Speed 2 when you hold a rod!",ChatColor.GOLD+"REQUIRES LVL: 1",ChatColor.GRAY+"Broken"));
    
            rod.setItemMeta(rodmeta);
    
            if(cfg.getInt(p.getUniqueId() + "." + "rank") <= 2){
                MaterialData data = rod.getData();
                data.setData((byte) 5);
                p.updateInventory();
            }else{
                MaterialData data = rod.getData();
                data.setData((byte) 2);
                p.updateInventory();
    
            }
    
     
  9. Offline

    Caderape2

    @SneakyBruh
    the data will define the color
     
  10. Offline

    AdamDev

    @SneakyBruh
    1. You have put "ItemStackrod =newItemStack(Material.STAINED_CLAY,1);"
    Its supposed to be:
    Code:
    ItemStack rod = new ItemStack(Material.STAINED_CLAY,1);
    
    2. I do suggest making an array list instead of using Arrays.asList();
    Code:
    ArrayList<String> rodlore = new ArrayList<String>();
    
    3. Doing the if statement will be totally wrong under it (Not trying to make you feel bad or anyone else for that matter):
    Code:
    if (cfg.getInt(p.getUniqueId()+".rank") <= 2) {
                   // blah
    } else {
                   // blah
    }
    
    4. As @Caderape2 had said, use (short) instead of (byte) will work
     
Thread Status:
Not open for further replies.

Share This Page