From 24d8ec7301b978e0881c038ea2c6b960c9873bf0 Mon Sep 17 00:00:00 2001 From: Jakob Schulz <55949993+Lordikak@users.noreply.github.com> Date: Wed, 20 May 2026 18:34:10 +0200 Subject: [PATCH] add "/team prefix" command --- .../steamwar/messages/BungeeCore.properties | 7 ++++ .../messages/BungeeCore_de.properties | 7 ++++ .../velocitycore/commands/TeamCommand.java | 35 +++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index c9fd04eb..8ca4ed04 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -498,6 +498,13 @@ TEAM_INFO_SW_USAGE = §8/§7team info §8[§eSW§8|§eSteamWar§8] TEAM_INFO_SW_HEADER = §eSteam§8War Server Team TEAM_INFO_SW_RANK = {0} §7({1})§8: {2} +#TEAM Prefix +TEAM_PREFIX_USAGE = §8/§7team prefix §8[§eteam§8|§eSW§8] +TEAM_PREFIX_CURRENT_TEAM = §7Current chat prefix§8: §eTeam +TEAM_PREFIX_CURRENT_SW = §7Current chat prefix§8: §eSteamWar +TEAM_PREFIX_SET_TEAM = §7Your chat prefix is now your §eteam prefix§7. +TEAM_PREFIX_SET_SW = §7Your chat prefix is now your §eSteamWar prefix§7. + #Team List TEAM_LIST_NOT_PAGE = §cNo page number entered TEAM_LIST_UNKNOWN_PAGE = §cInvalid page entered diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index d8320e66..026e19d9 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -470,6 +470,13 @@ TEAM_INFO_SW_USAGE = §8/§7team info §8[§eSW§8|§eSteamWar§8] TEAM_INFO_SW_HEADER = §eSteam§8War Serverteam TEAM_INFO_SW_RANK = {0} §7({1})§8: {2} +#Team Prefix +TEAM_PREFIX_USAGE = §8/§7team prefix §8[§eteam§8|§eSW§8] +TEAM_PREFIX_CURRENT_TEAM = §7Aktueller Chatprefix§8: §eTeam +TEAM_PREFIX_CURRENT_SW = §7Aktueller Chatprefix§8: §eSteamWar +TEAM_PREFIX_SET_TEAM = §7Dein Chatprefix ist jetzt dein §eTeamprefix§7. +TEAM_PREFIX_SET_SW = §7Dein Chatprefix ist jetzt dein §eSteamWar-Prefix§7. + #Team List TEAM_LIST_NOT_PAGE = §cKeine Seitenzahl angegeben TEAM_LIST_UNKNOWN_PAGE = §cUngültige Seitenzahl angegeben diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java index face1b22..406c0955 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/TeamCommand.java @@ -47,6 +47,8 @@ import static de.steamwar.persistent.Storage.teamInvitations; @Linked public class TeamCommand extends SWCommand { + private static final String PREFIX_MODE_CONFIG = "chatprefix"; + private static final String PREFIX_MODE_SW = "SW"; public TeamCommand() { super("team"); @@ -362,6 +364,39 @@ public class TeamCommand extends SWCommand { return "§e"; } + @Register(value = "prefix", description = "TEAM_PREFIX_USAGE") + public void prefix(@Validator("canUseTeamPrefix") Chatter sender){ + boolean swPrefix = PREFIX_MODE_SW.equals(UserConfig.getConfig(sender.user().getId(), PREFIX_MODE_CONFIG)); + sender.system(swPrefix ? "TEAM_PREFIX_CURRENT_SW" : "TEAM_PREFIX_CURRENT_TEAM"); + } + + @Register(value = "prefix", description = "TEAM_PREFIX_USAGE") + public void prefix(@Validator("canUseTeamPrefix") Chatter sender, PrefixMode mode) { + if (mode == PrefixMode.SW) { + UserConfig.updatePlayerConfig(sender.user().getId(), PREFIX_MODE_CONFIG, PREFIX_MODE_SW); + sender.system("TEAM_PREFIX_SET_SW"); + } else { + UserConfig.updatePlayerConfig(sender.user().getId(), PREFIX_MODE_CONFIG, null); + sender.system("TEAM_PREFIX_SET_TEAM"); + } + } + + @Validator("canUseTeamPrefix") + public TypeValidator canUseTeamPrefixValidator() { + return (sender, value, messageSender) -> { + SteamwarUser user = value.user(); + + return user.hasPerm(UserPerm.TEAM) + && user.getTeam() != 0 + && user.prefix() != UserPerm.emptyPrefix; + }; + } + + private enum PrefixMode { + TEAM, + SW + } + @Register("list") public void list(Chatter sender, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page) { final int TEAMS_PER_PAGE = 10;