Permissions

Discussion in 'Plugin Development' started by CactusComboPvP, Jul 12, 2014.

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

    CactusComboPvP

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    2. if(cmd.getName().equalsIgnoreCase("kits")) {
    3. Player p = (Player)sender;
    4. if(p.hasPermission("mKits.starter")) {
    5. p.sendMessage(ChatColor.RED + "Kits: " + ChatColor.GRAY + "Starter PvP VIP MVP PRO");
    6. }
    7. }
    8. return true;
    9. }
    10. }


    So I coded that, pretty plain. But what I want it to do is when they do the command, if they do not have permission for the kit it does not show up on the list. eg:

    If they don't have mKits.VIP
    Kits: Starter, PvP, MVP, PRO

    If they don't have mKits.PRO
    Kits: Starter, PvP, VIP, MVP

    and so on, no clue on how to do it, any help?
     
  2. Offline

    xAstraah

  3. Offline

    CactusComboPvP

  4. Code:java
    1.  
    2.  
    3. private final List<String> kits = Arrays.asList("Starter", "PvP", "VIP", "MVP", "PRO");
    4.  
    5. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    6. if(cmd.getName().equalsIgnoreCase("kits")) {
    7. Player p = (Player) sender;
    8. if(p.hasPermission("mKits.starter")) {
    9. List<String> permKits = new ArrayList<String>();
    10. for (String kit : kits) {
    11. if (p.hasPermission("mKits." + kit)) {
    12. permKits.add(kit);
    13. }
    14. }
    15. p.sendMessage(ChatColor.RED + "Kits: " + ChatColor.GRAY + StringUtils.join(permKits, " "));
    16. }
    17. }
    18. return true;
    19. }
    20.  
    21.  
     
  5. Offline

    ZodiacTheories

  6. Offline

    CactusComboPvP

    ZodiacTheories
    Clearly as you can see it is tagged to another person, so what he said I don't get.
     
  7. Offline

    ZodiacTheories

    CactusComboPvP

    So you do not understand switch statements? What they posted was basic Java, if you do not understand that then please go and learn java :)
     
Thread Status:
Not open for further replies.

Share This Page