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


Java Region类代码示例

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


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

示例1: execute

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
protected void execute(Event event) {
	String name = (String) this.name.getSingle(event);
	World world = (World) this.world.getSingle(event);
	ItemStack block = (ItemStack) this.block.getSingle(event);

	RegionManager regionManager = WGBukkit.getRegionManager((org.bukkit.World) world);
	if (!regionManager.hasRegion(name)) {
		Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
		return;
	}

	Vector v1 = regionManager.getRegion(name).getMaximumPoint();
	Vector v2 = regionManager.getRegion(name).getMinimumPoint();
	Region region = new CuboidRegion(v1, v2);
	BaseBlock b = new BaseBlock(block.getTypeId(), block.getData().getData());

	EditSession es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
	try {
		es.setBlocks(region, b);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:24,代码来源:EffSetBlocks.java

示例2: CuboidRegionSelector

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
/**
 * Create a copy of another selector.
 *
 * @param oldSelector another selector
 */
public CuboidRegionSelector(RegionSelector oldSelector) {
    this(checkNotNull(oldSelector).getIncompleteRegion().getWorld());

    if (oldSelector instanceof CuboidRegionSelector) {
        final CuboidRegionSelector cuboidRegionSelector = (CuboidRegionSelector) oldSelector;

        position1 = cuboidRegionSelector.position1;
        position2 = cuboidRegionSelector.position2;
    } else {
        final Region oldRegion;
        try {
            oldRegion = oldSelector.getRegion();
        } catch (IncompleteRegionException e) {
            return;
        }

        position1 = oldRegion.getMinimumPoint().toBlockVector();
        position2 = oldRegion.getMaximumPoint().toBlockVector();
    }
    region.setPos1(position1);
    region.setPos2(position2);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:28,代码来源:CuboidRegionSelector.java

示例3: replace

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"/replace", "/re", "/rep", "/r"},
        usage = "[from-mask] <to-pattern>",
        desc = "Replace all blocks in the selection with another",
        flags = "f",
        min = 1,
        max = 2
)
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Optional Mask from, Pattern to, CommandContext context) throws WorldEditException {
    player.checkConfirmationRegion(getArguments(context), region);
    if (from == null) {
        from = new ExistingBlockMask(editSession);
    }
    int affected = editSession.replaceBlocks(region, from, to);
    BBC.VISITOR_BLOCK.send(player, affected);
    if (!player.hasPermission("fawe.tips"))
        BBC.TIP_REPLACE_ID.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE).send(player);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:RegionCommands.java

示例4: runWithSelection

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
/**
 * Run safely on an existing world within a selection
 *
 * @param player
 * @param editSession
 * @param selection
 * @param filter
 * @param <G>
 * @param <T>
 * @return
 */
@Deprecated
public static <G, T extends MCAFilter<G>> T runWithSelection(Player player, EditSession editSession, Region selection, T filter) {
    if (!(selection instanceof CuboidRegion)) {
        BBC.NO_REGION.send(player);
        return null;
    }
    CuboidRegion cuboid = (CuboidRegion) selection;
    RegionWrapper wrappedRegion = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
    String worldName = Fawe.imp().getWorldName(editSession.getWorld());
    FaweQueue tmp = SetQueue.IMP.getNewQueue(worldName, true, false);
    MCAQueue queue = new MCAQueue(tmp);
    FawePlayer<Object> fp = FawePlayer.wrap(player);
    fp.checkAllowedRegion(selection);
    recordHistory(fp, editSession.getWorld(), iAnvilHistory -> {
        queue.filterCopy(filter, wrappedRegion, iAnvilHistory);
    });
    return filter;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:30,代码来源:AnvilCommands.java

示例5: deleteUnclaimed

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"deleteunclaimed"},
        usage = "<age-ticks> [file-age=60000]",
        desc = "(Supports: WG, P2, GP) Delete all chunks which haven't been occupied AND claimed",
        help = "(Supports: WG, P2, GP) Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" +
                "Have not been accessed since `file-duration` (ms) after creation and\n" +
                "Have not been used in the past `chunk-inactivity` (ms)" +
                "The auto-save interval is the recommended value for `file-duration` and `chunk-inactivity`",
        min = 1,
        max = 3
)
@CommandPermissions("worldedit.anvil.deleteunclaimed")
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
    String folder = Fawe.imp().getWorldName(player.getWorld());
    long chunkInactivityMillis = fileDurationMillis; // Use same value for now
    DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
    if (debug) filter.enableDebug();
    DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
    if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:AnvilCommands.java

