Fix some tab completions and optimize others
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
157aea068e
Commit
5b627a7819
@ -20,16 +20,11 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.command.SWCommandUtils;
|
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class IgnoreCommand extends SWCommand {
|
public class IgnoreCommand extends SWCommand {
|
||||||
|
|
||||||
public IgnoreCommand() {
|
public IgnoreCommand() {
|
||||||
@ -37,10 +32,9 @@ public class IgnoreCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "USAGE_IGNORE")
|
@Register(description = "USAGE_IGNORE")
|
||||||
public void genericCommand(ProxiedPlayer p, @ErrorMessage("UNKNOWN_PLAYER") ProxiedPlayer toIgnore) {
|
public void genericCommand(ProxiedPlayer p, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
||||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
|
|
||||||
SteamwarUser target = SteamwarUser.get(toIgnore.getUniqueId());
|
|
||||||
if(target.equals(user)){
|
if(target.equals(user)){
|
||||||
Message.send("IGNORE_YOURSELF", p);
|
Message.send("IGNORE_YOURSELF", p);
|
||||||
return;
|
return;
|
||||||
|
@ -158,8 +158,7 @@ public class PunishmentCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
List<String> players = BungeeCord.getInstance().getPlayers()
|
List<String> players = BungeeCord.getInstance().getPlayers().stream()
|
||||||
.stream()
|
|
||||||
.map(CommandSender::getName)
|
.map(CommandSender::getName)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
players.add(s);
|
players.add(s);
|
||||||
@ -169,9 +168,7 @@ public class PunishmentCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (punishmentType.getUnpunishmentMessage() == null) {
|
if (punishmentType.getUnpunishmentMessage() == null) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
String antiCommand = "un" + command;
|
String antiCommand = "un" + command;
|
||||||
new SWCommand(antiCommand, ConnectionListener.BAN_PERMISSION) {
|
new SWCommand(antiCommand, ConnectionListener.BAN_PERMISSION) {
|
||||||
@Register
|
@Register
|
||||||
|
@ -115,11 +115,9 @@ public class TeamCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "create", description = "TEAM_CREATE_USAGE")
|
@Register(value = "create", description = "TEAM_CREATE_USAGE")
|
||||||
public void create(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
|
public void create(@Validator("isNotInTeam") ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
Team team = Team.get(user.getTeam());
|
Team team = Team.get(user.getTeam());
|
||||||
if(unwantedInTeam(player, user))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(checkTeamKuerzel(player, team, kuerzel))
|
if(checkTeamKuerzel(player, team, kuerzel))
|
||||||
return;
|
return;
|
||||||
@ -134,10 +132,8 @@ public class TeamCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register("join")
|
@Register("join")
|
||||||
public void join(ProxiedPlayer player, String... args){
|
public void join(@Validator("isNotInTeam") ProxiedPlayer player, String... args){
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
if(unwantedInTeam(player, user))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
return;
|
return;
|
||||||
@ -618,6 +614,20 @@ public class TeamCommand extends SWCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Validator(value = "isNotInTeam", local = true)
|
||||||
|
public TypeValidator<ProxiedPlayer> isNotInTeamValidator() {
|
||||||
|
return (sender, value, messageSender) -> {
|
||||||
|
if (!(sender instanceof ProxiedPlayer)) return false;
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||||
|
if (steamwarUser.getTeam() != 0) {
|
||||||
|
messageSender.send("TEAM_IN_TEAM");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Validator(value = "isInTeam", local = true)
|
@Validator(value = "isInTeam", local = true)
|
||||||
public TypeValidator<ProxiedPlayer> isInTeamValidator() {
|
public TypeValidator<ProxiedPlayer> isInTeamValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
@ -661,8 +671,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
List<Team> teams = Team.getAll();
|
return Team.getAll().stream()
|
||||||
return teams.stream()
|
|
||||||
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
|
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -680,8 +689,7 @@ public class TeamCommand extends SWCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
List<Team> teams = Team.getAll();
|
return Team.getAll().stream()
|
||||||
return teams.stream()
|
|
||||||
.filter(team -> team.getAddress() != null && !team.getAddress().isEmpty())
|
.filter(team -> team.getAddress() != null && !team.getAddress().isEmpty())
|
||||||
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
|
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -707,14 +715,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 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);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren