Archiviert
1
0

Fix Fabric stuff

Dieser Commit ist enthalten in:
yoyosource 2022-04-10 20:14:33 +02:00
Ursprung f7892d21d1
Commit e723224282
2 geänderte Dateien mit 16 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -38,8 +38,6 @@ import net.md_5.bungee.event.EventHandler;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException; import java.nio.charset.UnsupportedCharsetException;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
@ -48,9 +46,6 @@ public class Fabric extends BasicListener {
private final Set<String> neededMods = new HashSet<>(); private final Set<String> neededMods = new HashSet<>();
public static final Map<ProxiedPlayer, Integer> checkedPlayers = new HashMap<>();
private static final Map<ProxiedPlayer, Long> expectPluginMessage = new HashMap<>();
{ {
neededMods.add("java"); neededMods.add("java");
neededMods.add("minecraft"); neededMods.add("minecraft");
@ -58,9 +53,9 @@ public class Fabric extends BasicListener {
neededMods.add("steamwarmodsender"); neededMods.add("steamwarmodsender");
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
synchronized (expectPluginMessage) { synchronized (Storage.fabricExpectPluginMessage) {
for (Map.Entry<ProxiedPlayer, Long> entry : expectPluginMessage.entrySet()) { for (Map.Entry<ProxiedPlayer, Long> entry : Storage.fabricExpectPluginMessage.entrySet()) {
if (!checkedPlayers.containsKey(entry.getKey())) { if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) {
continue; continue;
} }
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) { if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
@ -84,15 +79,15 @@ public class Fabric extends BasicListener {
ProxiedPlayer player = (ProxiedPlayer) e.getSender(); ProxiedPlayer player = (ProxiedPlayer) e.getSender();
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (!checkedPlayers.containsKey(player)) { if (!Storage.fabricCheckedPlayers.containsKey(player)) {
synchronized (expectPluginMessage) { synchronized (Storage.fabricExpectPluginMessage) {
if (expectPluginMessage.containsKey(player)) { if (Storage.fabricExpectPluginMessage.containsKey(player)) {
banPlayer(user, player); banPlayer(user, player);
return; return;
} }
} }
} }
expectPluginMessage.remove(player); Storage.fabricExpectPluginMessage.remove(player);
List<Mod> mods = new LinkedList<>(); List<Mod> mods = new LinkedList<>();
@ -141,15 +136,15 @@ public class Fabric extends BasicListener {
} }
if(Utils.handleMods(player,mods)) { if(Utils.handleMods(player,mods)) {
if (checkedPlayers.containsKey(player)) { if (Storage.fabricCheckedPlayers.containsKey(player)) {
long current = checkedPlayers.get(player); long current = Storage.fabricCheckedPlayers.get(player);
if (current != dataString.hashCode()) { if (current != dataString.hashCode()) {
banPlayer(user, player); banPlayer(user, player);
return; return;
} }
} else { } else {
Message.send("MODIFICATION_CHECK_SUCCESS", player); Message.send("MODIFICATION_CHECK_SUCCESS", player);
checkedPlayers.put(player, dataString.hashCode()); Storage.fabricCheckedPlayers.put(player, dataString.hashCode());
} }
Storage.fabricPlayers.remove(player); Storage.fabricPlayers.remove(player);
} }
@ -158,8 +153,8 @@ public class Fabric extends BasicListener {
@EventHandler @EventHandler
public void onServerSwitchEvent(ServerSwitchEvent e) { public void onServerSwitchEvent(ServerSwitchEvent e) {
if (e.getFrom() == null) return; if (e.getFrom() == null) return;
synchronized (expectPluginMessage) { synchronized (Storage.fabricExpectPluginMessage) {
expectPluginMessage.put(e.getPlayer(), System.currentTimeMillis()); Storage.fabricExpectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
} }
} }
@ -189,9 +184,9 @@ public class Fabric extends BasicListener {
} }
public static void remove(ProxiedPlayer player) { public static void remove(ProxiedPlayer player) {
checkedPlayers.remove(player); Storage.fabricCheckedPlayers.remove(player);
synchronized (expectPluginMessage) { synchronized (Storage.fabricExpectPluginMessage) {
expectPluginMessage.remove(player); Storage.fabricExpectPluginMessage.remove(player);
} }
} }
} }

Datei anzeigen

@ -46,7 +46,7 @@ public class ModLoaderBlocker extends BasicListener {
if(new String(e.getData()).contains("fabric")){ if(new String(e.getData()).contains("fabric")){
ProxiedPlayer p = (ProxiedPlayer) sender; ProxiedPlayer p = (ProxiedPlayer) sender;
if (!Fabric.checkedPlayers.containsKey(p) && !Storage.fabricPlayers.contains(p)) { if (!Storage.fabricCheckedPlayers.containsKey(p) && !Storage.fabricPlayers.contains(p)) {
Storage.fabricPlayers.add(p); Storage.fabricPlayers.add(p);
Message.send("MODLOADER_INSTALLED_FABRIC", p, "Fabric"); Message.send("MODLOADER_INSTALLED_FABRIC", p, "Fabric");
} }