Exemplo n.º 1
0
 public static void adminAction(String adminName, String action, boolean isRed) {
   TFM_Util.bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA));
 }
Exemplo n.º 2
0
  public static void autoEject(Player player, String kickMessage) {
    EjectMethod method = EjectMethod.STRIKE_ONE;
    final String ip = TFM_Util.getIp(player);

    if (!TFM_Util.ejectTracker.containsKey(ip)) {
      TFM_Util.ejectTracker.put(ip, 0);
    }

    int kicks = TFM_Util.ejectTracker.get(ip);
    kicks += 1;

    TFM_Util.ejectTracker.put(ip, kicks);

    if (kicks <= 1) {
      method = EjectMethod.STRIKE_ONE;
    } else if (kicks == 2) {
      method = EjectMethod.STRIKE_TWO;
    } else if (kicks >= 3) {
      method = EjectMethod.STRIKE_THREE;
    }

    TFM_Log.info(
        "AutoEject -> name: "
            + player.getName()
            + " - player ip: "
            + ip
            + " - method: "
            + method.toString());

    player.setOp(false);
    player.setGameMode(GameMode.SURVIVAL);
    player.getInventory().clear();

    switch (method) {
      case STRIKE_ONE:
        {
          final Calendar cal = new GregorianCalendar();
          cal.add(Calendar.MINUTE, 1);
          final Date expires = cal.getTime();

          TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 1 minute.");

          TFM_BanManager.addIpBan(
              new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage));
          TFM_BanManager.addUuidBan(
              new TFM_Ban(
                  TFM_Util.getUuid(player), player.getName(), "AutoEject", expires, kickMessage));
          player.kickPlayer(kickMessage);

          break;
        }
      case STRIKE_TWO:
        {
          final Calendar c = new GregorianCalendar();
          c.add(Calendar.MINUTE, 3);
          final Date expires = c.getTime();

          TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 3 minutes.");

          TFM_BanManager.addIpBan(
              new TFM_Ban(ip, player.getName(), "AutoEject", expires, kickMessage));
          TFM_BanManager.addUuidBan(
              new TFM_Ban(
                  TFM_Util.getUuid(player), player.getName(), "AutoEject", expires, kickMessage));
          player.kickPlayer(kickMessage);
          break;
        }
      case STRIKE_THREE:
        {
          String[] ipAddressParts = ip.split("\\.");

          TFM_BanManager.addIpBan(
              new TFM_Ban(ip, player.getName(), "AutoEject", null, kickMessage));
          TFM_BanManager.addIpBan(
              new TFM_Ban(
                  ipAddressParts[0] + "." + ipAddressParts[1] + ".*.*",
                  player.getName(),
                  "AutoEject",
                  null,
                  kickMessage));
          TFM_BanManager.addUuidBan(
              new TFM_Ban(
                  TFM_Util.getUuid(player), player.getName(), "AutoEject", null, kickMessage));

          TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");

          player.kickPlayer(kickMessage);
          break;
        }
    }
  }
Exemplo n.º 3
0
 public static void bcastMsg(String message) {
   TFM_Util.bcastMsg(message, null);
 }