Dieser Commit ist enthalten in:
Ursprung
745d04845b
Commit
8d3037f67d
@ -30,8 +30,10 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ public class REntityServer implements Listener {
|
|||||||
private static final HashSet<Player> emptyPlayers = new HashSet<>(0);
|
private static final HashSet<Player> emptyPlayers = new HashSet<>(0);
|
||||||
|
|
||||||
private final HashMap<Long, HashSet<REntity>> entities = new HashMap<>();
|
private final HashMap<Long, HashSet<REntity>> entities = new HashMap<>();
|
||||||
private final HashMap<Long, HashSet<Player>> players = new HashMap<>();
|
private final HashMap<Long, Set<Player>> players = new HashMap<>();
|
||||||
private final HashMap<Player, Location> lastLocation = new HashMap<>();
|
private final HashMap<Player, Location> lastLocation = new HashMap<>();
|
||||||
|
|
||||||
public REntityServer() {
|
public REntityServer() {
|
||||||
@ -145,7 +147,7 @@ public class REntityServer implements Listener {
|
|||||||
forChunkInView(player, location, (x, z) -> players.get(chunkToId(x, z)).remove(player));
|
forChunkInView(player, location, (x, z) -> players.get(chunkToId(x, z)).remove(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMissing(HashSet<Player> of, HashSet<Player> in, Consumer<Consumer<Object>> packetProvider) {
|
private void onMissing(Set<Player> of, Set<Player> in, Consumer<Consumer<Object>> packetProvider) {
|
||||||
if(of == null)
|
if(of == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -178,7 +180,7 @@ 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);
|
players.getOrDefault(id, Collections.emptySet()).remove(player);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren