Archiviert
1
0

Merge branch 'master' into TeamTablist

Dieser Commit ist enthalten in:
YoyoNow 2022-10-24 17:17:35 +02:00
Commit 3606e75ab6
3 geänderte Dateien mit 14 neuen und 15 gelöschten Zeilen
src/de/steamwar/bungeecore

Datei anzeigen

@ -86,6 +86,7 @@ public class ErrorLogger extends Handler {
contains.add("Error occurred processing connection for"); contains.add("Error occurred processing connection for");
contains.add("Server is online mode!"); contains.add("Server is online mode!");
contains.add(" took "); contains.add(" took ");
contains.add("Could not translate packet ");
ignoreContains = Collections.unmodifiableList(contains); ignoreContains = Collections.unmodifiableList(contains);
} }
} }

Datei anzeigen

@ -211,6 +211,8 @@ public abstract class Node {
if(!process.waitFor(1, TimeUnit.SECONDS)) if(!process.waitFor(1, TimeUnit.SECONDS))
throw new IOException(hostname + " timeout"); throw new IOException(hostname + " timeout");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
if(reader == null)
throw new IOException("Why reader null? " + process.getInputStream());
calcLoadLimit(reader, reader); calcLoadLimit(reader, reader);
} }
} catch (IOException e) { } catch (IOException e) {

Datei anzeigen

@ -28,7 +28,7 @@ import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.Storage;
import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Mod;
import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SWException;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -40,7 +40,6 @@ import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException; import java.nio.charset.UnsupportedCharsetException;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public class Fabric extends BasicListener { public class Fabric extends BasicListener {
@ -59,7 +58,7 @@ public class Fabric extends BasicListener {
continue; continue;
} }
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) { if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey(), "Expected message not received"); logMessage(SteamwarUser.get(entry.getKey()), "Expected message not received", String.valueOf(entry.getValue()));
return; return;
} }
} }
@ -78,11 +77,12 @@ public class Fabric extends BasicListener {
ProxiedPlayer player = (ProxiedPlayer) e.getSender(); ProxiedPlayer player = (ProxiedPlayer) e.getSender();
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
byte[] data = e.getData();
if (!Storage.fabricCheckedPlayers.containsKey(player)) { if (!Storage.fabricCheckedPlayers.containsKey(player)) {
synchronized (Storage.fabricExpectPluginMessage) { synchronized (Storage.fabricExpectPluginMessage) {
if (Storage.fabricExpectPluginMessage.containsKey(player)) { if (Storage.fabricExpectPluginMessage.containsKey(player)) {
banPlayer(user, player, "Was not fabric checked but send message nonetheless"); logMessage(user, "Was not fabric checked but send message nonetheless", Arrays.toString(data));
return; return;
} }
} }
@ -91,11 +91,10 @@ public class Fabric extends BasicListener {
List<Mod> mods = new LinkedList<>(); List<Mod> mods = new LinkedList<>();
byte[] data = e.getData();
Utils.VarInt varInt = Utils.readVarInt(data,0); Utils.VarInt varInt = Utils.readVarInt(data,0);
if(data.length != varInt.length + varInt.value) { if(data.length != varInt.length + varInt.value) {
banPlayer(user,player, "Invalid message length"); logMessage(user, "Invalid message length", Arrays.toString(data));
return; return;
} }
@ -106,7 +105,7 @@ public class Fabric extends BasicListener {
try{ try{
dataString = new String(data, StandardCharsets.UTF_8); dataString = new String(data, StandardCharsets.UTF_8);
}catch (UnsupportedCharsetException exception) { }catch (UnsupportedCharsetException exception) {
banPlayer(user, player, "Unsupported charset"); logMessage(user, "Unsupported charset", Arrays.toString(data));
return; return;
} }
@ -115,7 +114,7 @@ public class Fabric extends BasicListener {
try { try {
array = new JsonParser().parse(dataString).getAsJsonArray(); array = new JsonParser().parse(dataString).getAsJsonArray();
}catch (JsonSyntaxException exception) { }catch (JsonSyntaxException exception) {
banPlayer(user, player, "Invalid json"); logMessage(user, "Invalid json", dataString);
return; return;
} }
@ -133,7 +132,7 @@ public class Fabric extends BasicListener {
*/ */
if(!neededModsContained(mods)) { if(!neededModsContained(mods)) {
banPlayer(user, player, "Needed mods are not contained"); logMessage(user, "Needed mods are not contained", dataString);
return; return;
} }
@ -141,7 +140,7 @@ public class Fabric extends BasicListener {
if (Storage.fabricCheckedPlayers.containsKey(player)) { if (Storage.fabricCheckedPlayers.containsKey(player)) {
long current = Storage.fabricCheckedPlayers.get(player); long current = Storage.fabricCheckedPlayers.get(player);
if (current != dataString.hashCode()) { if (current != dataString.hashCode()) {
banPlayer(user, player, ""); logMessage(user, "Mods changed during runtime", dataString);
return; return;
} }
} else { } else {
@ -178,11 +177,8 @@ public class Fabric extends BasicListener {
.count() == neededMods.size(); .count() == neededMods.size();
} }
public void banPlayer(SteamwarUser user, ProxiedPlayer player, String reason) { public void logMessage(SteamwarUser user, String reason, String data) {
user.punishPerma(Punishment.PunishmentType.Ban, SWException.log("Bungee", "FabricModSender " + user.getUserName() + ": " + reason, data);
Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()),
0);
BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName(), reason));
} }
public static void remove(ProxiedPlayer player) { public static void remove(ProxiedPlayer player) {