SteamWar/BungeeCore
Archiviert
13
2

Add TeamCommand MultiLang

Dieser Commit ist enthalten in:
Chaoscaot 2021-01-19 15:03:23 +01:00
Ursprung c0ff508f3d
Commit d20efc1a2f
2 geänderte Dateien mit 73 neuen und 36 gelöschten Zeilen

Datei anzeigen

@ -37,6 +37,7 @@ import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.time.Instant; import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import static de.steamwar.bungeecore.Storage.sessions; import static de.steamwar.bungeecore.Storage.sessions;
@ -397,38 +398,37 @@ public class TeamCommand extends BasicCommand {
private void info(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ private void info(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(args.length == 1 && user.getTeam() == 0){ if(args.length == 1 && user.getTeam() == 0){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§8/§eteam info §8[§eTeamname§8]"); Message.send("TEAM_INFO_SYNTAX", player);
return; return;
}else if(user.getTeam() == 0 || args.length == 2){ }else if(user.getTeam() == 0 || args.length == 2){
team = Team.get(args[1]); team = Team.get(args[1]);
} }
if(team == null){ if(team == null){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieses Team gibt es nicht"); Message.send("UNKNOWN_TEAM", player);
return; return;
} }
BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§" + team.getTeamColor() + team.getTeamKuerzel() + "§8]"); Message.sendPrefixless("TEAM_INFO_TEAM", player, team.getTeamName(), team.getTeamColor(), team.getTeamKuerzel());
BungeeCore.send(player, "§7Leader§8: " + playerName(SteamwarUser.get(team.getTeamLeader()))); Message.sendPrefixless("TEAM_INFO_LEADER", player, playerName(SteamwarUser.get(team.getTeamLeader())));
if(team.getMembers().size() > 1) { if(team.getMembers().size() > 1) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("§7Member§8: ");
List<Integer> members = team.getMembers(); List<Integer> members = team.getMembers();
for (int i : members) { for (int i : members) {
if (i == team.getTeamLeader()) if (i == team.getTeamLeader())
continue; continue;
sb.append(playerName(SteamwarUser.get(i))).append(" "); sb.append(playerName(SteamwarUser.get(i))).append(" ");
} }
BungeeCore.send(player, sb.toString()); Message.sendPrefixless("TEAM_INFO_MEMBER", player, sb.toString());
} }
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId()); Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
if(!events.isEmpty()){ if(!events.isEmpty()){
StringBuilder sb = new StringBuilder("§7Events§8: §e"); StringBuilder sb = new StringBuilder();
for(Event e : events) for(Event e : events)
sb.append(e.getEventName()).append(" "); sb.append(e.getEventName()).append(" ");
BungeeCore.send(player, sb.toString()); Message.sendPrefixless("TEAM_INFO_EVENTS", player, sb.toString());
} }
} }
@ -441,7 +441,7 @@ public class TeamCommand extends BasicCommand {
try{ try{
page = Integer.parseInt(args[1]); page = Integer.parseInt(args[1]);
}catch(NumberFormatException e){ }catch(NumberFormatException e){
BungeeCore.send(player, "§cKeine Seitenzahl angegeben"); Message.send("TEAM_LIST_NOT_PAGE", player);
return; return;
} }
}else }else
@ -450,32 +450,31 @@ public class TeamCommand extends BasicCommand {
List<Team> all = Team.getAll(); List<Team> all = Team.getAll();
final int lastPage = ((all.size() - 1) / 10) + 1; final int lastPage = ((all.size() - 1) / 10) + 1;
if(page < 1 || page > lastPage){ if(page < 1 || page > lastPage){
BungeeCore.send(player, "§cUngültige Seitenzahl angegeben"); Message.send("TEAM_LIST_UNKNOWN_PAGE", player);
return; return;
} }
BungeeCore.send(player, "§7§lTeamliste §7" + page + "§8/§7" + lastPage); Message.sendPrefixless("TEAM_LIST_HEADER", player, page, lastPage);
for(int i = (page-1) * TEAMS_PER_PAGE; i < (page-1) * TEAMS_PER_PAGE + TEAMS_PER_PAGE && i < all.size(); i++){ for(int i = (page-1) * TEAMS_PER_PAGE; i < (page-1) * TEAMS_PER_PAGE + TEAMS_PER_PAGE && i < all.size(); i++){
Team tm = all.get(i); Team tm = all.get(i);
BungeeCore.send(player,
"§" + tm.getTeamColor() + tm.getTeamKuerzel() + " §e" + tm.getTeamName() + " §8[§7" + SteamwarUser.get(tm.getTeamLeader()).getUserName() + "§8]", Message.sendPrefixless("TEAM_LIST_TEAM", player, Message.parse("TEAM_LIST_TEAM_HOVER", player),
"§7Teaminfo", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + tm.getTeamKuerzel()), tm.getTeamColor(), tm.getTeamKuerzel(), tm.getTeamName(), SteamwarUser.get(tm.getTeamLeader()).getUserName());
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + tm.getTeamKuerzel()));
} }
TextComponent beforePage = new TextComponent("««"); TextComponent beforePage = new TextComponent("««");
if(page > 1){ if(page > 1){
beforePage.setColor(ChatColor.YELLOW); beforePage.setColor(ChatColor.YELLOW);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create())); beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.parse("TEAM_LIST_PREV", player)).create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team list " + (page - 1))); beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team list " + (page - 1)));
}else }else
beforePage.setColor(ChatColor.DARK_GRAY); beforePage.setColor(ChatColor.DARK_GRAY);
TextComponent nextPage = new TextComponent(" Seite »»"); TextComponent nextPage = new TextComponent(" " + Message.parse("TEAM_LIST_PAGE", player) +" »»");
if(page < lastPage){ if(page < lastPage){
nextPage.setColor(ChatColor.YELLOW); nextPage.setColor(ChatColor.YELLOW);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create())); nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.parse("TEAM_LIST_NEXT", player)).create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team list " + (page + 1))); nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team list " + (page + 1)));
}else }else
nextPage.setColor(ChatColor.DARK_GRAY); nextPage.setColor(ChatColor.DARK_GRAY);
@ -489,12 +488,13 @@ public class TeamCommand extends BasicCommand {
return; return;
if(args.length < 2){ if(args.length < 2){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§8/§eteam event §8[§eEvent§8] - §7um daran teilzunehmen"); Message.send("TEAM_EVENT_SYNTAX", player);
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId()); Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
if(!events.isEmpty()){ if(!events.isEmpty()){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Dein Team nimmt an folgenden Events teil§8:"); Message.send("TEAM_EVENT_HEADER", player);
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
for(Event e : events) for(Event e : events)
BungeeCore.send(player, "§7" + e.getStart().toLocalDateTime().format(EventCommand.DATE_FORMAT) + "§8: §e" + e.getEventName()); Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
} }
return; return;
} }
@ -507,22 +507,22 @@ public class TeamCommand extends BasicCommand {
Event event = Event.get(args[1]); Event event = Event.get(args[1]);
if(event == null){ if(event == null){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieses Event gibt es nicht"); Message.send("TEAM_EVENT_NO_EVENT", player);
return; return;
} }
if(Instant.now().isAfter(event.getEnd().toInstant())){ if(Instant.now().isAfter(event.getEnd().toInstant())){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieses Event ist bereits vorbei"); Message.send("TEAM_EVENT_OVER", player);
return; return;
} }
if(TeamTeilnahme.nimmtTeil(team.getTeamId(), event.getEventID())){ if(TeamTeilnahme.nimmtTeil(team.getTeamId(), event.getEventID())){
TeamTeilnahme.notTeilnehmen(team.getTeamId(), event.getEventID()); TeamTeilnahme.notTeilnehmen(team.getTeamId(), event.getEventID());
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Dein Team nimmt nicht mehr am Event teil"); Message.send("TEAM_EVENT_LEFT", player);
}else{ }else{
TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID()); TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID());
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Dein Team nimmt nun am Event §e" + event.getEventName() + " §7 teil!"); Message.send("TEAM_EVENT_JOINED", player, event.getEventName());
BungeeCore.send(player, "§7Um die Teilnahme abzusagen, wiederhole den Befehl"); Message.sendPrefixless("TEAM_EVENT_HOW_TO_LEAVE", player);
} }
} }
@ -540,7 +540,7 @@ public class TeamCommand extends BasicCommand {
colors.add(new SWListInv.SWListEntry<>(item, stringSWListEntry.getObject())); colors.add(new SWListInv.SWListEntry<>(item, stringSWListEntry.getObject()));
}); });
SWListInv<String> inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> {}); SWListInv<String> inv = new SWListInv<>(player, Message.parse("TEAM_COLOR_TITLE", player), colors, (click, element) -> {});
inv.setCallback((click, element) -> { inv.setCallback((click, element) -> {
inv.close(); inv.close();
team.setTeamColor(element); team.setTeamColor(element);
@ -550,13 +550,13 @@ public class TeamCommand extends BasicCommand {
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){ private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
if(arg.length() < 4 || arg.length() > 15){ if(arg.length() < 4 || arg.length() > 15){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen"); Message.send("TEAM_NAME_LENGHT", player);
return true; return true;
} }
Team t = Team.get(arg); Team t = Team.get(arg);
if(t != null && t.getTeamId() != team.getTeamId()){ if(t != null && t.getTeamId() != team.getTeamId()){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEs gibt bereits ein Team mit diesem Namen"); Message.send("TEAM_NAME_TAKEN", player);
return true; return true;
} }
return false; return false;
@ -564,13 +564,13 @@ public class TeamCommand extends BasicCommand {
private boolean checkTeamKuerzel(ProxiedPlayer player, Team team, String arg){ private boolean checkTeamKuerzel(ProxiedPlayer player, Team team, String arg){
if(arg.length() < 2 || arg.length() > 4){ if(arg.length() < 2 || arg.length() > 4){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin Teamkürzel muss aus 2 bis 4 Buchstaben bestehen"); Message.send("TEAM_KUERZEL_LENGHT", player);
return true; return true;
} }
Team t = Team.get(arg); Team t = Team.get(arg);
if(t != null && (team == null || t.getTeamId() != team.getTeamId())){ if(t != null && (team == null || t.getTeamId() != team.getTeamId())){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEs gibt bereits ein Team mit diesem Namen"); Message.send("TEAM_KUERZEL_TAKEN", player);
return true; return true;
} }
return false; return false;
@ -578,7 +578,7 @@ public class TeamCommand extends BasicCommand {
private boolean unwantedInTeam(ProxiedPlayer player, SteamwarUser user){ private boolean unwantedInTeam(ProxiedPlayer player, SteamwarUser user){
if(user.getTeam() != 0){ if(user.getTeam() != 0){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu bist bereits in einem Team"); Message.send("TEAM_IN_TEAM", player);
return true; return true;
} }
return false; return false;
@ -586,7 +586,7 @@ public class TeamCommand extends BasicCommand {
private boolean notInTeam(ProxiedPlayer player, SteamwarUser user){ private boolean notInTeam(ProxiedPlayer player, SteamwarUser user){
if(user.getTeam() == 0){ if(user.getTeam() == 0){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu bist in keinem Team"); Message.send("TEAM_NOT_IN_TEAM", player);
return true; return true;
} }
return false; return false;
@ -596,7 +596,7 @@ public class TeamCommand extends BasicCommand {
if(notInTeam(player, user)) if(notInTeam(player, user))
return true; return true;
if(team.getTeamLeader() != user.getId()){ if(team.getTeamLeader() != user.getId()){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu bist nicht der Teamleader"); Message.send("TEAM_NOT_LEADER", player);
return true; return true;
} }
return false; return false;
@ -604,7 +604,7 @@ public class TeamCommand extends BasicCommand {
private boolean notDuringEvent(ProxiedPlayer player){ private boolean notDuringEvent(ProxiedPlayer player){
if(Event.get() != null){ if(Event.get() != null){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDies ist während eines Events nicht möglich"); Message.send("TEAM_NOT_IN_EVENT", player);
return true; return true;
} }
return false; return false;

Datei anzeigen

@ -3,6 +3,7 @@ SPACER=
UNKNOWN_COMMAND=§cUnbekannter Befehl. UNKNOWN_COMMAND=§cUnbekannter Befehl.
UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht. UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht.
UNKNOWN_TEAM=§cDieses Team gibt es nicht
INVALID_TIME=§cUngültige Zeitangabe. INVALID_TIME=§cUngültige Zeitangabe.
JOIN_PLAYER_BLOCK=§cDu kannst diesem Spieler derzeit nicht folgen. JOIN_PLAYER_BLOCK=§cDu kannst diesem Spieler derzeit nicht folgen.
@ -291,6 +292,10 @@ TC_NO_TEAM=§cDu bist in keinem Team
TC_FORMAT=§8TC §e{0}§8» §r{1} TC_FORMAT=§8TC §e{0}§8» §r{1}
#TeamCommand #TeamCommand
TEAM_IN_TEAM=§cDu bist bereits in einem Team
TEAM_NOT_IN_TEAM=§cDu bist in keinem Team
TEAM_NOT_LEADER=§cDu bist nicht der Teamleader
TEAM_NOT_IN_EVENT=§cDies ist während eines Events nicht möglich
TEAM_HELP_HEADER=§7Mit §e/team §7verwaltest du dein Team TEAM_HELP_HEADER=§7Mit §e/team §7verwaltest du dein Team
TEAM_HELP_LIST=§8/§eteam list §8- §7Liste alle Teams auf TEAM_HELP_LIST=§8/§eteam list §8- §7Liste alle Teams auf
TEAM_HELP_INFO=§8/§eteam info §8- §7Informiere dich über ein Team TEAM_HELP_INFO=§8/§eteam info §8- §7Informiere dich über ein Team
@ -342,10 +347,14 @@ TEAM_REMOVE_REMOVED_TARGET=§cDu wurdest aus dem Team entfernt
#Team Kuerzel #Team Kuerzel
TEAM_KUERZEL_SYNTAX=§8/§eteam changekuerzel §8[§eTeamkürzel§8] TEAM_KUERZEL_SYNTAX=§8/§eteam changekuerzel §8[§eTeamkürzel§8]
TEAM_KUERZEL_CHANGED=§7Du hast das Kürzel des Teams geändert! TEAM_KUERZEL_CHANGED=§7Du hast das Kürzel des Teams geändert!
TEAM_KUERZEL_LENGHT=§cEin Teamkürzel muss aus 2 bis 4 Buchstaben bestehen
TEAM_KUERZEL_TAKEN=§cEs gibt bereits ein Team mit diesem Namen
#Team Name #Team Name
TEAM_NAME_SYNTAX=§8/§eteam changename §8[§eTeamname§8] TEAM_NAME_SYNTAX=§8/§eteam changename §8[§eTeamname§8]
TEAM_NAME_CHANGED=§7Du hast das Team umbenannt! TEAM_NAME_CHANGED=§7Du hast das Team umbenannt!
TEAM_NAME_LENGHT=§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen
TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen
#Team Leader #Team Leader
TEAM_LEADER_SYNTAX=§cBitte gib ein Teammitglied an TEAM_LEADER_SYNTAX=§cBitte gib ein Teammitglied an
@ -354,3 +363,31 @@ TEAM_LEADER_NOT_MEMBER=§cDer Spieler ist nicht in deinem Team
TEAM_LEADER_CHANGED=§7Du hast den Spieler §e{0} §7zum Leader gemacht! TEAM_LEADER_CHANGED=§7Du hast den Spieler §e{0} §7zum Leader gemacht!
#Team Info #Team Info
TEAM_INFO_SYNTAX=§8/§eteam info §8[§eTeamname§8]
TEAM_INFO_TEAM=§7Team §e{0} §8[§{1}{2}§8]
TEAM_INFO_LEADER=§7Leader§8: {0}
TEAM_INFO_MEMBER=§7Member§8: {0}
TEAM_INFO_EVENTS=§7Events§8: §e{0}
#Team List
TEAM_LIST_NOT_PAGE=§cKeine Seitenzahl angegeben
TEAM_LIST_UNKNOWN_PAGE=§cUngültige Seitenzahl angegeben
TEAM_LIST_HEADER=§7§lTeamliste §7{0}§8/§7{1}
TEAM_LIST_TEAM=§{0}{1} §e{2} §8[§7{3}}§8]
TEAM_LIST_TEAM_HOVER=§7Teaminfo
TEAM_LIST_PAGE=Seite
TEAM_LIST_NEXT=§eNächste Seite
TEAM_LIST_PREV=§eVorherige Seite
#Team Event
TEAM_EVENT_SYNTAX=§8/§eteam event §8[§eEvent§8] - §7um daran teilzunehmen
TEAM_EVENT_HEADER=§7Dein Team nimmt an folgenden Events teil§8:
TEAM_EVENT_EVENT=§7{0}§8: §e{1}
TEAM_EVENT_NO_EVENT=§cDieses Event gibt es nicht
TEAM_EVENT_OVER=§cDieses Event ist bereits vorbei
TEAM_EVENT_LEFT=§7Dein Team nimmt nicht mehr am Event teil
TEAM_EVENT_JOINED=§7Dein Team nimmt nun am Event §e{0} §7 teil!
TEAM_EVENT_HOW_TO_LEAVE=§7Um die Teilnahme abzusagen, wiederhole den Befehl
#Team Color
TEAM_COLOR_TITLE=§6Farbe wählen