예제 #1
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onServerPing(ServerListPingEvent event) {
    final String ip = event.getAddress().getHostAddress();

    if (TFM_BanManager.isIpBanned(ip)) {
      event.setMotd(ChatColor.RED + TFM_Util.getPlayerFromIp(ip) + ", you are banned.");
      return;
    }

    if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) {
      event.setMotd(ChatColor.RED + "KrazyOP is currently closed.");
      return;
    }

    if (TFM_ConfigEntry.TRAINING_SESSION.getBoolean()) {
      event.setMotd(ChatColor.RED + "KrazyOP is currently in a training session.");
      return;
    }

    if (Bukkit.hasWhitelist()) {
      event.setMotd(ChatColor.RED + "Whitelist is currently enabled.");
      return;
    }

    if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers()) {
      event.setMotd(ChatColor.RED + "KrazyOP is currently full.");
      return;
    }

    // Colorful MOTD
    String message =
        String.format(
            "Welcome to "
                + TFM_Util.randomChatColor()
                + TFM_ConfigEntry.SERVER_NAME.getString()
                + TFM_Util.randomChatColor()
                + "%s"
                + TFM_Util.randomChatColor()
                + "!"
                + TFM_Util.randomChatColor()
                + " - Fun, Free and Easy! \nRunning on Spigot for Minecraft 1.8.7!",
            TFM_Util.getPlayerFromIp(ip));

    final StringBuilder motd = new StringBuilder();

    for (String word : message.split(" ")) {
      motd.append(TFM_Util.randomChatColor()).append(word).append(" ");
    }

    event.setMotd(motd.toString());
  }
    @Override
    public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
    {
        if (args.length == 1)
        {
            if (!args[0].equals("reload"))
            {
                return false;
            }

            if (!TFM_AdminList.isSuperAdmin(sender))
            {
                playerMsg(TFM_Command.MSG_NO_PERMS);
                return true;
            }

            TFM_MainConfig.load();
            TFM_AdminList.load();
            TFM_PermbanList.load();
            TFM_PlayerList.load();
            TFM_BanManager.load();
            TFM_CommandBlocker.load();

            final String message = String.format("%s v%s.%s reloaded.",
                    TotalFreedomMod.pluginName,
                    TotalFreedomMod.pluginVersion,
                    TotalFreedomMod.buildNumber);

            playerMsg(message);
            TFM_Log.info(message);
            return true;
        }

        playerMsg("NickFreedomMod for 'Nick Freedom', the forked all-op server, forked from TotalFreedom.", ChatColor.GOLD);
        playerMsg(String.format("Version "
                + ChatColor.BLUE + "%s.%s" + ChatColor.GOLD + ", built "
                + ChatColor.BLUE + "%s" + ChatColor.GOLD + " by "
                + ChatColor.BLUE + "%s" + ChatColor.GOLD + ".",
                TotalFreedomMod.pluginVersion,
                TotalFreedomMod.buildNumber,
                TotalFreedomMod.buildDate,
                TotalFreedomMod.buildCreator), ChatColor.GOLD);
        playerMsg("Running on " + TFM_ConfigEntry.SERVER_NAME.getString() + ".", ChatColor.GOLD);
        playerMsg("Created by Madgeek1450 and Prozza. Later forked by ItsTeeqo_ (_ItsNick_) to make NickFreedom", ChatColor.GOLD);

        return true;
    }