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


Java RegionManager類代碼示例

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


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

示例1: execute

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
protected void execute(Event event) {
	String name = (String) this.name.getSingle(event);
	World world = (World) this.world.getSingle(event);

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

	regionManager.removeRegion(name, RemovalStrategy.REMOVE_CHILDREN);
	try {
		regionManager.save();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:18,代碼來源:EffDeleteRegion.java

示例2: isPVPEnabled

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

示例3: addMembers

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
/**
 * Adds a list of members to a region.
 *
 * @param world World were the region is.
 * @param regionName The ID of the region.
 * @param playerNames Players to be added.
 * @return true on succes, false on failure.
 */
public boolean addMembers(World world, String regionName, String[] playerNames) {
    RegionManager rm = wgp.getRegionManager(world);
    if (rm == null) {
        return false;
    }
    ProtectedRegion region = rm.getRegion(regionName);
    if (region == null) {
        return false;
    }
    DefaultDomain members = region.getMembers();
    for (String playerName : playerNames) {
        members.addPlayer(playerName);
    }
    region.setMembers(members);
    try {
        rm.save();
    } catch (ProtectionDatabaseException ex) {
        plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
        return false;
    }
    return true;
}
 
開發者ID:ddonofrio,項目名稱:libelula,代碼行數:31,代碼來源:WorldGuardManager.java

示例4: removeMembers

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
/**
 * Removes a list of members from a region.
 *
 * @param world World were the region is.
 * @param regionName The ID of the region.
 * @param playerNames Players to be added.
 * @return true on succes, false on failure.
 */
public boolean removeMembers(World world, String regionName, String[] playerNames) {
    RegionManager rm = wgp.getRegionManager(world);
    if (rm == null) {
        return false;
    }
    ProtectedRegion region = rm.getRegion(regionName);
    if (region == null) {
        return false;
    }
    DefaultDomain members = region.getMembers();
    for (String playerName : playerNames) {
        members.removePlayer(playerName);
    }
    region.setMembers(members);
    try {
        rm.save();
    } catch (ProtectionDatabaseException ex) {
        plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
        return false;
    }
    return true;
}
 
開發者ID:ddonofrio,項目名稱:libelula,代碼行數:31,代碼來源:WorldGuardManager.java

示例5: addAudio

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
public boolean addAudio(CommandSender sender, AudioTrack audio, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioTrack> audioTracks = getRegionSetFlag(region, plugin.getAudioFlag());
    if (!audioTracks.add(audio)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-audio-exists", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioFlag(), audioTracks)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.audio-added", audio, regionId);
    return true;
}
 
開發者ID:DeadmanDungeons,項目名稱:AudioConnect,代碼行數:21,代碼來源:RegionCommand.java

示例6: removeAudio

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
public boolean removeAudio(CommandSender sender, AudioTrack audio, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioTrack> audioTracks = getRegionSetFlag(region, plugin.getAudioFlag());
    if (!audioTracks.remove(audio)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-audio-absent", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioFlag(), audioTracks)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.audio-removed", audio, regionId);
    return true;
}
 
開發者ID:DeadmanDungeons,項目名稱:AudioConnect,代碼行數:21,代碼來源:RegionCommand.java

示例7: addDelay

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
public boolean addDelay(CommandSender sender, AudioDelay delay, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioDelay> audioDelays = getRegionSetFlag(region, plugin.getAudioDelayFlag());
    if (!audioDelays.add(delay)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-delay-exists", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioDelayFlag(), audioDelays)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.delay-added", delay, regionId);
    return true;
}
 
開發者ID:DeadmanDungeons,項目名稱:AudioConnect,代碼行數:21,代碼來源:RegionCommand.java

示例8: removeDelay

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
public boolean removeDelay(CommandSender sender, AudioDelay delay, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioDelay> audioDelays = getRegionSetFlag(region, plugin.getAudioDelayFlag());
    if (!audioDelays.remove(delay)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-delay-absent", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioDelayFlag(), audioDelays)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.delay-removed", delay, regionId);
    return true;
}
 
開發者ID:DeadmanDungeons,項目名稱:AudioConnect,代碼行數:21,代碼來源:RegionCommand.java

示例9: importRegion

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
@Override
protected boolean importRegion(String regionId, String audioId) {
    boolean imported = false;
    for (RegionManager regionManager : regionManagers) {
        // Region IDs are unique for each RegionAudio import, so no need to synchronize
        ProtectedRegion region = regionManager.getRegion(regionId);
        if (region != null) {
            AudioTrack audioTrack = new AudioTrack(audioId);
            Set<AudioTrack> audioTracks = region.getFlag(plugin.getAudioFlag());
            audioTracks = (audioTracks != null ? new HashSet<>(audioTracks) : new HashSet<AudioTrack>());
            if (audioTracks.add(audioTrack)) {
                region.setFlag(plugin.getAudioFlag(), audioTracks);
            }
            imported = true;
        }
    }
    return imported;
}
 
開發者ID:DeadmanDungeons,項目名稱:AudioConnect,代碼行數:19,代碼來源:ImportCommand.java

示例10: getRegion

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
public ProtectedRegion getRegion(final Player player, final Location loc)
{
    final com.sk89q.worldguard.LocalPlayer localplayer = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().wrapPlayer(player);
    RegionManager manager = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(player.getWorld());
    final ProtectedRegion global = manager.getRegion("__global__");
    if (global != null && !isDenied(localplayer, global))
    {
        return global;
    }
    
    final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation());
    for (final ProtectedRegion region : regions)
    {
        if (!isDenied(localplayer, region))
        {
            return region;
        }
    }
    return null;
}
 
開發者ID:isokissa3,項目名稱:WorldGuardExtraFlagsPlugin,代碼行數:21,代碼來源:FaweWorldEditFlag.java

示例11: execute

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

示例12: get

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> list = new ArrayList<String>(pregion.getMembers().getPlayers());

	String[] s = new String[list.size()];
	return (String[]) list.toArray(s);
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:22,代碼來源:ExprAllMembers.java

示例13: get

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> rfl = new ArrayList<String>();

	for (Entry<Flag<?>, Object> ra : pregion.getFlags().entrySet()) {
		rfl.add(ra.getKey().getName());
	}

	String[] s = new String[rfl.size()];
	return (String[]) rfl.toArray(s);
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:26,代碼來源:ExprAllFlagsOfRegion.java

示例14: get

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
protected Location[] get(Event event) {
	String name = (String) this.region.getSingle(event);
	World world = (World) this.world.getSingle(event);

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

	double x = regionManager.getRegion(name).getMaximumPoint().getX();
	double y = regionManager.getRegion(name).getMaximumPoint().getY();
	double z = regionManager.getRegion(name).getMaximumPoint().getZ();

	Location pos1 = new Location(world, x, y, z);

	return new Location[] { pos1 };
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:19,代碼來源:ExprGetPoint2.java

示例15: get

import com.sk89q.worldguard.protection.managers.RegionManager; //導入依賴的package包/類
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> list = new ArrayList<String>(pregion.getOwners().getPlayers());

	String[] s = new String[list.size()];
	return (String[]) list.toArray(s);
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:22,代碼來源:ExprAllOwners.java


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