private void heal(Player player, String[] args) {
    if (!AdminPermissions.has(player, Perms.ADMINHEAL)
        && !AdminPermissions.has(player, Perms.ANYHEAL)) {
      player.sendMessage("You don't have permission to use that command.");
      return;
    } else if (!AdminHandler.isAdminMode(player.getName())
        && !AdminPermissions.has(player, Perms.ANYHEAL)) {
      player.sendMessage("You must be in admin mode to heal players.");
      return;
    } else if (args.length == 0) {
      heal(player, player, true);
      return;
    }
    if (args[0].equalsIgnoreCase("all")) {
      for (Player target : plugin.getServer().getOnlinePlayers()) heal(player, target, false);

      player.sendMessage("You have healed all online players.");
      return;
    }
    List<String> players = new ArrayList<String>();
    for (Player target : plugin.getServer().getOnlinePlayers()) {
      if (target.getName().contains(args[0])) {
        heal(player, target, false);
        players.add(target.getName());
      }
    }

    if (players.isEmpty()) player.sendMessage("Could not find any players named " + args[0] + ".");
    else {
      String message = "You have healed:";
      for (String pName : players) message += "  " + pName;

      player.sendMessage(message);
    }
  }
 /**
  * Toggles stealth login/logoff mode
  *
  * @param player
  */
 public void stealth(Player player) {
   String playerName = player.getName();
   // Check permissions to use the command
   if (AdminPermissions.has(player, Perms.STEALTH)) {
     // If the player is already stealthed, disable and send them a message
     if (AdminHandler.isStealthed(playerName)) {
       AdminHandler.setStealthed(playerName, false);
       AdminHandler.fakeLog(playerName, true);
       player.sendMessage(
           ChatColor.RED
               + "Stealth-Mode "
               + ChatColor.WHITE
               + "is now "
               + ChatColor.RED
               + "disabled.");
     } else {
       // Check if this player is in the admin map - add if necessary
       if (!AdminHandler.contains(playerName)) AdminHandler.add(playerName);
       // Now enable stealth mode and send the messages
       AdminHandler.setStealthed(playerName, true);
       AdminHandler.fakeLog(playerName, false);
       player.sendMessage(
           ChatColor.GREEN
               + "Stealth-Mode "
               + ChatColor.WHITE
               + "is now "
               + ChatColor.GREEN
               + "enabled.");
     }
     AdminHandler.savePlayer(playerName);
   } else {
     // If they don't have permissions let them know
     AdminPermissions.noPermsMessage(player);
   }
 }
 /**
  * Sends a fake login message to all players connected that do not have all-messages permission
  */
 public void fakeLogin(Player player) {
   if (AdminPermissions.has(player, Perms.FAKELOG)) {
     AdminHandler.fakeLog(player.getName(), true);
   } else {
     AdminPermissions.noPermsMessage(player);
   }
 }
  private void bring(Player player, String[] args) {
    if (!AdminPermissions.has(player, Perms.ADMINTP)
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You don't have permission to use that command.");
      return;
    } else if (!AdminHandler.isAdminMode(player.getName())
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You must be in admin mode to teleport.");
      return;
    } else if (args.length < 1) {
      player.sendMessage("You must specify a player to bring to your location.");
      return;
    } else {
      if (args[0].equalsIgnoreCase("all")) {
        teleportAll(player, player.getLocation());
        player.sendMessage("You have teleported everyone to your location.");
        return;
      } else {
        boolean match = false;
        for (Player p : plugin.getServer().getOnlinePlayers()) {
          if (p.getName().contains(args[0])) {
            match = true;
            p.teleport(player);
            p.sendMessage(player.getName() + " has brought you to their location.");
            player.sendMessage("You have brought " + p.getName() + " to your locations.");
          }
        }
        if (!match) player.sendMessage("Could not find any players named " + args[0] + ".");

        return;
      }
    }
  }
 /** Checks permissions for using /return then attempts to return the player to a saved location */
 public void returnLoc(Player player) {
   if (AdminPermissions.has(player, Perms.RETURN)) {
     if (!admins.returnPlayer(player))
       player.sendMessage("You don't have a location saved to return to!");
   } else {
     // If they don't have permissions let them know
     AdminPermissions.noPermsMessage(player);
   }
 }
  /**
   * Checks permissions then: Saves a players current location to the admin map
   *
   * @param player
   */
  public void saveLoc(Player player) {
    String playerName = player.getName();
    if (AdminPermissions.has(player, Perms.RETURN)) {
      if (!AdminHandler.contains(playerName)) AdminHandler.add(playerName);

      AdminHandler.setOrigin(playerName, player.getLocation());
      AdminHandler.savePlayer(playerName);
      player.sendMessage(
          "You have saved your location at: "
              + ChatColor.DARK_AQUA
              + AdminHandler.getLocationString(playerName));
    } else {
      // If they don't have permissions let them know
      AdminPermissions.noPermsMessage(player);
    }
  }
 /**
  * Toggles admin-mode for a player God, NoPickup, Stealth, Invis + Saves Location or Disables them
  * and returns to the saved location
  *
  * @param player
  */
 public void adminMode(Player player) {
   String playerName = player.getName();
   if (AdminPermissions.has(player, Perms.ADMINMODE)) {
     // If this player is already in admin-mode - toggle it off.
     if (AdminHandler.isAdminMode(playerName)) {
       AdminHandler.setAdminMode(playerName, false);
       if (AdminPermissions.has(player, Perms.FAKELOG)) AdminHandler.fakeLog(playerName, true);
       admins.goVisible(player);
       player.sendMessage(
           ChatColor.RED
               + "Admin-Mode "
               + ChatColor.WHITE
               + "is now "
               + ChatColor.RED
               + "disabled.");
       // Return the player a half-second later
       admins.returnPlayer(player);
     } else {
       // Check if this player is in the admin map - add if necessary
       if (!AdminHandler.contains(playerName)) AdminHandler.add(playerName);
       // Enable adminmode and send the message
       AdminHandler.setAdminMode(playerName, true);
       if (AdminPermissions.has(player, Perms.FAKELOG)) AdminHandler.fakeLog(playerName, true);
       admins.goInvisibleInitial(player);
       player.sendMessage(
           ChatColor.GREEN
               + "Admin-Mode "
               + ChatColor.WHITE
               + "is now "
               + ChatColor.GREEN
               + "enabled.");
       // Save the players current location as their origin.
       AdminHandler.setOrigin(playerName, player.getLocation());
       player.sendMessage(
           "You have saved your location at: "
               + ChatColor.BLUE
               + AdminHandler.getLocationString(playerName));
     }
     AdminHandler.savePlayer(playerName);
   } else {
     // If they don't have permissions let them know
     AdminPermissions.noPermsMessage(player);
   }
 }
  private void put(Player player, String[] args) {
    Block block = player.getTargetBlock(null, 50).getRelative(BlockFace.UP);
    if (!AdminPermissions.has(player, Perms.ADMINTP)
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You don't have permission to use that command");
      return;
    } else if (!AdminHandler.isAdminMode(player.getName())
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You must be in admin mode to teleport");
      return;
    } else if (args.length < 1) {
      player.sendMessage("You must specify a player to bring to your location");
      return;
    } else if (block == null) {
      player.sendMessage("Could not determine a block to teleport players to, aborting teleport.");
    } else if (args[0].equalsIgnoreCase("all")) {
      teleportAll(player, block.getLocation());
      player.sendMessage("You have teleported everyone to the target.");
    } else {
      List<String> players = new ArrayList<String>();
      for (Player p : plugin.getServer().getOnlinePlayers()) {
        if (p.getName().toLowerCase().contains(args[0].toLowerCase())) {
          p.teleport(block.getLocation());
          p.sendMessage(player.getName() + " has teleported you.");
          players.add(p.getName());
        }
      }

      if (players.isEmpty()) player.sendMessage("Could not find any players named " + args[0]);
      else {
        String message = "You have brought to your location:";
        for (String pName : players) message += "  " + pName;

        player.sendMessage(message);
      }
      return;
    }
  }
 /**
  * Lists what admin modes a player currently has.
  *
  * @param player
  * @param args
  */
 public void adminStatus(Player player, String[] args) {
   if (AdminPermissions.hasAny(player)) {
     if (args.length < 1) {
       // send string of info for this player;
       player.sendMessage(AdminHandler.infoString(player));
     } else if (AdminPermissions.has(player, Perms.STATUS)) {
       for (Player pStatus : plugin.getServer().getOnlinePlayers()) {
         if (pStatus.getName().equalsIgnoreCase(args[0])) {
           // Send infostring for this player
           player.sendMessage(AdminHandler.infoString(pStatus));
           player.sendMessage(
               pStatus.getName()
                   + " is currently saved to: "
                   + AdminHandler.getLocationString(pStatus.getName()));
         } else {
           player.sendMessage("Could not find a player named " + args[0]);
         }
       }
     }
   } else {
     AdminPermissions.noPermsMessage(player);
   }
 }
 /**
  * Toggles the player being invisible/visible to players Also toggles off Picking up of items
  * while invisibility is on.
  *
  * @param player
  */
 public void vanish(Player player) {
   String playerName = player.getName();
   // Check permissions to use the command
   if (AdminPermissions.has(player, Perms.VANISH)) {
     // If the player is already vanished - unvanish them.
     if (AdminHandler.isInvisible(playerName)) {
       AdminHandler.setInvis(playerName, false);
       AdminHandler.setNoPickup(playerName, false);
       admins.goVisible(player);
       player.sendMessage(
           ChatColor.RED
               + " No-Pickup & Invisibility "
               + ChatColor.WHITE
               + "are now "
               + ChatColor.RED
               + "disabled.");
     } else {
       // Check if the player is in the admin map - add if not
       if (!AdminHandler.contains(playerName)) AdminHandler.add(playerName);
       // Now enable invis, no pickup and send the message
       AdminHandler.setInvis(playerName, true);
       AdminHandler.setNoPickup(playerName, true);
       admins.goInvisibleInitial(player);
       player.sendMessage(
           ChatColor.GREEN
               + "No-Pickup & Invisibility "
               + ChatColor.WHITE
               + "are now "
               + ChatColor.GREEN
               + "enabled.");
     }
     AdminHandler.savePlayer(playerName);
   } else {
     // Let the player know they don't have permission
     AdminPermissions.noPermsMessage(player);
   }
 }
  /**
   * Toggles god-mode for the player
   *
   * @param player
   */
  public void godMode(Player player) {
    String playerName = player.getName();
    if (AdminPermissions.has(player, Perms.GOD)) {
      // If this player is already in god-mode - toggle it off.
      if (AdminHandler.isGod(playerName)) {
        AdminHandler.setGod(playerName, false);
        player.sendMessage(
            ChatColor.RED
                + "God-Mode "
                + ChatColor.WHITE
                + "is now "
                + ChatColor.RED
                + "disabled.");
      } else {
        // Check if this player is in the admin map - add if necessary
        if (!AdminHandler.contains(playerName)) {
          AdminHandler.add(playerName);
          log.info("Added player to admin mapping");
        }

        // Now enable it and send the message
        AdminHandler.setGod(playerName, true);
        player.sendMessage(
            ChatColor.GREEN
                + "God-Mode "
                + ChatColor.WHITE
                + "is now "
                + ChatColor.GREEN
                + "enabled.");
      }
      AdminHandler.savePlayer(playerName);
    } else {
      // If they don't have permissions let them know
      AdminPermissions.noPermsMessage(player);
    }
  }
  private void tp(Player player, String[] args) {
    if (!AdminPermissions.has(player, Perms.ADMINTP)
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You don't have permission to use that command");
      return;
    } else if (!AdminHandler.isAdminMode(player.getName())
        && !AdminPermissions.has(player, Perms.ANYTP)) {
      player.sendMessage("You must be in admin mode to teleport");
      return;
    } else if (args.length < 1) {
      player.sendMessage("You must specify at least 1 argument for teleportation");
      return;
    }
    // Assume player or world if there is only 1 arg.
    if (args.length == 1) {
      Player target = null;
      World targetWorld = plugin.getServer().getWorld(args[0]);
      for (Player p : plugin.getServer().getOnlinePlayers()) {
        if (p.getName().toLowerCase().contains(args[0].toLowerCase())
            && target == null
            && targetWorld == null) {
          target = p;
          break;
        }
      }
      if (targetWorld == null && target == null) {
        player.sendMessage("Could not find that target");
      } else if (targetWorld != null) {
        player.teleport(targetWorld.getSpawnLocation());
      } else {
        player.teleport(target.getLocation());
      }
    }
    // Assume teleporting one player to another if 2 args
    else if (args.length == 2) {
      Player target = null;
      Player sent = null;
      World targetWorld = plugin.getServer().getWorld(args[1]);
      for (Player p : plugin.getServer().getOnlinePlayers()) {
        if (p.getName().toLowerCase().contains(args[1].toLowerCase())
            && target == null
            && targetWorld == null) target = p;

        if (p.getName().toLowerCase().contains(args[0].toLowerCase())
            && (sent == null || (p != target && target != null))) sent = p;

        if (sent != null && (targetWorld != null || target != null)) break;
      }
      if (sent == null) {
        player.sendMessage("Could not find a player named " + args[0]);
      } else if (target == null && targetWorld == null) {
        player.sendMessage("Could not find that target.");
      } else if (target == sent) {
        player.sendMessage("You can not send a player to themselves.");
      } else if (targetWorld != null) {
        sent.teleport(targetWorld.getSpawnLocation());
        player.sendMessage(
            "You have teleported " + sent.getName() + " to " + targetWorld.getName());
      } else {
        sent.teleport(target.getLocation());
        player.sendMessage("You have teleported " + sent.getName() + " to " + target.getName());
      }
    }
    // Assume coordinate if 3 args
    else if (args.length == 3) {
      try {
        int x = Integer.parseInt(args[0]);
        int y = Integer.parseInt(args[1]);
        int z = Integer.parseInt(args[2]);
        player.teleport(new Location(player.getWorld(), x, y, z));
      } catch (Exception e) {
        player.sendMessage("The proper format for coordinate teleporting is /tp x y z");
      }
      return;
    }
  }