Package org.bukkit.entity

Examples of org.bukkit.entity.Player


   * @param alias
   * @return
   */
  public static Boolean invite(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // save invite, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-invite")) {
        String pName = player.getName();
        if (args.length == 1) {
          // no arguments, provide command help
          Commands.showCommandHelpAndUsage(sender, "cex_home", "home_invite");
          return true;
        }
       
        try {
          ResultSet res;
          if (multiHomesEnabled) {
            // if multiple homes are enabled, we check for a home in player's current world
            res = SQLManager.query_res("SELECT id_home, allowed_players FROM " + SQLManager.prefix + "homes WHERE player_name = ? AND world_name = ?", pName, player.getWorld().getName());
          } else {
            // multiple homes disabled, we check for player's home anywhere
            res = SQLManager.query_res("SELECT id_home, allowed_players FROM " + SQLManager.prefix + "homes WHERE player_name = ?", pName);
          }

          while (res.next()) {
            String allowedPlayers;
            if ((res.getString("allowed_players") != null) && !res.getString("allowed_players").equals("") && !res.wasNull()) {
              allowedPlayers = res.getString("allowed_players");
              if (!allowedPlayers.equals(args[1]) && !allowedPlayers.contains("," + args[1]) && !allowedPlayers.contains(args[1] + ",")) {
                allowedPlayers = allowedPlayers + "," + args[1];
              } else {
                // player already invited
                LogHelper.showInfos(sender, "[" + args[1] + " #####homePlayerAlreadyInvited2#####[" + pName + "#####homePlayerAlreadyInvited3");
                return true;
              }
            } else {
              allowedPlayers = args[1];
            }

            // update the DB with new allowed_players value
            SQLManager.query("UPDATE " + SQLManager.prefix + "homes SET allowed_players = ? WHERE id_home = ?", allowedPlayers, res.getInt("id_home"));
           
            // inform user that his friend was invited
            LogHelper.showInfos(sender, "[" + Nicknames.getNick(args[1]) + " #####homeInviteSuccessful");
           
            // if the actual friend is online, inform him as well
            Player p = Bukkit.getServer().getPlayer(args[1]);
            if (p != null) {
              LogHelper.showInfos(p, "homeYouHaveBeenInvited1#####[" + Nicknames.getNick(pName) + "#####homeYouHaveBeenInvited2", "homeYouHaveBeenInvited3#####[" + Nicknames.getNick(pName) + " #####homeYouHaveBeenInvited4");
            }
           
            // return here, since we can only invite to a single home
View Full Code Here


   * @param alias
   * @return
   */
  public static Boolean uninvite(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // remove the requested invite, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-uninvite")) {
        String pName = player.getName();
        if (args.length == 1) {
          // no arguments, provide command help
          Commands.showCommandHelpAndUsage(sender, "cex_home", "home_uninvite");
          return true;
        }
       
        try {
          ResultSet res;
          if (multiHomesEnabled) {
            // if multiple homes are enabled, we uninvite from home in player's current world
            res = SQLManager.query_res("SELECT id_home, allowed_players FROM " + SQLManager.prefix + "homes WHERE player_name = ? AND world_name = ?", pName, player.getWorld().getName());
          } else {
            // multiple homes disabled, we uninvite from player's home anywhere
            res = SQLManager.query_res("SELECT id_home, allowed_players FROM " + SQLManager.prefix + "homes WHERE player_name = ?", pName);
          }

          while (res.next()) {
            List<Object> newAllowedPlayers = new ArrayList<Object>();
            Boolean playerFound = false;
            if ((res.getString("allowed_players") != null) && !res.getString("allowed_players").equals("") && !res.wasNull()) {
              String[] allowedPlayers = res.getString("allowed_players").split(",");
              for (String s : allowedPlayers) {
                if (!s.equals(args[1])) {
                  newAllowedPlayers.add(s);
                } else {
                  playerFound = true;
                }
              }
             
              // the requested player is not invited to this home
              if (!playerFound) {
                LogHelper.showInfo("[" + Nicknames.getNick(args[1]) + " #####homePlayerUninviteNotFound", sender);
                return true;
              }
            } else {
              // no invited players
              LogHelper.showInfo("homeNoPlayersInvited", sender);
              return true;
            }

            // update the DB with new newAllowedPlayers value
            SQLManager.query("UPDATE " + SQLManager.prefix + "homes SET allowed_players = ? WHERE id_home = ?", Utils.implode(newAllowedPlayers, ","), res.getInt("id_home"));
           
            // inform user that the player was uninvited
            LogHelper.showInfos(sender, "[" + Nicknames.getNick(args[1]) + " #####homePlayerUninvited");
           
            // if the actual player is online, inform him as well
            Player p = Bukkit.getServer().getPlayer(args[1]);
            if (p != null) {
              LogHelper.showInfos(p, "homePlayerUninviteNotify#####[" + Nicknames.getNick(pName) + "#####homeYouHaveBeenInvited2");
            }
           
            // return here, since we can only uninvite a single player
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean list(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // check to which homes is player invited, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-list")) {
        // create ExecutorService to manage threads                       
        ExecutorService threadExecutor = Executors.newFixedThreadPool(1);
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean ilist(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // check who is invited to player's home, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-ilist")) {
        try {
          String pName = player.getName();
          // holds players invited to homes in nickname form
          List<String> nickPlayers = new ArrayList<String>();
          ResultSet res;
          if (multiHomesEnabled) {
            res = SQLManager.query_res("SELECT allowed_players FROM " + SQLManager.prefix + "homes WHERE player_name = ? AND world_name = ?", pName, player.getWorld().getName());
          } else {
            res = SQLManager.query_res("SELECT allowed_players FROM " + SQLManager.prefix + "homes WHERE player_name = ?", pName);
          }
         
          while (res.next()) {
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean listall(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // check who is invited to player's home, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-listall")) {
        try {
          // holds the names of players with houses in nickname form
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean make_public(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // make player's home public, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-public")) {
        try {
          String pName = player.getName();
          Boolean homeFound = false;
          ResultSet res;

          // let's see if the player has any home set
          if (multiHomesEnabled) {
            res = SQLManager.query_res("SELECT id_home FROM " + SQLManager.prefix + "homes WHERE player_name = ? AND world_name = ?", pName, player.getWorld().getName());
          } else {
            res = SQLManager.query_res("SELECT id_home FROM " + SQLManager.prefix + "homes WHERE player_name = ?", pName);
          }
         
          while (res.next()) {
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean make_private(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // make player's home public, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-private")) {
        try {
          String pName = player.getName();
          Boolean homeFound = false;
          ResultSet res;

          // let's see if the player has any home set
          if (multiHomesEnabled) {
            res = SQLManager.query_res("SELECT id_home FROM " + SQLManager.prefix + "homes WHERE player_name = ? AND world_name = ?", pName, player.getWorld().getName());
          } else {
            res = SQLManager.query_res("SELECT id_home FROM " + SQLManager.prefix + "homes WHERE player_name = ?", pName);
          }
         
          while (res.next()) {
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean delete(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // delete player's home, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-delete")) {
        try {
          // check if we're having player's name passed as a parameter, in which case that'll be our home to delete
          String pName = "";
          if (args.length > 1) {
            pName = args[1];
          } else {
            pName = player.getName();
          }
          List<Object> homeIds = new ArrayList<Object>();
          ResultSet res;

          // let's see if the player has any home set
          if (multiHomesEnabled) {
            res = SQLManager.query_res("SELECT id_home FROM " + SQLManager.prefix + "homes WHERE player_name = ? AND world_name = ?", pName, player.getWorld().getName());
          } else {
            res = SQLManager.query_res("SELECT id_home FROM " + SQLManager.prefix + "homes WHERE player_name = ?", pName);
          }
         
          // assemble list of home IDs to delete
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean iclear(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      Player player = (Player)sender;
     
      // select all homes to be cleared up, if we didn't spam too much :)
      if (!Utils.checkCommandSpam(player, "home-iclear")) {
        if (args.length == 1) {
          // no arguments, provide command help
View Full Code Here

 
  public static Boolean run(CommandSender sender, String alias, String[] args) {
    if (PlayerHelper.checkIsPlayer(sender) && !Utils.checkCommandSpam((Player) sender, "setmyrank")) {
      if ((args.length == 1) && (Permissions.checkPerms((Player) sender, "cex.setmyrank.*") || Permissions.checkPerms((Player) sender, "cex.setmyrank." + args[0]))) {
        // Command Variables
        Player player = (Player)sender;
        String rank = args[0];
       
        // Check for Vault/Permissions
          if(Vault.permsEnabled() != true) {
          LogHelper.logSevere(_("permissionsNotFound", ""));
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.