geforkt von SteamWar/BungeeCore
Add DevCommand
Dieser Commit ist enthalten in:
Ursprung
47711b746e
Commit
b16b258ba2
@ -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,19 +51,25 @@ 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."));
|
||||||
String[] server = s.split("\\.");
|
} else {
|
||||||
if (args[0].equals(server[0])) {
|
send(devSever, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> sender.sendMessage("§eSteam§8War§8» §cDer Server ist derzeit nicht erreichbar."));
|
||||||
sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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) {
|
private void sendToServer(ProxiedPlayer proxiedPlayer, String name, int port) {
|
||||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
|
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
|
||||||
ServerInfo serverInfo = ProxyServer.getInstance().constructServerInfo("Dev-" + name, address, "SteamWar.de - Subserver", false);
|
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) {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren