SteamWar/BungeeCore
Archiviert
13
2

Update some stuff #339

Zusammengeführt
Lixfel hat 9 Commits von FabricModStuff nach master 2022-04-09 20:58:27 +02:00 zusammengeführt
2 geänderte Dateien mit 29 neuen und 1 gelöschten Zeilen
Nur Änderungen aus Commit c05a2e4ae6 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -19,7 +19,10 @@
package de.steamwar.bungeecore.listeners.mods;
import com.google.gson.*;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Storage;
@ -27,8 +30,10 @@ import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.bungeecore.sql.Mod;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.event.EventHandler;
import java.nio.charset.StandardCharsets;
@ -36,6 +41,7 @@ import java.nio.charset.UnsupportedCharsetException;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public class Fabric extends BasicListener {
@ -43,12 +49,22 @@ public class Fabric extends BasicListener {
private final Set<String> neededMods = new HashSet<>();
public static final Map<ProxiedPlayer, Integer> checkedPlayers = new HashMap<>();
public static final Map<ProxiedPlayer, Long> expectPluginMessage = new HashMap<>();
{
neededMods.add("java");
neededMods.add("minecraft");
neededMods.add("fabricloader");
neededMods.add("steamwarmodsender");
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
for (Map.Entry<ProxiedPlayer, Long> entry : expectPluginMessage.entrySet()) {
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey());
return;
}
}
}, 0, 1, TimeUnit.SECONDS);
}
@EventHandler
@ -63,6 +79,11 @@ public class Fabric extends BasicListener {
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (expectPluginMessage.containsKey(player) && !checkedPlayers.containsKey(player)) {
banPlayer(user, player);
return;
}
List<Mod> mods = new LinkedList<>();
byte[] data = e.getData();
@ -124,6 +145,12 @@ public class Fabric extends BasicListener {
}
}
@EventHandler
public void onServerSwitchEvent(ServerSwitchEvent e) {
if (e.getFrom() == null) return;
expectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
}
private boolean isSortedAlphabetically(List<Mod> mods) {
boolean isSorted = true;
for(int i = 0; i < mods.size() - 1; i++) {

Datei anzeigen

@ -59,6 +59,7 @@ public class ModLoaderBlocker extends BasicListener {
@EventHandler
public void onDisconnect(PlayerDisconnectEvent e){
Fabric.checkedPlayers.remove(e.getPlayer());
Fabric.expectPluginMessage.remove(e.getPlayer());
Storage.fabricPlayers.remove(e.getPlayer());
}