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);
}
}
Aggregations