Archiviert
1
0

Merge branch 'master' into Better7Sanitize

Dieser Commit ist enthalten in:
YoyoNow 2021-07-12 09:21:04 +02:00
Commit 57f84002ba
4 geänderte Dateien mit 85 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -121,6 +121,7 @@ public class BungeeCore extends Plugin {
new UnIgnoreCommand(); new UnIgnoreCommand();
new PollresultCommand(); new PollresultCommand();
new ResourcereloadCommand(); new ResourcereloadCommand();
new StatCommand();
if(!EVENT_MODE){ if(!EVENT_MODE){
new WebregisterCommand(); new WebregisterCommand();

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<String, Integer> 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);
}
}
}

Datei anzeigen

@ -19,10 +19,7 @@
package de.steamwar.bungeecore.listeners; package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.commands.BauCommand; import de.steamwar.bungeecore.commands.BauCommand;
import de.steamwar.bungeecore.commands.TpCommand; import de.steamwar.bungeecore.commands.TpCommand;
import de.steamwar.bungeecore.comms.packets.PingPacket; import de.steamwar.bungeecore.comms.packets.PingPacket;
@ -51,6 +48,8 @@ public class ChatListener extends BasicListener {
sanitize7(e); sanitize7(e);
if(e.getMessage().startsWith("/")) if(e.getMessage().startsWith("/"))
onCommand(e); onCommand(e);
else if(e.getMessage().startsWith("+"))
onPlusMessage(e);
else else
onChat(e); onChat(e);
} }
@ -120,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); 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){ private void onChat(ChatEvent e){
if(e.getSender() instanceof ProxiedPlayer){ if(e.getSender() instanceof ProxiedPlayer){
ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); ProxiedPlayer sender = (ProxiedPlayer) e.getSender();

Datei anzeigen

@ -104,6 +104,7 @@ MOD_YELLOW_PLUR=§7Deaktiviere die Mods\n§e{0}\n§7um weiter auf §eSteam§8War
#Various commands #Various commands
ALERT=§f{0} ALERT=§f{0}
STAT_SERVER=§7Server §f{0} - §7Ram §f{1} §7CPU §f{2} §7Server Count §f{3}
#Ban&Mute-Command #Ban&Mute-Command
BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4} BAN_TEAM_BANNED={0} §c{1} wurde von {2} {3} gebannt. §f§lGrund: §f{4}