mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-20 19:11:13 +02:00
Cleanup usage of BukkitWorldConfiguration
This commit is contained in:
parent
d4d7601125
commit
405b210fb5
@ -27,6 +27,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,8 +78,8 @@ protected ConfigurationManager getConfig() {
|
|||||||
* @param world The world to get the configuration for.
|
* @param world The world to get the configuration for.
|
||||||
* @return The configuration for {@code world}
|
* @return The configuration for {@code world}
|
||||||
*/
|
*/
|
||||||
protected BukkitWorldConfiguration getWorldConfig(World world) {
|
protected WorldConfiguration getWorldConfig(World world) {
|
||||||
return (BukkitWorldConfiguration) getConfig().get(world);
|
return getConfig().get(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +88,7 @@ protected BukkitWorldConfiguration getWorldConfig(World world) {
|
|||||||
* @param player The player to get the wold from
|
* @param player The player to get the wold from
|
||||||
* @return The {@link BukkitWorldConfiguration} for the player's world
|
* @return The {@link BukkitWorldConfiguration} for the player's world
|
||||||
*/
|
*/
|
||||||
protected BukkitWorldConfiguration getWorldConfig(LocalPlayer player) {
|
protected WorldConfiguration getWorldConfig(LocalPlayer player) {
|
||||||
return getWorldConfig((World) player.getExtent());
|
return getWorldConfig((World) player.getExtent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public void onPlaceBlock(final PlaceBlockEvent event) {
|
|||||||
final Player player = event.getCause().getFirstPlayer();
|
final Player player = event.getCause().getFirstPlayer();
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
final BukkitWorldConfiguration wcfg = getWorldConfig(WorldGuardPlugin.inst().wrapPlayer(player));
|
final BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(WorldGuardPlugin.inst().wrapPlayer(player));
|
||||||
|
|
||||||
// Early guard
|
// Early guard
|
||||||
if (!wcfg.signChestProtection) {
|
if (!wcfg.signChestProtection) {
|
||||||
@ -81,7 +81,7 @@ public void onPlaceBlock(final PlaceBlockEvent event) {
|
|||||||
public void onBreakBlock(final BreakBlockEvent event) {
|
public void onBreakBlock(final BreakBlockEvent event) {
|
||||||
final Player player = event.getCause().getFirstPlayer();
|
final Player player = event.getCause().getFirstPlayer();
|
||||||
|
|
||||||
final BukkitWorldConfiguration wcfg = getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
final BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
||||||
|
|
||||||
// Early guard
|
// Early guard
|
||||||
if (!wcfg.signChestProtection) {
|
if (!wcfg.signChestProtection) {
|
||||||
@ -107,7 +107,7 @@ public void onBreakBlock(final BreakBlockEvent event) {
|
|||||||
public void onUseBlock(final UseBlockEvent event) {
|
public void onUseBlock(final UseBlockEvent event) {
|
||||||
final Player player = event.getCause().getFirstPlayer();
|
final Player player = event.getCause().getFirstPlayer();
|
||||||
|
|
||||||
final BukkitWorldConfiguration wcfg = getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
final BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
||||||
|
|
||||||
// Early guard
|
// Early guard
|
||||||
if (!wcfg.signChestProtection) {
|
if (!wcfg.signChestProtection) {
|
||||||
@ -132,7 +132,7 @@ public void onUseBlock(final UseBlockEvent event) {
|
|||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onSignChange(SignChangeEvent event) {
|
public void onSignChange(SignChangeEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitWorldConfiguration wcfg = getWorldConfig(WorldGuardPlugin.inst().wrapPlayer(player));
|
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(WorldGuardPlugin.inst().wrapPlayer(player));
|
||||||
|
|
||||||
if (wcfg.signChestProtection) {
|
if (wcfg.signChestProtection) {
|
||||||
if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
|
if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||||
import com.sk89q.worldguard.bukkit.util.Events;
|
import com.sk89q.worldguard.bukkit.util.Events;
|
||||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
@ -163,10 +164,6 @@ public void registerEvents() {
|
|||||||
getPlugin().getServer().getPluginManager().registerEvents(new SpigotCompatListener(), getPlugin());
|
getPlugin().getServer().getPluginManager().registerEvents(new SpigotCompatListener(), getPlugin());
|
||||||
} catch (LinkageError ignored) {
|
} catch (LinkageError ignored) {
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
getPlugin().getServer().getPluginManager().registerEvents(new LingeringPotionListener(), getPlugin());
|
|
||||||
} catch (NoClassDefFoundError ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -463,7 +460,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
|||||||
// emit a "use block here" event where the player is
|
// emit a "use block here" event where the player is
|
||||||
// standing, which is a hack to protect items that don't
|
// standing, which is a hack to protect items that don't
|
||||||
// throw events
|
// throw events
|
||||||
if (item != null && getWorldConfig(BukkitAdapter.adapt(player.getWorld())).blockUseAtFeet.test(item)) {
|
if (item != null && ((BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(player.getWorld()))).blockUseAtFeet.test(item)) {
|
||||||
if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, player.getLocation().getBlock()))) {
|
if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, player.getLocation().getBlock()))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -570,7 +567,7 @@ public void onPlayerBucketFill(PlayerBucketFillEvent event) {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onBlockFromTo(BlockFromToEvent event) {
|
public void onBlockFromTo(BlockFromToEvent event) {
|
||||||
BukkitWorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getBlock().getWorld()));
|
WorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getBlock().getWorld()));
|
||||||
|
|
||||||
// This only applies to regions but nothing else cares about high
|
// This only applies to regions but nothing else cares about high
|
||||||
// frequency events at the moment
|
// frequency events at the moment
|
||||||
@ -939,6 +936,23 @@ public void onBlockDispense(BlockDispenseEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onLingeringSplash(LingeringPotionSplashEvent event) {
|
||||||
|
AreaEffectCloud aec = event.getAreaEffectCloud();
|
||||||
|
LingeringPotion potion = event.getEntity();
|
||||||
|
World world = potion.getWorld();
|
||||||
|
Cause cause = create(event.getEntity());
|
||||||
|
|
||||||
|
// Fire item interaction event
|
||||||
|
Events.fireToCancel(event, new UseItemEvent(event, cause, world, potion.getItem()));
|
||||||
|
|
||||||
|
// Fire entity spawn event
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
// radius unfortunately doesn't go through with this, so only a single location is tested
|
||||||
|
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, aec.getLocation().add(0.5, 0, 0.5), EntityType.AREA_EFFECT_CLOUD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the right click of a block while an item is held.
|
* Handle the right click of a block while an item is held.
|
||||||
*
|
*
|
||||||
@ -1027,11 +1041,11 @@ private static <T extends Event & Cancellable> void handleInventoryHolderUse(T o
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasInteractBypass(Block block) {
|
private boolean hasInteractBypass(Block block) {
|
||||||
return getWorldConfig(BukkitAdapter.adapt(block.getWorld())).allowAllInteract.test(block);
|
return ((BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(block.getWorld()))).allowAllInteract.test(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasInteractBypass(World world, ItemStack item) {
|
private boolean hasInteractBypass(World world, ItemStack item) {
|
||||||
return getWorldConfig(BukkitAdapter.adapt(world)).allowAllInteract.test(item);
|
return ((BukkitWorldConfiguration) getWorldConfig(BukkitAdapter.adapt(world))).allowAllInteract.test(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBlockModifiedOnClick(Block block, boolean rightClick) {
|
private boolean isBlockModifiedOnClick(Block block, boolean rightClick) {
|
||||||
@ -1069,23 +1083,4 @@ public void onBlockExplode(BlockExplodeEvent event) {
|
|||||||
event.getBlock().getLocation().getWorld(), event.blockList(), Material.AIR));
|
event.getBlock().getLocation().getWorld(), event.blockList(), Material.AIR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LingeringPotionListener implements Listener {
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
|
||||||
public void onLingeringSplash(LingeringPotionSplashEvent event) {
|
|
||||||
AreaEffectCloud aec = event.getAreaEffectCloud();
|
|
||||||
LingeringPotion potion = event.getEntity();
|
|
||||||
World world = potion.getWorld();
|
|
||||||
Cause cause = create(event.getEntity());
|
|
||||||
|
|
||||||
// Fire item interaction event
|
|
||||||
Events.fireToCancel(event, new UseItemEvent(event, cause, world, potion.getItem()));
|
|
||||||
|
|
||||||
// Fire entity spawn event
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
// radius unfortunately doesn't go through with this, so only a single location is tested
|
|
||||||
Events.fireToCancel(event, new SpawnEntityEvent(event, cause, aec.getLocation().add(0.5, 0, 0.5), EntityType.AREA_EFFECT_CLOUD));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,11 @@
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent;
|
||||||
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
import com.sk89q.worldguard.bukkit.event.block.PlaceBlockEvent;
|
||||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
|
||||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
@ -77,7 +76,7 @@ public void onBreakBlock(final BreakBlockEvent event) {
|
|||||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(event.getWorld());
|
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(event.getWorld());
|
||||||
if (!isRegionSupportEnabled(weWorld)) return; // Region support disabled
|
if (!isRegionSupportEnabled(weWorld)) return; // Region support disabled
|
||||||
|
|
||||||
BukkitWorldConfiguration config = getWorldConfig(weWorld);
|
WorldConfiguration config = getWorldConfig(weWorld);
|
||||||
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
|
||||||
|
|
||||||
Block block;
|
Block block;
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.cause.Cause;
|
import com.sk89q.worldguard.bukkit.cause.Cause;
|
||||||
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
import com.sk89q.worldguard.bukkit.event.DelegateEvent;
|
||||||
@ -35,14 +34,15 @@
|
|||||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||||
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
|
import com.sk89q.worldguard.bukkit.internal.WGMetadata;
|
||||||
import com.sk89q.worldguard.protection.DelayedRegionOverlapAssociation;
|
|
||||||
import com.sk89q.worldguard.bukkit.protection.events.DisallowedPVPEvent;
|
import com.sk89q.worldguard.bukkit.protection.events.DisallowedPVPEvent;
|
||||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||||
import com.sk89q.worldguard.bukkit.util.Events;
|
import com.sk89q.worldguard.bukkit.util.Events;
|
||||||
import com.sk89q.worldguard.bukkit.util.InteropUtils;
|
import com.sk89q.worldguard.bukkit.util.InteropUtils;
|
||||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.domains.Association;
|
import com.sk89q.worldguard.domains.Association;
|
||||||
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
import com.sk89q.worldguard.internal.permission.RegionPermissionModel;
|
||||||
|
import com.sk89q.worldguard.protection.DelayedRegionOverlapAssociation;
|
||||||
import com.sk89q.worldguard.protection.association.Associables;
|
import com.sk89q.worldguard.protection.association.Associables;
|
||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
@ -136,7 +136,7 @@ private boolean isWhitelisted(Cause cause, World world, boolean pvp) {
|
|||||||
} else if (rootCause instanceof Player) {
|
} else if (rootCause instanceof Player) {
|
||||||
Player player = (Player) rootCause;
|
Player player = (Player) rootCause;
|
||||||
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
|
||||||
BukkitWorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(world));
|
WorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(world));
|
||||||
|
|
||||||
if (config.fakePlayerBuildOverride && InteropUtils.isFakePlayer(player)) {
|
if (config.fakePlayerBuildOverride && InteropUtils.isFakePlayer(player)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.util.Entities;
|
import com.sk89q.worldguard.bukkit.util.Entities;
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
@ -109,7 +110,7 @@ public void onEntityInteract(EntityInteractEvent event) {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(entity.getWorld()));
|
||||||
|
|
||||||
if (block.getType() == Material.FARMLAND) {
|
if (block.getType() == Material.FARMLAND) {
|
||||||
if (/* entity instanceof Creature && // catch for any entity (not thrown for players) */
|
if (/* entity instanceof Creature && // catch for any entity (not thrown for players) */
|
||||||
@ -121,8 +122,8 @@ public void onEntityInteract(EntityInteractEvent event) {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
BukkitWorldConfiguration wcfg =
|
WorldConfiguration wcfg =
|
||||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||||
|
|
||||||
if (event instanceof PlayerDeathEvent && wcfg.disableDeathMessages) {
|
if (event instanceof PlayerDeathEvent && wcfg.disableDeathMessages) {
|
||||||
((PlayerDeathEvent) event).setDeathMessage("");
|
((PlayerDeathEvent) event).setDeathMessage("");
|
||||||
@ -134,7 +135,7 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
|||||||
DamageCause type = event.getCause();
|
DamageCause type = event.getCause();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||||
|
|
||||||
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
||||||
if (wcfg.antiWolfDumbness && !(type == DamageCause.VOID)) {
|
if (wcfg.antiWolfDumbness && !(type == DamageCause.VOID)) {
|
||||||
@ -201,8 +202,8 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|||||||
Entity attacker = event.getDamager();
|
Entity attacker = event.getDamager();
|
||||||
Entity defender = event.getEntity();
|
Entity defender = event.getEntity();
|
||||||
|
|
||||||
BukkitWorldConfiguration wcfg =
|
WorldConfiguration wcfg =
|
||||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(defender.getWorld()));
|
WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(BukkitAdapter.adapt(defender.getWorld()));
|
||||||
|
|
||||||
if (defender instanceof ItemFrame) {
|
if (defender instanceof ItemFrame) {
|
||||||
if (checkItemFrameProtection(attacker, (ItemFrame) defender)) {
|
if (checkItemFrameProtection(attacker, (ItemFrame) defender)) {
|
||||||
@ -297,7 +298,7 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player) defender;
|
Player player = (Player) defender;
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
@ -366,7 +367,7 @@ public void onEntityDamage(EntityDamageEvent event) {
|
|||||||
DamageCause type = event.getCause();
|
DamageCause type = event.getCause();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(defender.getWorld()));
|
||||||
|
|
||||||
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
if (defender instanceof Wolf && ((Wolf) defender).isTamed()) {
|
||||||
if (wcfg.antiWolfDumbness) {
|
if (wcfg.antiWolfDumbness) {
|
||||||
@ -567,7 +568,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||||
Entity ent = event.getEntity();
|
Entity ent = event.getEntity();
|
||||||
|
|
||||||
if (cfg.activityHaltToggle) {
|
if (cfg.activityHaltToggle) {
|
||||||
@ -614,7 +615,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||||
|
|
||||||
// allow spawning of creatures from plugins
|
// allow spawning of creatures from plugins
|
||||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||||
@ -670,7 +671,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onCreatePortal(EntityCreatePortalEvent event) {
|
public void onCreatePortal(EntityCreatePortalEvent event) {
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||||
|
|
||||||
switch (event.getEntityType()) {
|
switch (event.getEntityType()) {
|
||||||
case ENDER_DRAGON:
|
case ENDER_DRAGON:
|
||||||
@ -682,7 +683,7 @@ public void onCreatePortal(EntityCreatePortalEvent event) {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPigZap(PigZapEvent event) {
|
public void onPigZap(PigZapEvent event) {
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||||
|
|
||||||
if (wcfg.disablePigZap) {
|
if (wcfg.disablePigZap) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -692,7 +693,7 @@ public void onPigZap(PigZapEvent event) {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onCreeperPower(CreeperPowerEvent event) {
|
public void onCreeperPower(CreeperPowerEvent event) {
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getEntity().getWorld()));
|
||||||
|
|
||||||
if (wcfg.disableCreeperPower) {
|
if (wcfg.disableCreeperPower) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -706,7 +707,7 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
|||||||
World world = ent.getWorld();
|
World world = ent.getWorld();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||||
|
|
||||||
if (wcfg.disableHealthRegain) {
|
if (wcfg.disableHealthRegain) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -726,7 +727,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
|||||||
Location location = block.getLocation();
|
Location location = block.getLocation();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(ent.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(ent.getWorld()));
|
||||||
if (ent instanceof Enderman) {
|
if (ent instanceof Enderman) {
|
||||||
if (wcfg.disableEndermanGriefing) {
|
if (wcfg.disableEndermanGriefing) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -768,7 +769,7 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
|||||||
private boolean checkItemFrameProtection(Entity attacker, ItemFrame defender) {
|
private boolean checkItemFrameProtection(Entity attacker, ItemFrame defender) {
|
||||||
World world = attacker.getWorld();
|
World world = attacker.getWorld();
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
// bukkit throws this event when a player attempts to remove an item from a frame
|
// bukkit throws this event when a player attempts to remove an item from a frame
|
||||||
if (!(attacker instanceof Player)) {
|
if (!(attacker instanceof Player)) {
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
@ -74,7 +74,7 @@ public void onHangingBreak(HangingBreakEvent event) {
|
|||||||
Hanging hanging = event.getEntity();
|
Hanging hanging = event.getEntity();
|
||||||
World world = hanging.getWorld();
|
World world = hanging.getWorld();
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||||
|
|
||||||
if (event instanceof HangingBreakByEntityEvent) {
|
if (event instanceof HangingBreakByEntityEvent) {
|
||||||
HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event;
|
HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event;
|
||||||
|
@ -23,12 +23,11 @@
|
|||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
import com.sk89q.worldguard.bukkit.event.player.ProcessPlayerEvent;
|
||||||
import com.sk89q.worldguard.bukkit.util.Events;
|
import com.sk89q.worldguard.bukkit.util.Events;
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
@ -103,8 +102,7 @@ public void registerEvents() {
|
|||||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
BukkitWorldConfiguration wcfg =
|
WorldConfiguration wcfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
||||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
|
||||||
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().getIfPresent(localPlayer);
|
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().getIfPresent(localPlayer);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
GameModeFlag handler = session.getHandler(GameModeFlag.class);
|
GameModeFlag handler = session.getHandler(GameModeFlag.class);
|
||||||
@ -126,7 +124,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
|
|||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(localPlayer.getWorld());
|
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||||
|
|
||||||
if (cfg.activityHaltToggle) {
|
if (cfg.activityHaltToggle) {
|
||||||
player.sendMessage(ChatColor.YELLOW
|
player.sendMessage(ChatColor.YELLOW
|
||||||
@ -161,8 +159,8 @@ public void onPlayerJoin(PlayerJoinEvent event) {
|
|||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
BukkitWorldConfiguration wcfg =
|
WorldConfiguration wcfg =
|
||||||
(BukkitWorldConfiguration) WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(localPlayer.getWorld());
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(localPlayer.getLocation(), localPlayer, Flags.SEND_CHAT))) {
|
if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(localPlayer.getLocation(), localPlayer, Flags.SEND_CHAT))) {
|
||||||
player.sendMessage(ChatColor.RED + "You don't have permission to chat in this region!");
|
player.sendMessage(ChatColor.RED + "You don't have permission to chat in this region!");
|
||||||
@ -228,7 +226,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||||
|
|
||||||
if (wcfg.removeInfiniteStacks
|
if (wcfg.removeInfiniteStacks
|
||||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||||
@ -258,7 +256,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|
|||||||
@Nullable ItemStack item = event.getItem();
|
@Nullable ItemStack item = event.getItem();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||||
|
|
||||||
// Infinite stack removal
|
// Infinite stack removal
|
||||||
if ((type == Material.CHEST
|
if ((type == Material.CHEST
|
||||||
@ -323,7 +321,7 @@ private void handlePhysicalInteract(PlayerInteractEvent event) {
|
|||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||||
|
|
||||||
if (block.getType() == Material.FARMLAND && wcfg.disablePlayerCropTrampling) {
|
if (block.getType() == Material.FARMLAND && wcfg.disablePlayerCropTrampling) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -337,7 +335,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
|||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(localPlayer.getWorld());
|
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
ApplicableRegionSet set =
|
ApplicableRegionSet set =
|
||||||
@ -356,7 +354,7 @@ public void onItemHeldChange(PlayerItemHeldEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(player.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(player.getWorld()));
|
||||||
|
|
||||||
if (wcfg.removeInfiniteStacks
|
if (wcfg.removeInfiniteStacks
|
||||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||||
@ -375,7 +373,7 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(localPlayer.getWorld());
|
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
ApplicableRegionSet set =
|
ApplicableRegionSet set =
|
||||||
@ -425,7 +423,7 @@ public void onPlayerPortal(PlayerPortalEvent event) {
|
|||||||
}
|
}
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(event.getPlayer());
|
LocalPlayer localPlayer = plugin.wrapPlayer(event.getPlayer());
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getTo().getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getTo().getWorld()));
|
||||||
if (!wcfg.regionNetherPortalProtection) return;
|
if (!wcfg.regionNetherPortalProtection) return;
|
||||||
if (event.getCause() != TeleportCause.NETHER_PORTAL) {
|
if (event.getCause() != TeleportCause.NETHER_PORTAL) {
|
||||||
return;
|
return;
|
||||||
@ -469,7 +467,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(localPlayer.getWorld());
|
WorldConfiguration wcfg = cfg.get(localPlayer.getWorld());
|
||||||
|
|
||||||
if (wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
|
if (wcfg.useRegions && !WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, localPlayer.getWorld())) {
|
||||||
ApplicableRegionSet set =
|
ApplicableRegionSet set =
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.util.Locations;
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.session.MoveType;
|
import com.sk89q.worldguard.session.MoveType;
|
||||||
|
import com.sk89q.worldguard.util.Locations;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
@ -69,7 +69,7 @@ public void onVehicleMove(VehicleMoveEvent event) {
|
|||||||
}
|
}
|
||||||
World world = vehicle.getWorld();
|
World world = vehicle.getWorld();
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(world));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(world));
|
||||||
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
// Did we move a block?
|
// Did we move a block?
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.config.ConfigurationManager;
|
import com.sk89q.worldguard.config.ConfigurationManager;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
import com.sk89q.worldguard.protection.association.RegionAssociable;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
@ -59,7 +59,7 @@ public void registerEvents() {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onWeatherChange(WeatherChangeEvent event) {
|
public void onWeatherChange(WeatherChangeEvent event) {
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||||
|
|
||||||
if (event.toWeatherState()) {
|
if (event.toWeatherState()) {
|
||||||
if (wcfg.disableWeather) {
|
if (wcfg.disableWeather) {
|
||||||
@ -75,7 +75,7 @@ public void onWeatherChange(WeatherChangeEvent event) {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onThunderChange(ThunderChangeEvent event) {
|
public void onThunderChange(ThunderChangeEvent event) {
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||||
|
|
||||||
if (event.toThunderState()) {
|
if (event.toThunderState()) {
|
||||||
if (wcfg.disableThunder) {
|
if (wcfg.disableThunder) {
|
||||||
@ -91,7 +91,7 @@ public void onThunderChange(ThunderChangeEvent event) {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onLightningStrike(LightningStrikeEvent event) {
|
public void onLightningStrike(LightningStrikeEvent event) {
|
||||||
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager();
|
||||||
BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld()));
|
||||||
|
|
||||||
if (wcfg.disallowedLightningBlocks.size() > 0) {
|
if (wcfg.disallowedLightningBlocks.size() > 0) {
|
||||||
Material targetId = event.getLightning().getLocation().getBlock().getType();
|
Material targetId = event.getLightning().getLocation().getBlock().getType();
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
package com.sk89q.worldguard.bukkit.listener;
|
package com.sk89q.worldguard.bukkit.listener;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldguard.bukkit.BukkitWorldConfiguration;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
import com.sk89q.worldguard.bukkit.event.entity.SpawnEntityEvent;
|
||||||
|
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -40,7 +40,7 @@ public WorldRulesListener(WorldGuardPlugin plugin) {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onSpawnEntity(final SpawnEntityEvent event) {
|
public void onSpawnEntity(final SpawnEntityEvent event) {
|
||||||
BukkitWorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
WorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getWorld()));
|
||||||
|
|
||||||
// ================================================================
|
// ================================================================
|
||||||
// EXP_DROPS flag
|
// EXP_DROPS flag
|
||||||
|
Loading…
Reference in New Issue
Block a user