add "/team prefix" command

This commit is contained in:
Jakob Schulz
2026-05-20 18:34:10 +02:00
parent a5992a9e4e
commit 24d8ec7301
3 changed files with 49 additions and 0 deletions
@@ -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_HEADER = §eSteam§8War Server Team
TEAM_INFO_SW_RANK = {0} §7({1})§8: {2} 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
TEAM_LIST_NOT_PAGE = §cNo page number entered TEAM_LIST_NOT_PAGE = §cNo page number entered
TEAM_LIST_UNKNOWN_PAGE = §cInvalid page entered TEAM_LIST_UNKNOWN_PAGE = §cInvalid page entered
@@ -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_HEADER = §eSteam§8War Serverteam
TEAM_INFO_SW_RANK = {0} §7({1})§8: {2} 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
TEAM_LIST_NOT_PAGE = §cKeine Seitenzahl angegeben TEAM_LIST_NOT_PAGE = §cKeine Seitenzahl angegeben
TEAM_LIST_UNKNOWN_PAGE = §cUngültige Seitenzahl angegeben TEAM_LIST_UNKNOWN_PAGE = §cUngültige Seitenzahl angegeben
@@ -47,6 +47,8 @@ import static de.steamwar.persistent.Storage.teamInvitations;
@Linked @Linked
public class TeamCommand extends SWCommand { public class TeamCommand extends SWCommand {
private static final String PREFIX_MODE_CONFIG = "chatprefix";
private static final String PREFIX_MODE_SW = "SW";
public TeamCommand() { public TeamCommand() {
super("team"); super("team");
@@ -362,6 +364,39 @@ public class TeamCommand extends SWCommand {
return "§e"; 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<Chatter> 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") @Register("list")
public void list(Chatter sender, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page) { public void list(Chatter sender, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page) {
final int TEAMS_PER_PAGE = 10; final int TEAMS_PER_PAGE = 10;