本文整理汇总了Java中com.sk89q.worldedit.data.DataException类的典型用法代码示例。如果您正苦于以下问题:Java DataException类的具体用法?Java DataException怎么用?Java DataException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataException类属于com.sk89q.worldedit.data包,在下文中一共展示了DataException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveTerrain
import com.sk89q.worldedit.data.DataException; //导入依赖的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();
}
示例2: loadSchematic
import com.sk89q.worldedit.data.DataException; //导入依赖的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) {
}
}
示例3: loadIslandSchematic
import com.sk89q.worldedit.data.DataException; //导入依赖的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);
}
}
});
}
示例4: saveRegionBlocks
import com.sk89q.worldedit.data.DataException; //导入依赖的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;
}
示例5: loadBounds
import com.sk89q.worldedit.data.DataException; //导入依赖的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;
}
示例6: save
import com.sk89q.worldedit.data.DataException; //导入依赖的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);
}
}
}
}
示例7: paste
import com.sk89q.worldedit.data.DataException; //导入依赖的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);
}
}
});
}
}
示例8: regenerate
import com.sk89q.worldedit.data.DataException; //导入依赖的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();
}
}
示例9: run
import com.sk89q.worldedit.data.DataException; //导入依赖的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());
}
}
示例10: saveClipboardToFile
import com.sk89q.worldedit.data.DataException; //导入依赖的package包/类
private static void saveClipboardToFile(CuboidClipboard clip, String name, File animationFolder) {
SchematicFormat sf = SchematicFormat.MCEDIT;
try {
File data = new File(animationFolder + File.separator + name + ".schematic");
sf.save(clip, data);
//p.sendMessage("File " + data.getAbsolutePath() + " saved!");
} catch (IOException | DataException ex) {
Logger.getLogger(AnimationFactory.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例11: loadFrame
import com.sk89q.worldedit.data.DataException; //导入依赖的package包/类
public static CuboidClipboard loadFrame(String frameName) {
try {
SchematicFormat sf = MCEditSchematicFormat.MCEDIT;
CuboidClipboard clip = sf.load(new File(MCMEAnimations.MCMEAnimationsInstance.getDataFolder() + File.separator + "schematics" + File.separator + "animations" + File.separator + frameName + ".schematic"));
return clip;
} catch (IOException | DataException ex) {
Logger.getLogger(WELoader.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
示例12: loadArea
import com.sk89q.worldedit.data.DataException; //导入依赖的package包/类
private static void loadArea(World world, File file, Vector origin)
throws DataException, IOException, MaxChangedBlocksException {
SchematicFormat schematic = SchematicFormat.MCEDIT;
CuboidClipboard clipboard = schematic.load(file);
clipboard.paste(new EditSession(new BukkitWorld(world), 20000), origin,
true);
}
示例13: getChildTag
import com.sk89q.worldedit.data.DataException; //导入依赖的package包/类
private static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected) throws DataException {
return expected.cast(items.get(key));
}