SteamWar/BauSystem2.0
Archiviert
12
0

Update tracer
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-04-12 16:24:32 +02:00
Ursprung 597c968463
Commit bcdad382c7

Datei anzeigen

@ -25,7 +25,9 @@ import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.*; 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) { public boolean follow(Player follower, Player following) {
if (followerMap.containsKey(follower)) return false; if (followerMap.containsKey(follower)) return false;
followerMap.computeIfAbsent(following, ignored -> new HashSet<>()).add(follower); 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());
});
});
}
} }