Пример #1
0
 public static void setPvPState(Player player, boolean state) {
   if (state) {
     player.setMetadata(PVP_META, new FixedMetadataValue(PLUGIN, true));
     player.setPlayerListName(ChatColor.RED + player.getName());
   } else {
     player.removeMetadata(PVP_META, PLUGIN);
     player.setPlayerListName(null);
   }
   OneB.sendMsg(player, "PvP " + getPvPStateString(player) + ".");
 }
Пример #2
0
  public void FlairUpdate() {

    // Flairs from Command Block The Button - Teams
    // PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
    Player p = Bukkit.getPlayer(getUuid());
    if (p != null) p.setPlayerListName(String.format("%s%s", p.getName(), GetFormattedFlair()));
  }
 // Player Tab and auto Tags
 @EventHandler(priority = EventPriority.HIGH)
 public static void onPlayerJoinEvent(PlayerJoinEvent event) {
   Player player = event.getPlayer();
   if (TFM_Util.DEVELOPERS.contains(player.getName())) {
     player.setPlayerListName(ChatColor.DARK_PURPLE + player.getName());
     TFM_PlayerData.getPlayerData(player).setTag("&8[&5Developer&8]");
   } else if (TFM_AdminList.isSeniorAdmin(player)) {
     player.setPlayerListName(ChatColor.LIGHT_PURPLE + player.getName());
     TFM_PlayerData.getPlayerData(player).setTag("&8[&dSenior Admin&8]");
   } else if (TFM_AdminList.isTelnetAdmin(player, true)) {
     player.setPlayerListName(ChatColor.GREEN + player.getName());
     TFM_PlayerData.getPlayerData(player).setTag("&8[&2Telnet Admin&8]");
   } else if (TFM_AdminList.isSuperAdmin(player)) {
     player.setPlayerListName(ChatColor.AQUA + player.getName());
     TFM_PlayerData.getPlayerData(player).setTag("&8[&BSuper Admin&8]");
   }
 }
Пример #4
0
  @Override
  public void setListName(String senderId, String listName) {
    if (listName == null) {
      this.idToListName.remove(senderId);
    } else {
      this.idToListName.put(senderId, listName);
    }

    Player player = Bukkit.getPlayerExact(senderId);
    if (player == null) return;
    player.setPlayerListName(this.getListName(senderId));
  }
 @EventHandler
 public void displayNames(PlayerLoginEvent e) {
   if (e.getResult() != Result.ALLOWED) return;
   Player p = e.getPlayer();
   if (p == null) return;
   String dispname = PConfManager.getPValString(p, "dispname");
   if (dispname == null || dispname.equals("")) dispname = p.getName().trim();
   dispname = dispname.trim();
   if (dispname == null) return;
   p.setDisplayName(dispname);
   if (dispname.length() <= 16) p.setPlayerListName(dispname);
 }
Пример #6
0
  @EventHandler
  public void onJoin(PlayerJoinEvent event) {
    try {
      Player player = event.getPlayer();
      String playerName = player.getName();
      String playerDisplayName = player.getDisplayName();
      UUID playerUUID = player.getUniqueId();

      storage.onlineStrings.add(playerName);
      storage.onlineUUIDs.add(playerUUID);

      player.setPlayerListName(playerName);

    } catch (Exception e) {
      handleCrash(e);
    }
  }
