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


Java ApplicableRegionSet.getRegions方法代碼示例

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


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

示例1: isPVPEnabled

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
public static boolean isPVPEnabled(Location location) {
	String global = "__global__";
	if(plugin.getWorldGuard().getRegionManager(location.getWorld()) == null)	
		return true;
	RegionManager regionManager = plugin.getWorldGuard().getRegionManager(location.getWorld());
	ApplicableRegionSet arset = regionManager.getApplicableRegions(location);
	ProtectedRegion region = regionManager.getRegion(global);
	int priority = -10000;
	for(ProtectedRegion r : arset.getRegions()) { 
		if(r.getPriority() > priority) {
			region = r;
			priority = r.getPriority();
		}
	}
	if(region == null) {
		if(regionManager.getRegion(global) == null)
			return false;
		return "ALLOW".equals(regionManager.getRegion(global).getFlag(DefaultFlag.PVP).toString());
	}
	if(region.getFlag(DefaultFlag.PVP) == null)
		return true;
	return "ALLOW".equalsIgnoreCase(region.getFlag(DefaultFlag.PVP).toString());
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:24,代碼來源:Utility.java

示例2: queryRegions

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
private Set<String> queryRegions(Location location) {
    RegionContainer container = worldGuard.getRegionContainer();
    RegionQuery query = container.createQuery();
    ApplicableRegionSet set = query.getApplicableRegions(location);

    if (set.size() == 0) {
        return Collections.emptySet();
    }

    final Set<String> regions = new HashSet<>();
    for (ProtectedRegion r : set.getRegions()) {
        regions.add(r.getId().toLowerCase());
    }

    return regions;
}
 
開發者ID:lucko,項目名稱:ConditionalPerms,代碼行數:17,代碼來源:WorldGuardHook.java

示例3: getStationAtLocation

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
public static String getStationAtLocation(Location l){
	System.out.println("Method called.");
	ApplicableRegionSet set = wg.getRegionManager(l.getWorld()).getApplicableRegions(l);
	System.out.println("Crazy test!");
	Set<ProtectedRegion> regions = set.getRegions();
	java.util.Iterator<ProtectedRegion> i = regions.iterator();
	while(i.hasNext()){
		ProtectedRegion r = i.next();
		List<String> stations = new ArrayList<String>();
		stations.addAll(alphaStations);
		stations.addAll(betaStations);
		stations.addAll(gammaStations);
		for(String s : stations){
			if(r.getId().equals(s.toLowerCase())){
				return s;
			}
		}
	}
	return null;
}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:21,代碼來源:StationUtils.java

示例4: onSpawn

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSpawn(PlayerInteractEvent e){
    Player p = e.getPlayer();

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if(e.getHand() != EquipmentSlot.HAND) return;
        if (e.getItem() == null || !e.getItem().hasItemMeta() || !e.getItem().getItemMeta().hasDisplayName() || e.getItem().getType() != Material.MONSTER_EGG) return;
        if (!ChatColor.stripColor(e.getItem().getItemMeta().getDisplayName()).contains("Spawn")) return;
        int id = Integer.parseInt(e.getItem().getItemMeta().getLore().get(0));
        String s = e.getItem().getItemMeta().getLore().get(1);

        boolean canCatch = true;
        ApplicableRegionSet region = plugin.getWg().getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation());
        for (ProtectedRegion r : region.getRegions()) if (!r.getOwners().contains(p.getName())) canCatch = false;

        if (!canCatch) {
            p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes spawnear un mob en parcelas ajenas");
            return;
        }

        SNMob mob = new SNMob(p);
        if (!mob.isOwner(id)) {
           p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No eres el dueño de este huevo");
            return;
        }
        mob.spawnMob(id, s);
        p.getInventory().getItemInMainHand().setAmount(-1);
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:30,代碼來源:SpawnMob.java

示例5: canUseDuelCommands

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
public boolean canUseDuelCommands(Player player) {
    if (!isEnabled() || !config.isDuelZoneEnabled()) {
        return true;
    }

    List<String> allowedRegions = config.getDuelZoneRegions();
    WorldGuardPlugin worldguard = (WorldGuardPlugin) getPlugin();
    ApplicableRegionSet regions = worldguard.getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation());

    if (regions.getRegions().isEmpty()) {
        return false;
    }

    for (ProtectedRegion region : regions.getRegions()) {
        if (allowedRegions.contains(region.getId())) {
            return true;
        }
    }

    return false;
}
 
開發者ID:RealizedMC,項目名稱:Duels,代碼行數:22,代碼來源:WorldGuardHook.java

