diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java
index 8b78cb6..f0a8bb7 100644
--- a/src/de/steamwar/bungeecore/BungeeCore.java
+++ b/src/de/steamwar/bungeecore/BungeeCore.java
@@ -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();
@@ -122,6 +123,7 @@ public class BungeeCore extends Plugin {
new PollresultCommand();
new ResourcereloadCommand();
new ListCommand();
+ new StatCommand();
if(!EVENT_MODE){
new WebregisterCommand();
diff --git a/src/de/steamwar/bungeecore/commands/DevCommand.java b/src/de/steamwar/bungeecore/commands/DevCommand.java
new file mode 100644
index 0000000..7e5ed2d
--- /dev/null
+++ b/src/de/steamwar/bungeecore/commands/DevCommand.java
@@ -0,0 +1,97 @@
+/*
+ * 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 .
+ */
+
+package de.steamwar.bungeecore.commands;
+
+import de.steamwar.bungeecore.Message;
+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.function.Predicate;
+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[] devServer = DevServerDir.list();
+ if (devServer == null || devServer.length == 0) {
+ Message.send("DEV_NO_SERVER", sender);
+ } else if (devServer.length == 1) {
+ String[] server = devServer[0].split("\\.");
+ sendToServer((ProxiedPlayer) sender, server[0], Integer.parseInt(server[1]));
+ } else {
+ if (args.length == 0) {
+ send(devServer, (ProxiedPlayer) sender, s -> s.equalsIgnoreCase(((ProxiedPlayer) sender).getDisplayName()), () -> Message.send("DEV_UNKNOWN_SERVER", sender));
+ } else {
+ send(devServer, (ProxiedPlayer) sender, args[0]::equalsIgnoreCase, () -> Message.send("DEV_NO_SERVER", sender));
+ }
+ }
+ }
+
+ private void send(String[] devServer, ProxiedPlayer sender, Predicate 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);
+ proxiedPlayer.connect(serverInfo);
+ }
+
+ @Override
+ public Iterable 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]).filter(s -> {
+ if (args.length == 0) return true;
+ return s.startsWith(args[0]);
+ }).collect(Collectors.toList());
+ }
+}
diff --git a/src/de/steamwar/bungeecore/commands/StatCommand.java b/src/de/steamwar/bungeecore/commands/StatCommand.java
new file mode 100644
index 0000000..506ecab
--- /dev/null
+++ b/src/de/steamwar/bungeecore/commands/StatCommand.java
@@ -0,0 +1,66 @@
+/*
+ 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 .
+*/
+
+package de.steamwar.bungeecore.commands;
+
+import de.steamwar.bungeecore.LoadEvaluation;
+import de.steamwar.bungeecore.Message;
+import net.md_5.bungee.api.CommandSender;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+public class StatCommand extends BasicCommand {
+
+ public StatCommand() {
+ super("stat", "bungeecore.softreload", "stats");
+ }
+
+ @Override
+ public void execute(CommandSender sender, String[] args) {
+ try {
+ Process process = new ProcessBuilder("ps", "x").start();
+ process.waitFor();
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ Map serverCounts = new HashMap<>();
+ bufferedReader.lines().forEach(s -> {
+ if (!s.contains("--port")) {
+ return;
+ }
+ String server = "SW";
+ if (s.contains("ssh -L")) {
+ server = s.substring(s.indexOf("ssh -L") + 6).split(" ")[2];
+ }
+ serverCounts.put(server, serverCounts.computeIfAbsent(server, s1 -> 0) + 1);
+ });
+ serverCounts.forEach((s, integer) -> {
+ if (s.equals("SW")) {
+ Message.send("STAT_SERVER", sender, s, LoadEvaluation.getRamPercentage(), LoadEvaluation.getCPULoad(), integer);
+ } else {
+ Message.send("STAT_SERVER", sender, s.toUpperCase(), LoadEvaluation.getRemoteRamPercentage(s), LoadEvaluation.getRemoteCPULoad(s), integer);
+ }
+ });
+ } catch (Exception e) {
+ throw new SecurityException(e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java
index b850835..a73ea6d 100644
--- a/src/de/steamwar/bungeecore/listeners/ChatListener.java
+++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java
@@ -19,10 +19,7 @@
package de.steamwar.bungeecore.listeners;
-import de.steamwar.bungeecore.BungeeCore;
-import de.steamwar.bungeecore.Message;
-import de.steamwar.bungeecore.Servertype;
-import de.steamwar.bungeecore.Subserver;
+import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.commands.BauCommand;
import de.steamwar.bungeecore.commands.TpCommand;
import de.steamwar.bungeecore.comms.packets.PingPacket;
@@ -51,6 +48,8 @@ public class ChatListener extends BasicListener {
sanitize7(e);
if(e.getMessage().startsWith("/"))
onCommand(e);
+ else if(e.getMessage().startsWith("+"))
+ onPlusMessage(e);
else
onChat(e);
}
@@ -64,6 +63,10 @@ public class ChatListener extends BasicListener {
e.setMessage("/" + e.getMessage().substring(1));
}else if(begin.startsWith("77") && begin.substring(2).matches("[A-Za-z]+")){
e.setMessage("//" + e.getMessage().substring(2));
+ }else if(begin.startsWith("7/") && begin.substring(2).matches("[A-Za-z]+")){
+ e.setMessage("//" + e.getMessage().substring(2));
+ }else if(begin.startsWith("/7") && begin.substring(2).matches("[A-Za-z]+")){
+ e.setMessage("//" + e.getMessage().substring(2));
}
}
@@ -116,6 +119,20 @@ public class ChatListener extends BasicListener {
scheduler.schedule(BungeeCore.get(), () -> Message.sendPrefixless("MSG_FORMAT", sender, "YoyoNow", sender.getDisplayName(), Message.parse("CHAT_YOYONOW_4", sender)), 12, TimeUnit.SECONDS);
}
+ private void onPlusMessage(ChatEvent e) {
+ ProxiedPlayer p = (ProxiedPlayer) e.getSender();
+ Subserver subserver = Subserver.getSubserver(p);
+ if(subserver instanceof Bauserver) {
+ String[] smolArgs = e.getMessage().substring(1).split(" ");
+ String[] args = new String[smolArgs.length + 1];
+ args[0] = "";
+ System.arraycopy(smolArgs, 0, args, 1, smolArgs.length);
+ localChat(e, args);
+ } else {
+ onChat(e);
+ }
+ }
+
private void onChat(ChatEvent e){
if(e.getSender() instanceof ProxiedPlayer){
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties
index dd74cdb..eab98a5 100644
--- a/src/de/steamwar/messages/BungeeCore.properties
+++ b/src/de/steamwar/messages/BungeeCore.properties
@@ -9,6 +9,9 @@ INVALID_TIME=§cUngültige Zeitangabe.
STEAMWAR_BRAND=§eSteam§8War.de §7({0}) §r<- §e{1} §7({2})§r
+DEV_NO_SERVER=§cDer Server ist derzeit nicht erreichbar.
+DEV_UNKNOWN_SERVER=§cBitte gib einen DevServer an.
+
#ModLoader blocker
MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten.
MODLOADER_DENIED=§cMit Fabric, Forge und LiteLoader kannst du keinen Arenen beitreten.
@@ -104,6 +107,7 @@ MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War
#Various commands
ALERT=§f{0}
+STAT_SERVER=§7Server §f{0} - §7Ram §f{1} §7CPU §f{2} §7Server Count §f{3}
#Ban&Mute-Command
BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4}