Пример #7
0
 @EventHandler
 public void onJoin(PlayerJoinEvent e) {
   Player p = e.getPlayer();
   String name = p.getName();
   if (name.length() > 14) {
     name = name.substring(0, 14);
   }
   p.setPlayerListName(ChatColor.GREEN + name);
   p.setDisplayName("§a" + p.getName());
   e.setJoinMessage(null);
   if (plugin.getConfig().getBoolean("Complete")) {
     if (plugin.spieler == null) {
       SpeedBuilder.gm.Start(p);
     } else {
       SpeedBuilder.pm.SpectatorJoin(p);
     }
   }
 }
  @EventHandler(priority = EventPriority.MONITOR)
  public void onPlayerJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    final String ip = TFM_Util.getIp(player);
    final TFM_Player playerEntry;
    TFM_Log.info(
        "[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip,
        true);
    // Check absolute value to account for negatives
    if (Math.abs(player.getLocation().getX()) >= MAX_XY_COORD
        || Math.abs(player.getLocation().getZ()) >= MAX_XY_COORD) {
      player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
    }
    // Handle PlayerList entry (persistent)
    if (TFM_PlayerList.existsEntry(player)) {
      playerEntry = TFM_PlayerList.getEntry(player);
      playerEntry.setLastLoginUnix(TFM_Util.getUnixTime());
      playerEntry.setLastLoginName(player.getName());
      playerEntry.addIp(ip);
      playerEntry.save();
    } else {
      playerEntry = TFM_PlayerList.getEntry(player);
      TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player));
    }

    // Generate PlayerData (non-persistent)
    final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
    playerdata.setSuperadminIdVerified(false);

    if (TFM_AdminList.isSuperAdmin(player)) {
      for (String storedIp : playerEntry.getIps()) {
        TFM_BanManager.unbanIp(storedIp);
        TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(storedIp));
      }

      TFM_BanManager.unbanUuid(TFM_UuidManager.getUniqueId(player));

      player.setOp(true);

      // Verify strict IP match
      if (!TFM_AdminList.isIdentityMatched(player)) {
        playerdata.setSuperadminIdVerified(false);
        TFM_Util.bcastMsg(
            "Warning: "
                + player.getName()
                + " is an admin, but is using an account not registered to one of their ip-list.",
            ChatColor.RED);
      } else {
        playerdata.setSuperadminIdVerified(true);
        TFM_AdminList.updateLastLogin(player);
      }
    }

    TFM_PlayerData.getPlayerData(player).setCommandSpy(true);

    // Handle admin impostors
    if (TFM_AdminList.isAdminImpostor(player)) {
      TFM_Util.bcastMsg(
          "Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!",
          ChatColor.RED);
      TFM_Util.bcastMsg(
          ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
      player.getInventory().clear();
      player.setOp(false);
      player.setGameMode(GameMode.SURVIVAL);
      TFM_PlayerData.getPlayerData(player).setFrozen(true);
    } else if (TFM_AdminList.isSuperAdmin(player)
        || TFM_Util.DEVELOPERS.contains(player.getName())) {
      TFM_Util.bcastMsg(
          ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
    }

    // TODO: Cleanup
    String name = player.getName();
    if (TFM_Util.DEVELOPERS.contains(player.getName())) {
      name = ChatColor.DARK_PURPLE + name;
      TFM_PlayerData.getPlayerData(player).setTag("&8[&5Developer&8]");
    }
    if (TFM_Util.EXECUTIVES.contains(player.getName())) {
      name = ChatColor.DARK_BLUE + name;
      TFM_PlayerData.getPlayerData(player).setTag("&8[&1Executive&8]");
    }
    if (TFM_Util.MANAGERS.contains(player.getName())) {
      name = ChatColor.DARK_RED + name;
      TFM_PlayerData.getPlayerData(player).setTag("&8[&4Admin Manager&8]");
    } else if (TFM_AdminList.isSuperAdmin(player)) {
      if (TFM_ConfigEntry.SERVER_OWNERS.getList().contains(name)) {
        name = ChatColor.BLUE + name;
        TFM_PlayerData.getPlayerData(player).setTag("&8[&9Owner&8]");
      } else if (TFM_AdminList.isSeniorAdmin(player)) {
        name = ChatColor.LIGHT_PURPLE + name;
        TFM_PlayerData.getPlayerData(player).setTag("&8[&dSenior Admin&8]");
      } else if (TFM_AdminList.isTelnetAdmin(player, true)) {
        name = ChatColor.DARK_GREEN + name;
        TFM_PlayerData.getPlayerData(player).setTag("&8[&2Telnet Admin&8]");
      } else {
        name = ChatColor.AQUA + name;
        TFM_PlayerData.getPlayerData(player).setTag("&8[&BSuper Admin&8]");
      }
    }

    try {
      player.setPlayerListName(StringUtils.substring(name, 0, 16));
    } catch (IllegalArgumentException ex) {
    }

    new BukkitRunnable() {
      @Override
      public void run() {
        if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) {
          player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
        }

        if (TotalFreedomMod.lockdownEnabled) {
          TFM_Util.playerMsg(
              player,
              "Warning: Server is currenty in lockdown-mode, new players will not be able to join!",
              ChatColor.RED);
        }
      }
    }.runTaskLater(TotalFreedomMod.plugin, 20L * 1L);
  }
