本文整理汇总了Java中com.sk89q.worldguard.protection.regions.ProtectedRegion.getFlag方法的典型用法代码示例。如果您正苦于以下问题:Java ProtectedRegion.getFlag方法的具体用法?Java ProtectedRegion.getFlag怎么用?Java ProtectedRegion.getFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldguard.protection.regions.ProtectedRegion
的用法示例。
在下文中一共展示了ProtectedRegion.getFlag方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isPVPEnabled
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的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());
}
示例2: importRegion
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的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;
}
示例3: onCrossBoundary
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
if (!WorldGuardUtils.hasBypass(player))
{
if (!player.hasMetadata("WGEFP-TPOEF"))
{
for (ProtectedRegion exitd : exited)
{
com.sk89q.worldedit.Location location = exitd.getFlag(FlagUtils.TELEPORT_ON_EXIT);
if (location != null)
{
player.setMetadata("WGEFP-TPOEF", new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), null));
player.teleport(BukkitUtil.toLocation(location));
break;
}
}
}
}
return true;
}
示例4: doUnloadChunkFlagWorldCheck
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
public static void doUnloadChunkFlagWorldCheck(World world)
{
for (ProtectedRegion region : WorldGuardExtraFlagsPlugin.worldGuardPlugin.getRegionManager(world).getRegions().values())
{
if (region.getFlag(FlagUtils.CHUNK_UNLOAD) == State.DENY)
{
WorldGuardExtraFlagsPlugin.getPlugin().getLogger().info("Loading chunks for region " + region.getId() + " located in " + world.getName() + " due to chunk-unload flag being deny");
Location min = BukkitUtil.toLocation(world, region.getMinimumPoint());
Location max = BukkitUtil.toLocation(world, region.getMaximumPoint());
for(int x = min.getChunk().getX(); x <= max.getChunk().getX(); x++)
{
for(int z = min.getChunk().getZ(); z <= max.getChunk().getZ(); z++)
{
world.getChunkAt(x, z).load(true);
}
}
}
}
}
示例5: allowSpawn
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
/**
* Modifies the worldguard regions at the given location to allow spawning for PetBlocks.
*
* @param location location
* @throws NoSuchMethodException exception
* @throws IllegalAccessException exception
* @throws InvocationTargetException exception
*/
public synchronized static void allowSpawn(Location location) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final WorldGuardPlugin worldGuard = getWorldGuard();
final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
final Iterable<?> set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
for (final Object region1 : set) {
final ProtectedRegion region = (ProtectedRegion) region1;
if (region.getFlag(DefaultFlag.MOB_SPAWNING) == State.DENY) {
region.setFlag(DefaultFlag.MOB_SPAWNING, State.ALLOW);
flags.add(region);
}
}
}
示例6: allowSpawn
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
public synchronized static void allowSpawn(Location location) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException {
final WorldGuardPlugin worldGuard = getWorldGuard();
final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
final ApplicableRegionSet set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
final Iterable<ProtectedRegion> regions = (Iterable<ProtectedRegion>) getMethod(set.getClass(), "getRegions").invoke(set);
for (final ProtectedRegion region : regions) {
if (region.getFlag(DefaultFlag.MOB_SPAWNING) == State.DENY) {
region.setFlag(DefaultFlag.MOB_SPAWNING, State.ALLOW);
flags.add(region);
}
}
}
示例7: allowSpawn
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
public synchronized static void allowSpawn(Location location, Plugin plugin) {
final WorldGuardPlugin worldGuard = (WorldGuardPlugin) plugin;
final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
final ApplicableRegionSet set = regionManager.getApplicableRegions(location);
for (final ProtectedRegion region : set) {
if (region.getFlag(DefaultFlag.MOB_SPAWNING) == State.DENY) {
region.setFlag(DefaultFlag.MOB_SPAWNING, State.ALLOW);
flags.add(region);
}
}
}
示例8: allowSpawn
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
public synchronized static void allowSpawn(Location location, Plugin plugin) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
final WorldGuardPlugin worldGuard = (WorldGuardPlugin) plugin;
final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
final ApplicableRegionSet set = regionManager.getApplicableRegions(location);
@SuppressWarnings("unchecked") final
Iterable<ProtectedRegion> regions = (Iterable<ProtectedRegion>) getMethod(set.getClass()).invoke(set);
for (final ProtectedRegion region : regions) {
if (region.getFlag(DefaultFlag.MOB_SPAWNING) == State.DENY) {
region.setFlag(DefaultFlag.MOB_SPAWNING, State.ALLOW);
flags.add(region);
}
}
}
示例9: getRegionSetFlag
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
private <T> Set<T> getRegionSetFlag(ProtectedRegion region, SetFlag<T> setFlag) {
Set<T> flagValue = region.getFlag(setFlag);
if (flagValue == null) {
return new HashSet<>();
} else {
return new HashSet<>(flagValue);
}
}
示例10: onChunkUnloadEvent
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的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;
}
}
}
示例11: checkWorldGuardValidity
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
/**
* Checks WorldGuard validity if possible
*
* @param selection region selection
* @return true if valid
*/
private boolean checkWorldGuardValidity(RegionSelection selection) {
if(!plugin.getDependencyManager().isEnabled(Dependency.WORLDGUARD)) {
return true;
}
WorldGuardPlugin worldGuard = plugin.getDependencyManager().get(Dependency.WORLDGUARD, WorldGuardPlugin.class);
Area selectionArea = new Area(new Rectangle(
selection.getCorner(selection.getCorner(0).getBlockX() < selection.getCorner(1).getBlockX() ? 0 : 1).getBlockX(),
selection.getCorner(selection.getCorner(0).getBlockZ() < selection.getCorner(1).getBlockZ() ? 0 : 1).getBlockZ(),
selection.getWidth(),
selection.getLength())
);
for(ProtectedRegion region : worldGuard.getRegionManager(selection.getWorld()).getRegions().values()) {
if(region.getFlag((Flag) RegionManager.WORLDGUARD_FLAG) == StateFlag.State.ALLOW) {
continue;
}
Area regionArea = RegionUtils.toArea(region);
regionArea.intersect(selectionArea);
if(!regionArea.isEmpty()) {
return false;
}
}
return true;
}
示例12: setFlag
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
/**
* Set a WorldGuard region flag.
* @param region The WorldGuard region to set
* @param flag The flag to set
* @param value The value to set the flag to
* @param <V> They type of flag to set
* @throws InvalidFlagFormat When the value of the flag is wrong
*/
private <V> void setFlag(ProtectedRegion region, Flag<V> flag, String value) throws InvalidFlagFormat {
V current = region.getFlag(flag);
V next = plugin.getWorldGuardHandler().parseFlagInput(flag, value);
if(!Objects.equals(current, next)) {
region.setFlag(flag, next);
}
}
示例13: printAudioInfo
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
public boolean printAudioInfo(CommandSender sender, 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> regionAudio = region.getFlag(plugin.getAudioFlag());
Set<AudioDelay> regionAudioDelay = region.getFlag(plugin.getAudioDelayFlag());
StringBuilder audioInfo = new StringBuilder();
ChatColor color1 = plugin.getMessenger().getPrimaryColor();
ChatColor color2 = plugin.getMessenger().getSecondaryColor();
ChatColor color3 = plugin.getMessenger().getTertiaryColor();
audioInfo.append(color2);
audioInfo.append("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
audioInfo.append(" Region Audio Info ");
audioInfo.append("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
audioInfo.append("\n");
audioInfo.append(color2).append("Region: ").append(color1).append(regionId).append("\n");
audioInfo.append(color2).append("Audio: ").append("\n");
if (regionAudio == null || regionAudio.isEmpty()) {
audioInfo.append(ChatColor.RED).append(" * NONE *").append("\n");
} else {
for (AudioTrack audio : regionAudio) {
audioInfo.append(color3).append("- ").append(color1).append(audio.getAudioId());
audioInfo.append(color2).append(" (").append("track: ");
if (audio.getTrackId() != null) {
audioInfo.append(color1).append(audio.getTrackId());
} else {
audioInfo.append("default");
}
audioInfo.append(color2).append(", time: ");
if (audio.getDayTime() != null) {
audioInfo.append(color1).append(audio.getDayTime().name().toLowerCase());
} else {
audioInfo.append("any");
}
audioInfo.append(color2).append(")").append("\n");
}
}
audioInfo.append(color2).append("Audio Delay: ").append("\n");
if (regionAudioDelay == null || regionAudioDelay.isEmpty()) {
audioInfo.append(ChatColor.RED).append(" * NONE *").append("\n");
} else {
for (AudioDelay audioDelay : regionAudioDelay) {
audioInfo.append(color3).append("- ").append(color1).append(audioDelay.getDelayTime());
audioInfo.append(color2).append(" (").append("track: ");
audioInfo.append(color2).append(" (").append("track: ");
if (audioDelay.getTrackId() != null) {
audioInfo.append(color1).append(audioDelay.getTrackId());
} else {
audioInfo.append("default");
}
audioInfo.append(color2).append(")").append("\n");
}
}
sender.sendMessage(audioInfo.toString());
return true;
}
示例14: isDenied
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
public boolean isDenied(LocalPlayer localplayer, ProtectedRegion region)
{
return region.getFlag(FlagUtils.WORLDEDIT) == State.DENY;
}