本文整理汇总了Java中com.sk89q.worldedit.bukkit.BukkitWorld类的典型用法代码示例。如果您正苦于以下问题:Java BukkitWorld类的具体用法?Java BukkitWorld怎么用?Java BukkitWorld使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BukkitWorld类属于com.sk89q.worldedit.bukkit包,在下文中一共展示了BukkitWorld类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populate
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的package包/类
@Override
public void populate(World world, Random random, Chunk chunk)
{
if (this.bukkitWorld == null)
{
this.bukkitWorld = new BukkitWorld(world);
this.es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(this.bukkitWorld, -1);
this.es.setFastMode(false);
}
if (MathHelper.nextInt(random, 0, 100) == 0)
{
int xFortress = chunk.getX() * 16 + random.nextInt(15);
int zFortress = chunk.getZ() * 16 + random.nextInt(15);
this.generateBlazeFortress(world, xFortress, zFortress);
}
}
示例2: saveSchematic
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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);
}
}
示例3: WorldEditClearFlatlandTask
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的package包/类
public WorldEditClearFlatlandTask(final uSkyBlock plugin, final CommandSender commandSender, final Region region, final String format) {
super(plugin);
setOnCompletion(new Runnable() {
@Override
public void run() {
String duration = TimeUtil.millisAsString(WorldEditClearFlatlandTask.this.getTimeElapsed());
log(Level.INFO, String.format("Region %s was cleared in %s", region.toString(), duration));
commandSender.sendMessage(String.format(format, duration));
}
});
this.plugin = plugin;
innerChunks = WorldEditHandler.getInnerChunks(region);
borderRegions = WorldEditHandler.getBorderRegions(region);
bukkitWorld = new BukkitWorld(plugin.getWorld());
minY = Math.min(region.getMinimumPoint().getBlockY(), region.getMaximumPoint().getBlockY());
maxY = Math.max(region.getMinimumPoint().getBlockY(), region.getMaximumPoint().getBlockY());
maxBlocks = 2*Math.max(region.getLength(), region.getWidth())*16*(maxY-minY);
}
示例4: saveRegionBlocks
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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: spawnTree
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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();
}
}
示例6: rawSetBlock
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的package包/类
@Override
public boolean rawSetBlock(Vector pt, BaseBlock block)
{
if (this.player instanceof BukkitPlayer && this.player.getWorld() instanceof BukkitWorld)
{
World world = ((BukkitWorld)this.player.getWorld()).getWorld();
BlockState oldState = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getState();
boolean success = super.rawSetBlock(pt, block);
if (success)
{
ActionWorldEdit action = this.listener.newAction(ActionWorldEdit.class, world);
if (action != null)
{
BlockState newState = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getState();
action.setOldBlock(oldState);
action.setNewBlock(newState);
action.setPlayer(((BukkitPlayer)this.player).getPlayer());
action.setLocation(newState.getLocation());
this.listener.logAction(action);
}
}
return success;
}
return super.rawSetBlock(pt, block);
}
示例7: saveWEChunk
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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();
}
}
示例8: place
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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.");
}
示例9: loadSchematic
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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);
}
示例10: execute
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的package包/类
@Override
protected void execute(Event e) {
File file;
if (name.getSingle(e).startsWith("/")) {
file = new File(
(name.getSingle(e) + ".schematic").replaceAll("/", Matcher.quoteReplacement(File.separator)));
} else {
file = new File(
("plugins/WorldEdit/schematics/" + (name.getSingle(e).contains(".") ? name.getSingle(e)
: new StringBuilder(String.valueOf(name.getSingle(e))).append(".schematic").toString()))
.replaceAll("/", Matcher.quoteReplacement(File.separator)));
}
Vector v = new Vector(loc.getSingle(e).getBlockX(), loc.getSingle(e).getBlockY(), loc.getSingle(e).getBlockZ());
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"),
new Runnable() {
@Override
public void run() {
try {
Boolean excludeair = false;
if (exair != null) {
excludeair = exair.getSingle(e);
}
Schematic schem = FaweAPI.load(file);
EditSession ext = schem.paste(new BukkitWorld(loc.getSingle(e).getWorld()), v, false,
excludeair, null);
} catch (IOException e1) {
main core = (main) Bukkit.getPluginManager().getPlugin("SharpSK");
core.getLogger().warning("Failed to paste schematic: " + "\"" + name.getSingle(e) + "\""
+ " An error occurred");
return;
}
}
});
}
示例11: save
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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);
}
}
}
}
示例12: paste
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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);
}
}
});
}
}
示例13: ByteSchematic
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的package包/类
/**
* Constructor
*
* @param wep the WorldEdit plugin instance
* @param world the world to work in
*/
public ByteSchematic(WorldEditPlugin wep, World world) {
we = wep.getWorldEdit();
localPlayer = null;
localSession = new LocalSession(we.getConfiguration());
editSession = new EditSession(new BukkitWorld(world), we.getConfiguration().maxChangeLimit);
}
示例14: pasteWithWE
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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();
}
}
示例15: regenerate
import com.sk89q.worldedit.bukkit.BukkitWorld; //导入依赖的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();
}
}