本文整理汇总了Java中com.sk89q.worldedit.schematic.SchematicFormat类的典型用法代码示例。如果您正苦于以下问题:Java SchematicFormat类的具体用法?Java SchematicFormat怎么用?Java SchematicFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SchematicFormat类属于com.sk89q.worldedit.schematic包,在下文中一共展示了SchematicFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FortressPopulator
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
public FortressPopulator(SurvivalGenerator plugin)
{
this.plugin = plugin;
this.logger = plugin.getLogger();
try
{
this.netherHouse = SchematicFormat.MCEDIT.load(new File(plugin.getDataFolder(), "/uhcrun_nether_1.schematic"));
this.netherFortress = SchematicFormat.MCEDIT.load(new File(plugin.getDataFolder(), "/uhcrun_nether_2.schematic"));
}
catch (IOException | DataException e)
{
e.printStackTrace();
}
this.random = new Random();
}
示例2: FlagPopulator
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
FlagPopulator(SurvivalGenerator plugin)
{
this.plugin = plugin;
this.locations = new ArrayList<>();
this.done = false;
try
{
this.flag = SchematicFormat.MCEDIT.load(new File(plugin.getDataFolder(), "/ufk_flag.schematic"));
List<String> locs = this.plugin.getConfig().getStringList("flags");
locs.forEach(string ->
{
String[] split = string.split(", ");
this.locations.add(Pair.of(new Location(this.plugin.getServer().getWorld(split[0]), Double.parseDouble(split[1]), Double.parseDouble(split[2]), Double.parseDouble(split[3])), Byte.parseByte(split[4])));
});
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例3: saveTerrain
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
/**
* Write the terrain bounded by the given locations to the given file as a MCedit format
* schematic.
*
* @param saveFile a File representing the schematic file to create
* @param l1 one corner of the region to save
* @param l2 the corner of the region to save, opposite to l1
* @throws DataException
* @throws IOException
*/
public void saveTerrain(File saveFile, Location l1, Location l2) throws FilenameException, DataException, IOException {
Vector min = getMin(l1, l2);
Vector max = getMax(l1, l2);
try {
saveFile = we.getSafeSaveFile(localPlayer,
saveFile.getParentFile(), saveFile.getName(),
EXTENSION, new String[]{EXTENSION});
} catch (FilenameException e) {
e.printStackTrace();
}
editSession.enableQueue();
CuboidClipboard clipboard = new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min);
clipboard.copy(editSession);
SchematicFormat.MCEDIT.save(clipboard, saveFile);
editSession.flushQueue();
}
示例4: SingleRoom
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
/**
* Creates a room with specified region and sign location.
*
* @param region
* name of the WorldGuard region
* @param signLoc
* location of the room sign
* @throws Exception
*/
public SingleRoom(RoomRent plugin, World world, String regionName, String signLoc) throws RoomException {
this.world = world;
this.plugin = plugin;
region = WorldGuardPlugin.inst().getRegionManager(world).getRegion(regionName);
if (region == null) {
throw new RoomException("Region with given name does not exist!");
}
sign = getBlock(signLoc, world);
FileConfiguration config = plugin.getDB().getConfig();
String rawRenter = config.getString(world.getName() + "." + regionName + ".player");
renter = (rawRenter == null) ? null : Bukkit.getOfflinePlayer(UUID.fromString(rawRenter));
String rawTime = config.getString(world.getName() + "." + regionName + ".time");
time = (rawTime == null) ? -1 : Long.parseLong(rawTime);
schematicFile = new File(plugin.getDataFolder(), sign.getWorld().getName() + File.separator + regionName);
if (schematicFile.exists()) {
schematic = SchematicFormat.getFormat(schematicFile);
}
}
示例5: loadSchematic
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
public void loadSchematic() {
String formatName = null;
File f = new File("plugins//BlockParty//Floors//" + this.floorName + ".schematic");
if (!f.exists()) {
return;
}
SchematicFormat format = formatName == null ? null : SchematicFormat.getFormat(formatName);
if (format == null) {
format = SchematicFormat.getFormat(f);
}
if (format == null) {
return;
}
try {
this.size = format.load(f).getSize();
this.sh = format.load(f);
} catch (DataException localDataException) {
} catch (IOException localIOException) {
}
}
示例6: loadIslandSchematic
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
@Override
public void loadIslandSchematic(final File file, final Location origin, final PlayerPerk playerPerk) {
plugin.async(new Runnable() {
@Override
public void run() {
boolean noAir = false;
boolean entities = true;
Vector to = new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
EditSession editSession = getEditSession(playerPerk, origin);
try {
SchematicFormat.getFormat(file)
.load(file)
.paste(editSession, to, noAir, entities);
editSession.flushQueue();
} catch (MaxChangedBlocksException | IOException | DataException e) {
log.log(Level.INFO, "Unable to paste schematic " + file, e);
}
}
});
}
示例7: saveRegionBlocks
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的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;
}
示例8: spawnTree
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的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();
}
}
示例9: saveWEChunk
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的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();
}
}
示例10: loadBounds
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的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;
}
示例11: place
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的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.");
}
示例12: save
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
public void save(UUID uuid, Chunk chunk, String snapshotName) {
if (this.hasValidAdapter) {
try {
File schematicFile = getSnapshotFileLocation(uuid, snapshotName);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
.getEditSession(new BukkitWorld(chunk.getWorld()), 0x3b9ac9ff);
Vector minPoint = new Vector(chunk.getX() * 16, 0, chunk.getZ() * 16);
Vector maxPoint = new Vector(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15);
editSession.enableQueue();
CuboidClipboard clipboard = new CuboidClipboard(maxPoint.subtract(minPoint).add(new Vector(1, 1, 1)),
minPoint);
clipboard.copy(editSession);
SchematicFormat.MCEDIT.save(clipboard, schematicFile);
editSession.flushQueue();
} catch (DataException | IOException ex) {
ex.printStackTrace();
}
for (Entity entity : chunk.getEntities()) {
if (entity instanceof LivingEntity) {
moveEntityToTop(entity);
}
}
}
}
示例13: paste
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
public void paste(final UUID uuid, final String snapshotName, final Chunk chunk) {
if (this.hasValidAdapter) {
final Location pasteLoc = convertChunkLocation(chunk);
final File snapshotFile = getSnapshotFileLocation(uuid, snapshotName);
Bukkit.getScheduler().runTask(CubitBukkitPlugin.inst(), () -> {
try {
EditSession editSession = new EditSession(new BukkitWorld(pasteLoc.getWorld()),
Integer.MAX_VALUE);
editSession.enableQueue();
SchematicFormat snapshot = SchematicFormat.getFormat(snapshotFile);
CuboidClipboard clipboard = snapshot.load(snapshotFile);
clipboard.paste(editSession, BukkitUtil.toVector(pasteLoc), false, true);
editSession.flushQueue();
} catch (MaxChangedBlocksException | DataException | IOException ex) {
ex.printStackTrace();
}
for (Entity entity : chunk.getEntities()) {
if (entity instanceof LivingEntity) {
moveEntityToTop(entity);
}
}
});
}
}
示例14: checkForOutdatedArenaSaveFiles
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的package包/类
public static void checkForOutdatedArenaSaveFiles() {
File f = new File("plugins/SurvivalGames/reset/");
List<String> outdated = new ArrayList<>();
if(f.exists()) {
for(String key : f.list()) {
if(!key.endsWith(".map"))
continue;
File file = new File("plugins/SurvivalGames/reset/" + key);
SchematicFormat sf = SchematicFormat.getFormat(file);
if(sf == null) {
outdated.add(key);
}
}
}
String s = null;
if(!outdated.isEmpty()) {
s = MessageHandler.getMessage("prefix") + "�cThe format of " + outdated.size() + " map saves is outdated�7: �e";
for(int i = 0; i < outdated.size(); i++) {
s+= outdated.get(i);
if(i != outdated.size() - 1) {
s+= "�7, �e";
} else {
s+= " �c! ";
}
}
s+= "Select all the arenas with �l/sg arena select �cand type �c�l/sg arena save�c! In the old format, the arenas will not reset!";
}
UpdateListener.setOutdatedMaps(s);
}
示例15: run
import com.sk89q.worldedit.schematic.SchematicFormat; //导入依赖的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());
}
}