Пример #9
0
  @Override
  public boolean onCommand(
      CommandSender sender, Command command, String commandLabel, String[] args) {
    ConsoleCommandSender consoleSender = sender.getServer().getConsoleSender();
    String prefix =
        (ChatColor.BOLD + (ChatColor.BLUE + "["))
            + (ChatColor.RESET + (ChatColor.YELLOW + "Kustom Warn"))
            + (ChatColor.BOLD + (ChatColor.BLUE + "]"))
            + ChatColor.RESET;
    String kickMessage = plugin.getConfig().getString("Kick Message");
    String banMessage = plugin.getConfig().getString("Ban Message");
    String reason = " ";
    for (int i = 1; i < args.length; i++) {
      reason += args[i] + " ";
    }
    if (commandLabel.equalsIgnoreCase("kwarn")) {
      if (!(sender instanceof Player)) {
        if (args.length == 0) {
          consoleSender.sendMessage(prefix + ChatColor.RED + "Not enough arguments!");
          consoleSender.sendMessage(prefix + ChatColor.RED + "Usage: /kwarn [player] (reason)");
          return true;
        } else if (args.length == 1) {
          Player targetPlayer = consoleSender.getServer().getPlayer(args[0]);
          if (targetPlayer != null) {
            List warnings =
                plugin
                    .getDatabase()
                    .find(Warnings.class)
                    .where()
                    .ieq("playerName", targetPlayer.getName())
                    .findList();
            if (plugin.getConfig().getBoolean("Alert Admins")) {
              Command.broadcastCommandMessage(
                  sender,
                  prefix
                      + ChatColor.AQUA
                      + targetPlayer.getName()
                      + " has been warned by a console user");
            }
            if ((warnings.size() + 1) >= plugin.getConfig().getInt("Kick After")) {
              targetPlayer.setPlayerListName(ChatColor.AQUA + targetPlayer.getName());
            } else if ((warnings.size() + 1) >= plugin.getConfig().getInt("Ban After"))
              if (warnings.size() != 0) {
                consoleSender.sendMessage(
                    prefix
                        + ChatColor.AQUA
                        + targetPlayer.getName()
                        + " has been warned "
                        + String.valueOf(warnings.size() + 1)
                        + " times");
              } else {
                consoleSender.sendMessage(
                    prefix
                        + ChatColor.AQUA
                        + "This is "
                        + targetPlayer.getName()
                        + "\'s first warning");
              }
            targetPlayer.sendMessage(
                prefix + ChatColor.RED + plugin.getConfig().getString("Warning Message"));
            Warnings warning =
                plugin
                    .getDatabase()
                    .find(Warnings.class)
                    .where()
                    .ieq("playerName", targetPlayer.getName())
                    .ieq("warningNumber", String.valueOf(warnings.size() + 1))
                    .findUnique();
            if (warnings.size() < plugin.getConfig().getInt("Ban After")) {
              warning = new Warnings();
              warning.setWarningNumber(String.valueOf(warnings.size() + 1));
              warning.setPlayerName(targetPlayer.getName());
              warning.setAdminName("console user");
            }
            plugin.getDatabase().save(warning);

            if ((warnings.size() + 1) == plugin.getConfig().getInt("Kick After")) {
              targetPlayer.kickPlayer(plugin.getConfig().getString("Kick Message"));
            } else if ((warnings.size() + 1) == plugin.getConfig().getInt("Ban After")) {
              targetPlayer.kickPlayer(plugin.getConfig().getString("Ban Message"));
              targetPlayer.setBanned(true);
            }
            return true;
          } else {
            consoleSender.sendMessage(prefix + ChatColor.RED + "Player not found!");
            return true;
          }
        } else if (args.length >= 2) {
          Player targetPlayer = consoleSender.getServer().getPlayer(args[0]);
          if (targetPlayer != null) {
            List warnings =
                plugin
                    .getDatabase()
                    .find(Warnings.class)
                    .where()
                    .ieq("playerName", targetPlayer.getName())
                    .findList();
            if (plugin.getConfig().getBoolean("Alert Admins")) {
              Command.broadcastCommandMessage(
                  sender,
                  prefix
                      + ChatColor.AQUA
                      + targetPlayer.getName()
                      + " has been warned by a console user for "
                      + reason);
            }
            if (warnings.size() != 0) {
              consoleSender.sendMessage(
                  prefix
                      + ChatColor.AQUA
                      + targetPlayer.getName()
                      + " has been warned "
                      + String.valueOf(warnings.size() + 1)
                      + " times");
            } else {
              consoleSender.sendMessage(
                  prefix
                      + ChatColor.AQUA
                      + "This is "
                      + targetPlayer.getName()
                      + "\'s first warning");
            }
            if (plugin.getConfig().getBoolean("Alert Admins")) {
              Command.broadcastCommandMessage(
                  sender,
                  prefix
                      + ChatColor.AQUA
                      + targetPlayer.getName()
                      + " has been warned by a console user");
            }
            if ((warnings.size() + 1) >= plugin.getConfig().getInt("Kick After")) {
              targetPlayer.setPlayerListName(ChatColor.AQUA + targetPlayer.getName());
            }
            targetPlayer.sendMessage(
                prefix
                    + ChatColor.RED
                    + plugin.getConfig().getString("Warning For")
                    + " "
                    + reason);
            Warnings warning =
                plugin
                    .getDatabase()
                    .find(Warnings.class)
                    .where()
                    .ieq("playerName", targetPlayer.getName())
                    .ieq("warningNumber", String.valueOf(warnings.size() + 1))
                    .findUnique();
            if (warnings.size() < plugin.getConfig().getInt("Ban After")) {
              warning = new Warnings();
              warning.setWarningNumber(String.valueOf(warnings.size() + 1));
              warning.setPlayerName(targetPlayer.getName());
              warning.setAdminName("console user");
              warning.setWarningReason(reason);
            }
            plugin.getDatabase().save(warning);

            if ((warnings.size() + 1) == plugin.getConfig().getInt("Kick After")) {
              targetPlayer.kickPlayer(plugin.getConfig().getString("Kick Message"));
            } else if ((warnings.size() + 1) == plugin.getConfig().getInt("Ban After")) {
              targetPlayer.kickPlayer(plugin.getConfig().getString("Ban Message"));
              targetPlayer.setBanned(true);
            }
            return true;
          }
        }
      } else {
        Player player = (Player) sender;
        if (player.hasPermission("kustomwarn.warn") || player.isOp()) {
          if (args.length == 0) {
            if (plugin == null) {
              player.sendMessage(prefix + "Plugin is null");
            }
            player.sendMessage(prefix + ChatColor.RED + "Not enough arguments!");
            player.sendMessage(prefix + ChatColor.RED + "Usage: /kwarn [player] (reason)");
            return true;
          } else if (args.length == 1) {
            Player targetPlayer = player.getServer().getPlayer(args[0]);
            if (targetPlayer != null) {
              List warnings =
                  plugin
                      .getDatabase()
                      .find(Warnings.class)
                      .where()
                      .ieq("playerName", targetPlayer.getName())
                      .findList();
              if (plugin.getConfig().getBoolean("Alert Admins")) {
                Command.broadcastCommandMessage(
                    sender,
                    prefix
                        + ChatColor.AQUA
                        + targetPlayer.getName()
                        + " has been warned by "
                        + player.getName());
              }
              if (warnings.size() != 0) {
                player.sendMessage(
                    prefix
                        + ChatColor.AQUA
                        + targetPlayer.getName()
                        + " has been warned "
                        + String.valueOf(warnings.size() + 1)
                        + " times");
              } else {
                player.sendMessage(
                    prefix
                        + ChatColor.AQUA
                        + "This is "
                        + targetPlayer.getName()
                        + "\'s first warning");
              }
              targetPlayer.sendMessage(
                  prefix + ChatColor.RED + plugin.getConfig().getString("Warning Message"));
              Warnings warning =
                  plugin
                      .getDatabase()
                      .find(Warnings.class)
                      .where()
                      .ieq("playerName", targetPlayer.getName())
                      .ieq("warningNumber", String.valueOf(warnings.size() + 1))
                      .findUnique();
              if (warnings.size() < plugin.getConfig().getInt("Ban After")) {
                warning = new Warnings();
                warning.setWarningNumber(String.valueOf(warnings.size() + 1));
                warning.setPlayerName(targetPlayer.getName());
                warning.setAdminName(player.getName());
              }
              plugin.getDatabase().save(warning);

              if ((warnings.size() + 1) == plugin.getConfig().getInt("Kick After")) {
                targetPlayer.kickPlayer(plugin.getConfig().getString("Kick Message"));
              } else if ((warnings.size() + 1) == plugin.getConfig().getInt("Ban After")) {
                targetPlayer.kickPlayer(plugin.getConfig().getString("Ban Message"));
                targetPlayer.setBanned(true);
              }
              if (plugin.getConfig().getBoolean("Alert Admins")) {
                Command.broadcastCommandMessage(
                    sender,
                    prefix
                        + ChatColor.AQUA
                        + targetPlayer.getName()
                        + " has been warned by a console user");
              }
              if ((warnings.size() + 1) >= plugin.getConfig().getInt("Kick After")) {
                targetPlayer.setPlayerListName(ChatColor.AQUA + targetPlayer.getName());
              }
              return true;
            } else {
              player.sendMessage(prefix + ChatColor.RED + "Player not found!");
              return true;
            }
          } else if (args.length >= 2) {
            Player targetPlayer = player.getServer().getPlayer(args[0]);
            if (targetPlayer != null) {
              List warnings =
                  plugin
                      .getDatabase()
                      .find(Warnings.class)
                      .where()
                      .ieq("playerName", targetPlayer.getName())
                      .findList();
              if (plugin.getConfig().getBoolean("Alert Admins")) {
                Command.broadcastCommandMessage(
                    sender,
                    prefix
                        + ChatColor.AQUA
                        + targetPlayer.getName()
                        + " has been warned by "
                        + player.getName()
                        + " for "
                        + reason);
              }
              if (warnings.size() != 0) {
                player.sendMessage(
                    prefix
                        + ChatColor.AQUA
                        + targetPlayer.getName()
                        + " has been warned "
                        + String.valueOf(warnings.size() + 1)
                        + " times");
              }
              if (setKicked(targetPlayer.getName())) {
                targetPlayer.kickPlayer(plugin);
              } else {
                player.sendMessage(
                    prefix
                        + ChatColor.AQUA
                        + "This is "
                        + targetPlayer.getName()
                        + "\'s first warning");
              }
              targetPlayer.sendMessage(
                  prefix
                      + ChatColor.RED
                      + plugin.getConfig().getString("Warning For")
                      + " "
                      + reason);
              Warnings warning =
                  plugin
                      .getDatabase()
                      .find(Warnings.class)
                      .where()
                      .ieq("playerName", targetPlayer.getName())
                      .ieq("warningNumber", String.valueOf(warnings.size() + 1))
                      .findUnique();
              if (warnings.size() < plugin.getConfig().getInt("Ban After")) {
                warning = new Warnings();
                warning.setWarningNumber(String.valueOf(warnings.size() + 1));
                warning.setPlayerName(targetPlayer.getName());
                warning.setAdminName(player.getName());
                warning.setWarningReason(reason);
              }
              plugin.getDatabase().save(warning);

              if (plugin.getConfig().getBoolean("Alert Admins")) {
                Command.broadcastCommandMessage(
                    sender,
                    prefix
                        + ChatColor.AQUA
                        + targetPlayer.getName()
                        + " has been warned by a console user");
              }
              return true;
            } else {
              player.sendMessage(prefix + ChatColor.RED + "Player not found");
              return true;
            }
          }
        }
      }
    }
    return true;
  }
