13
0
Dieser Commit ist enthalten in:
Lixfel 2020-11-15 12:08:58 +01:00
Ursprung 1c1b55efac
Commit 4fa02d1296

Datei anzeigen

@ -41,7 +41,9 @@ public abstract class REntity {
protected REntity(int internalId, Entity entity){
this.internalId = internalId;
this.entity = entity;
entities.put(internalId, this);
synchronized(entities){
entities.put(internalId, this);
}
for(Player player : Bukkit.getOnlinePlayers()){
sendToPlayer(player);
@ -49,17 +51,15 @@ public abstract class REntity {
}
public static void playerJoins(Player player){
for(REntity entity : entities.values()){
entity.sendToPlayer(player);
entity.sendLocation(player);
synchronized(entities){
for(REntity entity : entities.values()){
entity.sendToPlayer(player);
entity.sendLocation(player);
}
}
}
protected static EntityLiving getShooter(){
for(REntity entity : entities.values()){
if(entity.entity instanceof EntityLiving)
return (EntityLiving) entity.entity;
}
return ((CraftPlayer)Bukkit.getOnlinePlayers().iterator().next()).getHandle();
}
@ -69,10 +69,12 @@ public abstract class REntity {
public static void removeAll(){
int entity_counter = 0;
while(!entities.isEmpty()){
entity_counter++;
REntity entity = entities.values().iterator().next();
entity.remove();
synchronized (entities){
while(!entities.isEmpty()){
entity_counter++;
REntity entity = entities.values().iterator().next();
entity.remove();
}
}
System.out.println("Has to remove manually " + entity_counter + " entities!");
}
@ -96,7 +98,9 @@ public abstract class REntity {
connection.sendPacket(packet);
}
Bukkit.getScheduler().runTask(SpectateSystem.get(), entity::die);
entities.remove(internalId);
synchronized (entities){
entities.remove(internalId);
}
}
public void sneak(boolean sneaking) {