SteamWar/BungeeCore
Archiviert
13
2

DevServer #227

Manuell gemergt
YoyoNow hat 6 Commits von DevServer nach master 2021-07-12 09:22:33 +02:00 zusammengeführt
2 geänderte Dateien mit 87 neuen und 0 gelöschten Zeilen
Nur Änderungen aus Commit 47711b746e werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -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();

Datei anzeigen

@ -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.");
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

devServer

devServer
Veraltet
Review

Behoben

Behoben
} else if (devSever.length == 1) {
YoyoNow markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Warum null?

Warum null?
Veraltet
Review

Weil .list() null zurück geben kann, ich weiß auch nicht warum, SonarLint meckert dies an.

Weil .list() null zurück geben kann, ich weiß auch nicht warum, SonarLint meckert dies an.
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());
}
}