Example #1
0
 @CommandRequirements()
 @Command(
     aliases = "npc",
     usage = "remove (all)",
     desc = "remove NPCs",
     modifiers = "remove",
     min = 1,
     max = 2)
 public static void remove(CommandContext args, Player player, HumanNPC npc) {
   if (args.argsLength() == 2 && args.getString(1).equalsIgnoreCase("all")) {
     if (PermissionManager.hasPermission(player, "citizens.basic.modify.remove.all")) {
       if (NPCManager.GlobalUIDs.size() == 0) {
         Messaging.sendError(player, "There are no NPCs to remove.");
         return;
       }
       NPCManager.removeAll(NPCRemoveReason.COMMAND);
       NPCDataManager.deselectNPC(player);
       player.sendMessage(ChatColor.GRAY + "The NPC(s) disappeared.");
     } else {
       Messaging.sendError(player, MessageUtils.noPermissionsMessage);
     }
     return;
   }
   if (npc == null) {
     player.sendMessage(MessageUtils.mustHaveNPCSelectedMessage);
     return;
   }
   if ((!NPCManager.isOwner(player, npc.getUID())
           && PermissionManager.hasPermission(player, "citizens.admin.override.remove"))
       || (NPCManager.isOwner(player, npc.getUID())
           && PermissionManager.hasPermission(player, "citizens.basic.modify.remove"))) {
     NPCManager.remove(npc.getUID(), NPCRemoveReason.COMMAND);
     NPCDataManager.deselectNPC(player);
     player.sendMessage(StringUtils.wrap(npc.getName(), ChatColor.GRAY) + " disappeared.");
     return;
   }
   Messaging.sendError(player, MessageUtils.noPermissionsMessage);
 }
Example #2
0
 // Removes all NPCs.
 public static void removeAll(NPCRemoveReason reason) {
   for (int i : GlobalUIDs.keySet()) {
     remove(i, reason);
   }
 }