Пример #10
0
  @EventHandler
  public void on(PlayerJoinEvent e) {

    final Player p = e.getPlayer();

    Tablist tab = new Tablist();
    tab.setFooter("§3OreBattle v1.0");
    tab.setHeader("§a" + Bukkit.getServerName());
    tab.send(p);

    if (Devathlon.Status == GameStatus.Lobby) {

      /*TagManager tm = new TagManager(p);
      tm.changeTag(tm.getTagByPermissions());
      tm.setTag();*/

      e.setJoinMessage(
          "§7> "
              + p.getDisplayName()
              + " §3hat das Spiel betreten. ("
              + Bukkit.getOnlinePlayers().size()
              + "/"
              + Bukkit.getMaxPlayers()
              + ")");

      if (Bukkit.getOnlinePlayers().size() == 5 && Devathlon.Timer > 10) {
        Devathlon.Timer = 10;
      }

      clearupperson(p);
      createPlayerStats(p);

      p.getInventory()
          .setItem(
              0, createItemstack(Material.COMPASS, "§9Teamauswahl §7<Rechtsklick>", 1, (byte) 0));
      p.getInventory()
          .setItem(
              8,
              createItemstack(
                  Material.SLIME_BALL, "§9Zurück zur Lobby §7<Rechtsklick>", 1, (byte) 0));
      if (Devathlon.sql == true) {
        p.getInventory()
            .setItem(
                4,
                createItemstack(Material.NETHER_STAR, "§9Kitauswahl §7<Rechtsklick>", 1, (byte) 0));
      }

      p.getInventory().setHeldItemSlot(0);
      p.teleport(OreBattle_Command.getLocation("Lobby", true));
      p.sendMessage(Devathlon.prefix + "§3Willkommen bei OreBattle v1.0");

    } else {

      e.setJoinMessage("");

      p.getInventory().clear();
      p.getInventory()
          .setItem(
              0,
              createItemstack(Material.REDSTONE_BLOCK, "§cTeam Rot §7<Rechtsklick>", 1, (byte) 0));
      p.getInventory()
          .setItem(
              1, createItemstack(Material.LAPIS_BLOCK, "§9Team Blau §7<Rechtsklick>", 1, (byte) 0));
      p.getInventory()
          .setItem(
              8,
              createItemstack(
                  Material.SLIME_BALL, "§9Zurück zur Lobby §7<Rechtsklick>", 1, (byte) 0));

      TagManager tm = new TagManager(p);
      tm.changeTag("7");
      tm.setTag();
      p.setPlayerListName("§7[§cX§7] §8| §7" + p.getName());
      p.setDisplayName("§7[§cX§7] " + p.getName());

      Global.spectator.add(p);

      for (Player all : Bukkit.getOnlinePlayers()) {
        all.hidePlayer(p);
        for (Player spec : Global.spectator) {
          spec.showPlayer(p);
          p.showPlayer(spec);
        }
      }

      p.setAllowFlight(true);
      p.setFlying(true);
      p.sendMessage(Devathlon.prefix + "§3Du bist jetzt Spectator.");
      p.teleport(OreBattle_Command.getLocation("Spectator", true));
    }
  }
