geforkt von SteamWar/BungeeCore
Parsing funktioniert + notwendige mods check
Dieser Commit ist enthalten in:
Ursprung
3a6f3fb4c0
Commit
657c03dff1
@ -39,6 +39,15 @@ import java.util.logging.Level;
|
||||
|
||||
public class Fabric extends BasicListener {
|
||||
|
||||
private final List<String> neededMods = new LinkedList<>();
|
||||
|
||||
{
|
||||
neededMods.add("java");
|
||||
neededMods.add("minecraft");
|
||||
neededMods.add("fabricloader");
|
||||
neededMods.add("steamwarmodsender");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||
if(!e.getTag().equals("fabricmodsender:mods"))
|
||||
@ -52,9 +61,12 @@ public class Fabric extends BasicListener {
|
||||
|
||||
List<Mod> mods = new LinkedList<>();
|
||||
|
||||
String dataString = new String(e.getData(), StandardCharsets.UTF_8).substring(1);
|
||||
byte[] data = e.getData();
|
||||
Utils.VarInt varInt = Utils.readVarInt(data,0);
|
||||
|
||||
System.out.println(dataString);
|
||||
data = Arrays.copyOfRange(data,varInt.length, data.length);
|
||||
|
||||
String dataString = new String(data, StandardCharsets.UTF_8);
|
||||
|
||||
try {
|
||||
JsonArray array = new JsonParser().parse(dataString).getAsJsonArray();
|
||||
@ -68,7 +80,14 @@ public class Fabric extends BasicListener {
|
||||
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");
|
||||
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;
|
||||
}
|
||||
|
||||
@ -89,4 +108,12 @@ public class Fabric extends BasicListener {
|
||||
}
|
||||
return isSorted;
|
||||
}
|
||||
|
||||
private boolean modsAreAbsent(List<Mod> mods) {
|
||||
return mods.stream()
|
||||
.map(Mod::getModName)
|
||||
.filter(neededMods::contains)
|
||||
.distinct()
|
||||
.count() == neededMods.size();
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren