SteamWar/BungeeCore
Archiviert
13
2

Fix Fabric stuff -> Storage #342

Zusammengeführt
Lixfel hat 1 Commits von FixFabricStuff nach master 2022-04-11 08:04:09 +02:00 zusammengeführt
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.UnsupportedCharsetException;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
@ -48,9 +46,6 @@ public class Fabric extends BasicListener {
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("minecraft");
@ -58,9 +53,9 @@ public class Fabric extends BasicListener {
neededMods.add("steamwarmodsender");
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
synchronized (expectPluginMessage) {
for (Map.Entry<ProxiedPlayer, Long> entry : expectPluginMessage.entrySet()) {
if (!checkedPlayers.containsKey(entry.getKey())) {
synchronized (Storage.fabricExpectPluginMessage) {
for (Map.Entry<ProxiedPlayer, Long> entry : Storage.fabricExpectPluginMessage.entrySet()) {
if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) {
continue;
}
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
@ -84,15 +79,15 @@ public class Fabric extends BasicListener {
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (!checkedPlayers.containsKey(player)) {
synchronized (expectPluginMessage) {
if (expectPluginMessage.containsKey(player)) {
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
synchronized (Storage.fabricExpectPluginMessage) {
if (Storage.fabricExpectPluginMessage.containsKey(player)) {
banPlayer(user, player);
return;
}
}
}
expectPluginMessage.remove(player);
Storage.fabricExpectPluginMessage.remove(player);
List<Mod> mods = new LinkedList<>();
@ -141,15 +136,15 @@ public class Fabric extends BasicListener {
}
if(Utils.handleMods(player,mods)) {
if (checkedPlayers.containsKey(player)) {
long current = checkedPlayers.get(player);
if (Storage.fabricCheckedPlayers.containsKey(player)) {
long current = Storage.fabricCheckedPlayers.get(player);
if (current != dataString.hashCode()) {
banPlayer(user, player);
return;
}
} else {
Message.send("MODIFICATION_CHECK_SUCCESS", player);
checkedPlayers.put(player, dataString.hashCode());
Storage.fabricCheckedPlayers.put(player, dataString.hashCode());
}
Storage.fabricPlayers.remove(player);
}
@ -158,8 +153,8 @@ public class Fabric extends BasicListener {
@EventHandler
public void onServerSwitchEvent(ServerSwitchEvent e) {
if (e.getFrom() == null) return;
synchronized (expectPluginMessage) {
expectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
synchronized (Storage.fabricExpectPluginMessage) {
Storage.fabricExpectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
}
}
@ -189,9 +184,9 @@ public class Fabric extends BasicListener {
}
public static void remove(ProxiedPlayer player) {
checkedPlayers.remove(player);
synchronized (expectPluginMessage) {
expectPluginMessage.remove(player);
Storage.fabricCheckedPlayers.remove(player);
synchronized (Storage.fabricExpectPluginMessage) {
Storage.fabricExpectPluginMessage.remove(player);
}
}
}

Datei anzeigen

@ -46,7 +46,7 @@ public class ModLoaderBlocker extends BasicListener {
if(new String(e.getData()).contains("fabric")){
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);
Message.send("MODLOADER_INSTALLED_FABRIC", p, "Fabric");
}