mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Try to avoid async issues with entity trackers
This commit is contained in:
parent
63ef3cdc73
commit
85e46c6324
@ -87,7 +87,8 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateLastPlayer(EntityPlayer lastUpdatedPlayer) {
|
public void updateLastPlayer(EntityPlayer lastUpdatedPlayer) {
|
||||||
if (tracker.dead || lastUpdatedPlayer == null || tracker.getBukkitEntity().getType() != EntityType.PLAYER)
|
if (tracker.dead || lastUpdatedPlayer == null || tracker.getBukkitEntity().getType() != EntityType.PLAYER
|
||||||
|
|| !CitizensAPI.hasImplementation())
|
||||||
return;
|
return;
|
||||||
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
|
@ -35,8 +35,8 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateLastPlayer() {
|
public void updateLastPlayer() {
|
||||||
if (tracker.isRemoved() || lastUpdatedPlayer == null
|
if (tracker.isRemoved() || lastUpdatedPlayer == null || tracker.getBukkitEntity().getType() != EntityType.PLAYER
|
||||||
|| tracker.getBukkitEntity().getType() != EntityType.PLAYER)
|
|| !CitizensAPI.hasImplementation())
|
||||||
return;
|
return;
|
||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
|
@ -35,8 +35,8 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateLastPlayer() {
|
public void updateLastPlayer() {
|
||||||
if (tracker.isRemoved() || lastUpdatedPlayer == null
|
if (tracker.isRemoved() || lastUpdatedPlayer == null || tracker.getBukkitEntity().getType() != EntityType.PLAYER
|
||||||
|| tracker.getBukkitEntity().getType() != EntityType.PLAYER)
|
|| !CitizensAPI.hasImplementation())
|
||||||
return;
|
return;
|
||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
|
@ -58,7 +58,8 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateLastPlayer(ServerPlayer lastUpdatedPlayer) {
|
public void updateLastPlayer(ServerPlayer lastUpdatedPlayer) {
|
||||||
if (tracker.isRemoved() || tracker.getBukkitEntity().getType() != EntityType.PLAYER)
|
if (tracker.isRemoved() || tracker.getBukkitEntity().getType() != EntityType.PLAYER
|
||||||
|
|| !CitizensAPI.hasImplementation())
|
||||||
return;
|
return;
|
||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NPC npc = ((NPCHolder) tracker).getNPC();
|
NPC npc = ((NPCHolder) tracker).getNPC();
|
||||||
|
@ -59,7 +59,8 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateLastPlayer(ServerPlayer lastUpdatedPlayer) {
|
public void updateLastPlayer(ServerPlayer lastUpdatedPlayer) {
|
||||||
if (tracker.isRemoved() || tracker.getBukkitEntity().getType() != EntityType.PLAYER)
|
if (tracker.isRemoved() || tracker.getBukkitEntity().getType() != EntityType.PLAYER
|
||||||
|
|| !CitizensAPI.hasImplementation())
|
||||||
return;
|
return;
|
||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
||||||
|
@ -380,6 +380,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
public boolean addEntityToWorld(org.bukkit.entity.Entity entity, SpawnReason custom) {
|
public boolean addEntityToWorld(org.bukkit.entity.Entity entity, SpawnReason custom) {
|
||||||
int viewDistance = -1;
|
int viewDistance = -1;
|
||||||
ChunkMap chunkMap = null;
|
ChunkMap chunkMap = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
chunkMap = ((ServerChunkCache) getHandle(entity).level().getChunkSource()).chunkMap;
|
chunkMap = ((ServerChunkCache) getHandle(entity).level().getChunkSource()).chunkMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user