當前位置: 首頁>>代碼示例>>Java>>正文


Java EmptyClipboardException類代碼示例

本文整理匯總了Java中com.sk89q.worldedit.EmptyClipboardException的典型用法代碼示例。如果您正苦於以下問題:Java EmptyClipboardException類的具體用法?Java EmptyClipboardException怎麽用?Java EmptyClipboardException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EmptyClipboardException類屬於com.sk89q.worldedit包,在下文中一共展示了EmptyClipboardException類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: pasteWithWE

import com.sk89q.worldedit.EmptyClipboardException; //導入依賴的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: loadClipboardFromDisk

import com.sk89q.worldedit.EmptyClipboardException; //導入依賴的package包/類
/**
 * Loads any history items from disk:
 * - Should already be called if history on disk is enabled
 */
public void loadClipboardFromDisk() {
    File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.CLIPBOARD + File.separator + getUUID() + ".bd");
    try {
        if (file.exists() && file.length() > 5) {
            DiskOptimizedClipboard doc = new DiskOptimizedClipboard(file);
            Player player = toWorldEditPlayer();
            LocalSession session = getSession();
            try {
                if (session.getClipboard() != null) {
                    return;
                }
            } catch (EmptyClipboardException e) {
            }
            if (player != null && session != null) {
                WorldData worldData = player.getWorld().getWorldData();
                Clipboard clip = doc.toClipboard();
                ClipboardHolder holder = new ClipboardHolder(clip, worldData);
                getSession().setClipboard(holder);
            }
        }
    } catch (Exception ignore) {
        Fawe.debug("====== INVALID CLIPBOARD ======");
        MainUtil.handleError(ignore, false);
        Fawe.debug("===============---=============");
        Fawe.debug("This shouldn't result in any failure");
        Fawe.debug("File: " + file.getName() + " (len:" + file.length() + ")");
        Fawe.debug("===============---=============");
    }
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:34,代碼來源:FawePlayer.java

示例3: stencilBrush

import com.sk89q.worldedit.EmptyClipboardException; //導入依賴的package包/類
@Command(
        aliases = {"stencil", "color"},
        usage = "<pattern> [radius=5] [file|#clipboard|imgur=null] [rotation=360] [yscale=1.0]",
        desc = "Use a height map to paint a surface",
        help =
                "Use a height map to paint any surface.\n" +
                        "The -w flag will only apply at maximum saturation\n" +
                        "The -r flag will apply random rotation",
        min = 1,
        max = -1
)
@CommandPermissions("worldedit.brush.stencil")
public BrushSettings stencilBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('w') boolean onlyWhite, @Switch('r') boolean randomRotate, CommandContext context) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    InputStream stream = getHeightmapStream(filename);
    HeightBrush brush;
    try {
        brush = new StencilBrush(stream, rotation, yscale, onlyWhite, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null);
    } catch (EmptyClipboardException ignore) {
        brush = new StencilBrush(stream, rotation, yscale, onlyWhite, null);
    }
    if (randomRotate) {
        brush.setRandomRotate(true);
    }
    return get(context)
            .setBrush(brush)
            .setSize(radius)
            .setFill(fill);
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:30,代碼來源:BrushCommands.java

示例4: fullcopy

import com.sk89q.worldedit.EmptyClipboardException; //導入依賴的package包/類
@Command(
        aliases = {"#fullcopy"},
        desc = "Places your full clipboard at each block",
        usage = "[schem|folder|url=#copy] [rotate=false] [flip=false]",
        min = 0,
        max = 2
)
public Pattern fullcopy(Player player, Extent extent, LocalSession session, @Optional("#copy") String location, @Optional("false") boolean rotate, @Optional("false") boolean flip) throws EmptyClipboardException, InputParseException, IOException {
    List<ClipboardHolder> clipboards;
    switch (location.toLowerCase()) {
        case "#copy":
        case "#clipboard":
            ClipboardHolder clipboard = session.getExistingClipboard();
            if (clipboard == null) {
                throw new InputParseException("To use #fullcopy, please first copy something to your clipboard");
            }
            if (!rotate && !flip) {
                return new FullClipboardPattern(extent, clipboard.getClipboard());
            }
            clipboards = Collections.singletonList(clipboard);
            break;
        default:
            MultiClipboardHolder multi = ClipboardFormat.SCHEMATIC.loadAllFromInput(player, player.getWorld().getWorldData(), location, true);
            clipboards = multi != null ? multi.getHolders() : null;
            break;
    }
    if (clipboards == null) {
        throw new InputParseException("#fullcopy:<source>");
    }
    return new RandomFullClipboardPattern(extent, player.getWorld().getWorldData(), clipboards, rotate, flip);
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:32,代碼來源:PatternCommands.java

示例5: exec

import com.sk89q.worldedit.EmptyClipboardException; //導入依賴的package包/類
@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
	Static.checkPlugin("WorldEdit", t);
	int yaxis = 0,
			xaxis = 0,
			zaxis = 0;
	MCPlayer plyr = null;
	switch (args.length) {
		case 3:
			xaxis = Static.getInt32(args[1], t);
			zaxis = Static.getInt32(args[2], t);
		case 1:
			yaxis = Static.getInt32(args[0], t);
			break;
		case 4:
			xaxis = Static.getInt32(args[2], t);
			zaxis = Static.getInt32(args[3], t);
		case 2:
			yaxis = Static.getInt32(args[1], t);
			plyr = Static.GetPlayer(args[0], t);
			break;
	}
	try {
		ClipboardCommands command = new ClipboardCommands(WorldEdit.getInstance());
		SKCommandSender user = getSKPlayer(plyr, t);
		command.rotate(user, user.getLocalSession(), (double) yaxis, (double) xaxis, (double) zaxis);
	} catch (EmptyClipboardException e) {
		throw new CRENotFoundException("The clipboard is empty, copy something to it first!", t);
	} catch (WorldEditException ex) {
		throw new CREPluginInternalException(ex.getMessage(), t);
	}
	return CVoid.VOID;
}
 
