geforkt von SteamWar/BungeeCore
Update TeamCommand (not finished)
Dieser Commit ist enthalten in:
Ursprung
d559c61846
Commit
561289b5a6
@ -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()));
|
||||
|
@ -444,13 +444,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cYou were removed from the team.
|
||||
#Team Kuerzel
|
||||
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eshortcut§8]
|
||||
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 Name
|
||||
TEAM_NAME_USAGE=§8/§7team changename §8[§eteam name§8]
|
||||
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 Leader
|
||||
|
@ -422,13 +422,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cDu wurdest aus dem Team entfernt.
|
||||
#Team Kuerzel
|
||||
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eTeamkürzel§8]
|
||||
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 Name
|
||||
TEAM_NAME_USAGE=§8/§7team changename §8[§eTeamname§8]
|
||||
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 Leader
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren