@Override public boolean equals(Object other) { if (other == null) { return false; } else if ((other instanceof BukkitWorld)) { return ((BukkitWorld) other).getWorld().equals(getWorld()); } else if (other instanceof com.sk89q.worldedit.world.World) { return ((com.sk89q.worldedit.world.World) other).getName().equals(getName()); } else { return false; } }
@Override public long getRemainingWeatherDuration() { return getWorld().getWeatherDuration(); }
@Override public String getName() { return getWorld().getName(); }
@Override public int getMaxY() { return getWorld().getMaxHeight() - 1; }
@Override public List<com.sk89q.worldedit.entity.Entity> getEntities() { List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>(); for (Entity entity : getWorld().getEntities()) { list.add(BukkitAdapter.adapt(entity)); } return list; }
@Override public boolean playEffect(Vector3 position, int type, int data) { World world = getWorld(); final Effect effect = effects.get(type); if (effect == null) { return false; } world.playEffect(BukkitAdapter.adapt(world, position), effect, data); return true; }
@Override public BlockVector3 getSpawnPosition() { return BukkitAdapter.asBlockVector(getWorld().getSpawnLocation()); }
@Override public void dropItem(Vector3 pt, BaseItemStack item) { World world = getWorld(); world.dropItemNaturally(BukkitAdapter.adapt(world, pt), BukkitAdapter.adapt(item)); }
@Override public List<com.sk89q.worldedit.entity.Entity> getEntities(Region region) { World world = getWorld(); List<Entity> ents = world.getEntities(); List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>(); for (Entity ent : ents) { if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) { entities.add(BukkitAdapter.adapt(ent)); } } return entities; }
@Override public void fixAfterFastMode(Iterable<BlockVector2> chunks) { World world = getWorld(); for (BlockVector2 chunkPos : chunks) { world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ()); } }
@Override public boolean notifyAndLightBlock(BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType) throws WorldEditException { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { adapter.notifyAndLightBlock(BukkitAdapter.adapt(getWorld(), position), previousType); return true; } return false; }
@Override public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) { World world = getWorld(); TreeType bukkitType = toBukkitTreeType(type); return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType, new EditSessionBlockChangeDelegate(editSession)); }
@Override public int getBlockLightLevel(BlockVector3 pt) { return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel(); }
@Override public BaseBlock getFullBlock(BlockVector3 position) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)); } else { return getBlock(position).toBaseBlock(); } }
@Override public void checkLoadedChunk(BlockVector3 pt) { World world = getWorld(); if (!world.isChunkLoaded(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)) { world.loadChunk(pt.getBlockX() >> 4, pt.getBlockZ() >> 4); } }
@Override public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) { Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); return BukkitAdapter.adapt(bukkitBlock.getBlockData()); }
@Override public boolean setBiome(BlockVector2 position, BaseBiome biome) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { Biome bukkitBiome = adapter.getBiome(biome.getId()); getWorld().setBiome(position.getBlockX(), position.getBlockZ(), bukkitBiome); return true; } else { return false; } } }
@Override public BaseBiome getBiome(BlockVector2 position) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { int id = adapter.getBiomeId(getWorld().getBiome(position.getBlockX(), position.getBlockZ())); return new BaseBiome(id); } else { return new BaseBiome(0); } }