• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClipboardReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sk89q.worldedit.extent.clipboard.io.ClipboardReader的典型用法代码示例。如果您正苦于以下问题:Java ClipboardReader类的具体用法?Java ClipboardReader怎么用?Java ClipboardReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClipboardReader类属于com.sk89q.worldedit.extent.clipboard.io包,在下文中一共展示了ClipboardReader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: pasteWithWE

import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; //导入依赖的package包/类
public static void pasteWithWE(Player p, File f) throws DataException {
	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(f));
	    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));
	    
	    ClipboardHolder holder = session.getClipboard();
	    
	    Operation op = holder.createPaste(session.createEditSession(sp), ws.getWorldData()).to(session.getPlacementPosition(sp)).build();
	    Operations.completeLegacy(op);
	} catch (IOException | MaxChangedBlocksException | EmptyClipboardException | IncompleteRegionException e) {
		e.printStackTrace();
	}		
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:26,代码来源:WEListener.java


示例2: execute

import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; //导入依赖的package包/类
public Integer execute(ICancelabeEditSession editSession) throws MaxChangedBlocksException {
    try {
        ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(file));
        WorldData worldData = bukkitWorld.getWorldData();
        Clipboard clipboard = reader.read(worldData);
        ClipboardHolder holder = new ClipboardHolder(clipboard, worldData);
        editSession.enableQueue();
        editSession.setFastMode(true);
        Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
        final Operation operation = holder
                .createPaste(editSession, worldData)
                .to(to)
                .ignoreAirBlocks(true)
                .build();
        Operations.completeBlindly(operation);
        editSession.flushQueue();
    } catch (IOException e) {
        log.log(Level.WARNING, "Error trying to paste " + file, e);
    }
    return 32768;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:22,代码来源:AWE330Adaptor.java


示例3: execute

import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; //导入依赖的package包/类
public Integer execute(CancelabeEditSession editSession) throws MaxChangedBlocksException {
    try {
        ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(file));
        WorldData worldData = bukkitWorld.getWorldData();
        Clipboard clipboard = reader.read(worldData);
        ClipboardHolder holder = new ClipboardHolder(clipboard, worldData);
        editSession.enableQueue();
        editSession.setFastMode(true);
        Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
        final Operation operation = holder
                .createPaste(editSession, worldData)
                .to(to)
                .ignoreAirBlocks(true)
                .build();
        Operations.completeBlindly(operation);
        editSession.flushQueue();
    } catch (IOException e) {
        log.log(Level.WARNING, "Error trying to paste " + file, e);
    }
    return 0;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:22,代码来源:AWE211Adaptor.java


示例4: execute

import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; //导入依赖的package包/类
public Integer execute(CancelabeEditSession editSession) throws MaxChangedBlocksException {
    try {
        ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(file));
        WorldData worldData = bukkitWorld.getWorldData();
        Clipboard clipboard = reader.read(worldData);
        ClipboardHolder holder = new ClipboardHolder(clipboard, worldData);
        editSession.enableQueue();
        editSession.setFastMode(true);
        Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
        final Operation operation = holder
                .createPaste(editSession, worldData)
                .to(to)
                .ignoreAirBlocks(true)
                .build();
        Operations.completeBlindly(operation);
        editSession.flushQueue();
    } catch (IOException e) {
        log.log(Level.WARNING, "Error trying to paste " + file, e);
    }
    return 32768;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:22,代码来源:AWE311Adaptor.java


示例5: getHolder

import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; //导入依赖的package包/类
private ClipboardHolder getHolder(String resourceName, WorldData worldData) throws IOException {
  try (InputStream bis = Files.newInputStream(getFile(resourceName))) {
    ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(bis);
    Clipboard clipboard = reader.read(worldData);
    return new ClipboardHolder(clipboard, worldData);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:8,代码来源:WEDecorator.java


示例6: exec

import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; //导入依赖的package包/类
@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {

	Static.checkPlugin("WorldEdit", t);
	WorldEdit worldEdit = WorldEdit.getInstance();
	String filename = args[0].val();
	MCPlayer player = null;
	if (args.length == 2) {
		player = Static.GetPlayer(args[1], t);
	}
	SKCommandSender user = getSKPlayer(player, t);

	File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
	File f;

	try {
		f = worldEdit.getSafeOpenFile(user, dir, filename, "schematic", "schematic");
	} catch (FilenameException fne) {
		throw new CREIOException(fne.getMessage(), t);
	}

	if (!f.exists()) {
		throw new CREIOException("Schematic " + filename + " does not exist!", t);
	}

	Closer closer = Closer.create();
	try {
		String filePath = f.getCanonicalPath();
		String dirPath = dir.getCanonicalPath();

		if (!filePath.substring(0, dirPath.length()).equals(dirPath)) {
			throw new CREIOException("Clipboard file could not read or it does not exist.", t);
		} else {
			FileInputStream fis = closer.register(new FileInputStream(f));
			BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
			ClipboardReader reader = ClipboardFormat.SCHEMATIC.getReader(bis);

			WorldData worldData = user.getWorld().getWorldData();
			Clipboard clipboard = reader.read(worldData);
			user.getLocalSession().setClipboard(new ClipboardHolder(clipboard, worldData));
		}
	} catch (IOException e) {
		throw new CREIOException("Schematic could not read or it does not exist: " + e.getMessage(), t);
	} finally {
		try {
			closer.close();
		} catch (IOException ignored) {
		}
	}
	return CVoid.VOID;
}
 
开发者ID:jb-aero,项目名称:SKCompat,代码行数:52,代码来源:CHWorldEdit.java


示例7: getReader

import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; //导入依赖的package包/类
/**
 * Create a reader.
 *
 * @param inputStream the input stream
 * @return a reader
 * @throws java.io.IOException thrown on I/O error
 */
ClipboardReader getReader(InputStream inputStream) throws IOException;
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:9,代码来源:IClipboardFormat.java



注:本文中的com.sk89q.worldedit.extent.clipboard.io.ClipboardReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PropertyKind类代码示例发布时间:2022-05-23
下一篇:
Java Util类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap