Package org.bukkit.entity

Examples of org.bukkit.entity.Player


   * @param args
   * @return
   */
  public static Boolean run(CommandSender sender, String alias, String[] args) {
    if (PlayerHelper.checkIsPlayer(sender)) {
      Player player = (Player)sender;

      if (args.length > 0) {
        if (Permissions.checkPerms(player, "cex.tpaccept")) {
          // check if the requested player is online
          Player tpaPlayer = Bukkit.getServer().getPlayer(args[0]);

          // if player is offline...
          if (tpaPlayer == null) {
            LogHelper.showWarning("invalidPlayer", sender);
            return true;
          }

                    if (CombatTag.isInCombat(tpaPlayer)){
                        LogHelper.showWarning("tpCombatTag", player);
                        return true;
                    }
         
          // check if there is a TPA or TPAHERE request for the given players combination
          String id = tpaPlayer.getName() + "#####" + player.getName();
          if (Teleportation.tpaallRequests.contains(id)){
            // remove pending request
            Teleportation.tpaallRequests.remove(id);
            // teleport the player to us
            Teleportation.delayedTeleport(player, tpaPlayer.getLocation());
            LogHelper.showInfo("tpAccept#####[" + Nicknames.getNick(tpaPlayer.getName()), sender);
            if ((CommandsEX.loadedClasses.contains("Command_cex_inv") && !Common.invisiblePlayers.contains(sender.getName())) || !CommandsEX.loadedClasses.contains("Command_cex_inv")){
              LogHelper.showInfo("[" + Nicknames.getNick(sender.getName()) + " #####tpAcceptNotify", tpaPlayer);
            }
          } else if (Teleportation.tpaRequests.contains(id)) {
            // remove pending request
            Teleportation.tpaRequests.remove(id);
            // teleport us to the given player
            Teleportation.delayedTeleport(tpaPlayer, player.getLocation());
            LogHelper.showInfo("tpAccept#####[" + Nicknames.getNick(tpaPlayer.getName()), sender);
            if ((CommandsEX.loadedClasses.contains("Command_cex_inv") && !Common.invisiblePlayers.contains(sender.getName())) || !CommandsEX.loadedClasses.contains("Command_cex_inv")){
              LogHelper.showInfo("[" + Nicknames.getNick(sender.getName()) " #####tpAcceptNotify", tpaPlayer);
            }
          } else if (Teleportation.tpahereRequests.contains(id)) {
            // remove pending request
            Teleportation.tpahereRequests.remove(id);
            // teleport the player to us
            Teleportation.delayedTeleport(player, tpaPlayer.getLocation());
            LogHelper.showInfo("tpAccept#####[" + Nicknames.getNick(tpaPlayer.getName()), sender);
            if ((CommandsEX.loadedClasses.contains("Command_cex_inv") && !Common.invisiblePlayers.contains(sender.getName())) || !CommandsEX.loadedClasses.contains("Command_cex_inv")){
              LogHelper.showInfo("[" + Nicknames.getNick(sender.getName()) + " #####tpAcceptNotify", tpaPlayer);
            }
          } else {
            // no matching request found
View Full Code Here


   */
 
  public static Boolean run(CommandSender sender, String alias, String[] args){

    if (sender instanceof Player){
      Player player = (Player) sender;
      if (Utils.checkCommandSpam(player, "cex_healall")){
        return true;
      }
    }
   
View Full Code Here

    if (args.length < 2){
      Commands.showCommandHelpAndUsage(sender, "cex_csudo", alias);
      return true;
    }
   
    Player target = Bukkit.getPlayer(args[0]);
   
    if (target == null){
      LogHelper.showWarning("invalidPlayer", sender);
      return true;
    }
   
    String message = Utils.collectArgs(args, 1);
    target.chat(message);
   
    return true;
  }
View Full Code Here

    }
  }
   
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e){
      Player player = e.getPlayer();
      if (result.equals(UpdateResult.UPDATE_AVAILABLE) && player.hasPermission("cex.update.alert")){
        player.sendMessage(ChatColor.AQUA + "A new version of CommandsEX is available!");
          //player.sendMessage(ChatColor.AQUA + getLatestVersionString());
          player.sendMessage(ChatColor.AQUA + "http://http://dev.bukkit.org/server-mods/commandsex/");
      }
    }
View Full Code Here

    if (args.length > 1){
      Commands.showCommandHelpAndUsage(sender, "cex_tpaall", alias);
      return true;
    }
   
    Player to = null;
    int sent = 0;
   
    if (args.length == 0){
      if (!(sender instanceof Player)){
        Commands.showCommandHelpAndUsage(sender, "cex_tpaall", alias);
        return true;
      } else {
        to = (Player) sender;
      }
    } else {
      to = Bukkit.getPlayer(args[0]);
      if (to == null){
        LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
        return true;
      }
    }

    // load TPA timeout from config if not present
    if (tTimeout == 0) {
      Integer t = CommandsEX.getConf().getInt("tpaTimeout");
      if (t > 0) {
        tTimeout = t;
      } else {
        // fallback to default if we didn't find a valid config value
        tTimeout = 50;
      }
    }

    for (Player player : Bukkit.getOnlinePlayers()){
      if (player != sender){
        String id = to.getName() + "#####" + player.getName();
        Teleportation.tpaallRequests.add(id);
        // set timeout function that will cancel TPA request if timeout is reached
        player.sendMessage(ChatColor.GREEN + Nicknames.getNick(to.getName()) + " " + _("tpRequest1", sender.getName()));
        player.sendMessage(ChatColor.GREEN + _("tpRequest2", sender.getName()));
        player.sendMessage(ChatColor.GREEN + _("tpRequest3", sender.getName()));
        // don't increase the sent count if the player is invisible
        if (CommandsEX.loadedClasses.contains("Command_cex_inv") && !Common.invisiblePlayers.contains(to.getName())){
          sent++;
        } else {
          sent++;
        }
        CommandsEX.plugin.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new TpRequestCanceller("tpaall", id), (20 * tTimeout));
 
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean mute(CommandSender sender, String[] args, String command, String alias) {
    // check if requested player is online
    Player p = Bukkit.getServer().getPlayer(args[0]);
    String pName = "";
    if (p == null) {
      // requested player not found
      LogHelper.showWarning("invalidPlayer", sender);
      return true;
    } else {
      pName = p.getName();
    }

    // if we don't have time parameter, mute player indefinitelly (until server restarts that it)
    Integer plusValue = 0;
    if (args.length == 1) {
      mutedPlayers.put(pName, "0-0");
    } else {
      // match time value with regex
      try {
        Map<String, Integer> t = Utils.parseTime(args);
        // save a timestamp after which our player should not be muted anymore
        Integer stamp = Utils.getUnixTimestamp(0L);
        plusValue = (t.get("days") * 86400) + (t.get("hours") * 3600) + (t.get("minutes") * 60) + t.get("seconds");

        if (plusValue > 0) {
          // start a timeout function to unmute the player after his mute period has passed
          Integer timerValue = CommandsEX.plugin.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new Runnable() {
            @Override
            public void run() {
              // run through all muted players and unmute those who should be unmuted
              Iterator<Entry<String, String>> it = Chat.mutedPlayers.entrySet().iterator();
              Integer stamp = Utils.getUnixTimestamp(0L);
              List<String> toUnmute = new ArrayList<String>();
              while (it.hasNext()) {
                Map.Entry<String, String> pairs = (Map.Entry<String, String>)it.next();
                String[] s = pairs.getValue().split("-");
                Integer muteStamp = Integer.parseInt(s[0]);
               
                if (muteStamp <= stamp) {
                  toUnmute.add(pairs.getKey());
                }
              }
             
              if (toUnmute.size() > 0) {
                for (String s : toUnmute) {
                  Chat.mutedPlayers.remove(s);
                  // send message to player that he's been unmuted, if he's still online
                  Player p = Bukkit.getServer().getPlayer(s);
                  if (p != null) {
                    LogHelper.showInfo("chatPlayerYouAreUnmuted", p);
                  }
                }
              }
View Full Code Here

   * @param alias
   * @return
   */
  public static Boolean ban(CommandSender sender, String[] args, String command, String alias) {
    // check if player is online
    Player p = Bukkit.getServer().getPlayer(args[0]);
    OfflinePlayer pl = null;
    String pName;
    Boolean isOffline = false;
    if (p == null) {
      // player is offline, get his saved record
      isOffline = true;
      pl = Bukkit.getOfflinePlayer(args[0]);
      if (pl == null) {
        LogHelper.showWarning("invalidPlayer", sender);
        return true;
      } else {
        pName = pl.getName();
      }
    } else {
      pName = p.getName();
    }
   
    String pDispName;
   
    try {
      pDispName = Nicknames.getNick(pName);
    } catch (Exception ex){
      pDispName = pName;
    }
   
    // check if we have expiration date present
    Map<String, Integer> t;
    try {
      t = Utils.parseTime(args);
    } catch (Throwable e) {
      t = new HashMap<String, Integer>();
      t.put("not_found", 1);
    }

    // make timestamp from parsed time, so it can be used in database operations
    Timestamp stamp = new Timestamp(new java.util.Date().getTime());
    if (!t.containsKey("not_found")) {
      // add up required number of milliseconds to current date
      stamp = new Timestamp((new java.util.Date().getTime()) + (t.get("seconds") * 1000) + (t.get("minutes") * 60 * 1000) + (t.get("hours") * 3600 * 1000) + (t.get("days") * 86400 * 1000));
    }

    // assemble reason, if one was provided
    String reason = "";
    if (args.length > 1) {
      for (Integer i = (args[1].startsWith("t:") ? 2 : 1); i < args.length; i++) {
        reason = reason + " " + args[i];
      }
    }

    if (CommandsEX.sqlEnabled) {
      // if we don't have time value and the player has a certain number of previous bans, inform admin
      ResultSet res = SQLManager.query_res("SELECT Count(*) as Total FROM " + SQLManager.prefix + "bans WHERE player_name = ?", pName);
      try {
        while (res.next()) {
          Integer total = res.getInt("Total");
          // warn admin if temporary bans treshold was reached
          if (total > CommandsEX.getConf().getInt("minTempBansWarn")) {
            LogHelper.showInfo("bansTempBansTresholdReached1#####[" + total + " #####bansTempBansTresholdReached2", sender);
          }
          // store ban record in database
          if (t.containsKey("not_found")) {
            // no expiration - permaban
            SQLManager.query("INSERT INTO " + SQLManager.prefix + "bans (player_name, creation_date, creator, reason) VALUES (?, ?, ?, ?)", pName, new Timestamp(new java.util.Date().getTime()), sender.getName() , reason);
          } else {
            // temporary ban
            SQLManager.query("INSERT INTO " + SQLManager.prefix + "bans (player_name, creation_date, expiration_date, creator, reason) VALUES (?, ?, ?, ?, ?)", pName, new Timestamp(new java.util.Date().getTime()), stamp, sender.getName(), reason);
          }
        }
        res.close();
      } catch (Throwable e) {
        // unable to ban player
        LogHelper.showWarning("internalError", sender);
        LogHelper.logSevere("[CommandsEX] " + _("dbWriteError", ""));
        LogHelper.logDebug("Message: " + e.getMessage() + ", cause: " + e.getCause());
        return true;
      }
    }
   
    // ban player using server's banning system
    if (isOffline) {
      pl.setBanned(true);
    } else {
      p.setBanned(true);
    }
   
    // if we've banned the player temporarily, start timer
    if (!t.containsKey("not_found")) {
      Integer banTime = (t.get("seconds") + (t.get("minutes") * 60) + (t.get("hours") * 3600)+ (t.get("days") * 86400));
      CommandsEX.plugin.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new DelayedPardon(pName), (20 * banTime));
    }

    // tell everyone if not disallowed in config
    if (!CommandsEX.getConf().getBoolean("silentBans")) {
      CommandsEX.plugin.getServer().broadcastMessage(ChatColor.LIGHT_PURPLE + (!reason.equals("") ? (pDispName + " " + _("bansBeingBannedForMessage", "") + reason) : pDispName + " " + _("bansBeingBannedMessage", "")) + (!t.containsKey("not_found") ? " " + _("for", "") + " " + args[1].replace("t:", "") : ""));
    }

    // at last, kick the player if still online
    if (!isOffline) {
      p.kickPlayer(ChatColor.RED + (!reason.equals("") ? (_("bansYouAreBannedForMessage", "") + reason) :  _("bansGenericReason", "")));
    }
   
        return true;
  }
View Full Code Here

    // at last, kick each and every player with this IP that remains online
    Iterator<Entry<String, String>> it = CommandsEX.playerIPs.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<String, String> pairs = (Map.Entry<String, String>)it.next();
      if (pairs.getValue().equals(ip)) {
        Player p = Bukkit.getServer().getPlayer(pairs.getKey());
        if (p != null) {
          p.kickPlayer(ChatColor.RED + (!reason.equals("") ? (_("bansYouAreBannedForMessage", "") + reason) :  _("bansGenericReason", "")));
        }
      }
    }
   
    // and inform the person who was banning, of course
View Full Code Here

   */
  public static Boolean checkban(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      try {
        // see if we can find an active record of the given player in database
        Player p = Bukkit.getServer().getPlayer(args[0]);
        String pName = "";
        if (p == null) {
          OfflinePlayer pl = Bukkit.getOfflinePlayer(args[0]);
          if (pl == null) {
            // player not found
            LogHelper.showWarning("invalidPlayer", sender);
            return true;
          }
          pName = pl.getName();
        } else {
          pName = p.getName();
        }
       
        String pDispName = Nicknames.getNick(pName);

        ResultSet res = SQLManager.query_res("SELECT player_name, creation_date, expiration_date, creator, reason FROM " + SQLManager.prefix + "bans WHERE player_name = ? AND active = 1", pName);
View Full Code Here

   */
  public static Boolean showhistory(CommandSender sender, String[] args, String command, String alias) {
    if (CommandsEX.sqlEnabled) {
      try {
        // see if we can find an active record of the given player in database
        Player p = Bukkit.getServer().getPlayer(args[0]);
        String pName = "";
        if (p == null) {
          OfflinePlayer pl = Bukkit.getOfflinePlayer(args[0]);
          if (pl == null) {
            // player not found
            LogHelper.showWarning("invalidPlayer", sender);
            return true;
          }
          pName = pl.getName();
        } else {
          pName = p.getName();
        }
       
        String pDispName = Nicknames.getNick(pName);
       
        ResultSet res = SQLManager.query_res("SELECT player_name, creation_date, expiration_date, creator, reason FROM " + SQLManager.prefix + "bans WHERE player_name = ?", pName);
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.