diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 96c628a4..b34c0b55 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -23,10 +23,8 @@ import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.commands.TpCommand; import de.steamwar.bungeecore.comms.packets.PingPacket; -import de.steamwar.bungeecore.sql.Punishment; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.Team; -import de.steamwar.bungeecore.sql.UserGroup; +import de.steamwar.bungeecore.sql.*; +import lombok.val; import net.md_5.bungee.api.*; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -39,6 +37,7 @@ import net.md_5.bungee.event.EventHandler; import java.sql.Timestamp; import java.time.Instant; import java.util.List; +import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -200,7 +199,7 @@ public class ChatListener extends BasicListener { } private void publicChat(SteamwarUser user, ProxiedPlayer sender, String message){ - String name = sender.getDisplayName(); + String name = getEmblem(user) + sender.getDisplayName(); String chatcolor = user.getUserGroup().getChatColorCode(); if(user.getUserGroup() != UserGroup.Member || user.getTeam() == 12 || user.getTeam() == 285 || user.getTeam() == 54) @@ -228,6 +227,35 @@ public class ChatListener extends BasicListener { BungeeCore.log(sender.getServer().getInfo(), msg); } + private static String getEmblem(SteamwarUser user) { + int maxEloOfPlayer = 0; + ArenaMode arenaMode = null; + for (ArenaMode mode : ArenaMode.getAllModes()) { + if (!mode.isRanked()) continue; + if (UserElo.getFightsOfSeason(user.getId(), mode.getSchemType()) < 10) continue; + + Optional currentElo = UserElo.getElo(user.getId(), mode.getSchemType()); + if (currentElo.isPresent() && currentElo.get() > maxEloOfPlayer) { + maxEloOfPlayer = currentElo.get(); + arenaMode = mode; + } + } + + if (arenaMode == null) return ""; + int maxEloOfGameMode = UserElo.getMaxElo(arenaMode.getSchemType()); + return getEmblem(maxEloOfPlayer, maxEloOfGameMode); + } + + private static String getEmblem(int maxEloOfPlayer, int maxEloOfGameMode) { + if (maxEloOfPlayer > maxEloOfGameMode * 0.99) return "§5❂ "; + if (maxEloOfPlayer > maxEloOfGameMode * 0.94) return "§c✹ "; + if (maxEloOfPlayer > maxEloOfGameMode * 0.84) return "§b✸ "; + if (maxEloOfPlayer > maxEloOfGameMode * 0.69) return "§a✷ "; + if (maxEloOfPlayer > maxEloOfGameMode * 0.49) return "§e✶ "; + if (maxEloOfPlayer > maxEloOfGameMode * 0.26) return "§f✦ "; + return "§7✧ "; + } + private void localChat(ChatEvent e, String [] command){ ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); BungeeCore.log(sender, e.getMessage());