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


Java ProtectedCuboidRegion类代码示例

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


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

示例1: execute

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
protected void execute(Event event) {
	String name = (String) this.name.getSingle(event);
	Location loc1 = (Location) this.loc1.getSingle(event);
	Location loc2 = (Location) this.loc2.getSingle(event);
	World world = (World) this.world.getSingle(event);

	int x1 = loc1.getBlockX();
	int y1 = loc1.getBlockY();
	int z1 = loc1.getBlockZ();

	int x2 = loc2.getBlockX();
	int y2 = loc2.getBlockY();
	int z2 = loc2.getBlockZ();

	Vector p1 = new Vector(x1, y1, z1);
	Vector p2 = new Vector(x2, y2, z2);
	RegionManager regionManager = WGBukkit.getRegionManager(world);
	ProtectedCuboidRegion region = new ProtectedCuboidRegion(name, p1.toBlockVector(), p2.toBlockVector());
	regionManager.addRegion(region);
	try {
		regionManager.save();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:26,代码来源:EffCreateRegion.java

示例2: addRegion

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
/**
 * Criar uma nova região no WorldGuard
 *
 * @param name O nome da nova região
 * @param center O lugar central dela (para ser baseado o tamanho)
 * @param larg Um número inteiro para representar a largura
 * @param comp Um número inteiro para representar o comprimento
 * @param priority A prioridade da região
 * @return Retorna a região que foi criada se for criada com sucesso. Se já houver uma região com esse nome OU houver uma falha, retorna null.
 */
@Nullable
public static ProtectedRegion addRegion ( final String name, final Location center, final int larg, final int comp, final int priority )
{
	Preconditions.checkArgument( center.getWorld().getName().equalsIgnoreCase( center.getWorld().getName() ), "Worlds not same!" );
	Location prim = new Location( center.getWorld(), center.getBlockX() + larg, center.getBlockY(), center.getBlockZ() );
	Location sec = new Location( center.getWorld(), center.getBlockX() - comp, center.getBlockY(), center.getBlockZ() - comp );
	prim = Framework.getMinimumPoint( prim, sec );
	sec = Framework.getMaximumPoint( prim, sec );
	final WorldGuardPlugin plugin = ( WorldGuardPlugin ) Framework.worldguard;
	final RegionManager rm = plugin.getRegionManager( center.getWorld() );
	if ( rm.hasRegion( name ) )
	{
		return null;
	}
	else
	{
		final ProtectedCuboidRegion cuboid = new ProtectedCuboidRegion( name, Framework.getWorldEditVector( prim ), Framework.getWorldEditVector( sec ) );
		cuboid.setPriority( priority );
		rm.addRegion( cuboid );
		return cuboid;
	}
}
 
开发者ID:ProjectSandstone,项目名称:EventoZero,代码行数:33,代码来源:Framework.java

示例3: getPBregion

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
/**
 * returns a calculated ProtectedCuboidRegion from given params.
 *
 * @param loc Location of the protection block
 * @param length The lenght of the region
 * @param height The height of the region
 * @param width The width of the reguion
 * @param playerName The Owner of the region.
 * @return ProtectedCuboidRegion
 */
public ProtectedCuboidRegion getPBregion(Location loc, int length, int height, int width, String playerName) {

    BlockVector min = new BlockVector(loc.getBlockX() - ((length - 1) / 2),
            0,
            loc.getBlockZ() - ((width - 1) / 2));
    BlockVector max = new BlockVector(loc.getBlockX() + ((length - 1) / 2),
            255,
            loc.getBlockZ() + ((width - 1) / 2));

    if (height != 0) {
        min = min.setY(loc.getBlockY() - ((height - 1) / 2)).toBlockVector();
        max = max.setY(loc.getBlockY() + ((height - 1) / 2)).toBlockVector();
    }

    ProtectedCuboidRegion region = new ProtectedCuboidRegion("ps"
            + loc.getBlockX() + "x"
            + loc.getBlockY() + "y"
            + loc.getBlockZ() + "z", min, max);

    DefaultDomain dd = new DefaultDomain();
    dd.addPlayer(playerName);
    region.setOwners(dd);
    return region;
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:35,代码来源:WorldGuardManager.java

示例4: updateRegion

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
public static void updateRegion(IslandInfo islandInfo) {
    try {
        ProtectedCuboidRegion region = setRegionFlags(islandInfo);
        RegionManager regionManager = getWorldGuard().getRegionManager(uSkyBlock.getInstance().getWorld());
        regionManager.removeRegion(islandInfo.getName() + "island");
        regionManager.removeRegion(islandInfo.getLeader() + "island");
        regionManager.addRegion(region);
        String netherName = islandInfo.getName() + "nether";
        region = setRegionFlags(islandInfo, netherName);
        World netherWorld = uSkyBlock.getInstance().getSkyBlockNetherWorld();
        if (netherWorld != null) {
            regionManager = getWorldGuard().getRegionManager(netherWorld);
            regionManager.removeRegion(netherName);
            regionManager.addRegion(region);
        }
        islandInfo.setRegionVersion(getVersion());
    } catch (Exception e) {
        LogUtil.log(Level.SEVERE, "ERROR: Failed to update region for " + islandInfo.getName(), e);
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:21,代码来源:WorldGuardHandler.java

示例5: setVersionSpecificFlags

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
private static void setVersionSpecificFlags(ProtectedCuboidRegion region) {
    WorldGuardPlugin worldGuard = getWorldGuard();
    if (worldGuard != null && worldGuard.isEnabled() && worldGuard.getDescription() != null) {
        VersionUtil.Version wgVersion = VersionUtil.getVersion(worldGuard.getDescription().getVersion());
        if (wgVersion.isGTE("6.0")) {
            // Default values sort of bring us there... niiiiice
        } else {
            // 5.9 or below
            region.setFlag(DefaultFlag.ENTITY_ITEM_FRAME_DESTROY, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.ENTITY_PAINTING_DESTROY, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.CHEST_ACCESS, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.USE, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.DESTROY_VEHICLE, StateFlag.State.DENY);
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:17,代码来源:WorldGuardHandler.java

示例6: isIslandIntersectingSpawn

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
public static boolean isIslandIntersectingSpawn(Location islandLocation) {
    log.entering(CN, "isIslandIntersectingSpawn", islandLocation);
    try {
        int r = Settings.general_spawnSize;
        if (r == 0) {
            return false;
        }
        ProtectedRegion spawn = new ProtectedCuboidRegion("spawn", new BlockVector(-r, 0, -r), new BlockVector(r, 255, r));
        ProtectedCuboidRegion islandRegion = getIslandRegion(islandLocation);
        return !islandRegion.getIntersectingRegions(Collections.singletonList(spawn)).isEmpty();
    } catch (Exception e) {
        log.log(Level.SEVERE, "Unable to locate intersecting regions", e);
        return false;
    } finally {
        log.exiting(CN, "isIslandIntersectingSpawn");
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:18,代码来源:WorldGuardHandler.java

示例7: getWithin

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
public ArrayList<ABPortal> getWithin(final World world, final BlockVector min, final BlockVector max) {
    final RegionManager rm = wg.getRegionManager(world);
    if ( rm == null )
        return null;

    ProtectedCuboidRegion region = new ProtectedCuboidRegion(null, min, max);

    final ArrayList<ABPortal> out = new ArrayList<ABPortal>();
    for (final ProtectedRegion r: rm.getApplicableRegions(region)) {
        final String key = r.getId();
        if ( !key.startsWith("abyss-") )
            continue;

        final UUID uid = ParseUtils.tryUUID(key.substring(6));
        if ( uid == null )
            continue;

        final ABPortal portal = allPortals.get(uid);
        if ( portal != null )
            out.add(portal);
    }

    return out;
}
 
开发者ID:stendec,项目名称:Abyss,代码行数:25,代码来源:WorldGuardManager.java

示例8: regionAt

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
public Boolean regionAt(Chunk chunk) {
	String regionName = this.randomRegionName();
	
	int x1 = chunk.getX() << 4,
		z1 = chunk.getZ() << 4,
		y1 = 0;
	
	int x2 = x1 + 15,
		z2 = z1 + 15,
		y2 = chunk.getWorld().getMaxHeight();
	
	BlockVector point1 = new BlockVector(x1, y1, z1);
	BlockVector point2 = new BlockVector(x2, y2, z2);
	
	ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion(regionName, point1, point2);
	
	// Check over the regions, and ensure that none are in the configuration to ignore
	
	ApplicableRegionSet regions = WGBukkit.getRegionManager(chunk.getWorld()).getApplicableRegions(chunkRegion);
	for (ProtectedRegion region : regions) {
		if (Config.get().worldGuardIgnoreRegions.contains(region.getId())) continue;
		return true;
	}
	
	return false;
	
}
 
开发者ID:redstone,项目名称:FreshWilderness,代码行数:28,代码来源:WorldGuardEngine.java

示例9: onChunkUnloadEvent

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChunkUnloadEvent(ChunkUnloadEvent event)
{
	for (ProtectedRegion region : WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(event.getWorld()).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", new BlockVector(event.getChunk().getX() * 16, 0, event.getChunk().getZ() * 16), new BlockVector(event.getChunk().getX() * 16 + 15, 256, event.getChunk().getZ() * 16 + 15))))
	{
		if (region.getFlag(FlagUtils.CHUNK_UNLOAD) == State.DENY)
		{
			event.setCancelled(true);
			break;
		}
	}
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:13,代码来源:WorldListener.java

示例10: containsChunk

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
@Override
public boolean containsChunk(int chunkX, int chunkZ) {
    if (!large) return super.containsChunk(chunkX, chunkZ);
    BlockVector pos1 = new BlockVector(chunkX << 4, 0, chunkZ << 4);
    BlockVector pos2 = new BlockVector(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
    ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
    ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion);
    return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:10,代码来源:WorldGuardFilter.java

示例11: containsRegion

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
@Override
public boolean containsRegion(int mcaX, int mcaZ) {
    if (!large) return super.containsRegion(mcaX, mcaZ);
    BlockVector pos1 = new BlockVector(mcaX << 9, 0, mcaZ << 9);
    BlockVector pos2 = new BlockVector(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
    ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
    ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
    return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:10,代码来源:WorldGuardFilter.java

示例12: testCodecForCuboid

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
@Test
public void testCodecForCuboid() throws IOException {
    ProtectedRegion region = new ProtectedCuboidRegion("cuboid", new BlockVector(4, 4, 4), new BlockVector(42, 42, 42));
    fillRegion(region);
    ProcessingProtectedRegion container = new ProcessingProtectedRegion(region, "world");

    ProcessingProtectedRegion other;
    try (StringWriter sw = new StringWriter()) {
        codec.encode(new JsonWriter(sw), container, EncoderContext.builder().build());
        other = codec.decode(new JsonReader(sw.toString()), DecoderContext.builder().build());
    }

    Assert.assertEquals(container, other);
}
 
开发者ID:maxikg,项目名称:mongowg,代码行数:15,代码来源:ProcessingProtectedRegionCodecTest.java

示例13: getIslandRegion

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
public static ProtectedCuboidRegion getIslandRegion(Location islandLocation) {
    int r = Settings.island_radius;
    Vector islandCenter = new Vector(islandLocation.getBlockX(), 0, islandLocation.getBlockZ());
    return new ProtectedCuboidRegion(
            String.format("%d,%disland", islandCenter.getBlockX(), islandLocation.getBlockZ()),
            getProtectionVectorLeft(islandLocation),
            getProtectionVectorRight(islandLocation));
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:9,代码来源:WorldGuardHandler.java

示例14: createNewRegions

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
private void createNewRegions() {
	for (String planetName : centreCoordinates.keySet()){
		Integer[] minCoords = minRegionCoordinates.get(planetName);
		BlockVector minVector = new BlockVector(minCoords[0], minCoords[1], minCoords[2]);
		Integer[] maxCoords = maxRegionCoordinates.get(planetName);
		BlockVector maxVector = new BlockVector(maxCoords[0], maxCoords[1], maxCoords[2]);
		ProtectedCuboidRegion newRegion = new ProtectedCuboidRegion(planetName, minVector, maxVector);
		rgMgr.addRegion(newRegion);
	}	
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:11,代码来源:SQOrbitsPlanetMover.java

示例15: WorldguardCheck

import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; //导入依赖的package包/类
/**
 * Checks if the player is in, or near the specified WorldGuard regions.
 * @param l The location to check.
 * @return True or False, Is the location in one of these regions.
 */
public boolean WorldguardCheck(final Location l) {

    //Checks if plugin is installed.
    if (Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") != null) {

        //Checks if WorldGuard is enabled
        if (RandomCoords.getPlugin().config.getString("WorldGuard").equals("true")) {

            final int X = l.getBlockX();
            //  int Y = l.getBlockY();
            final int Z = l.getBlockZ();

            //Calls the BufferZone
            final int r = RandomCoords.getPlugin().config.getInt("CheckingRadius");


            //Checks all coordinates within the buffer zone for a region

                        //See if allRegions is enabled.
                        if (RandomCoords.getPlugin().config.getStringList("Regions").contains("allRegions")) {

                            return RandomCoords.getPlugin().getWorldGuard().getRegionManager(l.getWorld()).getApplicableRegions(l).size() == 0;
                        } else {
                            RegionContainer container = RandomCoords.getPlugin().getWorldGuard().getRegionContainer();
                            RegionManager regions = container.get(l.getWorld());
                            int cub = RandomCoords.getPlugin().config.getInt("CheckingRadius");
                            BlockVector p1 = new BlockVector(l.getX() + cub, 0.0D, l.getZ() + cub);
                            BlockVector p2 = new BlockVector(l.getX() - cub, 256.0D, l.getZ() - cub);
                            ProtectedRegion cuboid = new ProtectedCuboidRegion("RandomCoordsREGION-DO-NOT-USE", p1, p2);
                            ProtectedRegion regionRadius = cuboid;
                            ApplicableRegionSet set = regions.getApplicableRegions(regionRadius);
                            if(set.size() == 0 ) {
                                return true;
                            }
                            List<String> regionsToCheck = new ArrayList<>();

                            for(String name : RandomCoords.getPlugin().config.getStringList("Regions")) {

                                    if (set.getRegions().contains(regions.getRegion(name))) {
                                        regionsToCheck.add(name);
                                    }

                            }
                            return regionsToCheck == null || regionsToCheck.size() == 0;


                        }



        }

        return true;
    } else {

        return true;

    }
}
 
开发者ID:jolbol1,项目名称:RandomCoordinatesV2,代码行数:65,代码来源:WorldGuardCheck.java


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