Archiviert
1
0
Dieser Commit ist enthalten in:
zOnlyKroks 2022-03-23 17:02:42 +01:00
Ursprung 626a876f0f
Commit d500c376fa
3 geänderte Dateien mit 56 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -19,10 +19,9 @@
package de.steamwar.bungeecore.listeners.mods;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.*;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Storage;
import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.bungeecore.sql.Mod;
@ -34,6 +33,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.*;
@ -41,8 +41,7 @@ import java.util.logging.Level;
public class Fabric extends BasicListener {
private final List<String> neededMods = new LinkedList<>();
public static final Set<ProxiedPlayer> checkedPlayers = new HashSet();
private final Set<String> neededMods = new HashSet<>();
{
neededMods.add("java");
@ -61,6 +60,7 @@ public class Fabric extends BasicListener {
}
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
List<Mod> mods = new LinkedList<>();
@ -69,43 +69,48 @@ public class Fabric extends BasicListener {
data = Arrays.copyOfRange(data,varInt.length, data.length);
String dataString = new String(data, StandardCharsets.UTF_8);
if(data.length != varInt.length + varInt.value) {
banPlayer(user,player);
}
String dataString = "";
try{
dataString = new String(data, StandardCharsets.UTF_8);
}catch (UnsupportedCharsetException exception) {
banPlayer(user, player);
}
JsonArray array = new JsonArray();
try {
JsonArray array = new JsonParser().parse(dataString).getAsJsonArray();
array = new JsonParser().parse(dataString).getAsJsonArray();
}catch (JsonSyntaxException exception) {
banPlayer(user, player);
}
for(int i = 0; i < array.size(); i++) {
mods.add(Mod.get(array.get(i).getAsString(), Mod.Platform.FABRIC));
for(JsonElement mod : array) {
mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC));
}
boolean isSorted = isSortedAlphabetically(mods);
if(!isSorted) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true);
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte.");
banPlayer(user, player);
return;
}
if(!modsAreAbsent(mods)) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now()), "§7Du hast probiert den FabricModSender zu umgehen!", 0, true);
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch gebannt, da er den FabricModSender editiert hatte.");
banPlayer(user, player);
return;
}
if(Utils.handleMods(player,mods)) checkedPlayers.add(player);
}catch (Exception ex) {
ex.printStackTrace();
player.disconnect("§7Mod Verification failed! Contact a Developer");
if(Utils.handleMods(player,mods)) {
Storage.fabricPlayers.remove(player);
Message.send("MODIFICATION_CHECK_SUCCESS", player);
}
}
@EventHandler
public void onDisconnect(PlayerDisconnectEvent e){
checkedPlayers.remove(e.getPlayer());
}
private boolean isSortedAlphabetically(List<Mod> mods) {
boolean isSorted = true;
for(int i = 0; i < mods.size() - 1; i++) {
@ -124,4 +129,13 @@ public class Fabric extends BasicListener {
.distinct()
.count() == neededMods.size();
}
public void banPlayer(SteamwarUser user, ProxiedPlayer player) {
user.punish(Punishment.PunishmentType.Ban,
Timestamp.from(Instant.now()),
Message.parse("MODIFICATION_BAN_MESSAGE", player),
0,
true);
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + Message.parse("MODIFICATION_BAN_LOG", player));
}
}

Datei anzeigen

@ -73,7 +73,7 @@ public class ModLoaderBlocker extends BasicListener {
}
public static boolean isFabric(ProxiedPlayer player) {
return Storage.fabricPlayers.contains(player) && !Fabric.checkedPlayers.contains(player);
return Storage.fabricPlayers.contains(player);
}
public static void addServer(String server) {

Datei anzeigen

@ -583,3 +583,8 @@ RANK_UNPLACED=§eunplatziert
RANK_PLACED=§e{0}§8. §7mit §e{1} §7Elo§8.
RANK_EMBLEM=§eEmblem§8: {0}
RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8)
#Fabric Mod Sender
MODIFICATION_BAN_MESSAGE = "Du hast probiert den FabricModSender zu umgehen / zu modifizieren!"
MODIFICATION_BAN_LOG = " hat probiert den Fabric Mod Sender zu editieren / umzugehen!"
MODIFICATION_CHECK_SUCCESS = "§eDeine Mods wurden geprüft und du darfst nun auf Arenen joinen!"