SteamWar/BungeeCore
Archiviert
13
2
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.net.InetSocketAddress;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class DevCommand extends BasicCommand { public class DevCommand extends BasicCommand {
@ -50,17 +51,23 @@ public class DevCommand extends BasicCommand {
String[] server = devSever[0].split("\\."); String[] server = devSever[0].split("\\.");
sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1]));
} else { } else {
if (args.length != 0) { if (args.length == 0) {
for (String s : devSever) { 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."));
}
}
}
private void send(String[] devServer, ProxiedPlayer sender, Predicate<String> test, Runnable error) {
for (String s : devServer) {
String[] server = s.split("\\."); String[] server = s.split("\\.");
if (args[0].equals(server[0])) { if (test.test(server[0])) {
sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1])); sendToServer(sender, server[0], Integer.parseInt(server[1]));
return; break;
} }
} }
} error.run();
sender.sendMessage("§eSteam§8War§8» §cUnbekannter DevServer.");
}
} }
private void sendToServer(ProxiedPlayer proxiedPlayer, String name, int port) { private void sendToServer(ProxiedPlayer proxiedPlayer, String name, int port) {
@ -81,6 +88,9 @@ public class DevCommand extends BasicCommand {
if (args.length > 1) { if (args.length > 1) {
return Collections.emptyList(); 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());
} }
} }