Solved Preferences Plugin Help

Discussion in 'Plugin Development' started by DragonLordCR, Nov 22, 2016.

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

    DragonLordCR

    Hello, I want to create a preferences plugin, but I want if player open menu and has permission (exp) rank.player gui will present him only items for which he has permission, but if player has permission (exp) rank.admin he will get all like rank.player and more items.

    I will best present it like this:
    - Mineplex has prefs plugin, Players can use only some prefs, but YouTubers has more prefs (Forcefield, fly etc)
    can someone tell me how to add permission for one item. Thank you

    You are super intelligent if you understand what I want thank you
     
  2. Offline

    mythbusterma

    @DragonLordCR

    All you have to do is check if they have the permission before displaying the thing. Like Player#hasPermission()
     
  3. Offline

    jlin13

    One possible solution (which probably isn't the best):

    • Create a HashMap<String, (Reference to your item)> with the key as the correlating Permission to the reference to your GUI item as the value. Populate this HashMap either by reading data or hardcoding, whatever you want.
    • Loop through the keys when you create your GUI:
    Code:
    for (String perm : hashmapFromEarlier.keySet()) {}
    • Within that for loop, check if the player has the permission, and execute code to put the correlating item in the next slot in the GUI
     
  4. Offline

    DragonLordCR

    @mythbusterma Thank you, I found way to do that

    Code:
     
            Inventory inv = Bukkit.getServer().createInventory(null, 54, "§aPreferences");
            ItemStack neki = new ItemStack(Material.STONE);
            ItemStack n = new ItemStack(Material.ACACIA_FENCE);
            ItemStack mate = new ItemStack(Material.IRON_AXE);
            if(p.hasPermission("m.m")) {
                inv.addItem(mate);
            }
            inv.addItem(neki);
            inv.addItem(n);
            p.openInventory(inv);
    
    I mean that you want to do this (This names: neki, n, mate are just randomly clicked buttons)
     
Thread Status:
Not open for further replies.

Share This Page