開發者ID:jb-aero,項目名稱:SKCompat,代碼行數:34,代碼來源:CHWorldEdit.java

示例6: storeClip

import com.sk89q.worldedit.EmptyClipboardException; //導入依賴的package包/類
public static boolean storeClip(Player p, String frameName) {
        LocalSession s = MCMEAnimations.WEPlugin.getSession(p);
        try {
//            Selection sel = MCMEAnimations.WEPlugin.getSelection(p);
//            if(null == sel){
//                p.sendMessage(ChatColor.RED + "Select a placement block using WorldEdit!");
//                return false;
//            }
//            if(sel.getArea()!=1){
//                p.sendMessage(ChatColor.RED + "Select a single placement block using WorldEdit!");
//                return false;
//            }
            CuboidClipboard clip = s.getClipboard();
            boolean alreadyThere = false;
            for (MCMEClipboardStore cs : clips) {
                if (cs.getSchematicName().equals(frameName)) {
                    cs.setClip(clip);
                    p.sendMessage(ChatColor.BLUE + "Clipboard named \"" + frameName + "\" replaced.");
                    alreadyThere = true;
                    break;
                }
            }
            if (!alreadyThere) {
                MCMEClipboardStore store = new MCMEClipboardStore();
                store.setClip(clip);
                store.setSchematicName(frameName);
                clips.add(store);
                p.sendMessage(ChatColor.BLUE + "Clipboard named \"" + frameName + "\" stored.");
            }
            s.setClipboard(null);
            return true;
        } catch (EmptyClipboardException ex) {
            p.sendMessage(ChatColor.RED + "WorldEdit clipboard is empty! Remember to /copy before storing the frame");
            return false;
            //Logger.getLogger(AnimationFacroty.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
開發者ID:MCME,項目名稱:Animations-Redux,代碼行數:38,代碼來源:AnimationFactory.java

示例7: paletteblocks

import com.sk89q.worldedit.EmptyClipboardException; //導入依賴的package包/類
@Command(
        aliases = {"paletteblocks", "colorpaletterblocks", "setcolorpaletteblocks"},
        usage = "<blocks|#clipboard|*>",
        desc = "Set the blocks used for coloring",
        help = "Allow only specific blocks to be used for coloring\n" +
                "`blocks` is a list of blocks e.g. stone,bedrock,wool\n" +
                "`#clipboard` will only use the blocks present in your clipboard."
)
@CommandPermissions("worldedit.anvil.cfi")
public void paletteblocks(FawePlayer fp, @Optional String arg) throws ParameterException, EmptyClipboardException, InputParseException, FileNotFoundException {
    if (arg == null) {
        msg("What blocks do you want to color with?").newline()
        .text("&7[&aAll&7]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks")
        .newline()
        .text("&7[&aClipboard&7]").cmdTip(alias() + " PaletteBlocks #clipboard").text(" - The blocks in your clipboard")
        .newline()
        .text("&7[&aList&7]").suggestTip(alias() + " PaletteBlocks stone,gravel").text(" - A comma separated list of blocks")
        .newline()
        .text("&7[&aComplexity&7]").cmdTip(alias() + " Complexity").text(" - Block textures within a complexity range")
        .newline()
        .text("&8< &7[&aBack&7]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "coloring"))
        .send(fp);
        return;
    }
    HeightMapMCAGenerator generator = assertSettings(fp).getGenerator();
    ParserContext context = new ParserContext();
    context.setActor(fp.getPlayer());
    context.setWorld(fp.getWorld());
    context.setSession(fp.getSession());
    context.setExtent(generator);
    Request.request().setExtent(generator);

    Set<BaseBlock> blocks;
    switch (arg.toLowerCase()) {
        case "*": {
            generator.setTextureUtil(Fawe.get().getTextureUtil());
            return;
        }
        case "#clipboard": {
            ClipboardHolder holder = fp.getSession().getClipboard();
            Clipboard clipboard = holder.getClipboard();
            boolean[] ids = new boolean[Character.MAX_VALUE + 1];
            for (Vector pt : clipboard.getRegion()) {
                ids[clipboard.getBlock(pt).getCombined()] = true;
            }
            blocks = new HashSet<>();
            for (int combined = 0; combined < ids.length; combined++) {
                if (ids[combined]) blocks.add(FaweCache.CACHE_BLOCK[combined]);
            }
            break;
        }
        default: {
            blocks = worldEdit.getBlockFactory().parseFromListInput(arg, context);
            break;
        }
    }
    generator.setTextureUtil(new FilteredTextureUtil(Fawe.get().getTextureUtil(), blocks));
    coloring(fp);
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:60,代碼來源:CFICommands.java


注:本文中的com.sk89q.worldedit.EmptyClipboardException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。