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