use of com.sk89q.worldedit.bukkit.BukkitWorld in project modules-extra by CubeEngine.
the class LogEditSession method rawSetBlock.
@Override
public boolean rawSetBlock(Vector pt, BaseBlock block) {
if (this.player instanceof BukkitPlayer && this.player.getWorld() instanceof BukkitWorld) {
World world = ((BukkitWorld) this.player.getWorld()).getWorld();
BlockState oldState = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getState();
boolean success = super.rawSetBlock(pt, block);
if (success) {
ActionWorldEdit action = this.listener.newAction(ActionWorldEdit.class, world);
if (action != null) {
BlockState newState = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getState();
action.setOldBlock(oldState);
action.setNewBlock(newState);
action.setPlayer(((BukkitPlayer) this.player).getPlayer());
action.setLocation(newState.getLocation());
this.listener.logAction(action);
}
}
return success;
}
return super.rawSetBlock(pt, block);
}
use of com.sk89q.worldedit.bukkit.BukkitWorld in project FunnyGuilds by FunnyGuilds.
the class SchematicHelper method pasteSchematic.
public static boolean pasteSchematic(File schematicFile, Location location, boolean withAir) {
try {
Vector pasteLocation = new Vector(location.getX(), location.getY(), location.getZ());
World pasteWorld = new BukkitWorld(location.getWorld());
WorldData pasteWorldData = pasteWorld.getWorldData();
Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematicFile)).read(pasteWorldData);
Region pasteRegion = clipboard.getRegion();
Extent pasteExtent = WorldEdit.getInstance().getEditSessionFactory().getEditSession(pasteWorld, -1);
AffineTransform transform = new AffineTransform();
ForwardExtentCopy copy = new ForwardExtentCopy(pasteExtent, pasteRegion, clipboard.getOrigin(), pasteExtent, pasteLocation);
if (!transform.isIdentity()) {
copy.setTransform(transform);
}
if (!withAir) {
copy.setSourceMask(new ExistingBlockMask(clipboard));
}
Operations.completeLegacy(copy);
return true;
} catch (IOException | MaxChangedBlocksException e) {
FunnyLogger.exception(e);
return false;
}
}
Aggregations