SteamWar/BungeeCore
Archiviert
13
2

No autopermaban
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-10-13 13:04:58 +02:00
Ursprung 2c896e204f
Commit e0e18cab92

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) {