SteamWar/BauSystem2.0
Archiviert
12
0

Trace Refactor #233

Zusammengeführt
YoyoNow hat 121 Commits von TracerGUI nach master 2024-04-21 16:03:26 +02:00 zusammengeführt
Nur Änderungen aus Commit bcdad382c7 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -25,7 +25,9 @@ import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
import de.steamwar.bausystem.region.Region;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.*;
@ -190,10 +192,6 @@ public class TraceManager implements Listener {
});
}
public boolean hasFollower(Player player) {
return followerMap.containsKey(player);
}
public boolean follow(Player follower, Player following) {
if (followerMap.containsKey(follower)) return false;
followerMap.computeIfAbsent(following, ignored -> new HashSet<>()).add(follower);
@ -298,4 +296,20 @@ public class TraceManager implements Listener {
});
});
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
unfollow(event.getPlayer());
new ArrayList<>(followerMap.getOrDefault(event.getPlayer(), Collections.emptySet())).forEach(this::unfollow);
showDataPerRegionPerPlayer.forEach((region, playerPlayerTraceShowDataMap) -> {
playerPlayerTraceShowDataMap.remove(event.getPlayer());
});
tracesByRegion.forEach((region, integerTraceMap) -> {
integerTraceMap.forEach((integer, trace) -> {
trace.hide(event.getPlayer());
});
});
}
}