|
|
@ -24,6 +24,9 @@ import de.steamwar.bungeecore.Storage;
|
|
|
|
import de.steamwar.bungeecore.inventory.SWItem;
|
|
|
|
import de.steamwar.bungeecore.inventory.SWItem;
|
|
|
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
|
|
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
|
|
|
import de.steamwar.bungeecore.sql.*;
|
|
|
|
import de.steamwar.bungeecore.sql.*;
|
|
|
|
|
|
|
|
import de.steamwar.command.SWCommand;
|
|
|
|
|
|
|
|
import de.steamwar.command.TypeMapper;
|
|
|
|
|
|
|
|
import de.steamwar.command.TypeValidator;
|
|
|
|
import de.steamwar.messages.ChatSender;
|
|
|
|
import de.steamwar.messages.ChatSender;
|
|
|
|
import net.md_5.bungee.BungeeCord;
|
|
|
|
import net.md_5.bungee.BungeeCord;
|
|
|
|
import net.md_5.bungee.api.ChatColor;
|
|
|
|
import net.md_5.bungee.api.ChatColor;
|
|
|
@ -41,15 +44,12 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
|
|
|
|
import java.net.*;
|
|
|
|
import java.net.*;
|
|
|
|
import java.time.Instant;
|
|
|
|
import java.time.Instant;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static de.steamwar.bungeecore.Storage.teamInvitations;
|
|
|
|
import static de.steamwar.bungeecore.Storage.teamInvitations;
|
|
|
|
|
|
|
|
|
|
|
|
public class TeamCommand extends BasicCommand {
|
|
|
|
public class TeamCommand extends SWCommand {
|
|
|
|
|
|
|
|
|
|
|
|
private static final List<SWListInv.SWListEntry<String>> COLOR_CODES = new ArrayList<>();
|
|
|
|
private static final List<SWListInv.SWListEntry<String>> COLOR_CODES = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
@ -80,64 +80,238 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
super("team", "");
|
|
|
|
super("team", "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void help(CommandSender sender){
|
|
|
|
@Register(help = true)
|
|
|
|
Message.send("TEAM_HELP_HEADER", sender);
|
|
|
|
public void help(ProxiedPlayer player, String... args) {
|
|
|
|
Message.send("TEAM_HELP_LIST", sender);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_INFO", sender);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_TP", sender);
|
|
|
|
|
|
|
|
if(!(sender instanceof ProxiedPlayer))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
|
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
if(user.getTeam() == 0) {
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_CREATE", sender);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_JOIN", sender);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_CHAT", sender);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_EVENT", sender);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_LEAVE", sender);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(user.isLeader()){
|
|
|
|
Message.send("TEAM_HELP_HEADER", player);
|
|
|
|
Message.send("TEAM_HELP_INVITE", sender);
|
|
|
|
Message.send("TEAM_HELP_LIST", player);
|
|
|
|
Message.send("TEAM_HELP_REMOVE", sender);
|
|
|
|
Message.send("TEAM_HELP_INFO", player);
|
|
|
|
Message.send("TEAM_HELP_KUERZEL", sender);
|
|
|
|
Message.send("TEAM_HELP_TP", player);
|
|
|
|
Message.send("TEAM_HELP_NAME", sender);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_COLOR", sender);
|
|
|
|
if (user.getTeam() == 0) {
|
|
|
|
Message.send("TEAM_HELP_LEADER", sender);
|
|
|
|
Message.send("TEAM_HELP_CREATE", player);
|
|
|
|
Message.send("TEAM_HELP_STEP_BACK", sender);
|
|
|
|
Message.send("TEAM_HELP_JOIN", player);
|
|
|
|
Message.send("TEAM_HELP_SERVER", sender);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_CHAT", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_EVENT", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_LEAVE", player);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user.isLeader()) {
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_INVITE", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_REMOVE", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_KUERZEL", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_NAME", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_COLOR", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_LEADER", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_STEP_BACK", player);
|
|
|
|
|
|
|
|
Message.send("TEAM_HELP_SERVER", player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register(value = "create", description = "TEAM_CREATE_USAGE")
|
|
|
|
|
|
|
|
public void createTeam(@Validator("noTeam") ProxiedPlayer player, @Validator("unusedKuerzel") String kuerzel, @Validator("unusedName") String name) {
|
|
|
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player);
|
|
|
|
|
|
|
|
Team.create(kuerzel, name);
|
|
|
|
|
|
|
|
user.setTeam(Team.get(kuerzel).getTeamId());
|
|
|
|
|
|
|
|
user.setLeader(true);
|
|
|
|
|
|
|
|
Message.send("TEAM_CREATE_CREATED", player, name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register(value = "join", description = "TEAM_JOIN_USAGE")
|
|
|
|
|
|
|
|
public void joinTeam(@Validator("teamJoin") ProxiedPlayer player, @Mapper("teamJoinTypeMapper") Team toJoin) {
|
|
|
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player);
|
|
|
|
|
|
|
|
user.setTeam(toJoin.getTeamId());
|
|
|
|
|
|
|
|
teamInvitations.remove(user.getId());
|
|
|
|
|
|
|
|
Message.send("TEAM_JOIN_JOINED", player, toJoin.getTeamName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register("stepback")
|
|
|
|
|
|
|
|
public void stepBack(@Validator("isLeader") 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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register("leave")
|
|
|
|
|
|
|
|
public void leave(@Validator("inTeam") ProxiedPlayer player) {
|
|
|
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player);
|
|
|
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int teamSize = team.size();
|
|
|
|
|
|
|
|
if (teamSize > 1 && user.isLeader() && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)) {
|
|
|
|
|
|
|
|
Message.send("TEAM_OTHER_LEADER_REQUIRED", player);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.setTeam(0);
|
|
|
|
|
|
|
|
if (teamSize == 1) team.disband(user);
|
|
|
|
|
|
|
|
Message.send("TEAM_LEAVE_LEFT", player);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Validator(value = "noTeam", local = true)
|
|
|
|
|
|
|
|
private TypeValidator<ProxiedPlayer> noTeamValidator() {
|
|
|
|
|
|
|
|
return (sender, value, messageSender) -> {
|
|
|
|
|
|
|
|
if (SteamwarUser.get(value).getTeam() == 0) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_IN_TEAM");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Validator(value = "inTeam", local = true)
|
|
|
|
|
|
|
|
private TypeValidator<ProxiedPlayer> inTeamValidator() {
|
|
|
|
|
|
|
|
return (sender, value, messageSender) -> {
|
|
|
|
|
|
|
|
if (SteamwarUser.get(value).getTeam() != 0) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_NOT_IN_TEAM");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Validator(value = "isLeader", local = true)
|
|
|
|
|
|
|
|
private TypeValidator<ProxiedPlayer> isLeaderValidator() {
|
|
|
|
|
|
|
|
TypeValidator<ProxiedPlayer> inTeam = inTeamValidator();
|
|
|
|
|
|
|
|
return (sender, value, messageSender) -> {
|
|
|
|
|
|
|
|
if (!inTeam.validate(sender, value, messageSender)) return false;
|
|
|
|
|
|
|
|
SteamwarUser steamwarUser = SteamwarUser.get(value);
|
|
|
|
|
|
|
|
if (!steamwarUser.isLeader()) {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_NOT_LEADER");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Validator(value = "notDuringEvent", local = true)
|
|
|
|
|
|
|
|
private TypeValidator<ProxiedPlayer> notDuringEventValidator() {
|
|
|
|
|
|
|
|
return (sender, value, messageSender) -> {
|
|
|
|
|
|
|
|
if (Event.get() == null) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_NOT_IN_EVENT");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Validator(value = "teamJoin", local = true)
|
|
|
|
|
|
|
|
private TypeValidator<ProxiedPlayer> teamJoinValidator() {
|
|
|
|
|
|
|
|
TypeValidator<ProxiedPlayer> noTeam = noTeamValidator();
|
|
|
|
|
|
|
|
TypeValidator<ProxiedPlayer> notDuringEvent = notDuringEventValidator();
|
|
|
|
|
|
|
|
return (sender, value, messageSender) -> {
|
|
|
|
|
|
|
|
if (!noTeam.validate(sender, value, messageSender)) return false;
|
|
|
|
|
|
|
|
if (!notDuringEvent.validate(sender, value, messageSender)) return false;
|
|
|
|
|
|
|
|
if (!teamInvitations.containsKey(SteamwarUser.get(value).getId())) {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_JOIN_NO_INVITATION");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Mapper(value = "teamJoinTypeMapper", local = true)
|
|
|
|
|
|
|
|
private TypeMapper<Team> teamJoinTypeMapper() {
|
|
|
|
|
|
|
|
return new TypeMapper<Team>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Team map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
|
|
|
|
|
|
SteamwarUser user = SteamwarUser.get((ProxiedPlayer) commandSender);
|
|
|
|
|
|
|
|
List<Integer> invs = teamInvitations.get(user.getId());
|
|
|
|
|
|
|
|
if (invs.isEmpty()) return null;
|
|
|
|
|
|
|
|
if (s.equals("") && invs.size() == 1) {
|
|
|
|
|
|
|
|
return Team.get(invs.get(0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i : invs) {
|
|
|
|
|
|
|
|
Team team = Team.get(i);
|
|
|
|
|
|
|
|
if (team.getTeamName().equals(s)) return team;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean validate(CommandSender sender, Team value, MessageSender messageSender) {
|
|
|
|
|
|
|
|
if (value == null) {
|
|
|
|
|
|
|
|
SteamwarUser user = SteamwarUser.get((ProxiedPlayer) sender);
|
|
|
|
|
|
|
|
List<Integer> invs = teamInvitations.get(user.getId());
|
|
|
|
|
|
|
|
if (invs.isEmpty()) {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_JOIN_NO_INVITE");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_JOIN_NOT_BY_TEAM");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
|
|
|
|
|
|
|
SteamwarUser user = SteamwarUser.get((ProxiedPlayer) sender);
|
|
|
|
|
|
|
|
return teamInvitations.get(user.getId()).stream().map(Team::get).map(Team::getTeamName).collect(Collectors.toList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Validator(value = "unusedKuerzel", local = true)
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
Team t = Team.get(value);
|
|
|
|
|
|
|
|
if (t != null && (team == null || t.getTeamId() != team.getTeamId())) {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_KUERZEL_TAKEN");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Validator(value = "unusedName", local = true)
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
Team t = Team.get(value);
|
|
|
|
|
|
|
|
if (t != null && t.getTeamId() != team.getTeamId()) {
|
|
|
|
|
|
|
|
messageSender.send("TEAM_NAME_TAKEN");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void execute(CommandSender sender, String[] args){
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
|
|
|
if(args.length < 1){
|
|
|
|
if (args.length < 1) {
|
|
|
|
help(sender);
|
|
|
|
help(sender);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!(sender instanceof ProxiedPlayer))
|
|
|
|
if (!(sender instanceof ProxiedPlayer))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
|
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
|
|
|
|
|
|
|
switch(args[0].toLowerCase()){
|
|
|
|
switch (args[0].toLowerCase()) {
|
|
|
|
case "create":
|
|
|
|
|
|
|
|
create(player, user, team, args);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "join":
|
|
|
|
|
|
|
|
join(player, user, args);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "stepback":
|
|
|
|
|
|
|
|
stepBack(player,user,team);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "leave":
|
|
|
|
|
|
|
|
leave(player, user, team);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "invite":
|
|
|
|
case "invite":
|
|
|
|
invite(player, user, team, args);
|
|
|
|
invite(player, user, team, args);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -176,133 +350,32 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void create(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
|
|
|
|
if(unwantedInTeam(player, user))
|
|
|
|
private void invite(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length < 3){
|
|
|
|
if (notDuringEvent(player))
|
|
|
|
Message.send("TEAM_CREATE_USAGE", player);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(checkTeamKuerzel(player, team, args[1]))
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(checkTeamName(player, team, args[2]))
|
|
|
|
if (args.length != 2) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Team.create(args[1], args[2]);
|
|
|
|
|
|
|
|
user.setTeam(Team.get(args[1]).getTeamId());
|
|
|
|
|
|
|
|
user.setLeader(true);
|
|
|
|
|
|
|
|
Message.send("TEAM_CREATE_CREATED", player, args[2]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void join(ProxiedPlayer player, SteamwarUser user, String[] args){
|
|
|
|
|
|
|
|
if(unwantedInTeam(player, user))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!teamInvitations.containsKey(user.getId())){
|
|
|
|
|
|
|
|
Message.send("TEAM_JOIN_NO_INVITE", player);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Integer> invs = teamInvitations.get(user.getId());
|
|
|
|
|
|
|
|
Integer t = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(invs.size() == 1){
|
|
|
|
|
|
|
|
t = invs.get(0);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(args.length != 2){
|
|
|
|
|
|
|
|
Message.send("TEAM_JOIN_USAGE", player);
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
for(int inv : invs){
|
|
|
|
|
|
|
|
Team team = Team.get(inv);
|
|
|
|
|
|
|
|
sb.append(team.getTeamName()).append(" ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Message.send("TEAM_JOIN_INVITED", player, sb.toString());
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int inv : invs){
|
|
|
|
|
|
|
|
Team team = Team.get(inv);
|
|
|
|
|
|
|
|
if(team.getTeamName().equals(args[1])){
|
|
|
|
|
|
|
|
t = inv;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(t == null){
|
|
|
|
|
|
|
|
Message.send("TEAM_JOIN_NOT_BY_TEAM", player);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.setTeam(t);
|
|
|
|
|
|
|
|
teamInvitations.remove(user.getId());
|
|
|
|
|
|
|
|
Message.send("TEAM_JOIN_JOINED", player, Team.get(t).getTeamName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int teamSize = team.size();
|
|
|
|
|
|
|
|
if(teamSize > 1 && user.isLeader() && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){
|
|
|
|
|
|
|
|
Message.send("TEAM_OTHER_LEADER_REQUIRED", player);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.setTeam(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(teamSize == 1){
|
|
|
|
|
|
|
|
team.disband(user);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Message.send("TEAM_LEAVE_LEFT", player);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void invite(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length != 2){
|
|
|
|
|
|
|
|
Message.send("TEAM_INVITE_USAGE", player);
|
|
|
|
Message.send("TEAM_INVITE_USAGE", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
|
|
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;
|
|
|
|
}else if(target.getTeam() != 0){
|
|
|
|
} else if (target.getTeam() != 0) {
|
|
|
|
Message.send("TEAM_INVITE_IN_TEAM", player);
|
|
|
|
Message.send("TEAM_INVITE_IN_TEAM", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!teamInvitations.containsKey(target.getId()))
|
|
|
|
if (!teamInvitations.containsKey(target.getId()))
|
|
|
|
teamInvitations.put(target.getId(), new LinkedList<>());
|
|
|
|
teamInvitations.put(target.getId(), new LinkedList<>());
|
|
|
|
|
|
|
|
|
|
|
|
if(teamInvitations.get(target.getId()).contains(team.getTeamId())){
|
|
|
|
if (teamInvitations.get(target.getId()).contains(team.getTeamId())) {
|
|
|
|
Message.send("TEAM_INVITE_ALREADY_INVITED", player);
|
|
|
|
Message.send("TEAM_INVITE_ALREADY_INVITED", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -311,21 +384,21 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
|
|
|
|
|
|
|
|
Message.send("TEAM_INVITE_INVITED", player, args[1]);
|
|
|
|
Message.send("TEAM_INVITE_INVITED", player, args[1]);
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void remove(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
private void remove(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length != 2){
|
|
|
|
if (args.length != 2) {
|
|
|
|
Message.send("TEAM_REMOVE_USAGE", player);
|
|
|
|
Message.send("TEAM_REMOVE_USAGE", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -335,18 +408,18 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(teamInvitations.containsKey(target.getId())){
|
|
|
|
if (teamInvitations.containsKey(target.getId())) {
|
|
|
|
if(teamInvitations.get(target.getId()).remove((Integer) team.getTeamId())){
|
|
|
|
if (teamInvitations.get(target.getId()).remove((Integer) team.getTeamId())) {
|
|
|
|
Message.send("TEAM_REMOVE_INVITE", player);
|
|
|
|
Message.send("TEAM_REMOVE_INVITE", player);
|
|
|
|
if(teamInvitations.get(target.getId()).isEmpty())
|
|
|
|
if (teamInvitations.get(target.getId()).isEmpty())
|
|
|
|
teamInvitations.remove(target.getId());
|
|
|
|
teamInvitations.remove(target.getId());
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
Message.send("TEAM_REMOVE_NO_INVITE", player);
|
|
|
|
Message.send("TEAM_REMOVE_NO_INVITE", player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(target.getTeam() != user.getTeam()){
|
|
|
|
if (target.getTeam() != user.getTeam()) {
|
|
|
|
Message.send("TEAM_REMOVE_NOT_IN_TEAM", player);
|
|
|
|
Message.send("TEAM_REMOVE_NOT_IN_TEAM", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -355,67 +428,67 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
|
|
|
|
|
|
|
|
Message.send("TEAM_REMOVE_REMOVED", player);
|
|
|
|
Message.send("TEAM_REMOVE_REMOVED", player);
|
|
|
|
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
|
|
|
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
|
|
|
if(p != null)
|
|
|
|
if (p != null)
|
|
|
|
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
|
|
|
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void changekuerzel(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
private void changekuerzel(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
if (notDuringEvent(player))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length < 2){
|
|
|
|
if (args.length < 2) {
|
|
|
|
Message.send("TEAM_KUERZEL_USAGE", player);
|
|
|
|
Message.send("TEAM_KUERZEL_USAGE", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(checkTeamKuerzel(player, team, args[1]))
|
|
|
|
if (checkTeamKuerzel(player, team, args[1]))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
team.setTeamKuerzel(args[1]);
|
|
|
|
team.setTeamKuerzel(args[1]);
|
|
|
|
Message.send("TEAM_KUERZEL_CHANGED", player);
|
|
|
|
Message.send("TEAM_KUERZEL_CHANGED", player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void changename(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
private void changename(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
if (notDuringEvent(player))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length < 2){
|
|
|
|
if (args.length < 2) {
|
|
|
|
Message.send("TEAM_NAME_USAGE", player);
|
|
|
|
Message.send("TEAM_NAME_USAGE", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(checkTeamName(player, team, args[1]))
|
|
|
|
if (checkTeamName(player, team, args[1]))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
team.setTeamName(args[1]);
|
|
|
|
team.setTeamName(args[1]);
|
|
|
|
Message.send("TEAM_NAME_CHANGED", player);
|
|
|
|
Message.send("TEAM_NAME_CHANGED", player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void promote(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
private void promote(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
if (notDuringEvent(player))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length < 2){
|
|
|
|
if (args.length < 2) {
|
|
|
|
Message.send("TEAM_LEADER_USAGE", player);
|
|
|
|
Message.send("TEAM_LEADER_USAGE", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
|
|
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, args[1]);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(target.getTeam() != user.getTeam()){
|
|
|
|
if (target.getTeam() != user.getTeam()) {
|
|
|
|
Message.send("TEAM_LEADER_NOT_MEMBER", player);
|
|
|
|
Message.send("TEAM_LEADER_NOT_MEMBER", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -424,19 +497,19 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
Message.send("TEAM_LEADER_PROMOTED", player, args[1]);
|
|
|
|
Message.send("TEAM_LEADER_PROMOTED", player, args[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String playerName(SteamwarUser user){
|
|
|
|
private String playerName(SteamwarUser user) {
|
|
|
|
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName();
|
|
|
|
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
Message.send("TEAM_INFO_USAGE", player);
|
|
|
|
Message.send("TEAM_INFO_USAGE", 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) {
|
|
|
|
Message.send("UNKNOWN_TEAM", player);
|
|
|
|
Message.send("UNKNOWN_TEAM", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -449,51 +522,51 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
|
|
|
|
|
|
|
|
String members = getMemberList(users, false);
|
|
|
|
String members = getMemberList(users, false);
|
|
|
|
|
|
|
|
|
|
|
|
if(members.length() > 0) {
|
|
|
|
if (members.length() > 0) {
|
|
|
|
Message.sendPrefixless("TEAM_INFO_MEMBER", player, members);
|
|
|
|
Message.sendPrefixless("TEAM_INFO_MEMBER", player, members);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
|
|
|
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
|
|
|
if(!events.isEmpty()){
|
|
|
|
if (!events.isEmpty()) {
|
|
|
|
Message.sendPrefixless("TEAM_INFO_EVENTS", player, events.stream().map(Event::getEventName).collect(Collectors.joining(", ")));
|
|
|
|
Message.sendPrefixless("TEAM_INFO_EVENTS", player, events.stream().map(Event::getEventName).collect(Collectors.joining(", ")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String getMemberList(List<SteamwarUser> users, boolean leaders) {
|
|
|
|
private String getMemberList(List<SteamwarUser> users, boolean leaders) {
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
for(SteamwarUser user : users) {
|
|
|
|
for (SteamwarUser user : users) {
|
|
|
|
if(user.isLeader() == leaders) {
|
|
|
|
if (user.isLeader() == leaders) {
|
|
|
|
sb.append(playerName(user)).append(" ");
|
|
|
|
sb.append(playerName(user)).append(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb.toString();
|
|
|
|
return sb.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void list(ProxiedPlayer player, String[] args){
|
|
|
|
private void list(ProxiedPlayer player, String[] args) {
|
|
|
|
|
|
|
|
|
|
|
|
final int TEAMS_PER_PAGE = 10;
|
|
|
|
final int TEAMS_PER_PAGE = 10;
|
|
|
|
|
|
|
|
|
|
|
|
int page;
|
|
|
|
int page;
|
|
|
|
if(args.length > 1){
|
|
|
|
if (args.length > 1) {
|
|
|
|
try{
|
|
|
|
try {
|
|
|
|
page = Integer.parseInt(args[1]);
|
|
|
|
page = Integer.parseInt(args[1]);
|
|
|
|
}catch(NumberFormatException e){
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
Message.send("TEAM_LIST_NOT_PAGE", player);
|
|
|
|
Message.send("TEAM_LIST_NOT_PAGE", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else
|
|
|
|
} else
|
|
|
|
page = 1;
|
|
|
|
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) {
|
|
|
|
Message.send("TEAM_LIST_UNKNOWN_PAGE", player);
|
|
|
|
Message.send("TEAM_LIST_UNKNOWN_PAGE", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Message.sendPrefixless("TEAM_LIST_HEADER", player, page, 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);
|
|
|
|
|
|
|
|
|
|
|
|
Message.sendPrefixless("TEAM_LIST_TEAM", player, Message.parse("TEAM_LIST_TEAM_HOVER", player),
|
|
|
|
Message.sendPrefixless("TEAM_LIST_TEAM", player, Message.parse("TEAM_LIST_TEAM_HOVER", player),
|
|
|
@ -501,77 +574,77 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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(Message.parse("TEAM_LIST_PREV", player)).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(" " + Message.parse("TEAM_LIST_PAGE", player) +" »»");
|
|
|
|
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(Message.parse("TEAM_LIST_NEXT", player)).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);
|
|
|
|
|
|
|
|
|
|
|
|
beforePage.addExtra(nextPage);
|
|
|
|
beforePage.addExtra(nextPage);
|
|
|
|
player.sendMessage(beforePage);
|
|
|
|
player.sendMessage(beforePage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void event(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
private void event(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
if(notInTeam(player, user))
|
|
|
|
if (notInTeam(player, user))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(args.length < 2){
|
|
|
|
if (args.length < 2) {
|
|
|
|
Message.send("TEAM_EVENT_USAGE", player);
|
|
|
|
Message.send("TEAM_EVENT_USAGE", player);
|
|
|
|
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
|
|
|
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
|
|
|
if(!events.isEmpty()){
|
|
|
|
if (!events.isEmpty()) {
|
|
|
|
Message.send("TEAM_EVENT_HEADER", player);
|
|
|
|
Message.send("TEAM_EVENT_HEADER", player);
|
|
|
|
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
|
|
|
|
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
|
|
|
|
for(Event e : events)
|
|
|
|
for (Event e : events)
|
|
|
|
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
|
|
|
|
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
if (notDuringEvent(player))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
Event event = Event.get(args[1]);
|
|
|
|
Event event = Event.get(args[1]);
|
|
|
|
if(event == null){
|
|
|
|
if (event == null) {
|
|
|
|
Message.send("TEAM_EVENT_NO_EVENT", player);
|
|
|
|
Message.send("TEAM_EVENT_NO_EVENT", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(Instant.now().isAfter(event.getDeadline().toInstant())){
|
|
|
|
if (Instant.now().isAfter(event.getDeadline().toInstant())) {
|
|
|
|
Message.send("TEAM_EVENT_OVER", player);
|
|
|
|
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());
|
|
|
|
Message.send("TEAM_EVENT_LEFT", player);
|
|
|
|
Message.send("TEAM_EVENT_LEFT", player);
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID());
|
|
|
|
TeamTeilnahme.teilnehmen(team.getTeamId(), event.getEventID());
|
|
|
|
Message.send("TEAM_EVENT_JOINED", player, event.getEventName());
|
|
|
|
Message.send("TEAM_EVENT_JOINED", player, event.getEventName());
|
|
|
|
Message.sendPrefixless("TEAM_EVENT_HOW_TO_LEAVE", player);
|
|
|
|
Message.sendPrefixless("TEAM_EVENT_HOW_TO_LEAVE", player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
if(args.length == 1){
|
|
|
|
if (args.length == 1) {
|
|
|
|
if(notInTeam(player, user))
|
|
|
|
if (notInTeam(player, user))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
tp(player, team);
|
|
|
|
tp(player, team);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Team targetTeam = Team.get(args[1]);
|
|
|
|
Team targetTeam = Team.get(args[1]);
|
|
|
|
if(targetTeam == null){
|
|
|
|
if (targetTeam == null) {
|
|
|
|
Message.send("TEAM_TP_NO_TEAM", player);
|
|
|
|
Message.send("TEAM_TP_NO_TEAM", player);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -590,15 +663,15 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
return info;
|
|
|
|
return info;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
player.connect(ServerConnectRequest.builder()
|
|
|
|
player.connect(ServerConnectRequest.builder()
|
|
|
|
.target(serverInfo)
|
|
|
|
.target(serverInfo)
|
|
|
|
.connectTimeout(BungeeCord.getInstance().getConfig().getServerConnectTimeout())
|
|
|
|
.connectTimeout(BungeeCord.getInstance().getConfig().getServerConnectTimeout())
|
|
|
|
.retry(false)
|
|
|
|
.retry(false)
|
|
|
|
.reason(ServerConnectEvent.Reason.PLUGIN)
|
|
|
|
.reason(ServerConnectEvent.Reason.PLUGIN)
|
|
|
|
.callback((success, error) -> {
|
|
|
|
.callback((success, error) -> {
|
|
|
|
if (error != null) {
|
|
|
|
if (error != null) {
|
|
|
|
Message.send("TEAM_OFFLINE", player);
|
|
|
|
Message.send("TEAM_OFFLINE", player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.build());
|
|
|
|
.build());
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
((UserConnection) player).connect(serverInfo, (success, error) -> {
|
|
|
|
((UserConnection) player).connect(serverInfo, (success, error) -> {
|
|
|
@ -609,8 +682,8 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
|
|
|
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args) {
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
|
|
|
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -662,10 +735,10 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void changeColor(ProxiedPlayer player, SteamwarUser user, Team team) {
|
|
|
|
private void changeColor(ProxiedPlayer player, SteamwarUser user, Team team) {
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
if (notLeader(player, user, team))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
if (notDuringEvent(player))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
List<SWListInv.SWListEntry<String>> colors = new ArrayList<>();
|
|
|
|
List<SWListInv.SWListEntry<String>> colors = new ArrayList<>();
|
|
|
@ -675,7 +748,8 @@ 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, 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);
|
|
|
@ -683,62 +757,54 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
inv.open();
|
|
|
|
inv.open();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
Message.send("TEAM_NAME_LENGHT", player);
|
|
|
|
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()) {
|
|
|
|
Message.send("TEAM_NAME_TAKEN", player);
|
|
|
|
Message.send("TEAM_NAME_TAKEN", player);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
Message.send("TEAM_KUERZEL_LENGHT", player);
|
|
|
|
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())) {
|
|
|
|
Message.send("TEAM_KUERZEL_TAKEN", player);
|
|
|
|
Message.send("TEAM_KUERZEL_TAKEN", player);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean unwantedInTeam(ProxiedPlayer player, SteamwarUser user){
|
|
|
|
private boolean notInTeam(ProxiedPlayer player, SteamwarUser user) {
|
|
|
|
if(user.getTeam() != 0){
|
|
|
|
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);
|
|
|
|
Message.send("TEAM_NOT_IN_TEAM", player);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team){
|
|
|
|
private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team) {
|
|
|
|
if(notInTeam(player, user))
|
|
|
|
if (notInTeam(player, user))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
if(!user.isLeader()){
|
|
|
|
if (!user.isLeader()) {
|
|
|
|
Message.send("TEAM_NOT_LEADER", player);
|
|
|
|
Message.send("TEAM_NOT_LEADER", player);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean notDuringEvent(ProxiedPlayer player){
|
|
|
|
private boolean notDuringEvent(ProxiedPlayer player) {
|
|
|
|
if(Event.get() != null){
|
|
|
|
if (Event.get() != null) {
|
|
|
|
Message.send("TEAM_NOT_IN_EVENT", player);
|
|
|
|
Message.send("TEAM_NOT_IN_EVENT", player);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -746,9 +812,9 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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 == 1) {
|
|
|
|
tab.add("create");
|
|
|
|
tab.add("create");
|
|
|
|
tab.add("join");
|
|
|
|
tab.add("join");
|
|
|
|
tab.add("invite");
|
|
|
|
tab.add("invite");
|
|
|
@ -763,11 +829,11 @@ public class TeamCommand extends BasicCommand {
|
|
|
|
tab.add("changecolor");
|
|
|
|
tab.add("changecolor");
|
|
|
|
tab.add("tp");
|
|
|
|
tab.add("tp");
|
|
|
|
tab.add("server");
|
|
|
|
tab.add("server");
|
|
|
|
}else if(args.length == 2){
|
|
|
|
} 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()));
|
|
|
|
}else if(args[1].equalsIgnoreCase("join") || args[1].equalsIgnoreCase("info") || args[1].equalsIgnoreCase("tp")){
|
|
|
|
} else if (args[1].equalsIgnoreCase("join") || args[1].equalsIgnoreCase("info") || args[1].equalsIgnoreCase("tp")) {
|
|
|
|
List<Team> teams = Team.getAll();
|
|
|
|
List<Team> teams = Team.getAll();
|
|
|
|
teams.forEach(team -> {
|
|
|
|
teams.forEach(team -> {
|
|
|
|
tab.add(team.getTeamName());
|
|
|
|
tab.add(team.getTeamName());
|
|
|
|