Пример #11
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onChat(AsyncPlayerChatEvent ce) {
    if (ce.isCancelled()) {
      return;
    }

    Player player = ce.getPlayer();
    Game game = Main.getInstance().getGameManager().getGameOfPlayer(player);

    if (game == null) {
      boolean seperateGameChat = Main.getInstance().getBooleanConfig("seperate-game-chat", true);
      if (!seperateGameChat) {
        return;
      }

      Iterator<Player> recipiens = ce.getRecipients().iterator();
      while (recipiens.hasNext()) {
        Player recipient = recipiens.next();
        Game recipientGame = Main.getInstance().getGameManager().getGameOfPlayer(recipient);
        if (recipientGame != null) {
          recipiens.remove();
        }
      }
      return;
    }

    if (game.getState() == GameState.STOPPED) {
      return;
    }

    Team team = game.getPlayerTeam(player);
    String message = ce.getMessage();
    boolean isSpectator = game.isSpectator(player);

    if (Main.getInstance().getBooleanConfig("overwrite-names", false)) {
      if (team == null || isSpectator) {
        player.setDisplayName(ChatColor.stripColor(player.getName()));

        player.setPlayerListName(ChatColor.stripColor(player.getName()));
      } else {
        player.setDisplayName(team.getChatColor() + ChatColor.stripColor(player.getName()));
        player.setPlayerListName(team.getChatColor() + ChatColor.stripColor(player.getName()));
      }
    }

    if (Main.getInstance().getBooleanConfig("teamname-on-tab", false)
        && Utils.isSupportingTitles()) {
      if (team == null || isSpectator) {
        player.setPlayerListName(ChatColor.stripColor(player.getDisplayName()));
      } else {
        player.setPlayerListName(
            team.getChatColor()
                + team.getName()
                + ChatColor.WHITE
                + " | "
                + team.getChatColor()
                + ChatColor.stripColor(player.getDisplayName()));
      }
    }

    if (game.getState() != GameState.RUNNING && game.getState() == GameState.WAITING) {

      String format = null;
      if (team == null) {
        format =
            this.getChatFormat(
                Main.getInstance().getStringConfig("lobby-chatformat", "$player$: $msg$"),
                null,
                false,
                true);
      } else {
        format =
            this.getChatFormat(
                Main.getInstance().getStringConfig("ingame-chatformat", "<$team$>$player$: $msg$"),
                team,
                false,
                true);
      }

      ce.setFormat(format);
      return;
    }

    String toAllPrefix = Main.getInstance().getConfig().getString("chat-to-all-prefix", "@");

    if (message.trim().startsWith(toAllPrefix)
        || isSpectator
        || (game.getCycle().isEndGameRunning()
            && Main.getInstance().getBooleanConfig("global-chat-after-end", true))) {
      boolean seperateSpectatorChat =
          Main.getInstance().getBooleanConfig("seperate-spectator-chat", false);

      message = message.trim();
      if (!isSpectator
          && !(game.getCycle().isEndGameRunning()
              && Main.getInstance().getBooleanConfig("global-chat-after-end", true))) {
        ce.setMessage(message.substring(1, message.length()));
      } else {
        ce.setMessage(message);
      }

      String format =
          this.getChatFormat(
              Main.getInstance()
                  .getStringConfig("ingame-chatformat-all", "[$all$] <$team$>$player$: $msg$"),
              team,
              isSpectator,
              true);
      ce.setFormat(format);

      if (!Main.getInstance().isBungee() || seperateSpectatorChat) {
        Iterator<Player> recipiens = ce.getRecipients().iterator();
        while (recipiens.hasNext()) {
          Player recipient = recipiens.next();
          if (!game.isInGame(recipient)) {
            recipiens.remove();
            continue;
          }

          if (!seperateSpectatorChat) {
            continue;
          }

          if (isSpectator && !game.isSpectator(recipient)) {
            recipiens.remove();
          } else if (!isSpectator && game.isSpectator(recipient)) {
            recipiens.remove();
          }
        }
      }
    } else {
      message = message.trim();
      ce.setMessage(message);
      ce.setFormat(
          this.getChatFormat(
              Main.getInstance().getStringConfig("ingame-chatformat", "<$team$>$player$: $msg$"),
              team,
              false,
              false));

      Iterator<Player> recipiens = ce.getRecipients().iterator();
      while (recipiens.hasNext()) {
        Player recipient = recipiens.next();
        if (!game.isInGame(recipient) || !team.isInTeam(recipient)) {
          recipiens.remove();
        }
      }
    }
  }
