diff --git a/CommonCore/SQL/src/de/steamwar/sql/Team.kt b/CommonCore/SQL/src/de/steamwar/sql/Team.kt index 658e263a..156cbb46 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Team.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/Team.kt @@ -46,6 +46,10 @@ class Team(id: EntityID) : IntEntity(id) { fun byId(id: Int) = synchronized(teamCache) { teamCache.computeIfAbsent(id) { useDb { Team[id] } } } + @JvmStatic + fun getActiveById(id: Int) = + useDb { findById(id)?.takeUnless { it.deleted } } + @JvmStatic fun get(name: String) = useDb { find { (TeamTable.name.lowerCase() eq name.lowercase() or (TeamTable.kuerzel.lowerCase() eq name.lowercase())) and not(TeamTable.deleted) }.firstOrNull() } @@ -100,4 +104,4 @@ class Team(id: EntityID) : IntEntity(id) { set(value) = useDb { name = value } -} \ No newline at end of file +} diff --git a/VelocityCore/src/de/steamwar/velocitycore/chat/ChatFormat.java b/VelocityCore/src/de/steamwar/velocitycore/chat/ChatFormat.java index f335340f..611597d5 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/chat/ChatFormat.java +++ b/VelocityCore/src/de/steamwar/velocitycore/chat/ChatFormat.java @@ -133,7 +133,7 @@ public class ChatFormat { private static Component clickableTeam(Chatter receiver, Team team, Component component) { return component .hoverEvent(HoverEvent.showText(receiver.parse(new Message("CHAT_HOVER_TEAM_CLICK", team.getTeamName(), "ยง" + team.getTeamColor(), team.getTeamKuerzel())))) - .clickEvent(ClickEvent.suggestCommand("/team info " + team.getTeamKuerzel())); + .clickEvent(ClickEvent.suggestCommand("/team info id " + team.getTeamId())); } private static Component teamHover(Chatter receiver, Team team) { diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java index e92a1216..607aaa03 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/EventCommand.java @@ -128,7 +128,7 @@ public class EventCommand extends SWCommand { for (Map.Entry entry : Teampointssortet.entrySet()) { Component finalmessage = sender.parse("EVENT_TEAM_TABLE",Team.byId(entry.getKey()).getTeamColor(), Team.byId(entry.getKey()).getTeamKuerzel(), Team.byId(entry.getKey()).getTeamName(), entry.getValue()); - finalmessage = finalmessage.clickEvent(ClickEvent.runCommand("/team info " + Team.byId(entry.getKey()).getTeamName())); + finalmessage = finalmessage.clickEvent(ClickEvent.runCommand("/team info id " + entry.getKey())); sender.sendMessage(finalmessage); } } @@ -183,11 +183,11 @@ public class EventCommand extends SWCommand { Team blue = Team.byId(eventFight.getTeamBlue()); Team red = Team.byId(eventFight.getTeamRed()); Component finalfightline = sender.parse("EVENT_CURRENT_FIGHT_1", eventFight.getStartTime().toLocalDateTime().format(format), blue.getTeamColor(), blue.getTeamKuerzel()); - finalfightline = finalfightline.clickEvent(ClickEvent.runCommand("/team info " + blue.getTeamName())); + finalfightline = finalfightline.clickEvent(ClickEvent.runCommand("/team info id " + blue.getTeamId())); Component vs = sender.parse("EVENT_CURRENT_FIGHT_VS"); finalfightline = finalfightline.append(vs); Component redteam = sender.parse("EVENT_CURRENT_FIGHT_2", red.getTeamColor(), red.getTeamKuerzel()); - redteam = redteam.clickEvent(ClickEvent.runCommand("/team info " + red.getTeamName())); + redteam = redteam.clickEvent(ClickEvent.runCommand("/team info id " + red.getTeamId())); finalfightline = finalfightline.append(redteam); if (eventFight.hasFinished()) { @@ -272,4 +272,4 @@ public class EventCommand extends SWCommand { return List.of(eventFight.getTeamBlue(), eventFight.getTeamRed()); }); } -} \ No newline at end of file +} diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java index c3108a55..f1956418 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java @@ -285,6 +285,16 @@ public class TeamCommand extends SWCommand { info(sender, Team.byId(sender.user().getTeam())); } + @Register({"info", "id"}) + public void infoById(Chatter sender, int teamId) { + Team team = Team.getActiveById(teamId); + if (team == null) { + sender.system("UNKNOWN_TEAM"); + return; + } + info(sender, team); + } + @Register(value = "info", description = "TEAM_INFO_USAGE") public void info(Chatter sender, @ErrorMessage("UNKNOWN_TEAM") Team team) { if (team.getMembers().isEmpty()) { @@ -403,7 +413,7 @@ public class TeamCommand extends SWCommand { Team tm = all.get(i); sender.prefixless("TEAM_LIST_TEAM", new Message("TEAM_LIST_TEAM_HOVER"), - ClickEvent.runCommand("/team info " + tm.getTeamName()), tm.getTeamColor(), tm.getTeamKuerzel(), tm.getTeamName()); + ClickEvent.runCommand("/team info id " + tm.getTeamId()), tm.getTeamColor(), tm.getTeamKuerzel(), tm.getTeamName()); } Component beforePage = Component diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java index 2c7d5a62..52b23764 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/WhoisCommand.java @@ -67,7 +67,7 @@ public class WhoisCommand extends SWCommand { sender.system("WHOIS_USERNAME", user.getUserName()); sender.system("WHOIS_PREFIX", user.prefix().getColorCode() + user.prefix().getChatPrefix()); - sender.system("WHOIS_TEAM", new Message("WHOIS_TEAM_HOVER", team.getTeamName()), ClickEvent.runCommand("/team info " + team.getTeamName()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); + sender.system("WHOIS_TEAM", new Message("WHOIS_TEAM_HOVER", team.getTeamName()), ClickEvent.runCommand("/team info id " + team.getTeamId()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); if (!sender.user().hasPerm(UserPerm.TEAM)) return;