mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Optimize entity get (lazy nbt)
This commit is contained in:
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
@ -29,6 +30,8 @@ import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.NullWorld;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@ -40,6 +43,7 @@ import javax.annotation.Nullable;
|
||||
public class BukkitEntity implements Entity {
|
||||
|
||||
private final WeakReference<org.bukkit.entity.Entity> entityRef;
|
||||
private final EntityType type;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -48,6 +52,7 @@ public class BukkitEntity implements Entity {
|
||||
*/
|
||||
public BukkitEntity(org.bukkit.entity.Entity entity) {
|
||||
checkNotNull(entity);
|
||||
this.type = entity.getType();
|
||||
this.entityRef = new WeakReference<>(entity);
|
||||
}
|
||||
|
||||
@ -81,6 +86,11 @@ public class BukkitEntity implements Entity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.entity.EntityType getType() {
|
||||
return EntityTypes.get(type.getName().toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseEntity getState() {
|
||||
org.bukkit.entity.Entity entity = entityRef.get();
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -82,6 +83,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) {
|
||||
System.out.println(Fawe.isMainThread());
|
||||
World world = getWorld();
|
||||
|
||||
List<Entity> ents = world.getEntities();
|
||||
@ -96,6 +98,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
|
||||
System.out.println(Fawe.isMainThread());
|
||||
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
|
||||
for (Entity entity : getWorld().getEntities()) {
|
||||
list.add(BukkitAdapter.adapt(entity));
|
||||
|
Reference in New Issue
Block a user