SteamWar/SpigotCore
Archiviert
13
0

Fix Memory Leak
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2023-02-23 17:56:25 +01:00
Ursprung 5e6b86f2ba
Commit 02d756137e

Datei anzeigen

@ -197,11 +197,18 @@ public class REntityServer implements Listener {
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent e) { public void onQuit(PlayerQuitEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
viewDistance.remove(player);
Location location = lastLocation.remove(player); Location location = lastLocation.remove(player);
if(location == null) if(location == null)
return; return;
forChunkInView(player, location, (x, z) -> players.get(chunkToId(x, z)).remove(player)); forChunkInView(player, location, (x, z) -> {
long id = chunkToId(x, z);
Set<Player> playersInChunk = players.get(id);
playersInChunk.remove(player);
if(playersInChunk.isEmpty())
players.remove(id);
});
} }
private void onMissing(Set<Player> of, Set<Player> in, Consumer<Consumer<Object>> packetProvider) { private void onMissing(Set<Player> of, Set<Player> in, Consumer<Consumer<Object>> packetProvider) {
@ -237,7 +244,12 @@ public class REntityServer implements Listener {
private void removePlayerFromChunk(Player player, int x, int z) { private void removePlayerFromChunk(Player player, int x, int z) {
long id = chunkToId(x, z); long id = chunkToId(x, z);
players.get(id).remove(player);
Set<Player> playersInChunk = players.get(id);
playersInChunk.remove(player);
if(playersInChunk.isEmpty())
players.remove(id);
for(REntity entity : entities.getOrDefault(id, emptyEntities)) { for(REntity entity : entities.getOrDefault(id, emptyEntities)) {
entity.despawn(packet -> TinyProtocol.instance.sendPacket(player, packet)); entity.despawn(packet -> TinyProtocol.instance.sendPacket(player, packet));
} }