mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-13 11:41:43 +01:00
Change listeners to use the region query cache.
This commit is contained in:
parent
709ce9eb08
commit
cd62af698b
@ -89,4 +89,8 @@ public boolean hasPermission(String perm) {
|
||||
return plugin.hasPermission(player, perm);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -223,33 +223,13 @@ public List<RegionManager> getLoaded() {
|
||||
return Collections.unmodifiableList(container.getLoaded());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region query with no player.
|
||||
*
|
||||
* @return a new query
|
||||
*/
|
||||
public RegionQuery createAnonymousQuery() {
|
||||
return new RegionQuery(plugin, cache, (Player) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region query.
|
||||
*
|
||||
* @param player a player, or {@code null}
|
||||
* @return a new query
|
||||
*/
|
||||
public RegionQuery createQuery(@Nullable Player player) {
|
||||
return new RegionQuery(plugin, cache, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region query.
|
||||
*
|
||||
* @param player a player, or {@code null}
|
||||
* @return a new query
|
||||
*/
|
||||
public RegionQuery createQuery(@Nullable LocalPlayer player) {
|
||||
return new RegionQuery(plugin, cache, player);
|
||||
public RegionQuery createQuery() {
|
||||
return new RegionQuery(plugin, cache);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,45 +40,61 @@
|
||||
*/
|
||||
public class RegionQuery {
|
||||
|
||||
private final WorldGuardPlugin plugin;
|
||||
private final ConfigurationManager config;
|
||||
private final GlobalRegionManager globalManager;
|
||||
private final QueryCache cache;
|
||||
@Nullable
|
||||
private final LocalPlayer localPlayer;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param cache the query cache
|
||||
* @param player an optional player
|
||||
*/
|
||||
RegionQuery(WorldGuardPlugin plugin, QueryCache cache, @Nullable Player player) {
|
||||
this(plugin, cache, player != null ? plugin.wrapPlayer(player) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param cache the query cache
|
||||
* @param player an optional player
|
||||
*/
|
||||
RegionQuery(WorldGuardPlugin plugin, QueryCache cache, @Nullable LocalPlayer player) {
|
||||
RegionQuery(WorldGuardPlugin plugin, QueryCache cache) {
|
||||
checkNotNull(plugin);
|
||||
checkNotNull(cache);
|
||||
|
||||
this.plugin = plugin;
|
||||
this.config = plugin.getGlobalStateManager();
|
||||
this.cache = cache;
|
||||
//noinspection deprecation
|
||||
this.globalManager = plugin.getGlobalRegionManager();
|
||||
this.localPlayer = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the player (which must not be {@code null} can build at
|
||||
* the given location, using only the membership information and the state
|
||||
* of the {@link DefaultFlag#BUILD} flag to determine status.
|
||||
* Query for regions containing the given location.
|
||||
*
|
||||
* <p>An instance of {@link ApplicableRegionSet} will always be returned,
|
||||
* even if regions are disabled or region data failed to load. The most
|
||||
* appropriate implementation will be returned in such a case
|
||||
* (for example, if regions are disable, the returned implementation
|
||||
* would permit all activities).</p>
|
||||
*
|
||||
* @param location the location
|
||||
* @return a region set
|
||||
*/
|
||||
public ApplicableRegionSet queryContains(Location location) {
|
||||
checkNotNull(location);
|
||||
|
||||
World world = location.getWorld();
|
||||
WorldConfiguration worldConfig = config.get(world);
|
||||
|
||||
if (!worldConfig.useRegions) {
|
||||
return ApplicableRegionSet.getEmpty();
|
||||
}
|
||||
|
||||
RegionManager manager = globalManager.get(location.getWorld());
|
||||
if (manager != null) {
|
||||
return cache.queryContains(manager, location);
|
||||
} else {
|
||||
return ApplicableRegionSet.getEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a the player can build at the given location, checking membership
|
||||
* information and the state of the {@link DefaultFlag#BUILD} flag.
|
||||
*
|
||||
* <p>This method is used to check blocks and entities for which there
|
||||
* are no other related flags for (i.e. beds have the
|
||||
@ -89,13 +105,15 @@ public class RegionQuery {
|
||||
* depending on the configuration.</p>
|
||||
*
|
||||
* @param location the location
|
||||
* @param player the player
|
||||
* @return true if building is permitted
|
||||
* @throws NullPointerException if there is no player for this query
|
||||
*/
|
||||
public boolean testPermission(Location location) {
|
||||
public boolean testPermission(Location location, Player player) {
|
||||
checkNotNull(location);
|
||||
checkNotNull(localPlayer, "testPermission() requires a player for the query");
|
||||
|
||||
checkNotNull(player);
|
||||
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
World world = location.getWorld();
|
||||
WorldConfiguration worldConfig = config.get(world);
|
||||
|
||||
@ -112,10 +130,9 @@ public boolean testPermission(Location location) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the player (which must not be {@code null} can build at
|
||||
* the given location, using the membership information, state
|
||||
* of the {@link DefaultFlag#BUILD} flag, and the state of any passed
|
||||
* flags.
|
||||
* Test a the player can build at the given location, checking membership
|
||||
* information, state of the {@link DefaultFlag#BUILD} flag, and the state
|
||||
* of any passed flags.
|
||||
*
|
||||
* <p>This method is used to check blocks and entities for which there
|
||||
* are other related flags for (i.e. beds have the
|
||||
@ -128,14 +145,16 @@ public boolean testPermission(Location location) {
|
||||
* depending on the configuration.</p>
|
||||
*
|
||||
* @param location the location to test
|
||||
* @param player the player
|
||||
* @param flags an array of flags
|
||||
* @return true if the flag tests true
|
||||
*/
|
||||
public boolean testPermission(Location location, StateFlag... flags) {
|
||||
public boolean testPermission(Location location, Player player, StateFlag... flags) {
|
||||
checkNotNull(location);
|
||||
checkNotNull(flags);
|
||||
checkNotNull(localPlayer, "testPermission() requires a player for the query");
|
||||
checkNotNull(player);
|
||||
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
World world = location.getWorld();
|
||||
WorldConfiguration worldConfig = config.get(world);
|
||||
|
||||
@ -176,13 +195,15 @@ public boolean testPermission(Location location, StateFlag... flags) {
|
||||
* depending on the configuration.</p>
|
||||
*
|
||||
* @param location the location
|
||||
* @param player the player (or null)
|
||||
* @param flag the flag
|
||||
* @return true if the flag evaluates to {@code ALLOW}
|
||||
*/
|
||||
public boolean testState(Location location, StateFlag flag) {
|
||||
public boolean testState(Location location, @Nullable Player player, StateFlag flag) {
|
||||
checkNotNull(location);
|
||||
checkNotNull(flag);
|
||||
|
||||
LocalPlayer localPlayer = player != null ? plugin.wrapPlayer(player) : null;
|
||||
World world = location.getWorld();
|
||||
WorldConfiguration worldConfig = config.get(world);
|
||||
|
||||
|
@ -19,14 +19,12 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.util.RegionQueryUtil;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.RegionQueryUtil;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -34,8 +32,6 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
/**
|
||||
* This processes per-player state information and is also meant to be used
|
||||
* as a scheduled task.
|
||||
@ -86,9 +82,7 @@ public void run() {
|
||||
}
|
||||
}
|
||||
|
||||
Vector playerLocation = toVector(player.getLocation());
|
||||
RegionManager regionManager = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet applicable = regionManager.getApplicableRegions(playerLocation);
|
||||
ApplicableRegionSet applicable = plugin.getRegionContainer().createQuery().queryContains(player.getLocation());
|
||||
|
||||
if (!RegionQueryUtil.isInvincible(plugin, player, applicable)
|
||||
&& !plugin.getGlobalStateManager().hasGodMode(player)
|
||||
|
@ -63,15 +63,15 @@ public void onPlaceBlock(PlaceBlockEvent event) {
|
||||
Material type = event.getEffectiveMaterial();
|
||||
|
||||
if (player != null) {
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery(player);
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||
boolean canPlace;
|
||||
|
||||
// Flint and steel, fire charge
|
||||
if (type == Material.FIRE) {
|
||||
canPlace = query.testPermission(target, DefaultFlag.LIGHTER);
|
||||
canPlace = query.testPermission(target, player, DefaultFlag.LIGHTER);
|
||||
|
||||
} else {
|
||||
canPlace = query.testPermission(target);
|
||||
canPlace = query.testPermission(target, player);
|
||||
}
|
||||
|
||||
if (!canPlace) {
|
||||
@ -87,8 +87,8 @@ public void onBreakBlock(BreakBlockEvent event) {
|
||||
Location target = event.getTarget();
|
||||
|
||||
if (player != null) {
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery(player);
|
||||
boolean canBreak = query.testPermission(target);
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||
boolean canBreak = query.testPermission(target, player);
|
||||
|
||||
if (!canBreak) {
|
||||
tellErrorMessage(player, target);
|
||||
@ -104,24 +104,24 @@ public void onUseBlock(UseBlockEvent event) {
|
||||
Material type = event.getEffectiveMaterial();
|
||||
|
||||
if (player != null) {
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery(player);
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||
boolean canUse;
|
||||
|
||||
// Inventory blocks (CHEST_ACCESS)
|
||||
if (Materials.isInventoryBlock(type)) {
|
||||
canUse = query.testPermission(target, DefaultFlag.USE, DefaultFlag.CHEST_ACCESS);
|
||||
canUse = query.testPermission(target, player, DefaultFlag.USE, DefaultFlag.CHEST_ACCESS);
|
||||
|
||||
// Beds (SLEEP)
|
||||
} else if (type == Material.BED) {
|
||||
canUse = query.testPermission(target, DefaultFlag.USE, DefaultFlag.SLEEP);
|
||||
canUse = query.testPermission(target, player, DefaultFlag.USE, DefaultFlag.SLEEP);
|
||||
|
||||
// TNT (TNT)
|
||||
} else if (type == Material.TNT) {
|
||||
canUse = query.testPermission(target, DefaultFlag.TNT);
|
||||
canUse = query.testPermission(target, player, DefaultFlag.TNT);
|
||||
|
||||
// Everything else
|
||||
} else {
|
||||
canUse = query.testPermission(target, DefaultFlag.USE);
|
||||
canUse = query.testPermission(target, player, DefaultFlag.USE);
|
||||
}
|
||||
|
||||
if (!canUse) {
|
||||
@ -138,13 +138,13 @@ public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
EntityType type = event.getEffectiveType();
|
||||
|
||||
if (player != null) {
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery(player);
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||
boolean canSpawn;
|
||||
|
||||
if (Entities.isVehicle(type)) {
|
||||
canSpawn = query.testPermission(target, DefaultFlag.PLACE_VEHICLE);
|
||||
canSpawn = query.testPermission(target, player, DefaultFlag.PLACE_VEHICLE);
|
||||
} else {
|
||||
canSpawn = query.testPermission(target);
|
||||
canSpawn = query.testPermission(target, player);
|
||||
}
|
||||
|
||||
if (!canSpawn) {
|
||||
@ -161,13 +161,13 @@ public void onDestroyEntity(DestroyEntityEvent event) {
|
||||
EntityType type = event.getEntity().getType();
|
||||
|
||||
if (player != null) {
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery(player);
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||
boolean canDestroy;
|
||||
|
||||
if (Entities.isVehicle(type)) {
|
||||
canDestroy = query.testPermission(target, DefaultFlag.DESTROY_VEHICLE);
|
||||
canDestroy = query.testPermission(target, player, DefaultFlag.DESTROY_VEHICLE);
|
||||
} else {
|
||||
canDestroy = query.testPermission(target);
|
||||
canDestroy = query.testPermission(target, player);
|
||||
}
|
||||
|
||||
if (!canDestroy) {
|
||||
@ -183,8 +183,8 @@ public void onUseEntity(UseEntityEvent event) {
|
||||
Location target = event.getTarget();
|
||||
|
||||
if (player != null) {
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery(player);
|
||||
boolean canUse = query.testPermission(target, DefaultFlag.USE);
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||
boolean canUse = query.testPermission(target, player, DefaultFlag.USE);
|
||||
|
||||
if (!canUse) {
|
||||
tellErrorMessage(player, target);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
@ -28,7 +27,6 @@
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -55,8 +53,6 @@
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
/**
|
||||
* The listener for block events.
|
||||
*
|
||||
@ -275,9 +271,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(block.getLocation());
|
||||
|
||||
if (wcfg.highFreqFlags && isFireSpread
|
||||
&& !set.allows(DefaultFlag.FIRE_SPREAD)) {
|
||||
@ -351,14 +345,11 @@ public void onBlockBurn(BlockBurnEvent event) {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
Vector pt = toVector(block);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(block.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(block.getLocation());
|
||||
|
||||
if (!set.allows(DefaultFlag.FIRE_SPREAD)) {
|
||||
checkAndDestroyAround(block.getWorld(), x, y, z, BlockID.FIRE);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,8 +44,7 @@ public void onPlayerWhois(InfoComponent.PlayerWhoisEvent event) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
if (plugin.getGlobalStateManager().get(player.getWorld()).useRegions) {
|
||||
ApplicableRegionSet regions = plugin.getGlobalRegionManager()
|
||||
.get(player.getWorld()).getApplicableRegions(player.getLocation());
|
||||
ApplicableRegionSet regions = plugin.getRegionContainer().createQuery().queryContains(player.getLocation());
|
||||
|
||||
// Current regions
|
||||
StringBuilder regionStr = new StringBuilder();
|
||||
|
@ -19,14 +19,14 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.util.RegionQueryUtil;
|
||||
import com.sk89q.worldguard.bukkit.RegionQuery;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.util.RegionQueryUtil;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.GlobalRegionManager;
|
||||
import com.sk89q.worldguard.protection.events.DisallowedPVPEvent;
|
||||
@ -83,8 +83,6 @@
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
/**
|
||||
* Listener for entity related events.
|
||||
*
|
||||
@ -266,13 +264,11 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (attacker != null) {
|
||||
if (attacker instanceof Player) {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
Vector pt2 = toVector(attacker.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
RegionQuery query = plugin.getRegionContainer().createQuery();
|
||||
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) attacker))) {
|
||||
if (!query.testState(attacker.getLocation(), (Player) attacker, DefaultFlag.PVP)) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, true);
|
||||
} else if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.PVP ,localPlayer)) {
|
||||
} else if (!query.testState(defender.getLocation(), (Player) defender, DefaultFlag.PVP)) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, false);
|
||||
}
|
||||
}
|
||||
@ -286,10 +282,8 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && wcfg.explosionFlagCancellation) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (!set.allows(DefaultFlag.TNT, localPlayer)) {
|
||||
RegionQuery query = plugin.getRegionContainer().createQuery();
|
||||
if (!query.testState(defender.getLocation(), (Player) defender, DefaultFlag.TNT)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -310,18 +304,16 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
Fireball fireball = (Fireball) attacker;
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
RegionQuery query = plugin.getRegionContainer().createQuery();
|
||||
if (fireball.getShooter() instanceof Player) {
|
||||
Vector pt2 = toVector(((Player) fireball.getShooter()).getLocation());
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) fireball.getShooter()))) {
|
||||
Location pt2 = ((Player) fireball.getShooter()).getLocation();
|
||||
if (!query.testState(pt2, (Player) fireball.getShooter(), DefaultFlag.PVP)) {
|
||||
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, true);
|
||||
} else if (!set.allows(DefaultFlag.PVP, localPlayer)) {
|
||||
} else if (!query.testState(defender.getLocation(), (Player) defender, DefaultFlag.PVP)) {
|
||||
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, false);
|
||||
}
|
||||
} else {
|
||||
if (!set.allows(DefaultFlag.GHAST_FIREBALL, localPlayer) && wcfg.explosionFlagCancellation) {
|
||||
if (!query.testState(defender.getLocation(), (Player) defender, DefaultFlag.GHAST_FIREBALL) && wcfg.explosionFlagCancellation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -342,9 +334,8 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(defender.getLocation());
|
||||
|
||||
if (!set.allows(DefaultFlag.MOB_DAMAGE, localPlayer) && !(attacker instanceof Tameable)) {
|
||||
event.setCancelled(true);
|
||||
@ -368,8 +359,7 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
return;
|
||||
}
|
||||
Player beastMaster = (Player) ((Tameable) attacker).getOwner();
|
||||
Vector pt2 = toVector(attacker.getLocation());
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer(beastMaster))) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(attacker.getLocation()).allows(DefaultFlag.PVP, plugin.wrapPlayer(beastMaster))) {
|
||||
tryCancelPVPEvent(beastMaster, player, event, true);
|
||||
} else if (!set.allows(DefaultFlag.PVP, localPlayer)) {
|
||||
tryCancelPVPEvent(beastMaster, player, event, false);
|
||||
@ -411,10 +401,7 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.MOB_DAMAGE, localPlayer)) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(defender.getLocation()).allows(DefaultFlag.MOB_DAMAGE, localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -426,13 +413,9 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (event.getDamager() instanceof EnderPearl && attacker == player) return;
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
Vector pt2 = toVector(attacker.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) attacker))) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(attacker.getLocation()).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) attacker))) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, true);
|
||||
} else if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.PVP, localPlayer)) {
|
||||
} else if (!plugin.getRegionContainer().createQuery().queryContains(defender.getLocation()).allows(DefaultFlag.PVP, localPlayer)) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, false);
|
||||
}
|
||||
}
|
||||
@ -485,9 +468,7 @@ public void onEntityDamage(EntityDamageEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(defender.getLocation());
|
||||
|
||||
if (!set.allows(DefaultFlag.MOB_DAMAGE, plugin.wrapPlayer(player))) {
|
||||
event.setCancelled(true);
|
||||
@ -593,7 +574,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(block.getLocation()).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
@ -610,7 +591,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(block.getLocation()).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
@ -631,7 +612,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(block.getLocation()).allows(DefaultFlag.TNT)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
@ -663,7 +644,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(block.getLocation()).allows(DefaultFlag.GHAST_FIREBALL)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
@ -688,7 +669,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.OTHER_EXPLOSION)) {
|
||||
if (!plugin.getRegionContainer().createQuery().queryContains(block.getLocation()).allows(DefaultFlag.OTHER_EXPLOSION)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
@ -785,11 +766,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
Location eventLoc = event.getLocation();
|
||||
|
||||
if (wcfg.useRegions && cfg.useRegionsCreatureSpawnEvent) {
|
||||
Vector pt = toVector(eventLoc);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(eventLoc.getWorld());
|
||||
// @TODO get victims' stacktraces and find out why it's null anyway
|
||||
if (mgr == null) return;
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(eventLoc);
|
||||
|
||||
if (!set.allows(DefaultFlag.MOB_SPAWNING)) {
|
||||
event.setCancelled(true);
|
||||
|
@ -24,9 +24,9 @@
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.listener.FlagStateManager.PlayerFlagState;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.listener.FlagStateManager.PlayerFlagState;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
@ -44,7 +44,6 @@
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
@ -66,9 +65,6 @@
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.createTarget;
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a player.
|
||||
*/
|
||||
@ -184,8 +180,7 @@ public static boolean checkMove(WorldGuardPlugin plugin, Player player, Location
|
||||
|
||||
// Have to set this state
|
||||
if (state.lastExitAllowed == null) {
|
||||
state.lastExitAllowed = plugin.getGlobalRegionManager().get(world)
|
||||
.getApplicableRegions(toVector(from))
|
||||
state.lastExitAllowed = plugin.getRegionContainer().createQuery().queryContains(from)
|
||||
.allows(DefaultFlag.EXIT, localPlayer);
|
||||
}
|
||||
|
||||
@ -305,8 +300,7 @@ public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(player, player.getWorld())) {
|
||||
GameMode gameMode = plugin.getGlobalRegionManager().get(player.getWorld())
|
||||
.getApplicableRegions(player.getLocation()).getFlag(DefaultFlag.GAME_MODE);
|
||||
GameMode gameMode = plugin.getRegionContainer().createQuery().queryContains(player.getLocation()).getFlag(DefaultFlag.GAME_MODE);
|
||||
if (plugin.getFlagStateManager().getState(player).lastGameMode != null
|
||||
&& gameMode != null && event.getNewGameMode() != gameMode) {
|
||||
event.setCancelled(true);
|
||||
@ -435,10 +429,8 @@ public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
|
||||
if (state.lastWorld != null && !hasBypass) {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
Location loc = player.getLocation();
|
||||
Vector pt = new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(loc);
|
||||
|
||||
if (state.lastExitAllowed == null) {
|
||||
state.lastExitAllowed = set.allows(DefaultFlag.EXIT, localPlayer);
|
||||
@ -523,11 +515,9 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
Block placedIn = block.getRelative(event.getBlockFace());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet placedInSet = mgr.getApplicableRegions(placedIn.getLocation());
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(block.getLocation());
|
||||
ApplicableRegionSet placedInSet = plugin.getRegionContainer().createQuery().queryContains(placedIn.getLocation());
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (item.getTypeId() == wcfg.regionWand && plugin.hasPermission(player, "worldguard.region.wand")) {
|
||||
@ -609,9 +599,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(location);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(location);
|
||||
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
com.sk89q.worldedit.Location spawn = set.getFlag(DefaultFlag.SPAWN_LOC, localPlayer);
|
||||
@ -640,28 +628,6 @@ public void onItemHeldChange(PlayerItemHeldEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location location = player.getLocation();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(location);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, player.getWorld())
|
||||
&& !set.allows(DefaultFlag.SLEEP, plugin.wrapPlayer(player))) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage("This bed doesn't belong to you!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority= EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
World world = event.getFrom().getWorld();
|
||||
@ -669,11 +635,8 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(event.getFrom().getWorld());
|
||||
Vector pt = new Vector(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||
Vector ptFrom = new Vector(event.getFrom().getBlockX(), event.getFrom().getBlockY(), event.getFrom().getBlockZ());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet setFrom = mgr.getApplicableRegions(ptFrom);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(event.getTo());
|
||||
ApplicableRegionSet setFrom = plugin.getRegionContainer().createQuery().queryContains(event.getFrom());
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(event.getPlayer());
|
||||
|
||||
if (cfg.usePlayerTeleports) {
|
||||
@ -705,9 +668,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().hasBypass(player, world)) {
|
||||
Vector pt = toVector(player.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(player.getLocation());
|
||||
|
||||
Set<String> allowedCommands = set.getFlag(DefaultFlag.ALLOWED_CMDS, localPlayer);
|
||||
Set<String> blockedCommands = set.getFlag(DefaultFlag.BLOCKED_CMDS, localPlayer);
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit.listener;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -31,10 +31,6 @@
|
||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
|
||||
public class WorldGuardWeatherListener implements Listener {
|
||||
|
||||
@ -102,9 +98,7 @@ public void onLightningStrike(LightningStrikeEvent event) {
|
||||
|
||||
Location loc = event.getLightning().getLocation();
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(loc);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(loc.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet set = plugin.getRegionContainer().createQuery().queryContains(loc);
|
||||
|
||||
if (!set.allows(DefaultFlag.LIGHTNING)) {
|
||||
event.setCancelled(true);
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -50,6 +51,11 @@
|
||||
*/
|
||||
public class ApplicableRegionSet implements Iterable<ProtectedRegion> {
|
||||
|
||||
/**
|
||||
* A static instance of an empty set.
|
||||
*/
|
||||
private static final ApplicableRegionSet EMPTY = new ApplicableRegionSet(Collections.<ProtectedRegion>emptyList(), null);
|
||||
|
||||
private final SortedSet<ProtectedRegion> applicable;
|
||||
@Nullable
|
||||
private final ProtectedRegion globalRegion;
|
||||
@ -434,4 +440,11 @@ public Iterator<ProtectedRegion> iterator() {
|
||||
return applicable.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance that contains no regions and has no global region.
|
||||
*/
|
||||
public static ApplicableRegionSet getEmpty() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldguard.bukkit.RegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.RegionQuery;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
@ -84,33 +85,13 @@ public List<RegionManager> getLoaded() {
|
||||
return Collections.unmodifiableList(container.getLoaded());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region query with no player.
|
||||
*
|
||||
* @return a new query
|
||||
*/
|
||||
private RegionQuery createAnonymousQuery() {
|
||||
return container.createAnonymousQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region query.
|
||||
*
|
||||
* @param player a player, or {@code null}
|
||||
* @return a new query
|
||||
*/
|
||||
private RegionQuery createQuery(@Nullable Player player) {
|
||||
return container.createQuery(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new region query.
|
||||
*
|
||||
* @param player a player, or {@code null}
|
||||
* @return a new query
|
||||
*/
|
||||
private RegionQuery createQuery(@Nullable LocalPlayer player) {
|
||||
return container.createQuery(player);
|
||||
private RegionQuery createQuery() {
|
||||
return container.createQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,7 +100,7 @@ private RegionQuery createQuery(@Nullable LocalPlayer player) {
|
||||
* @param player the player
|
||||
* @param world the world
|
||||
* @return true if a bypass is permitted
|
||||
* @deprecated use {@link #createQuery(Player)}
|
||||
* @deprecated use {@link RegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasBypass(LocalPlayer player, World world) {
|
||||
@ -132,7 +113,7 @@ public boolean hasBypass(LocalPlayer player, World world) {
|
||||
* @param player the player
|
||||
* @param world the world
|
||||
* @return true if a bypass is permitted
|
||||
* @deprecated use {@link #createQuery(Player)}
|
||||
* @deprecated use {@link RegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasBypass(Player player, World world) {
|
||||
@ -152,7 +133,7 @@ public boolean hasBypass(Player player, World world) {
|
||||
* @param player the player
|
||||
* @param block the block
|
||||
* @return true if a bypass is permitted
|
||||
* @deprecated use {@link #createQuery(Player)}
|
||||
* @deprecated use {@link RegionContainer#createQuery()}
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
@ -173,11 +154,11 @@ public boolean canBuild(Player player, Block block) {
|
||||
* @param player the player
|
||||
* @param location the location
|
||||
* @return true if a bypass is permitted
|
||||
* @deprecated use {@link #createQuery(Player)}
|
||||
* @deprecated use {@link RegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean canBuild(Player player, Location location) {
|
||||
return createQuery(player).testPermission(location);
|
||||
return createQuery().testPermission(location, player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,7 +194,7 @@ public boolean canConstruct(Player player, Location location) {
|
||||
* @param flag the flag
|
||||
* @param location the location
|
||||
* @return true if set to true
|
||||
* @deprecated use {@link #createQuery(Player)}
|
||||
* @deprecated use {@link RegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -229,11 +210,16 @@ public boolean allows(StateFlag flag, Location location) {
|
||||
* @param location the location
|
||||
* @param player the actor
|
||||
* @return true if set to true
|
||||
* @deprecated use {@link #createQuery(Player)}
|
||||
* @deprecated use {@link RegionContainer#createQuery()}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean allows(StateFlag flag, Location location, @Nullable LocalPlayer player) {
|
||||
return createQuery(player).testState(location, flag);
|
||||
if (player instanceof BukkitPlayer) {
|
||||
Player p = ((BukkitPlayer) player).getPlayer();
|
||||
return createQuery().testState(location, p, flag);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Can't take a non-Bukkit player");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user