示例6: checkBlock

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
private boolean checkBlock(Player player, Block block) {

        if (player.hasPermission("umagic.bypass")) return true;

        RegionManager regionManager = getWorldGuard().getRegionManager(block.getWorld());
        ApplicableRegionSet applicableRegionSet = regionManager.getApplicableRegions(block.getLocation());

        if (applicableRegionSet.getRegions().isEmpty()) {
            getActionMessage().message(player, "" + ChatColor.RED + ChatColor.BOLD
                    + "The " + ChatColor.AQUA + ChatColor.BOLD + "Magical Hoe"
                    + ChatColor.RED + ChatColor.BOLD + " can only be used in regions!");
            return false;
        }

        for (ProtectedRegion region : applicableRegionSet.getRegions()) {

            boolean isOwner = region.isOwner(getWorldGuard().wrapPlayer(player));
            boolean isMember = region.isMember(getWorldGuard().wrapPlayer(player));

            if (!isOwner) if (!isMember) {
                getActionMessage().message(player, "" + ChatColor.RED + ChatColor.BOLD
                        + "You are not an owner or member of this region!");
                return false;
            }

        }

        return true;

    }
 
開發者ID:Ullarah,項目名稱:MinecraftPlugins,代碼行數:31,代碼來源:MagicFunctions.java

示例7: onMobCatch

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onMobCatch(ProjectileHitEvent e){
    Player p;
    if (e.getEntity().getShooter() instanceof Player) {
        p = (Player) e.getEntity().getShooter();
        if (canWork) {
            if (e.getEntity() instanceof Egg) {
                if (e.getHitEntity() instanceof Monster || e.getHitEntity() instanceof Animals || e.getHitEntity() instanceof Villager) {
                    if (mu.bannedMobs().contains(e.getEntity().getType())) {
                        p.sendMessage(this.plugin.getPrefix() + ChatColor.RED + "Este mob esta prohibido");
                        p.getInventory().addItem(pe.getPokeEgg());
                        return;
                    }
                    if (!vu.hasEnoughMoney(p, e.getHitEntity().getType().toString())) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No tienes dinero suficiente para hacer esto");
                        p.getInventory().addItem(pe.getPokeEgg());
                        return;
                    }
                    if (e.getEntity() instanceof Monster || e.getEntity() instanceof Animals){
                        LivingEntity le = (LivingEntity)e.getEntity();
                        if (le.getHealth() <= 0 || le.isDead()){
                            p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes capturar a un mob muerto");
                            p.getInventory().addItem(pe.getPokeEgg());
                            return;
                        }
                    }

                    boolean canCatch = true;
                    ApplicableRegionSet region = plugin.getWg().getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation());
                    for (ProtectedRegion r : region.getRegions()) if (!r.getOwners().contains(p.getName())) canCatch = false;

                    if (!canCatch) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes capturar a un mob en parcelas ajenas");
                        return;
                    }

                    //To Fix
                    if (e.getEntity() instanceof Mule || e.getEntity() instanceof Donkey || e.getEntity() instanceof Llama || e.getEntity() instanceof Villager){
                        p.sendMessage(ChatColor.RED + "Estos mobs están desactivados debido a un error de Minecraft.");
                        return;
                    }

                    SNMob mob = new SNMob(e.getHitEntity(), p);
                    mob.writeConfig();
                    mob.givePlayerEgg();

                    e.getHitEntity().remove();
                    p.sendMessage(this.plugin.getPrefix() + ChatColor.GREEN + "Has atrapado un mob");
                    p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);

                    vu.removeMoney(p, e.getHitEntity().getType().toString());

                    canWork = false;

                    if (e.getHitEntity().getType() == EntityType.VILLAGER) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "Los aldeanos tienen un pequeño error ahora mismo con los tradeos. Lo sentimos");
                    }
                }
            }
        }
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:63,代碼來源:CatchMob.java

示例8: checkBlock

import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
public boolean checkBlock(Player player, Block block) {

        if (player.hasPermission("chest.bypass")) return true;

        RegionManager regionManager = ChestInit.getWorldGuard().getRegionManager(block.getWorld());
        ApplicableRegionSet applicableRegionSet = regionManager.getApplicableRegions(block.getLocation());

        if (applicableRegionSet.getRegions().isEmpty()) return false;
        for (ProtectedRegion r : applicableRegionSet.getRegions())
            if (!r.isOwner(ChestInit.getWorldGuard().wrapPlayer(player))) return false;

        return true;

    }
 
開發者ID:Ullarah,項目名稱:MinecraftPlugins,代碼行數:15,代碼來源:ChestFunctions.java


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