示例6: removeLayers

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"removelayers"},
        usage = "<id>",
        desc = "Removes matching chunk layers",
        help = "Remove if all the selected layers in a chunk match the provided id"
)
@CommandPermissions("worldedit.anvil.removelayer")
public void removeLayers(Player player, EditSession editSession, @Selection Region selection, int id) throws WorldEditException {
    Vector min = selection.getMinimumPoint();
    Vector max = selection.getMaximumPoint();
    int minY = min.getBlockY();
    int maxY = max.getBlockY();
    RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id);
    MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
    if (result != null) {
        player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:19,代码来源:AnvilCommands.java

示例7: setskylighting

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"/setskylight"},
        desc = "Set sky lighting in a selection",
        min = 1,
        max = 1
)
@CommandPermissions("worldedit.light.set")
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
    FawePlayer fp = FawePlayer.wrap(player);
    final FaweLocation loc = fp.getLocation();
    final int cx = loc.x >> 4;
    final int cz = loc.z >> 4;
    final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
    for (Vector pt : region) {
        queue.setSkyLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value);
    }
    int count = 0;
    for (Vector2D chunk : region.getChunks()) {
        queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ()));
        count++;
    }
    BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:RegionCommands.java

示例8: setBlocks

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
/**
 * Sets all the blocks inside a region to a given block type.
 *
 * @param region the region
 * @param block  the block
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
@SuppressWarnings("deprecation")
public int setBlocks(final Region region, final BaseBlock block) {
    checkNotNull(region);
    checkNotNull(block);
    if (canBypassAll(region, false, true) && !block.hasNbtData()) {
        return changes = queue.setBlocks((CuboidRegion) region, block.getId(), block.getData());
    }
    try {
        if (hasExtraExtents()) {
            RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(extent, (block)), this);
            Operations.completeBlindly(visitor);
            this.changes += visitor.getAffected();
        } else {
            Iterator<BlockVector> iter = region.iterator();
            while (iter.hasNext()) {
                if (this.extent.setBlock(iter.next(), block)) {
                    changes++;
                }
            }
        }
    } catch (final WorldEditException e) {
        throw new RuntimeException("Unexpected exception", e);
    }
    return changes;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:34,代码来源:EditSession.java

示例9: forest

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"/forest"},
        usage = "[type] [density]",
        desc = "Make a forest within the region",
        min = 0,
        max = 2
)
@CommandPermissions("worldedit.region.forest")
@Logging(REGION)
public void forest(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
                   @Optional("5") @Range(min = 0, max = 100) double density,
                   CommandContext context) throws WorldEditException {
    player.checkConfirmationRegion(getArguments(context), region);

    density = density / 100;
    ForestGenerator generator = new ForestGenerator(editSession, new TreeGenerator(type));
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
    LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);

    BBC.COMMAND_TREE.send(player, ground.getAffected());
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:RegionCommands.java

示例10: setlighting

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"/setblocklight", "/setlight"},
        desc = "Set block lighting in a selection",
        min = 1,
        max = 1
)
@CommandPermissions("worldedit.light.set")
public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
    FawePlayer fp = FawePlayer.wrap(player);
    final FaweLocation loc = fp.getLocation();
    final int cx = loc.x >> 4;
    final int cz = loc.z >> 4;
    final NMSMappedFaweQueue queue = (NMSMappedFaweQueue) fp.getFaweQueue(false);
    for (Vector pt : region) {
        queue.setBlockLight((int) pt.getX(), (int) pt.getY(), (int) pt.getZ(), value);
    }
    int count = 0;
    for (Vector2D chunk : region.getChunks()) {
        queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ()));
        count++;
    }
    BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:RegionCommands.java

示例11: makeWalls

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
/**
 * Make the walls of the given region. The method by which the walls are found
 * may be inefficient, because there may not be an efficient implementation supported
 * for that specific shape.
 *
 * @param region  the region
 * @param pattern the pattern to place
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
@SuppressWarnings("deprecation")
public int makeWalls(final Region region, final Pattern pattern) throws WorldEditException {
    checkNotNull(region);
    checkNotNull(pattern);

    if (region instanceof CuboidRegion) {
        return this.makeCuboidWalls(region, pattern);
    } else {
        final int minY = region.getMinimumPoint().getBlockY();
        final int maxY = region.getMaximumPoint().getBlockY();
        final ArbitraryShape shape = new RegionShape(region) {
            @Override
            public BaseBlock getMaterial(final int x, final int y, final int z, final BaseBlock defaultMaterial) {
                if ((y > maxY) || (y < minY)) {
                    // Put holes into the floor and ceiling by telling ArbitraryShape that the shape goes on outside the region
                    return defaultMaterial;
                }

                return super.getMaterial(x, y, z, defaultMaterial);
            }
        };
        return shape.generate(this, pattern, true);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:35,代码来源:EditSession.java

示例12: flora

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"/flora"},
        usage = "[density]",
        desc = "Make flora within the region",
        min = 0,
        max = 1
)
@CommandPermissions("worldedit.region.flora")
@Logging(REGION)
public void flora(FawePlayer player, EditSession editSession, @Selection Region region, @Optional("10") @Range(min = 0, max = 100) double density, CommandContext context) throws WorldEditException {
    player.checkConfirmationRegion(getArguments(context), region);
    density = density / 100;
    FloraGenerator generator = new FloraGenerator(editSession);
    GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
    LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
    visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
    Operations.completeLegacy(visitor);

    BBC.COMMAND_FLORA.send(player, ground.getAffected());
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:RegionCommands.java

示例13: stackCuboidRegion

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
/**
 * Stack a cuboid region.
 *
 * @param region  the region to stack
 * @param dir     the direction to stack
 * @param count   the number of times to stack
 * @param copyAir true to also copy air blocks
 * @return number of blocks affected
 * @throws MaxChangedBlocksException thrown if too many blocks are changed
 */
public int stackCuboidRegion(final Region region, final Vector dir, final int count, final boolean copyAir, boolean copyEntities, boolean copyBiomes) {
    checkNotNull(region);
    checkNotNull(dir);
    checkArgument(count >= 1, "count >= 1 required");
    final Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
    final Vector to = region.getMinimumPoint();
    final ForwardExtentCopy copy = new ForwardExtentCopy(EditSession.this, region, EditSession.this, to);
    copy.setCopyEntities(copyEntities);
    copy.setCopyBiomes(copyBiomes);
    copy.setRepetitions(count);
    copy.setTransform(new AffineTransform().translate(dir.multiply(size)));
    Mask sourceMask = getSourceMask();
    if (sourceMask != null) {
        new MaskTraverser(sourceMask).reset(EditSession.this);
        copy.setSourceMask(sourceMask);
        setSourceMask(null);
    }
    if (!copyAir) {
        copy.setSourceMask(new ExistingBlockMask(EditSession.this));
    }
    Operations.completeBlindly(copy);
    return this.changes = copy.getAffected();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:34,代码来源:EditSession.java

示例14: hollow

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
@Command(
        aliases = {"/hollow"},
        usage = "[<thickness>[ <pattern>]]",
        desc = "Hollows out the object contained in this selection",
        help =
                "Hollows out the object contained in this selection.\n" +
                        "Optionally fills the hollowed out part with the given block.\n" +
                        "Thickness is measured in manhattan distance.",
        min = 0,
        max = 2
)
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
public void hollow(FawePlayer player, EditSession editSession,
                   @Selection Region region,
                   @Optional("0") @Range(min = 0) int thickness,
                   @Optional("air") Pattern pattern,
                   CommandContext context) throws WorldEditException {
    player.checkConfirmationRegion(getArguments(context), region);
    int affected = editSession.hollowOutRegion(region, thickness, pattern);
    BBC.VISITOR_BLOCK.send(player, affected);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:23,代码来源:RegionCommands.java

示例15: EWSelectionRegion

import com.sk89q.worldedit.regions.Region; //导入依赖的package包/类
public EWSelectionRegion(SpongeWorldEdit worldedit, Player player, LocalSession session, RegionSelector selector, Region region) {
	this.worldedit = worldedit;
	this.player = player;
	this.session = session;
	this.selector = selector;
	this.region = region;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:8,代码来源:EWSelectionRegion.java


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