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


Java CuboidClipboard类代码示例

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


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

示例1: saveSchematic

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public void saveSchematic(String file, final String world, final PlotId id) {
    Location bot = MainUtil.getPlotBottomLoc(world, id).add(1, 0, 1);
    Location top = MainUtil.getPlotTopLoc(world, id);
    Vector size = new Vector(top.getX() - bot.getX() + 1, top.getY() - bot.getY() - 1, top.getZ() - bot.getZ() + 1);
    Vector origin = new Vector(bot.getX(), bot.getY(), bot.getZ());
    CuboidClipboard clipboard = new CuboidClipboard(size, origin);
    Vector pos1 = new Vector(bot.getX(), bot.getY(), bot.getZ());
    Vector pos2 = new Vector(top.getX(), top.getY(), top.getZ());
    EditSession session = PlotSquared.worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999);
    clipboard.copy(session);
    try {
        clipboard.saveSchematic(new File(file));
        MainUtil.sendMessage(null, "&7 - &a  success: " + id);
    } catch (Exception e) {
        e.printStackTrace();
        MainUtil.sendMessage(null, "&7 - Failed to save &c" + id);
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:19,代码来源:WorldEditSchematic.java

示例2: saveRegionBlocks

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@Override
public boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterface) {
	boolean result = true;
	ProtectedRegion region = regionInterface.getRegion();
	// Get the origin and size of the region
	Vector origin = new Vector(region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(), region.getMinimumPoint().getBlockZ());
	Vector size = (new Vector(region.getMaximumPoint().getBlockX(), region.getMaximumPoint().getBlockY(), region.getMaximumPoint().getBlockZ()).subtract(origin)).add(new Vector(1, 1, 1));
	EditSession editSession = new EditSession(new BukkitWorld(regionInterface.getWorld()), pluginInterface.getConfig().getInt("maximumBlocks"));
	// Save the schematic
	editSession.enableQueue();
	CuboidClipboard clipboard = new CuboidClipboard(size, origin);
	clipboard.copy(editSession);
	Exception otherException = null;
	try {
		SchematicFormat.MCEDIT.save(clipboard, file);
	} catch(DataException | IOException e) {
		otherException = e;
	}
	if(otherException != null) {
		pluginInterface.getLogger().warning("Failed to save schematic for region " + regionInterface.getName());
		pluginInterface.debugI(ExceptionUtils.getStackTrace(otherException));
		result = false;
	}
	editSession.flushQueue();
	return result;
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:27,代码来源:WorldEditHandler5.java

示例3: spawnTree

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
private void spawnTree(Location startBlock, String fileName, Vector offset){
	BukkitWorld world = new BukkitWorld(startBlock.getWorld());
	EditSession session = new EditSession(world, 1000);
	WorldEditPlugin wep = ((WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"));
	WorldEdit we = wep.getWorldEdit();
	LocalConfiguration config = we.getConfiguration();
	BukkitPlayer p = wep.wrapPlayer(startBlock.getWorld().getPlayers().get(0));
	File dir = we.getWorkingDirectoryFile(config.saveDir);
       File f;
       Vector v = new Vector(startBlock.getX(), startBlock.getY(), startBlock.getZ());
       
	try {
		f = we.getSafeOpenFile(p, dir, fileName, "schematic", "schematic");
		CuboidClipboard cc = SchematicFormat.MCEDIT.load(f);
		cc.setOffset(offset);
		
		cc.paste(session, v, true);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:22,代码来源:TreeListener.java

示例4: buildIsland

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
/**
 * Clean up all blocks in a location and paste the island schematic instead.
 *
 * @param loc1  Minimum point of the island.
 * @param loc2  Maximum point of the island.
 * @param world World to create the island in.
 * @param file  Schematic file to load.
 */
protected Region buildIsland(Vector loc1, Vector loc2, World world, File file) {
    try {
        EditSession editSession = instance.getEngineManager().getWorldEditUtils().getEditSession(world);
        editSession.enableQueue();
        Region region = LocationsParser.getRegion(loc1, loc2);
        // Replacing the blocks is MUCH faster than just setting them all to air.
        editSession.replaceBlocks(region, null, AIR);
        editSession.flushQueue();
        // Loading schematics.
        CuboidClipboard cuboidClipboard = instance.getEngineManager().getWorldEditUtils().getCuboidClipboard(file);
        // Pasting the schematic.
        cuboidClipboard.paste(editSession, region.getCenter(), false);
        editSession.flushQueue();
        // Cause pokemon is awesome.
        return region;
    } catch (Exception ex) {
        throw new RuntimeException("Problem with generating island.", ex);
    }
}
 
开发者ID:aaomidi,项目名称:JustSkyblock,代码行数:28,代码来源:IslandGeneration.java

示例5: saveWEChunk

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
private void saveWEChunk(Chunk chunk, File saveFile)
{
	WorldEditPlugin wep = (WorldEditPlugin)Bukkit.getPluginManager().getPlugin("WorldEdit");
	if (wep == null) 
	{
		Bukkit.broadcastMessage(ChatColor.RED+"Unable to find WorldEdit plugin - Unable to restore.");
		return;
	}		
	EditSession editSession = new EditSession(new BukkitWorld(chunk.getWorld()), 1000);		
	Vector startPos =  locationToVector(chunk.getBlock(0, 0, 0).getLocation());
	Vector size = new Vector(16,256,16);
	
	CuboidClipboard clipboard = new CuboidClipboard(size, startPos);
	clipboard.copy(editSession);
	try 
	{
		SchematicFormat.MCEDIT.save(clipboard, saveFile);
	} 
	catch (Exception e) 
	{
		e.printStackTrace();
	}		
}
 
开发者ID:marsglorious,项目名称:NewNations,代码行数:24,代码来源:PlotRestoreManager.java

示例6: loadBounds

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public static CuboidRegion loadBounds(String frameName, MCMEAnimation animation) {
    SchematicFormat sf = MCEditSchematicFormat.MCEDIT;
    try {
        CuboidClipboard clip = sf.load(new File(MCMEAnimations.MCMEAnimationsInstance.getDataFolder() + File.separator + "schematics" + File.separator + "animations" + File.separator + frameName + ".schematic"));

        Vector v1 = new Vector(animation.origin.getX() + clip.getOffset().getX(), animation.origin.getY() + clip.getOffset().getY(), animation.origin.getZ() + clip.getOffset().getZ());
        Vector v2 = new Vector(Math.floor(animation.origin.getX() + clip.getWidth() + clip.getOffset().getX() - 1),
                Math.floor(animation.origin.getY() + clip.getHeight() + clip.getOffset().getY() - 1),
                Math.floor(animation.origin.getZ() + clip.getLength() + clip.getOffset().getZ() - 1));

        return new CuboidRegion(v1, v2);

    } catch (IOException | DataException ex) {
        Logger.getLogger(WELoader.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}
 
开发者ID:MCME,项目名称:Animations-Redux,代码行数:18,代码来源:WELoader.java

示例7: place

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
/**
 * Place the waiting lobby in the world
 */
public void place()
{
    this.logger.info("Generating lobby...");

    if (this.file.exists())
    {
        try
        {
            Vector vector = new Vector(0, 190, 0);

            World world = Bukkit.getWorld("world");
            world.loadChunk(0, 0);

            BukkitWorld bwf = new BukkitWorld(world);

            this.editSession = new EditSession(bwf, -1);
            this.editSession.setFastMode(true);

            CuboidClipboard c1 = SchematicFormat.MCEDIT.load(this.file);
            c1.paste(this.editSession, vector, true);
        }
        catch (MaxChangedBlocksException | IOException | DataException ex)
        {
            this.logger.log(Level.SEVERE, "Error in world", ex);
        }

    }
    else
    {
        this.logger.severe("File does not exist. Abort...");
    }

    this.logger.info("Done.");
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:38,代码来源:LobbyPopulator.java

示例8: loadSchematic

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static void loadSchematic(World world, int size, Vector v) throws Exception {
	if (getRandomCasa(size) == null) {
		return;
	}
	EditSession es = new EditSession(new BukkitWorld(world), Integer.MAX_VALUE);
	CuboidClipboard cc = CuboidClipboard.loadSchematic(getRandomCasa(size));
	cc.paste(es, v, false);
	cc.paste(es, v, false);
}
 
开发者ID:leonardosnt,项目名称:OldBukkit,代码行数:11,代码来源:TerrenosManager.java

示例9: load

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public static void load() {
	try {
		Chunk chunk = new Chunk(null, 0, 0);
		CuboidClipboard clipboard = CuboidClipboard.loadSchematic(new File(ProtocolSupportAntiBot.getInstance().getDataFolder(), name));
		for (int x = 0; x < clipboard.getLength(); x++) {
			for (int z = 0; z < clipboard.getWidth(); z++) {
				for (int y = 0; y < clipboard.getHeight(); y++) {
					BaseBlock block = clipboard.getBlock(new Vector(x, y, z));
					ChunkSection[] sections = chunk.getSections();
					int ysect = y >> 4;
					ChunkSection section = sections[ysect];
					if (section == null) {
						section = new ChunkSection(ysect, true);
						sections[ysect] = section; 
					}
					IBlockData iblockdata = Block.getById(block.getId()).fromLegacyData(block.getData());
					section.setType(x, y & 0xF, z, iblockdata);
					section.a(x, y & 0xF, z, 15);
					section.b(x, y & 0xF, z, 15);
				}
			}
		}
		PacketPlayOutMapChunk mapchunk = new PacketPlayOutMapChunk();
		chunkdata = PacketContainer.fromPacket(mapchunk);
		chunkdata.getBooleans().write(0, true);
		ByteBuf buffer = Unpooled.buffer();
		chunkdata.getIntegers().write(2, mapchunk.a(new PacketDataSerializer(buffer), chunk, true, 65535));
		byte[] bufferdata = new byte[buffer.readableBytes()];
		buffer.readBytes(bufferdata);
		chunkdata.getByteArrays().write(0, bufferdata);
		chunkdata.getSpecificModifier(List.class).write(0, Collections.emptyList());
	} catch (DataException | IOException e) {
	}
}
 
开发者ID:ProtocolSupport,项目名称:ProtocolSupportAntiBot,代码行数:35,代码来源:LobbySchematic.java

示例10: pasteWithWE

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public static void pasteWithWE(Player p, File file) {
	World world = p.getWorld();	
	Location loc = p.getLocation();
	
	EditSession es = new EditSession(new BukkitWorld(world), 999999999);		
	try {
		CuboidClipboard cc = CuboidClipboard.loadSchematic(file);
		cc.paste(es, new com.sk89q.worldedit.Vector(loc.getX(),loc.getY(),loc.getZ()), false);
	} catch (DataException | IOException | MaxChangedBlocksException e) {
		e.printStackTrace();
	}		
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:13,代码来源:WEListener.java

示例11: regenerate

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
/**
 * Pastes a schematic into the room.
 */
private void regenerate() {
	try {
		Location location = sign.getLocation();
		CuboidClipboard clipboard = schematic.load(schematicFile);
		BukkitWorld world = new BukkitWorld(location.getWorld());
		WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
		EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession(world, 64*64*64);
		Vector newOrigin = region.getMinimumPoint();
		clipboard.paste(editSession, newOrigin, false);
	} catch (DataException | MaxChangedBlocksException | IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Co0sh,项目名称:RoomRent,代码行数:17,代码来源:SingleRoom.java

示例12: place

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
public void place(Vector size, CuboidClipboard cc, String arenaName) {
	for (int x = 0; x < size.getBlockX(); x++) {
		for (int z = 0; z < size.getBlockZ(); z++) {
			World world = Bukkit.getWorld(((Config) BlockParty.getArena.get(arenaName)).getWorld().getName());
			world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setTypeId(cc.getBlock(new Vector(x, 0, z)).getId());
			world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setData((byte) cc.getBlock(new Vector(x, 0, z)).getData());
		}
	}
}
 
开发者ID:Hansdekip,项目名称:BlockParty-1.8,代码行数:14,代码来源:LoadFloor.java

示例13: run

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@Override
public void run(String playerID) throws QuestRuntimeException {
	try {
		Location location = loc.getLocation(playerID);
		SchematicFormat schematic = SchematicFormat.getFormat(file);
		CuboidClipboard clipboard = schematic.load(file);
		BukkitWorld world = new BukkitWorld(location.getWorld());
		EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession(world, 64*64*64);
		Vector newOrigin = BukkitUtil.toVector(location);
		clipboard.paste(editSession, newOrigin, noAir);
	} catch (DataException | IOException | MaxChangedBlocksException e) {
		Debug.error("Error while pasting a schematic: " + e.getMessage());
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:15,代码来源:PasteSchematicEvent.java

示例14: place

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void place(Vector size, CuboidClipboard cc, String arenaName) {
	for (int x = 0; x < size.getBlockX(); x++) {
		for (int z = 0; z < size.getBlockZ(); z++) {
			World world = Bukkit.getWorld(((Config) BlockParty.getArena.get(arenaName)).getWorld().getName());
			world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setTypeId(cc.getBlock(new Vector(x, 0, z)).getId());
			world.getBlockAt(((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockX() + x,
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockY(),
					((Config) BlockParty.getArena.get(arenaName)).getLocMin().getBlockZ() + z).setData((byte) cc.getBlock(new Vector(x, 0, z)).getData());
		}
	}
}
 
开发者ID:LekoHD,项目名称:BlockParty,代码行数:15,代码来源:LoadFloor.java

示例15: storeClip

import com.sk89q.worldedit.CuboidClipboard; //导入依赖的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


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