Archiviert
1
0
Dieser Commit ist enthalten in:
yoyosource 2021-07-10 22:38:44 +02:00
Ursprung 47711b746e
Commit b16b258ba2

Datei anzeigen

@ -28,6 +28,7 @@ import java.io.File;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class DevCommand extends BasicCommand {
@ -50,19 +51,25 @@ public class DevCommand extends BasicCommand {
String[] server = devSever[0].split("\\.");
sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1]));
} else {
if (args.length != 0) {
for (String s : devSever) {
String[] server = s.split("\\.");
if (args[0].equals(server[0])) {
sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1]));
return;
}
}
if (args.length == 0) {
send(devSever, (ProxiedPlayer) sender, s -> s.equalsIgnoreCase(((ProxiedPlayer) sender).getDisplayName()), () -> sender.sendMessage("§eSteam§8War§8» §cBitte gib einen DevServer an."));
} else {
send(devSever, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> sender.sendMessage("§eSteam§8War§8» §cDer Server ist derzeit nicht erreichbar."));
}
sender.sendMessage("§eSteam§8War§8» §cUnbekannter DevServer.");
}
}
private void send(String[] devServer, ProxiedPlayer sender, Predicate<String> test, Runnable error) {
for (String s : devServer) {
String[] server = s.split("\\.");
if (test.test(server[0])) {
sendToServer(sender, server[0], Integer.parseInt(server[1]));
break;
}
}
error.run();
}
private void sendToServer(ProxiedPlayer proxiedPlayer, String name, int port) {
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
ServerInfo serverInfo = ProxyServer.getInstance().constructServerInfo("Dev-" + name, address, "SteamWar.de - Subserver", false);
@ -81,6 +88,9 @@ public class DevCommand extends BasicCommand {
if (args.length > 1) {
return Collections.emptyList();
}
return Arrays.stream(devSever).map(s -> s.split("\\.")).map(s -> s[0]).collect(Collectors.toList());
return Arrays.stream(devSever).map(s -> s.split("\\.")).map(s -> s[0]).filter(s -> {
if (args.length == 0) return true;
return s.startsWith(args[0]);
}).collect(Collectors.toList());
}
}