Modularize potion blocking via the configuration.

This commit is contained in:
sk89q 2014-07-24 16:08:18 -07:00
parent 1a1acae588
commit b4880ae982
17 changed files with 392 additions and 110 deletions

View File

@ -27,8 +27,9 @@
import com.sk89q.worldguard.internal.Blocks;
import com.sk89q.worldguard.internal.Events;
import com.sk89q.worldguard.internal.cause.Causes;
import com.sk89q.worldguard.internal.event.Action;
import com.sk89q.worldguard.internal.event.Interaction;
import com.sk89q.worldguard.internal.event.BlockInteractEvent;
import com.sk89q.worldguard.internal.event.ItemInteractEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
@ -61,8 +62,6 @@
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
@ -121,7 +120,7 @@ public void onBlockDamage(BlockDamageEvent event) {
// Cake are damaged and not broken when they are eaten, so we must
// handle them a bit separately
if (target.getType() == Material.CAKE_BLOCK) {
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Action.INTERACT, target));
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Interaction.INTERACT, target));
}
}
@ -142,12 +141,12 @@ public void onBlockBreak(BlockBreakEvent event) {
}
}
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Action.BREAK, target));
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Interaction.BREAK, target));
if (wcfg.checkAttached) {
Block attachedTo = Blocks.getAttachesTo(target);
if (attachedTo != null) {
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Action.BREAK, attachedTo));
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Interaction.BREAK, attachedTo));
}
}
}
@ -476,12 +475,12 @@ public void onBlockPlace(BlockPlaceEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(world);
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Action.PLACE, target));
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Interaction.PLACE, target));
if (wcfg.checkAttached) {
Block attachedTo = Blocks.getAttachesTo(event.getBlockPlaced());
if (attachedTo != null) {
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Action.BREAK, attachedTo));
Events.fireToCancel(event, new BlockInteractEvent(event, Causes.create(event.getPlayer()), Interaction.BREAK, attachedTo));
}
}
@ -841,26 +840,9 @@ public void onBlockPistonRetract(BlockPistonRetractEvent event) {
}
}
/*
* Called when a block is damaged.
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
if (wcfg.blockPotions.size() > 0) {
ItemStack item = event.getItem();
if (item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
for (PotionEffect effect : potion.getEffects()) {
if (potion.isSplash() && wcfg.blockPotions.contains(effect.getType())) {
event.setCancelled(true);
return;
}
}
}
}
Events.fireToCancel(event, new ItemInteractEvent(event, Causes.create(event.getBlock()), Interaction.INTERACT, event.getBlock().getWorld(), event.getItem()));
}
/*

View File

@ -19,10 +19,19 @@
package com.sk89q.worldguard.bukkit;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
import java.util.Set;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
import com.sk89q.worldguard.internal.Events;
import com.sk89q.worldguard.internal.cause.Causes;
import com.sk89q.worldguard.internal.event.Interaction;
import com.sk89q.worldguard.internal.event.ItemInteractEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.GlobalRegionManager;
import com.sk89q.worldguard.protection.events.DisallowedPVPEvent;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
@ -70,18 +79,11 @@
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.projectiles.ProjectileSource;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.GlobalRegionManager;
import com.sk89q.worldguard.protection.events.DisallowedPVPEvent;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import java.util.Set;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
/**
* Listener for entity related events.
@ -928,25 +930,12 @@ public void onFoodLevelChange(FoodLevelChangeEvent event) {
public void onPotionSplash(PotionSplashEvent event) {
Entity entity = event.getEntity();
ThrownPotion potion = event.getPotion();
World world = entity.getWorld();
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(entity.getWorld());
WorldConfiguration wcfg = cfg.get(world);
if (wcfg.blockPotionsAlways && wcfg.blockPotions.size() > 0) {
boolean blocked = false;
for (PotionEffect effect : potion.getEffects()) {
if (wcfg.blockPotions.contains(effect.getType())) {
blocked = true;
break;
}
}
if (blocked) {
event.setCancelled(true);
return;
}
}
Events.fireToCancel(event, new ItemInteractEvent(event, Causes.create(potion.getShooter()), Interaction.INTERACT, world, potion.getItem()));
GlobalRegionManager regionMan = plugin.getGlobalRegionManager();

View File

@ -31,6 +31,10 @@
import com.sk89q.worldguard.blacklist.events.ItemDropBlacklistEvent;
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
import com.sk89q.worldguard.bukkit.FlagStateManager.PlayerFlagState;
import com.sk89q.worldguard.internal.Events;
import com.sk89q.worldguard.internal.cause.Causes;
import com.sk89q.worldguard.internal.event.Interaction;
import com.sk89q.worldguard.internal.event.ItemInteractEvent;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
@ -39,7 +43,6 @@
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@ -72,8 +75,6 @@
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
import java.util.Iterator;
import java.util.Set;
@ -497,6 +498,7 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
World world = player.getWorld();
ItemStack item = event.getItem();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
handleBlockRightClick(event);
@ -523,38 +525,8 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}
}
if (wcfg.blockPotions.size() > 0) {
ItemStack item = event.getItem();
if (item != null && item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
PotionEffect blockedEffect = null;
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
for (PotionEffect effect : potion.getEffects()) {
if (wcfg.blockPotions.contains(effect.getType())) {
blockedEffect = effect;
break;
}
}
if (blockedEffect != null) {
if (plugin.hasPermission(player, "worldguard.override.potions")) {
if (potion.isSplash() && wcfg.blockPotionsAlways) {
player.sendMessage(ChatColor.RED + "Sorry, potions with " +
blockedEffect.getType().getName() + " can't be thrown, " +
"even if you have a permission to bypass it, " +
"due to limitations (and because overly-reliable potion blocking is on).");
event.setUseItemInHand(Result.DENY);
return;
}
} else {
player.sendMessage(ChatColor.RED + "Sorry, potions with "
+ blockedEffect.getType().getName() + " are presently disabled.");
event.setUseItemInHand(Result.DENY);
return;
}
}
}
if (item != null) {
Events.fireItemEventToCancel(event, new ItemInteractEvent(event, Causes.create(event.getPlayer()), Interaction.INTERACT, world, item));
}
}

View File

@ -34,6 +34,7 @@
import com.sk89q.worldguard.bukkit.commands.ProtectionCommands;
import com.sk89q.worldguard.bukkit.commands.ToggleCommands;
import com.sk89q.worldguard.internal.listener.BlacklistListener;
import com.sk89q.worldguard.internal.listener.BlockedPotionsListener;
import com.sk89q.worldguard.internal.listener.ChestProtectionListener;
import com.sk89q.worldguard.internal.listener.RegionProtectionListener;
import com.sk89q.worldguard.protection.GlobalRegionManager;
@ -189,6 +190,7 @@ public void run() {
(new BlacklistListener(this)).registerEvents();
(new ChestProtectionListener(this)).registerEvents();
(new RegionProtectionListener(this)).registerEvents();
(new BlockedPotionsListener(this)).registerEvents();
configuration.updateCommandBookGodMode();

View File

@ -22,6 +22,8 @@
import org.bukkit.Bukkit;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Result;
import org.bukkit.event.player.PlayerInteractEvent;
/**
* Utility methods to deal with events.
@ -52,4 +54,23 @@ public static <T extends Event & Cancellable> boolean fireToCancel(Cancellable o
return false;
}
/**
* Fire the {@code eventToFire} if {@code original}
* and cancel the original if the fired event is cancelled.
*
* @param original the original event to potentially cancel
* @param eventToFire the event to fire to consider cancelling the original event
* @param <T> an event that can be fired and is cancellable
* @return true if the event was fired and it caused the original event to be cancelled
*/
public static <T extends Event & Cancellable> boolean fireItemEventToCancel(PlayerInteractEvent original, T eventToFire) {
Bukkit.getServer().getPluginManager().callEvent(eventToFire);
if (eventToFire.isCancelled()) {
original.setUseItemInHand(Result.DENY);
return true;
}
return false;
}
}

View File

@ -0,0 +1,48 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.internal.cause;
import org.bukkit.block.Block;
/**
* A cause that is a block.
*/
import static com.google.common.base.Preconditions.checkNotNull;
public class BlockCause implements Cause<Block> {
private final Block block;
/**
* Create a new instance.
*
* @param block the block
*/
public BlockCause(Block block) {
checkNotNull(block);
this.block = block;
}
@Override
public Block get() {
return block;
}
}

View File

@ -19,6 +19,8 @@
package com.sk89q.worldguard.internal.cause;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import javax.annotation.Nullable;
@ -50,6 +52,25 @@ public static Player getInvolvedPlayer(List<? extends Cause<?>> causes) {
return null;
}
/**
* Test whether the list of causes may indicate that a player was part of
* the cause, directly or indirectly.
*
* <p>An indirect cause would be a dispenser, for example.</p>
*
* @param causes a list of cuases
* @return true if the event involved a player
*/
public static boolean mayInvolvePlayer(List<? extends Cause<?>> causes) {
for (Cause<?> cause : causes) {
if (cause instanceof PlayerCause || cause instanceof BlockCause) {
return true; // This needs to be made smarter later
}
}
return false;
}
/**
* Create a list of causes from a list of objects representing causes.
*
@ -61,6 +82,10 @@ public static List<? extends Cause<?>> create(Object ... cause) {
for (Object o : cause) {
if (o instanceof Player) {
causes.add(new PlayerCause((Player) o));
} else if (o instanceof Block) {
causes.add(new BlockCause((Block) o));
} else if (o instanceof Entity) {
causes.add(new EntityCause((Entity) o));
} else {
causes.add(new UnknownCause(o));
}

View File

@ -0,0 +1,48 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.internal.cause;
import org.bukkit.entity.Entity;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* A cause that is an entity.
*/
public class EntityCause implements Cause<Entity> {
private final Entity entity;
/**
* Create a new instance.
*
* @param entity the entity
*/
public EntityCause(Entity entity) {
checkNotNull(entity);
this.entity = entity;
}
@Override
public Entity get() {
return entity;
}
}

