geforkt von SteamWar/BungeeCore
Update TpCommand
Dieser Commit ist enthalten in:
Ursprung
24456458de
Commit
9f9d082042
@ -22,6 +22,8 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -30,45 +32,62 @@ import net.md_5.bungee.api.config.ServerInfo;
|
|||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TpCommand extends BasicCommand {
|
public class TpCommand extends SWCommand {
|
||||||
|
|
||||||
public TpCommand(){
|
public TpCommand(){
|
||||||
super("join", null, "tp", "teleport");
|
super("join", null, "tp", "teleport");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public void execute(CommandSender s, String[] args) {
|
public void genericCommand(ProxiedPlayer p) {
|
||||||
if(!(s instanceof ProxiedPlayer))
|
ChatSender.of(p).system(Event.get() == null ? "TP_USAGE" : "TP_USAGE_EVENT");
|
||||||
return;
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) s;
|
|
||||||
|
|
||||||
ChatSender sender = ChatSender.of(player);
|
|
||||||
if(args.length == 0){
|
|
||||||
if(Event.get() == null)
|
|
||||||
sender.system("TP_USAGE");
|
|
||||||
else
|
|
||||||
sender.system("TP_USAGE_EVENT");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerInfo server = getTarget(args[0]);
|
|
||||||
boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo());
|
|
||||||
|
|
||||||
//Give control of teleport command to server
|
|
||||||
if (server == player.getServer().getInfo() || onTeamServer || server == null) {
|
|
||||||
Chat19.chat(player, "/tp " + String.join(" ", args));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
teleport(player, server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
public void teleportCommand(ProxiedPlayer p, @Mapper("to") String to, String... rest) {
|
||||||
if(args.length > 0)
|
ServerInfo server = getTarget(to);
|
||||||
return allPlayers(args[args.length - 1]);
|
|
||||||
return new ArrayList<>();
|
//Give control of teleport command to server
|
||||||
|
if (server == p.getServer().getInfo() || server == null) {
|
||||||
|
if (rest.length == 0) {
|
||||||
|
Chat19.chat(p, "/tp " + to);
|
||||||
|
} else {
|
||||||
|
Chat19.chat(p, "/tp " + to + " " + String.join(" ", rest));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
teleport(p, server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mapper("to")
|
||||||
|
@Cached(cacheDuration = 10, global = true)
|
||||||
|
public TypeMapper<String> tabCompleter() {
|
||||||
|
return new TypeMapper<String>() {
|
||||||
|
@Override
|
||||||
|
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
for (ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) {
|
||||||
|
list.add(player.getName());
|
||||||
|
}
|
||||||
|
if (Event.get() != null) {
|
||||||
|
EventStarter.getEventServer().keySet().forEach(teamId -> {
|
||||||
|
Team team = Team.get(teamId);
|
||||||
|
list.add(team.getTeamName());
|
||||||
|
list.add(team.getTeamKuerzel());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleport(ProxiedPlayer player, ServerInfo server){
|
public static void teleport(ProxiedPlayer player, ServerInfo server){
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren