SteamWar/BungeeCore
Archiviert
13
2

Fix some tab completions and optimize others
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-09-23 13:22:43 +02:00
Ursprung 157aea068e
Commit 5b627a7819
3 geänderte Dateien mit 22 neuen und 31 gelöschten Zeilen

Datei anzeigen

@ -20,16 +20,11 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.IgnoreSystem;
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 java.util.stream.Collectors;
public class IgnoreCommand extends SWCommand {
public IgnoreCommand() {
@ -37,10 +32,9 @@ public class IgnoreCommand extends SWCommand {
}
@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 target = SteamwarUser.get(toIgnore.getUniqueId());
if(target.equals(user)){
Message.send("IGNORE_YOURSELF", p);
return;

Datei anzeigen

@ -158,8 +158,7 @@ public class PunishmentCommand {
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
List<String> players = BungeeCord.getInstance().getPlayers()
.stream()
List<String> players = BungeeCord.getInstance().getPlayers().stream()
.map(CommandSender::getName)
.collect(Collectors.toList());
players.add(s);
@ -169,9 +168,7 @@ public class PunishmentCommand {
}
};
if (punishmentType.getUnpunishmentMessage() == null) {
return;
}
if (punishmentType.getUnpunishmentMessage() == null) return;
String antiCommand = "un" + command;
new SWCommand(antiCommand, ConnectionListener.BAN_PERMISSION) {
@Register

Datei anzeigen

@ -115,11 +115,9 @@ public class TeamCommand extends SWCommand {
}
@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());
Team team = Team.get(user.getTeam());
if(unwantedInTeam(player, user))
return;
if(checkTeamKuerzel(player, team, kuerzel))
return;
@ -134,10 +132,8 @@ public class TeamCommand extends SWCommand {
}
@Register("join")
public void join(ProxiedPlayer player, String... args){
public void join(@Validator("isNotInTeam") ProxiedPlayer player, String... args){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(unwantedInTeam(player, user))
return;
if(notDuringEvent(player))
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)
public TypeValidator<ProxiedPlayer> isInTeamValidator() {
return (sender, value, messageSender) -> {
@ -661,8 +671,7 @@ public class TeamCommand extends SWCommand {
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
List<Team> teams = Team.getAll();
return teams.stream()
return Team.getAll().stream()
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
.collect(Collectors.toList());
}
@ -680,8 +689,7 @@ public class TeamCommand extends SWCommand {
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
List<Team> teams = Team.getAll();
return teams.stream()
return Team.getAll().stream()
.filter(team -> team.getAddress() != null && !team.getAddress().isEmpty())
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
.collect(Collectors.toList());
@ -707,14 +715,6 @@ public class TeamCommand extends SWCommand {
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){
if(Event.get() != null){
Message.send("TEAM_NOT_IN_EVENT", player);