|
|
|
@ -186,7 +186,7 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
public void stepBack(ProxiedPlayer player) {
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
public void invite(ProxiedPlayer player, String... args){
|
|
|
|
|
@Register(value = "invite", description = "TEAM_INVITE_USAGE")
|
|
|
|
|
public void invite(ProxiedPlayer player, String toInvite){
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(args.length != 2){
|
|
|
|
|
Message.send("TEAM_INVITE_USAGE", player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(toInvite);
|
|
|
|
|
if(target == null){
|
|
|
|
|
Message.send("TEAM_INVITE_NO_PLAYER", player);
|
|
|
|
|
return;
|
|
|
|
@ -255,25 +250,20 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
if(p != null)
|
|
|
|
|
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("remove")
|
|
|
|
|
public void remove(ProxiedPlayer player, String... args){
|
|
|
|
|
@Register(value = "remove", description = "TEAM_REMOVE_USAGE")
|
|
|
|
|
public void remove(ProxiedPlayer player, String toRemove){
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(args.length != 2){
|
|
|
|
|
Message.send("TEAM_REMOVE_USAGE", player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(toRemove);
|
|
|
|
|
if(target == null){
|
|
|
|
|
Message.send("TEAM_REMOVE_NOT_PLAYER", player);
|
|
|
|
|
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){
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
@ -326,10 +316,10 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
@ -342,24 +332,18 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
Message.send("TEAM_NAME_CHANGED", player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("promote")
|
|
|
|
|
public void promote(ProxiedPlayer player, String... args){
|
|
|
|
|
@Register(value = "promote", description = "TEAM_LEADER_USAGE")
|
|
|
|
|
public void promote(ProxiedPlayer player, String toPromote){
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(args.length < 2){
|
|
|
|
|
Message.send("TEAM_LEADER_USAGE", player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
|
|
|
SteamwarUser target = SteamwarUser.get(toPromote);
|
|
|
|
|
if(target == null){
|
|
|
|
|
Message.send("TEAM_LEADER_NOT_USER", player, args[1]);
|
|
|
|
|
Message.send("TEAM_LEADER_NOT_USER", player, toPromote);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -369,7 +353,7 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target.setLeader(true);
|
|
|
|
|
Message.send("TEAM_LEADER_PROMOTED", player, args[1]);
|
|
|
|
|
Message.send("TEAM_LEADER_PROMOTED", player, toPromote);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String playerName(SteamwarUser user){
|
|
|
|
@ -421,23 +405,9 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("list")
|
|
|
|
|
public void list(ProxiedPlayer player, String... args){
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
|
|
|
|
|
public void list(ProxiedPlayer player, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page){
|
|
|
|
|
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();
|
|
|
|
|
final int lastPage = ((all.size() - 1) / 10) + 1;
|
|
|
|
|
if(page < 1 || page > lastPage){
|
|
|
|
@ -493,7 +463,7 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
@ -569,20 +539,16 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("server")
|
|
|
|
|
public void server(ProxiedPlayer player, String[] args){
|
|
|
|
|
@Register(value = "server", description = "TEAM_SERVER_USAGE")
|
|
|
|
|
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());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (args.length < 2) {
|
|
|
|
|
Message.send("TEAM_SERVER_USAGE", player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String server = args[1];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (isLocalhost(InetAddress.getByName(server))) {
|
|
|
|
|
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
|
|
|
@ -592,19 +558,7 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
|
|
|
|
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.setPort(port);
|
|
|
|
|
Storage.teamServers.remove(team.getTeamId());
|
|
|
|
@ -628,7 +582,7 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
public void changeColor(ProxiedPlayer player) {
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
Team team = Team.get(user.getTeam());
|
|
|
|
|
if(notLeader(player, user, team))
|
|
|
|
|
if(notLeader(player, user))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(notDuringEvent(player))
|
|
|
|
@ -683,7 +637,7 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team){
|
|
|
|
|
private boolean notLeader(ProxiedPlayer player, SteamwarUser user){
|
|
|
|
|
if(notInTeam(player, user))
|
|
|
|
|
return true;
|
|
|
|
|
if(!user.isLeader()){
|
|
|
|
@ -704,22 +658,7 @@ public class TeamCommand extends SWCommand {
|
|
|
|
|
// @Override
|
|
|
|
|
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args){
|
|
|
|
|
List<String> tab = new ArrayList<>();
|
|
|
|
|
if(args.length == 1){
|
|
|
|
|
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.length == 2){
|
|
|
|
|
if(args[1].equalsIgnoreCase("event")){
|
|
|
|
|
List<Event> coming = Event.getComing();
|
|
|
|
|
coming.forEach(event -> tab.add(event.getEventName()));
|
|
|
|
|