use of com.sk89q.worldedit.session.PasteBuilder in project FunnyGuilds by FunnyGuilds.
the class WorldEdit6Hook method pasteSchematic.
@Override
public boolean pasteSchematic(File schematicFile, Location location, boolean withAir) {
try {
Object pasteLocation = vectorConstructor.newInstance(location.getX(), location.getY(), location.getZ());
com.sk89q.worldedit.world.World pasteWorld = new BukkitWorld(location.getWorld());
Object pasteWorldData = getWorldData.invoke(pasteWorld);
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(new FileInputStream(schematicFile)));
Object reader = schematicReaderConstructor.newInstance(nbtStream);
Object clipboard = readSchematic.invoke(reader, pasteWorldData);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(pasteWorld, -1);
ClipboardHolder clipboardHolder = (ClipboardHolder) clipboardHolderConstructor.newInstance(clipboard, pasteWorldData);
PasteBuilder builder = ((PasteBuilder) pasteConstructor.newInstance(clipboardHolder, editSession, pasteWorldData));
builder = (PasteBuilder) pasteBuilderSetTo.invoke(builder, pasteLocation);
builder = builder.ignoreAirBlocks(!withAir);
Operations.completeLegacy(builder.build());
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | MaxChangedBlocksException | IOException ex) {
throw new RuntimeException("Could not paste schematic: " + schematicFile.getAbsolutePath(), ex);
}
return true;
}
Aggregations