Protect items in item frames in protected regions.

This commit is contained in:
wizjany 2013-12-09 08:39:55 -05:00
parent 6b16ed79b3
commit bbd1a0ef10

View File

@ -33,6 +33,7 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@ -235,6 +236,19 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}
}
}
if (defender instanceof ItemFrame && wcfg.useRegions) {
// bukkit throws this event when a player attempts to remove an item from a frame
World world = player.getWorld();
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !mgr.getApplicableRegions(defender.getLocation())
.canBuild(plugin.wrapPlayer(player))) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
event.setCancelled(true);
return;
}
}
}
if (defender instanceof Player) {