geforkt von SteamWar/BungeeCore
Update TeamCommand
Dieser Commit ist enthalten in:
Ursprung
e1a713d52f
Commit
9628ff8ac7
@ -129,6 +129,20 @@ public class TeamCommand extends SWCommand {
|
|||||||
Message.send("TEAM_JOIN_JOINED", player, toJoin.getTeamName());
|
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")
|
@Validator("noTeam")
|
||||||
private TypeValidator<ProxiedPlayer> noTeamValidator() {
|
private TypeValidator<ProxiedPlayer> noTeamValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
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")
|
@Validator("notDuringEvent")
|
||||||
private TypeValidator<ProxiedPlayer> notDuringEventValidator() {
|
private TypeValidator<ProxiedPlayer> notDuringEventValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
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")
|
@Validator("unusedKuerzel")
|
||||||
private TypeValidator<String> unusedTeamKuerzel() {
|
private TypeValidator<String> unusedTeamKuerzel() {
|
||||||
return (sender, value, messageSender) -> {
|
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());
|
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")
|
@Validator("unusedName")
|
||||||
private TypeValidator<String> unusedTeamName() {
|
private TypeValidator<String> unusedTeamName() {
|
||||||
return (sender, value, messageSender) -> {
|
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());
|
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());
|
Team team = Team.get(user.getTeam());
|
||||||
|
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "stepback":
|
|
||||||
stepBack(player,user,team);
|
|
||||||
break;
|
|
||||||
case "leave":
|
case "leave":
|
||||||
leave(player, user, team);
|
leave(player, user, team);
|
||||||
break;
|
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) {
|
private void leave(ProxiedPlayer player, SteamwarUser user, Team team) {
|
||||||
if (notInTeam(player, user))
|
if (notInTeam(player, user))
|
||||||
return;
|
return;
|
||||||
@ -703,7 +750,8 @@ public class TeamCommand extends SWCommand {
|
|||||||
colors.add(new SWListInv.SWListEntry<>(item, stringSWListEntry.getObject()));
|
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.setCallback((click, element) -> {
|
||||||
inv.close();
|
inv.close();
|
||||||
team.setTeamColor(element);
|
team.setTeamColor(element);
|
||||||
@ -739,14 +787,6 @@ public class TeamCommand extends SWCommand {
|
|||||||
return false;
|
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) {
|
private boolean notInTeam(ProxiedPlayer player, SteamwarUser user) {
|
||||||
if (user.getTeam() == 0) {
|
if (user.getTeam() == 0) {
|
||||||
Message.send("TEAM_NOT_IN_TEAM", player);
|
Message.send("TEAM_NOT_IN_TEAM", player);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren