SteamWar/BungeeCore
Archiviert
13
2

Update TeamCommand
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2022-09-22 17:03:26 +02:00
Ursprung e1a713d52f
Commit 9628ff8ac7

Datei anzeigen

@ -129,6 +129,20 @@ public class TeamCommand extends SWCommand {
Message.send("TEAM_JOIN_JOINED", player, toJoin.getTeamName());
}
@Register("stepback")
public void stepBack(@Validator("notLeader") ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player);
Team team = Team.get(user.getTeam());
if (team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)) {
Message.send("TEAM_OTHER_LEADER_REQUIRED", player);
return;
}
user.setLeader(false);
Message.send("TEAM_STEP_BACK", player);
}
@Validator("noTeam")
private TypeValidator<ProxiedPlayer> noTeamValidator() {
return (sender, value, messageSender) -> {
@ -141,10 +155,41 @@ public class TeamCommand extends SWCommand {
};
}
@Validator("notInTeam")
private TypeValidator<ProxiedPlayer> notInTeamValidator() {
return (sender, value, messageSender) -> {
if (SteamwarUser.get(value).getTeam() != 0) {
return true;
} else {
messageSender.send("TEAM_NOT_IN_TEAM");
return false;
}
};
}
@Validator("notLeader")
private TypeValidator<ProxiedPlayer> notLeaderValidator() {
TypeValidator<ProxiedPlayer> notInTeam = notInTeamValidator();
return (sender, value, messageSender) -> {
if (!notInTeam.validate(sender, value, messageSender)) return false;
SteamwarUser steamwarUser = SteamwarUser.get(value);
if (!steamwarUser.isLeader()) {
messageSender.send("TEAM_NOT_LEADER");
return false;
}
return true;
};
}
@Validator("notDuringEvent")
private TypeValidator<ProxiedPlayer> notDuringEventValidator() {
return (sender, value, messageSender) -> {
return !notDuringEvent(value);
if (Event.get() == null) {
return true;
} else {
messageSender.send("TEAM_NOT_IN_EVENT");
return false;
}
};
}
@ -201,16 +246,34 @@ public class TeamCommand extends SWCommand {
@Validator("unusedKuerzel")
private TypeValidator<String> unusedTeamKuerzel() {
return (sender, value, messageSender) -> {
if (value.length() < 2 || value.length() > 4) {
messageSender.send("TEAM_KUERZEL_LENGHT");
return false;
}
Team team = Team.get(SteamwarUser.get((ProxiedPlayer) sender).getTeam());
return !checkTeamKuerzel((ProxiedPlayer) sender, team, value);
Team t = Team.get(value);
if (t != null && (team == null || t.getTeamId() != team.getTeamId())) {
messageSender.send("TEAM_KUERZEL_TAKEN");
return false;
}
return true;
};
}
@Validator("unusedName")
private TypeValidator<String> unusedTeamName() {
return (sender, value, messageSender) -> {
if (value.length() < 4 || value.length() > 15) {
messageSender.send("TEAM_NAME_LENGHT");
return false;
}
Team team = Team.get(SteamwarUser.get((ProxiedPlayer) sender).getTeam());
return !checkTeamName((ProxiedPlayer) sender, team, value);
Team t = Team.get(value);
if (t != null && t.getTeamId() != team.getTeamId()) {
messageSender.send("TEAM_NAME_TAKEN");
return false;
}
return true;
};
}
@ -229,9 +292,6 @@ public class TeamCommand extends SWCommand {
Team team = Team.get(user.getTeam());
switch (args[0].toLowerCase()) {
case "stepback":
stepBack(player,user,team);
break;
case "leave":
leave(player, user, team);
break;
@ -273,19 +333,6 @@ public class TeamCommand extends SWCommand {
}
}
private void stepBack(ProxiedPlayer player, SteamwarUser user, Team team) {
if(notLeader(player, user, team))
return;
if(team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){
Message.send("TEAM_OTHER_LEADER_REQUIRED", player);
return;
}
user.setLeader(false);
Message.send("TEAM_STEP_BACK", player);
}
private void leave(ProxiedPlayer player, SteamwarUser user, Team team) {
if (notInTeam(player, user))
return;
@ -703,7 +750,8 @@ public class TeamCommand extends SWCommand {
colors.add(new SWListInv.SWListEntry<>(item, stringSWListEntry.getObject()));
});
SWListInv<String> inv = new SWListInv<>(player, Message.parse("TEAM_COLOR_TITLE", player), colors, (click, element) -> {});
SWListInv<String> inv = new SWListInv<>(player, Message.parse("TEAM_COLOR_TITLE", player), colors, (click, element) -> {
});
inv.setCallback((click, element) -> {
inv.close();
team.setTeamColor(element);
@ -739,14 +787,6 @@ public class TeamCommand extends SWCommand {
return false;
}
private boolean unwantedInTeam(ProxiedPlayer player, SteamwarUser user){
if(user.getTeam() != 0){
Message.send("TEAM_IN_TEAM", player);
return true;
}
return false;
}
private boolean notInTeam(ProxiedPlayer player, SteamwarUser user) {
if (user.getTeam() == 0) {
Message.send("TEAM_NOT_IN_TEAM", player);