Search in sources :

Example 56 with ChatColor

use of org.bukkit.ChatColor in project MyMaid2 by jaoafa.

the class TPSChange method run.

@Override
public void run() {
    String tps1m = TPSChecker.getTPS1m();
    String tps5m = TPSChecker.getTPS5m();
    String tps15m = TPSChecker.getTPS15m();
    ChatColor tps1mcolor;
    try {
        double tps1m_double = Double.parseDouble(tps1m);
        tps1mcolor = TPSChecker.TPSColor(tps1m_double);
        if (tps1m_double <= 15 && OldTps1mColor > 15) {
            // やばいぞ
            Bukkit.broadcastMessage("[TPSChecker] " + ChatColor.RED + "ちょっと待って!TPSがかなり下がっています!(" + tps1m + " / 20)");
            Bukkit.broadcastMessage("[TPSChecker] " + ChatColor.RED + "意図的なサーバへの負荷をかける行為は「サーバルール」の「サーバシステムに危害を加えない。」に違反すると判断される場合があります。あなたの行動が負荷になっていないかぜひ確認してみてください。");
            MyMaid2Premise.DiscordSend("[TPSChecker] ちょっと待って!TPSがかなり下がっています!(" + tps1m + " / 20)");
        }
        OldTps1mColor = tps1m_double;
    } catch (NumberFormatException e) {
        tps1mcolor = ChatColor.GREEN;
    }
    ChatColor tps5mcolor;
    try {
        double tps5m_double = Double.parseDouble(tps5m);
        tps5mcolor = TPSChecker.TPSColor(tps5m_double);
    } catch (NumberFormatException e) {
        tps5mcolor = ChatColor.GREEN;
    }
    ChatColor tps15mcolor;
    try {
        double tps15m_double = Double.parseDouble(tps15m);
        tps15mcolor = TPSChecker.TPSColor(tps15m_double);
    } catch (NumberFormatException e) {
        tps15mcolor = ChatColor.GREEN;
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    // String tpsmsg = "[\"\",{\"text\":\"TPS\n\",\"color\":\"gold\"},{\"text\":\"1m: \",\"color\":\"red\"},{\"text\":\"" + tps1m + "\",\"color\":\"" + tps1mcolor + "\"},{\"text\":\"\n\",\"color\":\"\"},{\"text\":\"5m: \",\"color\":\"yellow\"},{\"text\":\"" + tps5m + "\",\"color\":\"" + tps5mcolor + "\"},{\"text\":\"\n\",\"color\":\"none\"},{\"text\":\"15m: \",\"color\":\"green\"},{\"text\":\"" + tps15m + "\",\"color\":\"" + tps15mcolor + "\"}]";
    String tpsmsg = ChatColor.GOLD + "TPS\n" + ChatColor.RED + "1m: " + tps1mcolor + tps1m + "\n" + ChatColor.YELLOW + "5m: " + tps5mcolor + tps5m + "\n" + ChatColor.GREEN + "15m: " + tps15mcolor + tps15m;
    String header = ChatColor.GOLD + "jao " + ChatColor.YELLOW + "Minecraft " + ChatColor.AQUA + "Server\n" + "Date: " + sdf.format(new Date()) + "\n" + ChatColor.RED + "Online: " + Bukkit.getServer().getOnlinePlayers().size() + " / " + Bukkit.getServer().getMaxPlayers() + "\n" + "Vote: " + "{VOTECOUNT}" + "\n" + "OnlineTime: " + "{ONLINETIME}";
    for (Player player : Bukkit.getServer().getOnlinePlayers()) {
        PlayerVoteData pvd = new PlayerVoteData(player);
        String votecount = "取得に失敗しました。";
        try {
            votecount = pvd.get() + "回";
        } catch (ClassNotFoundException | UnsupportedOperationException | NullPointerException | SQLException e) {
            return;
        }
        int onlineTime = player.getStatistic(Statistic.PLAY_ONE_TICK) / 20;
        String time = getStringTime(onlineTime);
        String _header = header.replaceAll("\\{VOTECOUNT\\}", votecount);
        _header = _header.replaceAll("\\{ONLINETIME\\}", time);
        TitleAPI.sendTabTitle(player, _header, tpsmsg);
    }
}
Also used : Player(org.bukkit.entity.Player) SQLException(java.sql.SQLException) Date(java.util.Date) ChatColor(org.bukkit.ChatColor) SimpleDateFormat(java.text.SimpleDateFormat) PlayerVoteData(com.jaoafa.MyMaid2.Lib.PlayerVoteData)

Aggregations

ChatColor (org.bukkit.ChatColor)56 ArrayList (java.util.ArrayList)8 Player (org.bukkit.entity.Player)8 JSONObject (org.json.simple.JSONObject)6 IOException (java.io.IOException)4 SimpleDateFormat (java.text.SimpleDateFormat)3 Mage (com.elmakers.mine.bukkit.api.magic.Mage)2 PlayerVoteData (com.jaoafa.MyMaid2.Lib.PlayerVoteData)2 MassiveList (com.massivecraft.massivecore.collections.MassiveList)2 Method (java.lang.reflect.Method)2 SQLException (java.sql.SQLException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 MaxMoneyException (net.ess3.api.MaxMoneyException)2 DyeColor (org.bukkit.DyeColor)2 Color (pl.themolka.arcade.util.Color)2 FancyMessage (br.net.fabiozumbi12.RedProtect.Bukkit.Fanciful.FancyMessage)1 RPGui (br.net.fabiozumbi12.RedProtect.Bukkit.RPGui)1 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)1