Search in sources :

Example 1 with EntityWrapper

use of com.plotsquared.bukkit.entity.EntityWrapper in project PlotSquared by IntellectualSites.

the class ContentMap method saveEntitiesOut.

void saveEntitiesOut(Chunk chunk, CuboidRegion region) {
    for (Entity entity : chunk.getEntities()) {
        Location location = BukkitUtil.adapt(entity.getLocation());
        int x = location.getX();
        int z = location.getZ();
        if (BukkitChunkManager.isIn(region, x, z)) {
            continue;
        }
        if (entity.getVehicle() != null) {
            continue;
        }
        EntityWrapper wrap = new ReplicatingEntityWrapper(entity, (short) 2);
        wrap.saveEntity();
        this.entities.add(wrap);
    }
}
Also used : Entity(org.bukkit.entity.Entity) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) EntityWrapper(com.plotsquared.bukkit.entity.EntityWrapper) Location(com.plotsquared.core.location.Location)

Example 2 with EntityWrapper

use of com.plotsquared.bukkit.entity.EntityWrapper in project PlotSquared by IntellectualSites.

the class ContentMap method saveEntitiesIn.

void saveEntitiesIn(Chunk chunk, CuboidRegion region, boolean delete) {
    for (Entity entity : chunk.getEntities()) {
        Location location = BukkitUtil.adapt(entity.getLocation());
        int x = location.getX();
        int z = location.getZ();
        if (!BukkitChunkManager.isIn(region, x, z)) {
            continue;
        }
        if (entity.getVehicle() != null) {
            continue;
        }
        EntityWrapper wrap = new ReplicatingEntityWrapper(entity, (short) 2);
        wrap.saveEntity();
        this.entities.add(wrap);
        if (delete) {
            if (!(entity instanceof Player)) {
                entity.remove();
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) ReplicatingEntityWrapper(com.plotsquared.bukkit.entity.ReplicatingEntityWrapper) EntityWrapper(com.plotsquared.bukkit.entity.EntityWrapper) Location(com.plotsquared.core.location.Location)

Aggregations

EntityWrapper (com.plotsquared.bukkit.entity.EntityWrapper)2 ReplicatingEntityWrapper (com.plotsquared.bukkit.entity.ReplicatingEntityWrapper)2 Location (com.plotsquared.core.location.Location)2 Entity (org.bukkit.entity.Entity)2 Player (org.bukkit.entity.Player)1