Пример #12
0
 @Override
 public void setPlayerListName(String name) {
   caller.setPlayerListName(name);
 }
  @EventHandler(priority = EventPriority.MONITOR)
  public void onPlayerJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    final String ip = TFM_Util.getIp(player);

    final TFM_Player playerEntry;
    TFM_Log.info(
        "[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip,
        true);
    // Check absolute value to account for negatives
    if (Math.abs(player.getLocation().getX()) >= MAX_XY_COORD
        || Math.abs(player.getLocation().getZ()) >= MAX_XY_COORD) {
      player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
    }
    // Handle PlayerList entry (persistent)
    if (TFM_PlayerList.existsEntry(player)) {
      playerEntry = TFM_PlayerList.getEntry(player);
      playerEntry.setLastLoginUnix(TFM_Util.getUnixTime());
      playerEntry.setLastLoginName(player.getName());
      playerEntry.addIp(ip);
      playerEntry.save();
    } else {
      playerEntry = TFM_PlayerList.getEntry(player);
      TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player));
    }

    // Generate PlayerData (non-persistent)
    final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
    playerdata.setSuperadminIdVerified(false);

    if (TFM_AdminList.isSuperAdmin(player)) {
      for (String storedIp : playerEntry.getIps()) {
        TFM_BanManager.unbanIp(storedIp);
        TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(storedIp));
      }

      TFM_BanManager.unbanUuid(TFM_UuidManager.getUniqueId(player));

      player.setOp(true);

      // Verify strict IP match
      if (!TFM_AdminList.isIdentityMatched(player)) {
        playerdata.setSuperadminIdVerified(false);
        TFM_Util.bcastMsg(
            "Warning: "
                + player.getName()
                + " is an admin, but is using an account not registered to one of their ip-list.",
            ChatColor.RED);
      } else {
        playerdata.setSuperadminIdVerified(true);
        TFM_AdminList.updateLastLogin(player);
      }
    }

    // Handle admin impostors
    if (TFM_AdminList.isAdminImpostor(player)) {
      if (TFM_Util.imposters.contains(player.getName())) {
        TFM_Util.bcastMsg(
            "Warning: " + player.getName() + " is not an imposter and is just trolling.",
            ChatColor.RED);
        TFM_Util.bcastMsg(
            ChatColor.AQUA
                + player.getName()
                + " is a fake "
                + ChatColor.YELLOW
                + ChatColor.UNDERLINE
                + "Impostor");
      } else {
        TFM_Util.bcastMsg(
            "Warning: "
                + player.getName()
                + " has been flagged as an impostor and has been frozen!",
            ChatColor.RED);
        TFM_Util.bcastMsg(
            ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
        player.getInventory().clear();
        player.setOp(false);
        player.setGameMode(GameMode.SURVIVAL);
        TFM_PlayerData.getPlayerData(player).setFrozen(true);
        TFM_Util.bcastMsg("Admins, tell him to verify!", ChatColor.RED);
      }
    } else if (TFM_AdminList.isSuperAdmin(player)
        || TFM_Util.DEVELOPERS.contains(player.getName())) {
      TFM_Util.bcastMsg(
          ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
    }

    // TODO: Cleanup
    String name = player.getName();
    if (TFM_Util.RF_DEVELOPERS.contains(name)) {
      TFM_PlayerData.getPlayerData(player).setCommandSpy(true);
      player.setPlayerListName(ChatColor.DARK_PURPLE + name);
      TFM_PlayerData.getPlayerData(player).setTag("&8[&5Developer&8]");
      afterNameSet(player);
      return;
    } else if (player.getName().equals("iDelRey")) {
      TFM_PlayerData.getPlayerData(player).setCommandSpy(true);
      player.setPlayerListName(ChatColor.DARK_PURPLE + name);
      TFM_PlayerData.getPlayerData(player).setTag("&8[&5Lead Developer&8]");
      afterNameSet(player);
      return;
    } else if (player.getName().equals("reuben4545")) {
      TFM_PlayerData.getPlayerData(player).setCommandSpy(true);
      player.setPlayerListName(ChatColor.GREEN + name);
      TFM_PlayerData.getPlayerData(player).setTag("&8[&aLead Specialist&8]");
      afterNameSet(player);
      return;
    } else if (player.getName().equals("Joenmb")) {
      TFM_PlayerData.getPlayerData(player).setCommandSpy(true);
      player.setPlayerListName(ChatColor.DARK_PURPLE + name);
      TFM_PlayerData.getPlayerData(player).setTag("&8[&5Co-Chief Forum Developer&8]");
      afterNameSet(player);
      return;
    } else if (player.getName().equals("DarkGamingDronze")) {
      TFM_PlayerData.getPlayerData(player).setCommandSpy(true);
      player.setPlayerListName(ChatColor.BLUE + player.getName());
      TFM_PlayerData.getPlayerData(player).setTag("&8[&9Owner&8]");
      player.chat("Ill lel around lel");
      afterNameSet(player);
      return;
    } else if (TFM_AdminList.isSuperAdmin(player)) {
      TFM_PlayerData.getPlayerData(player).setCommandSpy(true);
      if (TFM_ConfigEntry.SERVER_OWNERS.getList().contains(name)) {
        player.setPlayerListName(ChatColor.BLUE + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&9Owner&8]");
        afterNameSet(player);
        return;
      } else if (player.getName().equals("MysteriAce")) {
        player.setPlayerListName(ChatColor.YELLOW + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&cMysteri&8]");
        afterNameSet(player);
        return;
      } else if (player.getName().equals("DarkHorse108")) {
        player.setPlayerListName(ChatColor.DARK_RED + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&4System Manager&8]");
        afterNameSet(player);
        return;
      }
      if (TFM_Util.FOP_DEVELOPERS.contains(name)) {
        player.setPlayerListName(ChatColor.DARK_PURPLE + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&5FOP-Developer&8]");
        afterNameSet(player);
        return;
      }
      if (TFM_Util.COOWNER.contains(name)) {
        player.setPlayerListName(ChatColor.DARK_BLUE + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&9Co-Owner&8]");
        afterNameSet(player);
        return;
      }
      if (TFM_Util.SPECIALISTS.contains(name)) {
        player.setPlayerListName(ChatColor.GREEN + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&aSpecialist&8]");
        afterNameSet(player);
        return;
      }
      if (TFM_Util.EXECUTIVES.contains(name)) {
        player.setPlayerListName(ChatColor.YELLOW + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&eExecutive&8]");
        afterNameSet(player);
        return;
      }
      if (TFM_Util.SYS.contains(name)) {
        player.setPlayerListName(ChatColor.DARK_RED + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&4System-Admin&8]");
        afterNameSet(player);
        return;
      } else if (TFM_AdminList.isSeniorAdmin(player)) {
        player.setPlayerListName(ChatColor.LIGHT_PURPLE + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&dSenior Admin&8]");
        afterNameSet(player);
        return;
      } else if (TFM_AdminList.isTelnetAdmin(player, true)) {
        player.setPlayerListName(ChatColor.DARK_GREEN + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&2Telnet Admin&8]");
        afterNameSet(player);
        return;
      } else {
        player.setPlayerListName(ChatColor.AQUA + name);
        TFM_PlayerData.getPlayerData(player).setTag("&8[&BSuper Admin&8]");
        afterNameSet(player);
        return;
      }
    }
  }