Determine highest ranked player.

Discussion in 'Plugin Development' started by Ad237, Sep 7, 2013.

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

    Ad237

    I am developing a plugin with a few admin commands for my server but one thing I have had in the past is admins trolling other admins by killing/kicking them. I want to be able to let admins kick lower members but not each other or the owner/devs. I know how to get a players rank but is there an easy way to determine which is higher.

    I want it in this order. From highest to lowest rank.

    Owner
    Developer
    Admin
    Mod
    Donator
    Player

    Thanks!
     
  2. Ad237
    It depends on how you check the ranks. If you're using permissions (ie "rank.admin/rank.mod"), then you'll have to compare the permissions. More information would be nice.
     
  3. Offline

    Ad237

    Assist Sorry. I am using permissions. How would I go about comparing the permissions? I have never really worked with ranks before. I can make a method that takes the permission and then returns the name of the rank but I don't know how to see if that rank is higher than the other player's rank. Thanks.

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  4. Offline

    MCForger

    Ad237
    Okay, something you can do is before an admin command check if the other player has the permission node "yourpluginname.admin". If hes does don't do anything and send a message saying you can not kick admins. Do the same kind of thing for the other ranks too.
     
  5. permissions? just do when someone loggs in they are added the a hashmap <player,int> if(hasperm Owner int rank = 6
    Developer rank = 5
    Admin rank = 4
    Mod rank =3
    Donator rank =2
    Player) rank =1
    when they use kick command if (rankhashmap.get(kicker)>rankhasmap.get(kicked)) kick the kicked if not don't kick

    basically checks if the kicking player/mod has a higher rank then the one they are kicking

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  6. Offline

    Gater12

    Ad237 I assume you have permissions when they are admin like staff.admin
    Code:java
    1. Player player = (Player) sender;
    2. Player targetPlayer = getServer().getPlayer(args[0]);
    3. if(targetPlayer.hasPermission("permission.node") || targetPlayer.isOp()){
    4. player.sendMessage("You cannot kick other admins!");
    5. }else{
    6. player.kickPlayer();
    7. }
     
Thread Status:
Not open for further replies.

Share This Page