当前位置: 首页>>代码示例>>Java>>正文


Java LocalSession.setClipboard方法代码示例

本文整理汇总了Java中com.sk89q.worldedit.LocalSession.setClipboard方法的典型用法代码示例。如果您正苦于以下问题:Java LocalSession.setClipboard方法的具体用法?Java LocalSession.setClipboard怎么用?Java LocalSession.setClipboard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldedit.LocalSession的用法示例。


在下文中一共展示了LocalSession.setClipboard方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pasteWithWE

import com.sk89q.worldedit.LocalSession; //导入方法依赖的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.LocalSession; //导入方法依赖的package包/类
@Override
protected void execute(Event e) {
	WorldEditPlugin wep = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
	LocalSession session = wep.getSession(pl.getSingle(e));

	Location point1loc = point1.getSingle(e);
	Location point2loc = point2.getSingle(e);

	Vector min = new Vector(point1loc.getBlockX(), point1loc.getBlockY(), point1loc.getZ());
	Vector max = new Vector(point2loc.getBlockX(), point2loc.getBlockY(), point2loc.getZ());
	CuboidRegion cr = new CuboidRegion(min, max);
	BlockArrayClipboard bc = new BlockArrayClipboard(cr);
	EditSession es = wep.createEditSession(pl.getSingle(e));
	try {
		if (origin == null) {
			bc.setOrigin(session.getPlacementPosition(wep.wrapPlayer(pl.getSingle(e))));
		} else {
			Location originloc = origin.getSingle(e);
			Vector originvec = new Vector(originloc.getBlockX(), originloc.getBlockY(), originloc.getBlockZ());
			bc.setOrigin(originvec);
		}
		session.setClipboard(new ClipboardHolder(bc, es.getWorld().getWorldData()));
		ForwardExtentCopy copy = new ForwardExtentCopy(es, cr, bc, cr.getMinimumPoint());
		Operations.complete(copy);

	} catch (WorldEditException e1) {
		main core = (main) Bukkit.getPluginManager().getPlugin("SharpSK");
		core.getLogger().warning("Failed to save selection. Something went wrong");
		return;
	}

}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:33,代码来源:EffSaveSelectionToClipboard.java

示例3: CopyPastaBrush

import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
public CopyPastaBrush(Player player, LocalSession session, boolean randomRotate, boolean autoRotate) {
    session.setClipboard(null);
    this.player = player;
    this.session = session;
    this.randomRotate = randomRotate;
    this.autoRotate = autoRotate;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:8,代码来源:CopyPastaBrush.java

示例4: clipboards

import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@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) {
            ClipboardHolder existing = session.getExistingClipboard();
            MultiClipboardHolder multi;
            if (existing instanceof MultiClipboardHolder) {
                multi = (MultiClipboardHolder) existing;
                for (ClipboardHolder holder : all.getHolders()) {
                    multi.add(holder);
                }
            } else  {
                multi = all;
                if (existing != null) {
                    multi.add(existing);
                }
            }
            session.setClipboard(multi);
            BBC.SCHEMATIC_LOADED.send(player, filename);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:41,代码来源:SchematicCommands.java

示例5: clear

import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
        aliases = {"clear"},
        usage = "",
        desc = "Clear your clipboard",
        min = 0,
        max = 0
)
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
public void clear(Player player, LocalSession session) throws WorldEditException {
    session.setClipboard(null);
    BBC.CLIPBOARD_CLEARED.send(player);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:13,代码来源:SchematicCommands.java

示例6: unload

import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
        aliases = {"unload"},
        usage = "[file]",
        desc = "Remove a clipboard from your multi-clipboard",
        min = 1,
        max = 1
)
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
public void unload(Player player, LocalSession session, String fileName) throws WorldEditException {
    URI uri;
    if (fileName.startsWith("file:/") || fileName.startsWith("http://") || fileName.startsWith("https://")) {
        uri = URI.create(fileName);
    } else {
        final LocalConfiguration config = this.worldEdit.getConfiguration();
        File working = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
        File root = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
        uri = new File(root, fileName).toURI();
    }

    boolean removed = false;
    ClipboardHolder clipboard = session.getClipboard();
    if (clipboard instanceof URIClipboardHolder) {
        URIClipboardHolder identifiable = (URIClipboardHolder) clipboard;
        if (identifiable.contains(uri)) {
            if (identifiable instanceof MultiClipboardHolder) {
                MultiClipboardHolder multi = (MultiClipboardHolder) identifiable;
                multi.remove(uri);
                if (multi.getHolders().isEmpty()) session.setClipboard(null);
            } else {
                session.setClipboard(null);
            }
            BBC.CLIPBOARD_CLEARED.send(player);
            return;
        }
    }
    BBC.CLIPBOARD_URI_NOT_FOUND.send(player, fileName);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:38,代码来源:SchematicCommands.java

示例7: clearClipboard

import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Deprecated // See SchematicCommands#clear
@Command(
        aliases = {"clearclipboard"},
        usage = "",
        desc = "Clear your clipboard",
        min = 0,
        max = 0
)
@CommandPermissions("worldedit.clipboard.clear")
public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
    session.setClipboard(null);
    BBC.CLIPBOARD_CLEARED.send(player);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:14,代码来源:ClipboardCommands.java


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