Exemplo n.º 1
0
 private void changePlayerRank(UUID toChange, PlayerType newRank) {
   if (gm.hasAccess(g, p.getUniqueId(), getAccordingPermission(g.getCurrentRank(toChange)))) {
     if (!g.isMember(toChange)) {
       p.sendMessage(
           ChatColor.RED
               + "This player is no longer on the group and can't be "
               + demoteOrPromote(g.getCurrentRank(toChange), newRank, false)
               + "d");
       return;
     }
     if (g.isOwner(toChange)) {
       p.sendMessage(ChatColor.RED + "This player owns the group and can't be demoted");
     }
     OfflinePlayer prom = Bukkit.getOfflinePlayer(toChange);
     NameLayerPlugin.log(
         Level.INFO,
         p.getName()
             + " changed player rank for "
             + NameAPI.getCurrentName(toChange)
             + " from "
             + g.getCurrentRank(toChange).toString()
             + " to "
             + newRank.toString()
             + " for group "
             + g.getName()
             + "via gui");
     if (prom.isOnline()) {
       Player oProm = (Player) prom;
       PromotePlayerEvent event =
           new PromotePlayerEvent(oProm, g, g.getCurrentRank(toChange), newRank);
       Bukkit.getPluginManager().callEvent(event);
       if (event.isCancelled()) {
         p.sendMessage(
             ChatColor.RED + "Could not change player rank, you should complain about this");
         return;
       }
       g.removeMember(toChange);
       g.addMember(toChange, newRank);
       oProm.sendMessage(
           ChatColor.GREEN
               + "You have been promoted to "
               + getRankName(toChange)
               + " in (Group) "
               + g.getName());
     } else {
       // player is offline change their perms
       g.removeMember(toChange);
       g.addMember(toChange, newRank);
     }
     p.sendMessage(
         ChatColor.GREEN
             + NameAPI.getCurrentName(toChange)
             + " has been "
             + demoteOrPromote(g.getCurrentRank(toChange), newRank, false)
             + "d to "
             + getRankName(toChange));
   } else {
     p.sendMessage(ChatColor.RED + "You have lost permission to remove this player");
   }
 }
Exemplo n.º 2
0
 @Override
 public void run() {
   Group g = getGroup();
   if (g.getGroupId() == -1) { // now try + num
     NameLayerPlugin.log(
         Level.WARNING,
         "Newfriend automatic group creation failed for " + g.getName() + " " + uuid);
     GroupManager gm = NameAPI.getGroupManager();
     if (inc == null) {
       inc = 0;
     } else {
       inc++;
     }
     if (inc < 20) {
       String newName = name + String.valueOf(inc);
       gm.createGroupAsync(new Group(newName, uuid, false, null, -1), this, true);
     }
   } else {
     NameLayerPlugin.log(
         Level.WARNING,
         "Newfriend automatic group creation succeeded for " + g.getName() + " " + uuid);
     g.setDefaultGroup(uuid);
   }
 }
Exemplo n.º 3
0
 private void removeMember(UUID toRemove) {
   if (gm.hasAccess(g, p.getUniqueId(), getAccordingPermission(g.getCurrentRank(toRemove)))) {
     if (!g.isMember(toRemove)) {
       p.sendMessage(ChatColor.RED + "This player is no longer on the group and can't be removed");
       return;
     }
     if (g.isOwner(toRemove)) {
       p.sendMessage(ChatColor.RED + "This player owns the group and can't be removed");
     }
     NameLayerPlugin.log(
         Level.INFO,
         p.getName()
             + " kicked "
             + NameAPI.getCurrentName(toRemove)
             + " from "
             + g.getName()
             + "via gui");
     g.removeMember(toRemove);
     p.sendMessage(
         ChatColor.GREEN + NameAPI.getCurrentName(toRemove) + " has been removed from the group");
   } else {
     p.sendMessage(ChatColor.RED + "You have lost permission to remove this player");
   }
 }