SteamWar/BungeeCore
Archiviert
13
2

Update TeamCommand (not finished)
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2023-01-23 18:15:37 +01:00
Ursprung d559c61846
Commit 561289b5a6
3 geänderte Dateien mit 33 neuen und 94 gelöschten Zeilen

Datei anzeigen

@ -186,7 +186,7 @@ public class TeamCommand extends SWCommand {
public void stepBack(ProxiedPlayer player) { public void stepBack(ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if(team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){ if(team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){
@ -221,22 +221,17 @@ public class TeamCommand extends SWCommand {
} }
@Register("invite") @Register(value = "invite", description = "TEAM_INVITE_USAGE")
public void invite(ProxiedPlayer player, String... args){ public void invite(ProxiedPlayer player, String toInvite){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if(notDuringEvent(player)) if(notDuringEvent(player))
return; return;
if(args.length != 2){ SteamwarUser target = SteamwarUser.get(toInvite);
Message.send("TEAM_INVITE_USAGE", player);
return;
}
SteamwarUser target = SteamwarUser.get(args[1]);
if(target == null){ if(target == null){
Message.send("TEAM_INVITE_NO_PLAYER", player); Message.send("TEAM_INVITE_NO_PLAYER", player);
return; return;
@ -255,25 +250,20 @@ public class TeamCommand extends SWCommand {
teamInvitations.get(target.getId()).add(team.getTeamId()); teamInvitations.get(target.getId()).add(team.getTeamId());
Message.send("TEAM_INVITE_INVITED", player, args[1]); Message.send("TEAM_INVITE_INVITED", player, toInvite);
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid()); ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
if(p != null) if(p != null)
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName()); Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
} }
@Register("remove") @Register(value = "remove", description = "TEAM_REMOVE_USAGE")
public void remove(ProxiedPlayer player, String... args){ public void remove(ProxiedPlayer player, String toRemove){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if(args.length != 2){ SteamwarUser target = SteamwarUser.get(toRemove);
Message.send("TEAM_REMOVE_USAGE", player);
return;
}
SteamwarUser target = SteamwarUser.get(args[1]);
if(target == null){ if(target == null){
Message.send("TEAM_REMOVE_NOT_PLAYER", player); Message.send("TEAM_REMOVE_NOT_PLAYER", player);
return; return;
@ -312,7 +302,7 @@ public class TeamCommand extends SWCommand {
public void changekuerzel(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGHT") String kuerzel){ public void changekuerzel(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGHT") String kuerzel){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if(notDuringEvent(player)) if(notDuringEvent(player))
@ -326,10 +316,10 @@ public class TeamCommand extends SWCommand {
} }
@Register(value = "changename", description = "TEAM_NAME_USAGE") @Register(value = "changename", description = "TEAM_NAME_USAGE")
public void changename(ProxiedPlayer player, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGHT") String name){ public void changename(ProxiedPlayer player, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if(notDuringEvent(player)) if(notDuringEvent(player))
@ -342,24 +332,18 @@ public class TeamCommand extends SWCommand {
Message.send("TEAM_NAME_CHANGED", player); Message.send("TEAM_NAME_CHANGED", player);
} }
@Register("promote") @Register(value = "promote", description = "TEAM_LEADER_USAGE")
public void promote(ProxiedPlayer player, String... args){ public void promote(ProxiedPlayer player, String toPromote){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); if(notLeader(player, user))
if(notLeader(player, user, team))
return; return;
if(notDuringEvent(player)) if(notDuringEvent(player))
return; return;
if(args.length < 2){ SteamwarUser target = SteamwarUser.get(toPromote);
Message.send("TEAM_LEADER_USAGE", player);
return;
}
SteamwarUser target = SteamwarUser.get(args[1]);
if(target == null){ if(target == null){
Message.send("TEAM_LEADER_NOT_USER", player, args[1]); Message.send("TEAM_LEADER_NOT_USER", player, toPromote);
return; return;
} }
@ -369,7 +353,7 @@ public class TeamCommand extends SWCommand {
} }
target.setLeader(true); target.setLeader(true);
Message.send("TEAM_LEADER_PROMOTED", player, args[1]); Message.send("TEAM_LEADER_PROMOTED", player, toPromote);
} }
private String playerName(SteamwarUser user){ private String playerName(SteamwarUser user){
@ -421,23 +405,9 @@ public class TeamCommand extends SWCommand {
} }
@Register("list") @Register("list")
public void list(ProxiedPlayer player, String... args){ public void list(ProxiedPlayer player, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
final int TEAMS_PER_PAGE = 10; final int TEAMS_PER_PAGE = 10;
int page;
if(args.length > 1){
try{
page = Integer.parseInt(args[1]);
}catch(NumberFormatException e){
Message.send("TEAM_LIST_NOT_PAGE", player);
return;
}
}else
page = 1;
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){
@ -493,7 +463,7 @@ public class TeamCommand extends SWCommand {
return; return;
} }
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if(notDuringEvent(player)) if(notDuringEvent(player))
@ -569,20 +539,16 @@ public class TeamCommand extends SWCommand {
*/ */
} }
@Register("server") @Register(value = "server", description = "TEAM_SERVER_USAGE")
public void server(ProxiedPlayer player, String[] args){ public void server(ProxiedPlayer player, String server, @Min(intValue = 1) @Max(intValue = 65535) @ErrorMessage("TEAM_SERVER_PORT_INVALID") int port){
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) { if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
return; return;
} }
if (args.length < 2) {
Message.send("TEAM_SERVER_USAGE", player);
return;
}
String server = args[1];
try { try {
if (isLocalhost(InetAddress.getByName(server))) { if (isLocalhost(InetAddress.getByName(server))) {
Message.send("TEAM_SERVER_ADDRESS_INVALID", player); Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
@ -592,19 +558,7 @@ public class TeamCommand extends SWCommand {
Message.send("TEAM_SERVER_ADDRESS_INVALID", player); Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
return; return;
} }
int port = 25565;
if (args.length == 3) {
try {
port = Integer.parseInt(args[2]);
if (port < 1 || port > 65535) {
Message.send("TEAM_SERVER_PORT_INVALID", player);
return;
}
} catch (NumberFormatException e) {
Message.send("TEAM_SERVER_PORT_INVALID", player);
return;
}
}
team.setAddress(server); team.setAddress(server);
team.setPort(port); team.setPort(port);
Storage.teamServers.remove(team.getTeamId()); Storage.teamServers.remove(team.getTeamId());
@ -628,7 +582,7 @@ public class TeamCommand extends SWCommand {
public void changeColor(ProxiedPlayer player) { public void changeColor(ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if(notLeader(player, user, team)) if(notLeader(player, user))
return; return;
if(notDuringEvent(player)) if(notDuringEvent(player))
@ -683,7 +637,7 @@ public class TeamCommand extends SWCommand {
return false; return false;
} }
private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team){ private boolean notLeader(ProxiedPlayer player, SteamwarUser user){
if(notInTeam(player, user)) if(notInTeam(player, user))
return true; return true;
if(!user.isLeader()){ if(!user.isLeader()){
@ -704,22 +658,7 @@ public class TeamCommand extends SWCommand {
// @Override // @Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args){ public Iterable<String> onTabComplete(CommandSender commandSender, String[] args){
List<String> tab = new ArrayList<>(); List<String> tab = new ArrayList<>();
if(args.length == 1){ if(args.length == 2){
tab.add("create");
tab.add("join");
tab.add("invite");
tab.add("stepback");
tab.add("leave");
tab.add("info");
tab.add("remove");
tab.add("event");
tab.add("changekuerzel");
tab.add("changename");
tab.add("promote");
tab.add("changecolor");
tab.add("tp");
tab.add("server");
}else if(args.length == 2){
if(args[1].equalsIgnoreCase("event")){ if(args[1].equalsIgnoreCase("event")){
List<Event> coming = Event.getComing(); List<Event> coming = Event.getComing();
coming.forEach(event -> tab.add(event.getEventName())); coming.forEach(event -> tab.add(event.getEventName()));

Datei anzeigen

@ -444,13 +444,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cYou were removed from the team.
#Team Kuerzel #Team Kuerzel
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eshortcut§8] TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eshortcut§8]
TEAM_KUERZEL_CHANGED=§7You changed your teams shortcut! TEAM_KUERZEL_CHANGED=§7You changed your teams shortcut!
TEAM_KUERZEL_LENGHT=§cA team shortcut has to consist of 2 to 4 characters. TEAM_KUERZEL_LENGTH=§cA team shortcut has to consist of 2 to 4 characters.
TEAM_KUERZEL_TAKEN=§cThere is already a team with that shortcut. TEAM_KUERZEL_TAKEN=§cThere is already a team with that shortcut.
#Team Name #Team Name
TEAM_NAME_USAGE=§8/§7team changename §8[§eteam name§8] TEAM_NAME_USAGE=§8/§7team changename §8[§eteam name§8]
TEAM_NAME_CHANGED=§7You have renamed your team! TEAM_NAME_CHANGED=§7You have renamed your team!
TEAM_NAME_LENGHT=§cA team name has to consist of 4 to 15 characters. TEAM_NAME_LENGTH=§cA team name has to consist of 4 to 15 characters.
TEAM_NAME_TAKEN=§cThere is already a team with that name. TEAM_NAME_TAKEN=§cThere is already a team with that name.
#Team Leader #Team Leader

Datei anzeigen

@ -422,13 +422,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cDu wurdest aus dem Team entfernt.
#Team Kuerzel #Team Kuerzel
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eTeamkürzel§8] TEAM_KUERZEL_USAGE=§8/§7team 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_LENGTH=§cEin Teamkürzel muss aus 2 bis 4 Buchstaben bestehen.
TEAM_KUERZEL_TAKEN=§cEs gibt bereits ein Team mit diesem Namen. TEAM_KUERZEL_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
#Team Name #Team Name
TEAM_NAME_USAGE=§8/§7team changename §8[§eTeamname§8] TEAM_NAME_USAGE=§8/§7team 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_LENGTH=§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen.
TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen. TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
#Team Leader #Team Leader