示例#1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * be.Balor.Manager.ACCommands#execute(org.bukkit.command.CommandSender,
  * java.lang.String[])
  */
 @Override
 public void execute(final CommandSender sender, final CommandArgs args)
     throws ActionNotPermitedException, PlayerNotFound {
   if (Utils.isPlayer(sender)) {
     final be.Balor.Tools.Home home = Utils.getHome(sender, args.getString(0));
     if (home == null) {
       return;
     }
     ACPlayer.getPlayer(home.player).removeHome(home.home);
     Utils.sI18n(sender, "rmHome", "home", home.home);
   }
 }
示例#2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * be.Balor.Manager.CoreCommand#execute(org.bukkit.command.CommandSender,
  * java.lang.String[])
  */
 @Override
 public void execute(final CommandSender sender, final CommandArgs args)
     throws ActionNotPermitedException, PlayerNotFound {
   final ACPlayer target = Utils.getACPlayer(sender, args, permNode);
   if (target != null) {
     final String playername;
     if (target.isOnline()) {
       playername = Utils.getPlayerName(target.getHandler(), sender);
     } else {
       playername = target.getName();
     }
     Utils.sI18n(
         sender, "playedTime", Utils.playedTime(playername, target.getCurrentPlayedTime()));
   }
 }
示例#3
0
 /*
  * (non-Javadoc)
  *
  * @see
  * be.Balor.Manager.CoreCommand#execute(org.bukkit.command.CommandSender,
  * java.lang.String[])
  */
 @Override
 public void execute(final CommandSender sender, final CommandArgs args) {
   final Player target = Utils.getUser(sender, args, permNode);
   if (target != null) {
     final String playername = Utils.getPlayerName(target, sender);
     final long total = ACPlayer.getPlayer(target).getCurrentPlayedTime();
     final Long[] time = Utils.transformToElapsedTime(total);
     final HashMap<String, String> replace = new HashMap<String, String>();
     replace.put("d", time[0].toString());
     replace.put("h", time[1].toString());
     replace.put("m", time[2].toString());
     replace.put("s", time[3].toString());
     replace.put("player", playername);
     Utils.sI18n(sender, "playedTime", replace);
   }
 }
示例#4
0
 /*
  * (non-Javadoc)
  *
  * @see
  * be.Balor.Manager.ACCommands#execute(org.bukkit.command.CommandSender,
  * java.lang.String[])
  */
 @Override
 public void execute(final CommandSender sender, final CommandArgs args)
     throws ActionNotPermitedException, PlayerNotFound {
   if (Utils.isPlayer(sender)) {
     final Player p = (Player) sender;
     String msg = "";
     Set<String> wp;
     if (args.hasFlag('a')) {
       if (!PermissionManager.hasPerm(sender, tpAll.getBukkitPerm())) {
         return;
       }
       wp = WorldManager.getInstance().getAllWarpList();
     } else {
       wp = ACWorld.getWorld(p.getWorld()).getWarpList();
     }
     sender.sendMessage(ChatColor.GOLD + "Warp Point(s) : " + ChatColor.WHITE + wp.size());
     for (final String name : wp) {
       msg += name + ", ";
       if (msg.length() >= ACMinecraftFontWidthCalculator.chatwidth) {
         sender.sendMessage(msg);
         msg = "";
       }
     }
     if (!msg.equals("")) {
       if (msg.endsWith(", ")) {
         msg = msg.substring(0, msg.lastIndexOf(","));
       }
       sender.sendMessage(msg);
     }
   }
 }
示例#5
0
 /*
  * (non-Javadoc)
  *
  * @see be.Balor.Manager.ACCommand#execute(org.bukkit.command.CommandSender,
  * java.lang.String[])
  */
 @Override
 public void execute(final CommandSender sender, final CommandArgs args)
     throws ActionNotPermitedException, PlayerNotFound {
   Plugin plug = ACHelper.getInstance().getCoreInstance();
   if (args.length >= 1) {
     plug = plug.getServer().getPluginManager().getPlugin(args.getString(0));
   }
   if (plug == null) {
     Utils.sI18n(sender, "pluginNotFound", "plugin", args.getString(0));
     return;
   }
   final PluginDescriptionFile pdf = plug.getDescription();
   final HashMap<String, String> replace = new HashMap<String, String>();
   replace.put("plugin", pdf.getName());
   replace.put("version", pdf.getVersion());
   Utils.sI18n(sender, "pluginVersion", replace);
 }
示例#6
0
  /*
   * (non-Javadoc)
   *
   * @see be.Balor.Manager.Commands.CoreCommand#execute(org.bukkit.command.
   * CommandSender, be.Balor.Manager.Commands.CommandArgs)
   */
  @Override
  public void execute(final CommandSender sender, final CommandArgs args)
      throws PlayerNotFound, ActionNotPermitedException {
    int page = 1;
    if (args.length == 1) {
      try {
        page = args.getInt(0);
      } catch (NumberFormatException e) {
        String msg = Utils.I18n("NaN", "number", args.getString(0));
        sender.sendMessage(msg + ChatColor.RED + " Used default page 1!");
        page = 1;
      }
    }

    try {
      for (final String s : Lister.getLister(Lister.List.BAN).getPage(page)) {
        sender.sendMessage(s);
      }
    } catch (final EmptyListException e) {
      LocaleHelper.NO_BANNED.sendLocale(sender);
    }
  }
