SteamWar/BungeeCore
Archiviert
13
2

Remove player tabcomplete in every command
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Add player tab complete to every command needing it
Fix some tabcomplete things
Dieser Commit ist enthalten in:
yoyosource 2023-09-23 12:57:41 +02:00
Ursprung 38eb8d9c06
Commit 157aea068e
10 geänderte Dateien mit 182 neuen und 180 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.util.BauLock;
import de.steamwar.bungeecore.util.BauLockState;
import de.steamwar.bungeecore.util.Chat19;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
@ -38,8 +39,10 @@ import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class BauCommand extends SWCommand {
@ -170,7 +173,7 @@ public class BauCommand extends SWCommand {
}
@Register("togglewe")
public void togglewe(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) {
public void togglewe(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
if (user == null) {
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "togglewe");
return;
@ -185,7 +188,7 @@ public class BauCommand extends SWCommand {
}
@Register("toggleworld")
public void toggleworld(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) {
public void toggleworld(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
if (user == null) {
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleworld");
return;
@ -200,7 +203,7 @@ public class BauCommand extends SWCommand {
}
@Register("toggleall")
public void toggleall(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) {
public void toggleall(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
if (user == null) {
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleall");
return;
@ -228,7 +231,7 @@ public class BauCommand extends SWCommand {
}
@Register(value = "delmember", description = "BAU_DELMEMBER_USAGE")
public void delmember(ProxiedPlayer p, SteamwarUser user) {
public void delmember(ProxiedPlayer p, @Mapper("addedUsers") SteamwarUser user) {
BauweltMember target = member(p, user);
if (target == null)
return;
@ -250,6 +253,25 @@ public class BauCommand extends SWCommand {
Message.send("BAU_DELMEMBER_DELETED", p);
}
@Mapper(value = "addedUsers", local = true)
public TypeMapper<SteamwarUser> addedUsers() {
return new TypeMapper<SteamwarUser>() {
@Override
public SteamwarUser map(CommandSender commandSender, String[] previousArguments, String s) {
return SteamwarUser.get(s);
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
if (!(sender instanceof ProxiedPlayer)) return Collections.emptyList();
return BauweltMember.getMembers(((ProxiedPlayer) sender).getUniqueId()).stream()
.map(bauweltMember -> SteamwarUser.get(bauweltMember.getMemberID()))
.map(steamwarUser -> steamwarUser.getUserName())
.collect(Collectors.toList());
}
};
}
@Register("resetall")
@Register("delete")
public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {

Datei anzeigen

@ -37,14 +37,10 @@ public class IgnoreCommand extends SWCommand {
}
@Register(description = "USAGE_IGNORE")
public void genericCommand(ProxiedPlayer p, @Mapper("player") String toIgnore) {
public void genericCommand(ProxiedPlayer p, @ErrorMessage("UNKNOWN_PLAYER") ProxiedPlayer toIgnore) {
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
SteamwarUser target = SteamwarUser.get(toIgnore);
if(target == null){
Message.send("UNKNOWN_PLAYER", p);
return;
}
SteamwarUser target = SteamwarUser.get(toIgnore.getUniqueId());
if(target.equals(user)){
Message.send("IGNORE_YOURSELF", p);
return;
@ -57,9 +53,4 @@ public class IgnoreCommand extends SWCommand {
IgnoreSystem.ignore(user, target);
Message.send("IGNORE_MESSAGE", p, target.getUserName());
}
@Mapper(value = "player", local = true)
public TypeMapper<String> playerTypeMapper() {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
}
}

Datei anzeigen

@ -23,15 +23,9 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.listeners.ConnectionListener;
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.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.stream.Collectors;
public class KickCommand extends SWCommand {
public KickCommand() {
@ -39,13 +33,7 @@ public class KickCommand extends SWCommand {
}
@Register(description = "KICK_USAGE")
public void genericCommand(CommandSender sender, @Mapper("player") String player, String... message) {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(player);
if(target == null){
Message.send("KICK_OFFLINE", sender);
return;
}
public void genericCommand(CommandSender sender, @ErrorMessage("KICK_OFFLINE") ProxiedPlayer target, String... message) {
if (message.length == 0) {
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
} else {
@ -53,9 +41,4 @@ public class KickCommand extends SWCommand {
}
Message.send("KICK_CONFIRM", sender, target.getName());
}
@Mapper(value = "player", local = true)
public TypeMapper<String> playerTypeMapper() {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
}
}

Datei anzeigen

@ -23,12 +23,15 @@ import com.google.gson.JsonParser;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.listeners.ConnectionListener;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.messages.ChatSender;
import de.steamwar.sql.BannedUserIPs;
import de.steamwar.sql.Punishment;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -42,12 +45,10 @@ import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.UUID;
import java.util.*;
import java.util.logging.Level;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class PunishmentCommand {
@ -119,7 +120,7 @@ public class PunishmentCommand {
new SWCommand(command, ConnectionListener.BAN_PERMISSION) {
@Register
public void genericCommand(ProxiedPlayer player, String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) {
public void genericCommand(ProxiedPlayer player, @Mapper("toPunish") String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) {
SteamwarUser punisher = SteamwarUser.get(player.getUniqueId());
if (punishmentType.isNeedsAdmin() && !punisher.hasPerm(UserPerm.MODERATION)) {
return;
@ -146,22 +147,39 @@ public class PunishmentCommand {
public void genericError(ProxiedPlayer player, String... args) {
ChatSender.of(player).send(true, ChatMessageType.CHAT, null, null, new Message("PUNISHMENT_USAGE", command));
}
@Mapper(value = "toPunish", local = true)
public TypeMapper<String> allUsers() {
return new TypeMapper<String>() {
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {
return s;
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
List<String> players = BungeeCord.getInstance().getPlayers()
.stream()
.map(CommandSender::getName)
.collect(Collectors.toList());
players.add(s);
return players;
}
};
}
};
if (punishmentType.getUnpunishmentMessage() == null) {
return;
}
String antiCommand = "un" + command;
new SWCommand(antiCommand, ConnectionListener.BAN_PERMISSION) {
@Register
public void genericCommand(ProxiedPlayer player, String toUnpunish) {
public void genericCommand(ProxiedPlayer player, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) {
return;
}
SteamwarUser target = existingUser(player, toUnpunish);
if (target == null)
return;
if (!target.isPunished(punishmentType)) {
Message.send(punishmentType.getUsageNotPunished(), player);
return;
@ -180,13 +198,6 @@ public class PunishmentCommand {
};
}
protected SteamwarUser existingUser(CommandSender sender, String arg){
SteamwarUser target = SteamwarUser.get(arg);
if(target == null)
Message.send("UNKNOWN_PLAYER", sender);
return target;
}
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
SteamwarUser target = getOrCreateOfflinePlayer(arg);
if(target == null)

Datei anzeigen

@ -40,17 +40,12 @@ public class RankCommand extends SWCommand {
@Register
public void ownRank(ProxiedPlayer player) {
rank(player, player.getName());
rank(player, SteamwarUser.get(player.getUniqueId()));
}
@Register
public void rank(ProxiedPlayer player, @Mapper("player") String s) {
SteamwarUser user = SteamwarUser.get(s);
if (user == null) {
Message.send("RANK_PLAYER_NOT_FOUND", player);
return;
}
if (!player.getName().equals(s)) {
public void rank(ProxiedPlayer player, @ErrorMessage("RANK_PLAYER_NOT_FOUND") SteamwarUser user) {
if (!player.getName().equals(user.getUserName())) {
Message.sendPrefixless("RANK_PLAYER_FOUND", player, user.getUserName());
}
@ -71,9 +66,4 @@ public class RankCommand extends SWCommand {
Message.sendPrefixless("RANK_EMBLEM", player, UserElo.getEmblemProgression(mode.getChatName(), user.getId()));
}
}
@Mapper(value = "player", local = true)
public TypeMapper<String> playerTypeMapper() {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
}
}

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.bungeecore.inventory.SWListInv;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import de.steamwar.messages.ChatSender;
import de.steamwar.sql.*;
import net.md_5.bungee.BungeeCord;
@ -46,6 +47,7 @@ import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static de.steamwar.bungeecore.Storage.teamInvitations;
@ -182,11 +184,9 @@ public class TeamCommand extends SWCommand {
}
@Register("stepback")
public void stepBack(ProxiedPlayer player) {
public void stepBack(@Validator("isLeader") ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(noRemainingLeaders(team, user)){
Message.send("TEAM_OTHER_LEADER_REQUIRED", player);
@ -198,11 +198,9 @@ public class TeamCommand extends SWCommand {
}
@Register("leave")
public void leave(ProxiedPlayer player){
public void leave(@Validator("isInTeam") ProxiedPlayer player){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notInTeam(player, user))
return;
int teamSize = team.size();
if(teamSize > 1 && user.isLeader() && noRemainingLeaders(team, user)) {
@ -225,16 +223,13 @@ public class TeamCommand extends SWCommand {
@Register(value = "invite", description = "TEAM_INVITE_USAGE")
public void invite(ProxiedPlayer player, String toInvite){
public void invite(@Validator("isLeader") ProxiedPlayer player, @AllowNull SteamwarUser target){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
SteamwarUser target = SteamwarUser.get(toInvite);
if(target == null){
Message.send("TEAM_INVITE_NO_PLAYER", player);
return;
@ -253,20 +248,17 @@ public class TeamCommand extends SWCommand {
teamInvitations.get(target.getId()).add(team.getTeamId());
Message.send("TEAM_INVITE_INVITED", player, toInvite);
Message.send("TEAM_INVITE_INVITED", player, target.getUserName());
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
if(p != null)
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
}
@Register(value = "remove", description = "TEAM_REMOVE_USAGE")
public void remove(ProxiedPlayer player, String toRemove){
public void remove(@Validator("isLeader") ProxiedPlayer player, @AllowNull @Mapper("memberList") SteamwarUser target){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
SteamwarUser target = SteamwarUser.get(toRemove);
if(target == null){
Message.send("TEAM_REMOVE_NOT_PLAYER", player);
return;
@ -301,12 +293,31 @@ public class TeamCommand extends SWCommand {
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
}
@Mapper(value = "memberList", local = true)
public TypeMapper<SteamwarUser> memberList() {
return new TypeMapper<SteamwarUser>() {
@Override
public SteamwarUser map(CommandSender commandSender, String[] previousArguments, String s) {
return SteamwarUser.get(s);
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
if (!(sender instanceof ProxiedPlayer)) return Collections.emptyList();
ProxiedPlayer player = (ProxiedPlayer) sender;
Team team = Team.get(SteamwarUser.get(player.getUniqueId()).getTeam());
return team.getMembers().stream()
.map(SteamwarUser::get)
.map(SteamwarUser::getUserName)
.collect(Collectors.toList());
}
};
}
@Register(value = "changekurzel", description = "TEAM_KUERZEL_USAGE")
public void changekuerzel(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel){
public void changekuerzel(@Validator("isLeader") ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
@ -319,11 +330,9 @@ 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_LENGTH") String name){
public void changename(@Validator("isLeader") 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))
return;
if(notDuringEvent(player))
return;
@ -336,17 +345,14 @@ public class TeamCommand extends SWCommand {
}
@Register(value = "promote", description = "TEAM_LEADER_USAGE")
public void promote(ProxiedPlayer player, String toPromote){
public void promote(@Validator("isLeader") ProxiedPlayer player, @AllowNull @Mapper("memberList") SteamwarUser target){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
SteamwarUser target = SteamwarUser.get(toPromote);
if(target == null){
Message.send("TEAM_LEADER_NOT_USER", player, toPromote);
Message.send("TEAM_LEADER_NOT_USER", player);
return;
}
@ -356,7 +362,7 @@ public class TeamCommand extends SWCommand {
}
target.setLeader(true);
Message.send("TEAM_LEADER_PROMOTED", player, toPromote);
Message.send("TEAM_LEADER_PROMOTED", player, target.getUserName());
}
private String playerName(SteamwarUser user){
@ -364,21 +370,15 @@ public class TeamCommand extends SWCommand {
}
@Register("info")
public void info(ProxiedPlayer player, String... args){
public void info(@Validator("isInTeam") ProxiedPlayer player){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(args.length == 0 && user.getTeam() == 0){
Message.send("TEAM_INFO_USAGE", player);
return;
}else if(user.getTeam() == 0 || args.length == 1){
team = Team.get(args[0]);
}
if(team == null){
Message.send("UNKNOWN_TEAM", player);
return;
info(player, team);
}
@Register(value = "info", description = "TEAM_INFO_USAGE")
public void info(ProxiedPlayer player, @ErrorMessage("UNKNOWN_TEAM") Team team){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Message.sendPrefixless("TEAM_INFO_TEAM", player, team.getTeamName(), team.getTeamColor(), team.getTeamKuerzel());
List<SteamwarUser> users = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList());
@ -448,11 +448,9 @@ public class TeamCommand extends SWCommand {
}
@Register("event")
public void event(ProxiedPlayer player) {
public void event(@Validator("isInTeam") ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notInTeam(player, user))
return;
Message.send("TEAM_EVENT_USAGE", player);
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
@ -465,14 +463,9 @@ public class TeamCommand extends SWCommand {
}
@Register("event")
public void event(ProxiedPlayer player, Event event){
public void event(@Validator("isLeader") ProxiedPlayer player, Event event){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notInTeam(player, user))
return;
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
@ -493,25 +486,15 @@ public class TeamCommand extends SWCommand {
}
@Register("tp")
public void tp(ProxiedPlayer player, String... args){
public void tp(@Validator("isInTeam") ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(args.length == 0){
if(notInTeam(player, user))
return;
tp(player, team);
return;
}
Team targetTeam = Team.get(args[0]);
if(targetTeam == null){
Message.send("TEAM_TP_NO_TEAM", player);
return;
}
tp(player, targetTeam);
}
private void tp(ProxiedPlayer player, Team targetTeam) {
if (targetTeam.getAddress() == null) {
@Register("tp")
public void tp(ProxiedPlayer player, @ErrorMessage("TEAM_TP_NO_TEAM") @Mapper("teamWithTeamServer") Team targetTeam) {
if (targetTeam.getAddress() == null || targetTeam.getAddress().isEmpty()) {
Message.send("TEAM_NO_ADDRESS", player);
return;
}
@ -551,11 +534,9 @@ public class TeamCommand extends SWCommand {
}
@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){
public void server(@Validator("isLeader") 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))
return;
if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
return;
}
@ -590,11 +571,9 @@ public class TeamCommand extends SWCommand {
}
@Register("color")
public void changeColor(ProxiedPlayer player) {
public void changeColor(@Validator("isLeader") ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
@ -639,6 +618,77 @@ public class TeamCommand extends SWCommand {
};
}
@Validator(value = "isInTeam", local = true)
public TypeValidator<ProxiedPlayer> isInTeamValidator() {
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_NOT_IN_TEAM");
return false;
}
return true;
};
}
@Validator(value = "isLeader", local = true)
public TypeValidator<ProxiedPlayer> isLeaderValidator() {
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_NOT_IN_TEAM");
return false;
}
if (!steamwarUser.isLeader()) {
messageSender.send("TEAM_NOT_LEADER");
return false;
}
return true;
};
}
@ClassMapper(Team.class)
@Cached(global = true, cacheDuration = 60)
public TypeMapper<Team> team() {
return new TypeMapper<Team>() {
@Override
public Team map(CommandSender commandSender, String[] previousArguments, String s) {
return Team.get(s);
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
List<Team> teams = Team.getAll();
return teams.stream()
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
.collect(Collectors.toList());
}
};
}
@Mapper(value = "teamWithTeamServer", local = true)
@Cached(global = true, cacheDuration = 60)
public TypeMapper<Team> teamWithTeamServer() {
return new TypeMapper<Team>() {
@Override
public Team map(CommandSender commandSender, String[] previousArguments, String s) {
return Team.get(s);
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
List<Team> teams = Team.getAll();
return teams.stream()
.filter(team -> team.getAddress() != null && !team.getAddress().isEmpty())
.flatMap(team -> Stream.of(team.getTeamName(), team.getTeamKuerzel()))
.collect(Collectors.toList());
}
};
}
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
Team t = Team.get(arg);
if(t != null && t.getTeamId() != team.getTeamId()){
@ -665,24 +715,6 @@ public class TeamCommand extends SWCommand {
return false;
}
private boolean notInTeam(ProxiedPlayer player, SteamwarUser user){
if(user.getTeam() == 0){
Message.send("TEAM_NOT_IN_TEAM", player);
return true;
}
return false;
}
private boolean notLeader(ProxiedPlayer player, SteamwarUser user){
if(notInTeam(player, user))
return true;
if(!user.isLeader()){
Message.send("TEAM_NOT_LEADER", player);
return true;
}
return false;
}
private boolean notDuringEvent(ProxiedPlayer player){
if(Event.get() != null){
Message.send("TEAM_NOT_IN_EVENT", player);

Datei anzeigen

@ -91,7 +91,7 @@ public class TpCommand extends SWCommand {
};
}
public static void teleport (ProxiedPlayer player, ServerInfo server) {
public static void teleport(ProxiedPlayer player, ServerInfo server) {
ChatSender sender = ChatSender.of(player);
if(CheckCommand.isChecking(player)){
sender.system("CHECK_CHECKING");

Datei anzeigen

@ -210,33 +210,6 @@ public class ChatListener extends BasicListener {
}).collect(Collectors.joining(" "));
}
@EventHandler
public void onTabCompleteEvent(TabCompleteEvent e){
List<String> suggestions = e.getSuggestions();
String [] cursor = e.getCursor().split(" ");
String last;
if(cursor.length != 0)
last = cursor[cursor.length - 1];
else
last = "";
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
String name = player.getName();
if (last.isEmpty() || name.startsWith(last)) {
suggestions.add(name);
}
}
if(last.startsWith("@")) {
String plrName = last.replace("@", "");
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
String name = player.getName();
if ((plrName.isEmpty() || name.startsWith(plrName)) && !plrName.equalsIgnoreCase(name)) {
suggestions.add("@" + name);
}
}
}
}
@EventHandler
public void onTabCompleteResponseEvent(TabCompleteResponseEvent e){
List<String> suggestions = e.getSuggestions();

Datei anzeigen

@ -460,7 +460,7 @@ TEAM_NAME_TAKEN=§cThere is already a team with that name.
#Team Leader
TEAM_LEADER_USAGE=§8/§7team promote §8[§emember§8]
TEAM_LEADER_NOT_USER=§cThe player {0} does not exist.
TEAM_LEADER_NOT_USER=§cUnknown player.
TEAM_LEADER_NOT_MEMBER=§cThis player is not in your team.
TEAM_LEADER_PROMOTED=§7You made §e{0} §7a leader!

Datei anzeigen

@ -438,7 +438,7 @@ TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
#Team Leader
TEAM_LEADER_USAGE=§8/§7team promote §8[§eMember§8]
TEAM_LEADER_NOT_USER=§cDen Spieler {0} gibt es nicht.
TEAM_LEADER_NOT_USER=§cUnbekannter Spieler.
TEAM_LEADER_NOT_MEMBER=§cDer Spieler ist nicht in deinem Team.
TEAM_LEADER_PROMOTED=§7Du hast den Spieler §e{0} §7zum Leader gemacht!