Add DevCommand
Dieser Commit ist enthalten in:
Ursprung
c980a1c92a
Commit
47711b746e
@ -108,6 +108,7 @@ public class BungeeCore extends Plugin {
|
||||
new DenyCommand("watchcat", "wc");
|
||||
new TeamCommand();
|
||||
new ServerTeamchatCommand();
|
||||
new DevCommand();
|
||||
new EventCommand();
|
||||
new EventreloadCommand();
|
||||
new EventRescheduleCommand();
|
||||
|
86
src/de/steamwar/bungeecore/commands/DevCommand.java
Normale Datei
86
src/de/steamwar/bungeecore/commands/DevCommand.java
Normale Datei
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DevCommand extends BasicCommand {
|
||||
|
||||
private final File DevServerDir = new File("/configs/DevServer");
|
||||
|
||||
public DevCommand() {
|
||||
super("dev", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof ProxiedPlayer)) {
|
||||
return;
|
||||
}
|
||||
String[] devSever = DevServerDir.list();
|
||||
if (devSever == null || devSever.length == 0) {
|
||||
sender.sendMessage("§eSteam§8War§8» §cDer Server ist derzeit nicht erreichbar.");
|
||||
} else if (devSever.length == 1) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage("§eSteam§8War§8» §cUnbekannter DevServer.");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
proxiedPlayer.connect(serverInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof ProxiedPlayer)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String[] devSever = DevServerDir.list();
|
||||
if (devSever == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (args.length > 1) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.stream(devSever).map(s -> s.split("\\.")).map(s -> s[0]).collect(Collectors.toList());
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren