當前位置: 首頁>>代碼示例>>Java>>正文


Java RegionManager.addRegion方法代碼示例

本文整理匯總了Java中com.sk89q.worldguard.protection.managers.RegionManager.addRegion方法的典型用法代碼示例。如果您正苦於以下問題:Java RegionManager.addRegion方法的具體用法?Java RegionManager.addRegion怎麽用?Java RegionManager.addRegion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sk89q.worldguard.protection.managers.RegionManager的用法示例。


在下文中一共展示了RegionManager.addRegion方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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.managers.RegionManager; //導入方法依賴的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: onUpdate

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void onUpdate(ObjectId updatedObject) {
    ProcessingProtectedRegion region = storageAdapter.load(updatedObject);
    ProtectedRegion protectedRegion = region.getRegion();
    if (checkIsIgnored(RegionStorageAdapter.RegionPath.create(region.getWorld(), protectedRegion.getId())))
        return;
    RegionManager regionManager = getRegionManager(region.getWorld());
    if (regionManager != null) {
        regionManager.removeRegion(protectedRegion.getId());
        regionManager.addRegion(protectedRegion);
        String parent = region.getParent();
        if (parent != null) {
            try {
                protectedRegion.setParent(regionManager.getRegion(parent));
            } catch (ProtectedRegion.CircularInheritanceException ignore) {
                LOGGER.warning("Circular inheritance for region " + protectedRegion.getId() + " of world " + region.getWorld() + ".");
            }
        }
    }
}
 
開發者ID:maxikg,項目名稱:mongowg,代碼行數:24,代碼來源:WorldGuardOpLogHandler.java

示例4: updateRegion

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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: onCreate

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void onCreate(BsonDocument createdDocument) {
    RegionStorageAdapter.RegionPath path = RegionStorageAdapter.RegionPath.create(createdDocument.getString("world").getValue() , createdDocument.getString("name").getValue());
    if (checkIsIgnored(path))
        return;
    RegionManager regionManager = getRegionManager(path);
    if (regionManager != null)
        regionManager.addRegion(read(createdDocument).getRegion());
}
 
開發者ID:maxikg,項目名稱:mongowg,代碼行數:13,代碼來源:WorldGuardOpLogHandler.java

示例6: newBlock

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
public void newBlock(ProtectedCuboidRegion regionToProtect, Location location, Player player, ItemMeta dtMeta, Material material, Byte materialData) {

        RegionManager rm = plugin.wgm.getRegionManager(location.getWorld());

        if (rm.overlapsUnownedRegion(regionToProtect, plugin.wgm.wrapPlayer(player))) {
            returnBlock(location, player, dtMeta);
            player.sendMessage(ChatColor.RED + plugin.i18n.getText("overlaps"));
            return;
        }

        if (plugin.config.ignoredWorldContains(location.getWorld())) {
            returnBlock(location, player, dtMeta);
            player.sendMessage(ChatColor.RED + plugin.i18n.getText("ignored_world"));
            return;
        }

        if (protectionBlockMap.containsKey(location)) {
            returnBlock(location, player, dtMeta);
            player.sendMessage(ChatColor.RED + plugin.i18n.getText("protection_over"));
            return;
        }

        int calculatedPriority = -1;
        for (ProtectedRegion pr : rm.getApplicableRegions(regionToProtect)) {
            if (pr.getPriority() > calculatedPriority) {
                calculatedPriority = pr.getPriority();
            }
        }

        regionToProtect.setPriority(calculatedPriority + 1);

        rm.addRegion(regionToProtect);
        player.sendMessage(ChatColor.GREEN + plugin.i18n.getText("pb_activated"));

        addProtectionBlock(location, regionToProtect, material, false,
                dtMeta.getDisplayName(), dtMeta.getLore(), materialData,
                (int) new Date().getTime() / 1000);

        try {
            rm.save();
        } catch (ProtectionDatabaseException ex) {
            Logger.getLogger(ProtectionBlocks.class
                    .getName()).log(Level.SEVERE, null, ex);
        }
        if (player.getGameMode() == GameMode.CREATIVE) {
            player.setItemInHand(new ItemStack(Material.AIR));
        }
        plugin.pc.removeAvailableId(dtMeta.getLore().get(2));
        new FlagsProcessor(plugin, location).runTaskAsynchronously(plugin);
    }
 
開發者ID:ddonofrio,項目名稱:libelula,代碼行數:51,代碼來源:ProtectionBlocks.java


注:本文中的com.sk89q.worldguard.protection.managers.RegionManager.addRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。