Package org.bukkit

Examples of org.bukkit.OfflinePlayer


        Integer timeRemain = (int) ((d.getTime() - c.getTime()) / 1000);
       
        // if we already should have pardoned this player, do it now
        if (timeRemain <= 0) {
          SQLManager.query("UPDATE " + SQLManager.prefix + "bans SET active = 0 WHERE player_name = ?", pName);
          OfflinePlayer p = Bukkit.getOfflinePlayer(pName);
            p.setBanned(false);
        } else {
          // set up scheduled task to be fired in number of seconds that remain from current time
          CommandsEX.plugin.getServer().getScheduler().scheduleSyncDelayedTask(CommandsEX.plugin, new DelayedPardon(pName), (20 * timeRemain));
        }
      }
 
View Full Code Here


   * @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
View Full Code Here

      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);
View Full Code Here

      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);
View Full Code Here

   */
  public static Boolean pardon(CommandSender sender, String[] args, String command, String alias) {
    if (args[0].matches(Bans.ipV4Regex) || args[0].matches(Bans.ipV6Regex)) {
      // check if we don't have an OfflinePlayer with this name banned (which can happen by mistake)
      // and unban in such case
      OfflinePlayer p = Bukkit.getOfflinePlayer(args[0]);
      if ((p != null) && p.isBanned()) {
        p.setBanned(false);
        LogHelper.showInfo("bansPlayerPardoned", sender);
      } else {
        // send message to the sender if we banned an IP, since no message is broadcasted then
        LogHelper.showInfo("bansIpPardoned", sender);
      }
View Full Code Here

        Boolean ipMatched = (this.pName.matches(Bans.ipV4Regex) || this.pName.matches(Bans.ipV6Regex));
        if (ipMatched) {
          Bukkit.unbanIP(this.pName);
        } else {
          // unban using built-in banning system
          OfflinePlayer p = Bukkit.getOfflinePlayer(this.pName);
          p.setBanned(false);
        }
       
        // tell everyone if not disallowed in config or not an IP address (so we don't foolishly reveal IP addresses that were banned :))
      if (!CommandsEX.getConf().getBoolean("silentBans") && !ipMatched) {
        CommandsEX.plugin.getServer().broadcastMessage(ChatColor.GREEN + pDispName + " " + _("bansPlayerPardoned", ""));
View Full Code Here

   
    // load kits of players that have been playing recently to speed up database lookups
    ResultSet res = SQLManager.query_res("SELECT player_name, kit_name FROM " + SQLManager.prefix + "kits_usage");
    try {
      while (res.next()) {
        OfflinePlayer op = Bukkit.getOfflinePlayer(res.getString("player_name"));
        if ((Utils.getUnixTimestamp(0L) - (int) (op.getLastPlayed() / 1000)) <= 1209600) {
          // only load data of players that were online in the past 2 weeks
          usedOneTimeKits.put(res.getString("player_name"), res.getString("kit_name"));
        }
      }
      res.close();
View Full Code Here

            if (pairs.getValue() > -1) continue;

            // check if the player's last logout time was not within last minTimeFromLogout seconds, in which case we don't bother
            // checking up on him and his playtime will be loaded as needed on Quit event
            String pName = (String)pairs.getKey();
            OfflinePlayer o = CommandsEX.plugin.getServer().getOfflinePlayer(pName);
           
            if ((o != null) && (o.getLastPlayed() > 0)) {
              // convert miliseconds of player last visit time to seconds
              Integer lastPlay = Utils.getUnixTimestamp(o.getLastPlayed());
              // check if we should be adding the player, based on last quitting time
              if ((stamp - lastPlay) >= (CommandsEX.minTimeFromLogout - 5)) {
                playerNames.add(pName);
              }
            } else {
View Full Code Here

          // get current Unix timestamp
          Integer stamp = Utils.getUnixTimestamp(0L);

          while (res.next()) {
            // get player's last join time
            OfflinePlayer o = CommandsEX.plugin.getServer().getOfflinePlayer(res.getString("player_name"));
            Integer lastJoinTime = Utils.getUnixTimestamp(o.getLastPlayed());
           
            // compare last join time with our requested number of days to past
            if ((stamp - lastJoinTime) >= daysInSeconds) {
              // match found, teleport player
              Teleportation.delayedTeleport(player, new Location(CommandsEX.plugin.getServer().getWorld(res.getString("world_name")), res.getInt("x"), res.getInt("y"), res.getInt("z"), (float) res.getDouble("yaw"), (float) res.getDouble("pitch")) );
View Full Code Here

        // get current Unix timestamp
        Integer stamp = Utils.getUnixTimestamp(0L);

        while (res.next()) {
          // get player's last join time
          OfflinePlayer o = CommandsEX.plugin.getServer().getOfflinePlayer(res.getString("player_name"));
          Integer lastJoinTime = Utils.getUnixTimestamp(o.getLastPlayed());
         
          // compare last join time with our requested number of days to past
          if ((stamp - lastJoinTime) >= daysInSeconds) {
            toClear.add(res.getInt("id_home"));
          }
View Full Code Here

TOP

Related Classes of org.bukkit.OfflinePlayer

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.