SteamWar/BungeeCore
Archiviert
13
2

Revert some stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-04-05 19:47:08 +02:00
Ursprung 3af6f43ccd
Commit 7b5ce77e93
2 geänderte Dateien mit 28 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -48,8 +48,10 @@ 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, Integer> checkedPlayers = new HashMap<>();
public static final Map<ProxiedPlayer, Long> expectPluginMessage = new HashMap<>(); private static final Map<ProxiedPlayer, Long> expectPluginMessage = new HashMap<>();
private static final Object OBJECT = new Object();
{ {
neededMods.add("java"); neededMods.add("java");
@ -58,10 +60,12 @@ public class Fabric extends BasicListener {
neededMods.add("steamwarmodsender"); neededMods.add("steamwarmodsender");
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
for (Map.Entry<ProxiedPlayer, Long> entry : expectPluginMessage.entrySet()) { synchronized (OBJECT) {
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) { for (Map.Entry<ProxiedPlayer, Long> entry : expectPluginMessage.entrySet()) {
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey()); if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
return; banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey());
return;
}
} }
} }
}, 0, 1, TimeUnit.SECONDS); }, 0, 1, TimeUnit.SECONDS);
@ -79,9 +83,13 @@ 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 (expectPluginMessage.containsKey(player) && !checkedPlayers.containsKey(player)) { if (!checkedPlayers.containsKey(player)) {
banPlayer(user, player); synchronized (OBJECT) {
return; if (expectPluginMessage.containsKey(player)) {
banPlayer(user, player);
return;
}
}
} }
List<Mod> mods = new LinkedList<>(); List<Mod> mods = new LinkedList<>();
@ -148,7 +156,9 @@ 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;
expectPluginMessage.put(e.getPlayer(), System.currentTimeMillis()); synchronized (OBJECT) {
expectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
}
} }
private boolean isSortedAlphabetically(List<Mod> mods) { private boolean isSortedAlphabetically(List<Mod> mods) {
@ -177,4 +187,11 @@ public class Fabric extends BasicListener {
true); true);
BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName())); BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName()));
} }
public static void remove(ProxiedPlayer player) {
synchronized (OBJECT) {
checkedPlayers.remove(player);
expectPluginMessage.remove(player);
}
}
} }

Datei anzeigen

@ -28,7 +28,6 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import java.nio.charset.StandardCharsets;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -58,8 +57,7 @@ public class ModLoaderBlocker extends BasicListener {
@EventHandler @EventHandler
public void onDisconnect(PlayerDisconnectEvent e){ public void onDisconnect(PlayerDisconnectEvent e){
Fabric.checkedPlayers.remove(e.getPlayer()); Fabric.remove(e.getPlayer());
Fabric.expectPluginMessage.remove(e.getPlayer());
Storage.fabricPlayers.remove(e.getPlayer()); Storage.fabricPlayers.remove(e.getPlayer());
} }