本文整理汇总了Java中com.sk89q.worldedit.CuboidClipboard.saveSchematic方法的典型用法代码示例。如果您正苦于以下问题:Java CuboidClipboard.saveSchematic方法的具体用法?Java CuboidClipboard.saveSchematic怎么用?Java CuboidClipboard.saveSchematic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.CuboidClipboard
的用法示例。
在下文中一共展示了CuboidClipboard.saveSchematic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: onCommand
import com.sk89q.worldedit.CuboidClipboard; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("room")) {
if (args.length == 0) {
showHelp(sender, label);
return true;
}
if (args[0].equalsIgnoreCase("reload")) {
plugin.reload();
return true;
}
if (args[0].equalsIgnoreCase("add")) {
if (sender instanceof Player) {
// set and region name must be provided
if (args.length < 3) {
sender.sendMessage("§cIncorrect amount of arguments: " + "/roomrent add <set> <region> [regen]");
return true;
}
Player player = ((Player) sender);
// region must exist
ProtectedRegion region = WorldGuardPlugin.inst().getRegionManager(player.getWorld()).getRegion(args[2]);
if (region == null) {
sender.sendMessage("§cThis region does not exist!");
return true;
}
// the player must look at the sign
Set<Material> transparent = new HashSet<Material>();
transparent.add(Material.AIR);
Block target = player.getTargetBlock(transparent, 15);
if (target.getType() != Material.SIGN_POST && target.getType() != Material.WALL_SIGN) {
sender.sendMessage("§cYou have to look at the sign!");
return true;
}
// check if the world does not conflict with configuration
String world = plugin.getConfig().getString("room_sets." + args[1] + ".world");
if (world == null) {
plugin.getConfig().set("room_sets." + args[1] + ".world", player.getWorld().getName());
} else if (!world.equals(target.getWorld().getName())) {
sender.sendMessage("§3This set is on another world!");
return true;
}
// adding region to the config
plugin.getConfig().set("room_sets." + args[1] + ".rooms." + args[2],
target.getLocation().getBlockX() + ";" + target.getLocation().getBlockY() + ";"
+ target.getLocation().getBlockZ());
plugin.saveConfig();
// if there is "regen" argument, add a schematic
if (args.length > 3 && args[3].equalsIgnoreCase("regen")) {
try {
WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
CuboidClipboard clipboard = new CuboidClipboard(size, region.getMinimumPoint());
EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 64*64*64);
CuboidRegion r = new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
clipboard.copy(editSession, r);
File worldDirectory = new File(plugin.getDataFolder(), world);
worldDirectory.mkdir();
clipboard.saveSchematic(new File(worldDirectory, args[2]));
} catch (IOException | DataException e) {
e.printStackTrace();
}
}
sender.sendMessage("§2Region successfully added!");
return true;
}
// the console cannot add rooms
sender.sendMessage("Please edit the files manually and " + "use /roomrent reload");
return true;
}
showHelp(sender, label);
return true;
}
return false;
}