Java Code Examples for com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat#findByAlias()
The following examples show how to use
com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat#findByAlias() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchematicCommands.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Command( aliases = {"loadall"}, usage = "[<format>] <filename|url>", help = "Load multiple clipboards\n" + "The -r flag will apply random rotation", desc = "Load multiple clipboards (paste will randomly choose one)" ) @Deprecated @CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.upload"}) public void loadall(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename, @Switch('r') boolean randomRotate) throws FilenameException { final ClipboardFormat format = ClipboardFormat.findByAlias(formatName); if (format == null) { BBC.CLIPBOARD_INVALID_FORMAT.send(player, formatName); return; } try { WorldData wd = player.getWorld().getWorldData(); MultiClipboardHolder all = format.loadAllFromInput(player, wd, filename, true); if (all != null) { session.addClipboard(all); BBC.SCHEMATIC_LOADED.send(player, filename); } } catch (IOException e) { throw new RuntimeException(e); } }
Example 2
Source File: WEHook.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static Region pasteWithWE(Player p, File file) { Location<World> loc = p.getLocation(); Region r = null; if (p.getLocation().getBlockRelative(Direction.DOWN).getBlock().getType().equals(BlockTypes.WATER) || p.getLocation().getBlockRelative(Direction.DOWN).getBlock().getType().equals(BlockTypes.FLOWING_WATER)) { RedProtect.get().lang.sendMessage(p, "playerlistener.region.needground"); return null; } SpongePlayer sp = SpongeWorldEdit.inst().wrapPlayer(p); SpongeWorld ws = SpongeWorldEdit.inst().getWorld(p.getWorld()); LocalSession session = SpongeWorldEdit.inst().getSession(p); Closer closer = Closer.create(); try { ClipboardFormat format = ClipboardFormat.findByAlias("schematic"); FileInputStream fis = closer.register(new FileInputStream(file)); BufferedInputStream bis = closer.register(new BufferedInputStream(fis)); ClipboardReader reader = format.getReader(bis); WorldData worldData = ws.getWorldData(); Clipboard clipboard = reader.read(ws.getWorldData()); session.setClipboard(new ClipboardHolder(clipboard, worldData)); Vector bmin = clipboard.getMinimumPoint(); Vector bmax = clipboard.getMaximumPoint(); Location<World> min = loc.add(bmin.getX(), bmin.getY(), bmin.getZ()); Location<World> max = loc.add(bmax.getX(), bmax.getY(), bmax.getZ()); PlayerRegion leader = new PlayerRegion(p.getUniqueId().toString(), p.getName()); RegionBuilder rb2 = new DefineRegionBuilder(p, min, max, "", leader, new HashSet<>(), false); if (rb2.ready()) { r = rb2.build(); } ClipboardHolder holder = session.getClipboard(); Operation op = holder.createPaste(session.createEditSession(sp), ws.getWorldData()).to(session.getPlacementPosition(sp)).build(); Operations.completeLegacy(op); } catch (IOException | EmptyClipboardException | IncompleteRegionException | MaxChangedBlocksException e) { CoreUtil.printJarVersion(); e.printStackTrace(); } return r; }
Example 3
Source File: ClipboardFormats.java From FastAsyncWorldedit with GNU General Public License v3.0 | 2 votes |
/** * Find the clipboard format named by the given alias. * * @param alias * the alias * @return the format, otherwise null if none is matched */ @Nullable public static ClipboardFormat findByAlias(String alias) { return ClipboardFormat.findByAlias(alias); }