View File

@ -32,7 +32,7 @@ abstract class AbstractInteractEvent extends Event implements Cancellable {
private final Event originalEvent;
private final List<? extends Cause<?>> causes;
private final Action action;
private final Interaction interaction;
private boolean cancelled;
/**
@ -40,15 +40,15 @@ abstract class AbstractInteractEvent extends Event implements Cancellable {
*
* @param originalEvent the original event
* @param causes a list of causes, where the originating causes are at the beginning
* @param action the action that is being taken
* @param interaction the action that is being taken
*/
protected AbstractInteractEvent(Event originalEvent, List<? extends Cause<?>> causes, Action action) {
protected AbstractInteractEvent(Event originalEvent, List<? extends Cause<?>> causes, Interaction interaction) {
checkNotNull(originalEvent);
checkNotNull(causes);
checkNotNull(action);
checkNotNull(interaction);
this.originalEvent = originalEvent;
this.causes = causes;
this.action = action;
this.interaction = interaction;
}
/**
@ -75,8 +75,8 @@ public List<? extends Cause<?>> getCauses() {
*
* @return the action
*/
public Action getAction() {
return action;
public Interaction getInteraction() {
return interaction;
}
@Override

View File

@ -41,11 +41,11 @@ public class BlockInteractEvent extends AbstractInteractEvent {
*
* @param originalEvent the original event
* @param causes a list of causes, where the originating causes are at the beginning
* @param action the action that is being taken
* @param interaction the action that is being taken
* @param target the target block being affected
*/
public BlockInteractEvent(Event originalEvent, List<? extends Cause<?>> causes, Action action, Block target) {
super(originalEvent, causes, action);
public BlockInteractEvent(Event originalEvent, List<? extends Cause<?>> causes, Interaction interaction, Block target) {
super(originalEvent, causes, interaction);
checkNotNull(target);
this.target = target;
}

View File

@ -41,11 +41,11 @@ public class EntityInteractEvent extends AbstractInteractEvent {
*
* @param originalEvent the original event
* @param causes a list of causes, where the originating causes are at the beginning
* @param action the action that is being taken
* @param interaction the action that is being taken
* @param target the target entity being affected
*/
public EntityInteractEvent(Event originalEvent, List<? extends Cause<?>> causes, Action action, Entity target) {
super(originalEvent, causes, action);
public EntityInteractEvent(Event originalEvent, List<? extends Cause<?>> causes, Interaction interaction, Entity target) {
super(originalEvent, causes, interaction);
checkNotNull(target);
this.target = target;
}

View File

@ -22,7 +22,7 @@
/**
* Represents a possible act upon an object.
*/
public enum Action {
public enum Interaction {
PLACE,
BREAK,

View File

@ -0,0 +1,85 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.internal.event;
import com.sk89q.worldguard.internal.cause.Cause;
import org.bukkit.World;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Fired when an item is interacted with.
*/
public class ItemInteractEvent extends AbstractInteractEvent {
private static final HandlerList handlers = new HandlerList();
private final World world;
private final ItemStack itemStack;
/**
* Create a new instance.
*
* @param originalEvent the original event
* @param causes a list of causes, where the originating causes are at the beginning
* @param interaction the action that is being taken
* @param world the world
* @param itemStack the item
*/
public ItemInteractEvent(Event originalEvent, List<? extends Cause<?>> causes, Interaction interaction, World world, ItemStack itemStack) {
super(originalEvent, causes, interaction);
checkNotNull(world);
checkNotNull(itemStack);
this.world = world;
this.itemStack = itemStack;
}
/**
* Get the world.
*
* @return the world
*/
public World getWorld() {
return world;
}
/**
* Get the item stack.
*
* @return the item stack
*/
public ItemStack getItemStack() {
return itemStack;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -58,7 +58,7 @@ public void handleBlockInteract(BlockInteractEvent event) {
}
if (player != null) {
switch (event.getAction()) {
switch (event.getInteraction()) {
case BREAK:
if (!wcfg.getBlacklist().check(
new BlockBreakBlacklistEvent(getPlugin().wrapPlayer(player), toVector(target), target.getTypeId()), false, false)) {

View File

@ -0,0 +1,110 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.internal.listener;
import com.sk89q.worldguard.bukkit.BukkitUtil;
import com.sk89q.worldguard.bukkit.ConfigurationManager;
import com.sk89q.worldguard.bukkit.WorldConfiguration;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.internal.cause.Causes;
import com.sk89q.worldguard.internal.event.ItemInteractEvent;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
/**
* Handles blocked potions.
*/
public class BlockedPotionsListener extends AbstractListener {
/**
* Construct the listener.
*
* @param plugin an instance of WorldGuardPlugin
*/
public BlockedPotionsListener(WorldGuardPlugin plugin) {
super(plugin);
}
@EventHandler
public void onItemInteract(ItemInteractEvent event) {
// We only care about player caused events
if (!Causes.mayInvolvePlayer(event.getCauses())) {
return;
}
ConfigurationManager cfg = getPlugin().getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getWorld());
ItemStack item = event.getItemStack();
// Only block potions via PotionSplashEvent if "over reliable potion
// blocking" is enabled
if (!wcfg.blockPotionsAlways && event.getOriginalEvent() instanceof PotionSplashEvent) {
return;
}
// We only care about portions
if (item.getType() != Material.POTION || BukkitUtil.isWaterPotion(item)) {
return;
}
if (!wcfg.blockPotions.isEmpty()) {
PotionEffect blockedEffect = null;
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
// Find the first blocked effect
for (PotionEffect effect : potion.getEffects()) {
if (wcfg.blockPotions.contains(effect.getType())) {
blockedEffect = effect;
break;
}
}
if (blockedEffect != null) {
Player player = Causes.getInvolvedPlayer(event.getCauses());
if (player != null) {
if (getPlugin().hasPermission(player, "worldguard.override.potions")) {
if (potion.isSplash() && wcfg.blockPotionsAlways) {
player.sendMessage(ChatColor.RED + "Sorry, potions with " +
blockedEffect.getType().getName() + " can't be thrown, " +
"even if you have a permission to bypass it, " +
"due to limitations (and because overly-reliable potion blocking is on).");
event.setCancelled(true);
}
} else {
player.sendMessage(ChatColor.RED + "Sorry, potions with "
+ blockedEffect.getType().getName() + " are presently disabled.");
event.setCancelled(true);
}
} else {
event.setCancelled(true);
}
}
}
}
}

View File

@ -22,7 +22,7 @@
import com.sk89q.worldguard.bukkit.WorldConfiguration;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.internal.cause.Causes;
import com.sk89q.worldguard.internal.event.Action;
import com.sk89q.worldguard.internal.event.Interaction;
import com.sk89q.worldguard.internal.event.BlockInteractEvent;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
@ -61,7 +61,7 @@ public void handleBlockInteract(BlockInteractEvent event) {
return;
}
if (event.getAction() == Action.PLACE) {
if (event.getInteraction() == Interaction.PLACE) {
if (wcfg.getChestProtection().isChest(target.getTypeId())) {
if (wcfg.isAdjacentChestProtected(target, player)) {
player.sendMessage(ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for.");

View File

@ -21,7 +21,7 @@
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.internal.cause.Causes;
import com.sk89q.worldguard.internal.event.Action;
import com.sk89q.worldguard.internal.event.Interaction;
import com.sk89q.worldguard.internal.event.BlockInteractEvent;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
@ -59,7 +59,7 @@ public void handleBlockInteract(BlockInteractEvent event) {
return;
}
if (event.getAction() != Action.INTERACT) {
if (event.getInteraction() != Interaction.INTERACT) {
if (!getPlugin().getGlobalRegionManager().canConstruct(player, target)) {
tellErrorMessage(player, target);
event.setCancelled(true);