示例#7
0
文件: God.java 项目: syamn/AdminCmd
 /*
  * (non-Javadoc)
  *
  * @see
  * be.Balor.Manager.ACCommands#execute(org.bukkit.command.CommandSender,
  * java.lang.String[])
  */
 @Override
 public void execute(final CommandSender sender, final CommandArgs args)
     throws ActionNotPermitedException, PlayerNotFound {
   final String timeOut = args.getValueFlag('t');
   final Player player = Utils.getUser(sender, args, permNode);
   if (player != null) {
     final HashMap<String, String> replace = new HashMap<String, String>();
     replace.put("player", Utils.getPlayerName(player));
     final ACPlayer acp = ACPlayer.getPlayer(player);
     if (acp.hasPower(Type.GOD)) {
       acp.removePower(Type.GOD);
       Utils.sI18n(player, "godDisabled");
       if (!player.equals(sender)) {
         Utils.sI18n(sender, "godDisabledTarget", replace);
       }
     } else {
       acp.setPower(Type.GOD);
       Utils.sI18n(player, "godEnabled");
       if (!player.equals(sender)) {
         Utils.sI18n(sender, "godEnabledTarget", replace);
       }
       if (timeOut == null) {
         return;
       }
       int timeOutValue;
       try {
         timeOutValue = Integer.parseInt(timeOut);
       } catch (final Exception e) {
         Utils.sI18n(sender, "NaN", "number", timeOut);
         return;
       }
       ACPluginManager.getScheduler()
           .runTaskLaterAsynchronously(
               ACPluginManager.getCorePlugin(),
               new RemovePowerTask(acp, Type.GOD, sender),
               Utils.secInTick * ConfigEnum.SCALE_TIMEOUT.getInt() * timeOutValue);
     }
   }
 }
示例#8
0
  /*
   * (non-Javadoc)
   *
   * @see
   * be.Balor.Manager.ACCommands#execute(org.bukkit.command.CommandSender,
   * java.lang.String[])
   */
  @Override
  public void execute(final CommandSender sender, final CommandArgs args)
      throws ActionNotPermitedException, PlayerNotFound {
    final Player toBan = Utils.getPlayer(args.getString(0));
    final HashMap<String, String> replace = new HashMap<String, String>();
    String message = "";
    String banPlayerString;
    if (toBan != null) {
      banPlayerString = toBan.getName();
      if (!Utils.checkImmunity(sender, toBan)) {
        Utils.sI18n(sender, "insufficientLvl");
        return;
      }
    } else {
      banPlayerString = args.getString(0);
    }
    Integer tmpBan = null;
    if (args.length >= 2) {
      if (args.hasFlag('m')) {
        message =
            LocaleManager.getInstance()
                .get("kickMessages", args.getValueFlag('m'), "player", banPlayerString);
      }
      try {
        final int tmpIntTime = Utils.timeParser(args.getString(args.length - 1));
        if (tmpIntTime != -1) {
          tmpBan = tmpIntTime;
        }
      } catch (final NotANumberException e) {
        Utils.sI18n(sender, "NaN", "number", args.getString(args.length - 1));
        return;
      }
      if (message == null || (message != null && message.isEmpty())) {
        message = "";
        if (tmpBan == null) {
          for (int i = 1; i < args.length; i++) {
            message += args.getString(i) + " ";
          }
        } else {
          for (int i = 1; i < args.length - 1; i++) {
            message += args.getString(i) + " ";
          }
        }
      }
      if (message.isEmpty()) {
        message += " You have been banned ";
        if (!Utils.isPlayer(sender, false)) {
          message += "by Server Admin";
        } else {
          message += "by " + ChatColor.stripColor(Utils.getPlayerName((Player) sender));
        }
      }
    } else {
      if (message.isEmpty()) {
        message = "You have been banned ";
        if (!Utils.isPlayer(sender, false)) {
          message += "by Server Admin";
        } else {
          message += "by " + ChatColor.stripColor(Utils.getPlayerName((Player) sender));
        }
      }
    }
    message = message.trim();
    replace.put("player", banPlayerString);
    replace.put("reason", message);
    final Matcher ipv4 = Utils.REGEX_IP_V4.matcher(banPlayerString);
    final Matcher inaccurateIp = Utils.REGEX_INACCURATE_IP_V4.matcher(banPlayerString);
    if (tmpBan != null) {
      message += " (Banned for " + tmpBan + " minutes)";
      replace.put("reason", message);
      ITempBan ban;
      if (inaccurateIp.find()) {
        if (!ipv4.find()) {
          replace.clear();
          replace.put("ip", banPlayerString);
          LocaleHelper.INACC_IP.sendLocale(sender, replace);
          return;
        }
        ban = new TempBannedIP(banPlayerString, message, tmpBan * 60 * 1000);
        ACHelper.getInstance().banPlayer(ban);
      } else {
        ban = new TempBannedPlayer(banPlayerString, message, tmpBan * 60 * 1000);
        ACHelper.getInstance().banPlayer(ban);
      }
      ACPluginManager.getScheduler()
          .runTaskLaterAsynchronously(
              getPlugin(), new UnBanTask(ban, true), Utils.secInTick * 60 * tmpBan);
    } else {
      if (inaccurateIp.find()) {
        if (!ipv4.find()) {
          replace.clear();
          replace.put("ip", banPlayerString);
          LocaleHelper.INACC_IP.sendLocale(sender, replace);
          return;
        }
        ACHelper.getInstance().banPlayer(new BannedIP(banPlayerString, message));
      } else {
        ACHelper.getInstance().banPlayer(new BannedPlayer(banPlayerString, message));
      }
    }
    ACPlayer.getPlayer(toBan).setPower(Type.KICKED);
    if (toBan != null) {
      final String finalmsg = message;
      final Player finalToKick = toBan;
      ACPluginManager.scheduleSyncTask(
          new Runnable() {

            @Override
            public void run() {
              finalToKick.kickPlayer(finalmsg);
            }
          });
    }
    Utils.broadcastMessage(Utils.I18n("ban", replace));
  }