Dieser Commit ist enthalten in:
Ursprung
626a876f0f
Commit
d500c376fa
@ -19,10 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.listeners.mods;
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.*;
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
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;
|
||||||
@ -34,6 +33,7 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
|
|||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -41,8 +41,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class Fabric extends BasicListener {
|
public class Fabric extends BasicListener {
|
||||||
|
|
||||||
private final List<String> neededMods = new LinkedList<>();
|
private final Set<String> neededMods = new HashSet<>();
|
||||||
public static final Set<ProxiedPlayer> checkedPlayers = new HashSet();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
neededMods.add("java");
|
neededMods.add("java");
|
||||||
@ -61,6 +60,7 @@ public class Fabric extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
|
||||||
List<Mod> mods = new LinkedList<>();
|
List<Mod> mods = new LinkedList<>();
|
||||||
|
|
||||||
@ -69,41 +69,46 @@ public class Fabric extends BasicListener {
|
|||||||
|
|
||||||
data = Arrays.copyOfRange(data,varInt.length, data.length);
|
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 {
|
try {
|
||||||
JsonArray array = new JsonParser().parse(dataString).getAsJsonArray();
|
array = new JsonParser().parse(dataString).getAsJsonArray();
|
||||||
|
}catch (JsonSyntaxException exception) {
|
||||||
for(int i = 0; i < array.size(); i++) {
|
banPlayer(user, player);
|
||||||
mods.add(Mod.get(array.get(i).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.");
|
|
||||||
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.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Utils.handleMods(player,mods)) checkedPlayers.add(player);
|
|
||||||
}catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
player.disconnect("§7Mod Verification failed! Contact a Developer");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
for(JsonElement mod : array) {
|
||||||
public void onDisconnect(PlayerDisconnectEvent e){
|
mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC));
|
||||||
checkedPlayers.remove(e.getPlayer());
|
}
|
||||||
|
|
||||||
|
boolean isSorted = isSortedAlphabetically(mods);
|
||||||
|
|
||||||
|
if(!isSorted) {
|
||||||
|
banPlayer(user, player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!modsAreAbsent(mods)) {
|
||||||
|
banPlayer(user, player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Utils.handleMods(player,mods)) {
|
||||||
|
Storage.fabricPlayers.remove(player);
|
||||||
|
Message.send("MODIFICATION_CHECK_SUCCESS", player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSortedAlphabetically(List<Mod> mods) {
|
private boolean isSortedAlphabetically(List<Mod> mods) {
|
||||||
@ -124,4 +129,13 @@ public class Fabric extends BasicListener {
|
|||||||
.distinct()
|
.distinct()
|
||||||
.count() == neededMods.size();
|
.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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class ModLoaderBlocker extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFabric(ProxiedPlayer player) {
|
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) {
|
public static void addServer(String server) {
|
||||||
|
@ -583,3 +583,8 @@ RANK_UNPLACED=§eunplatziert
|
|||||||
RANK_PLACED=§e{0}§8. §7mit §e{1} §7Elo§8.
|
RANK_PLACED=§e{0}§8. §7mit §e{1} §7Elo§8.
|
||||||
RANK_EMBLEM=§eEmblem§8: {0}
|
RANK_EMBLEM=§eEmblem§8: {0}
|
||||||
RANK_NEEDED_FIGHTS_LEFT={0} §8(§7noch §e{1}§7 Kämpfe nötig§8)
|
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!"
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren