Re-added cake eat blocking on left click.

This commit is contained in:
sk89q 2011-04-13 03:11:05 -07:00
parent 08ab359534
commit af5d0c4b0e

View File

@ -57,6 +57,7 @@ public void registerEvents() {
PluginManager pm = plugin.getServer().getPluginManager();
pm.registerEvent(Event.Type.BLOCK_DAMAGE, this, Priority.High, plugin);
pm.registerEvent(Event.Type.BLOCK_BREAK, this, Priority.High, plugin);
pm.registerEvent(Event.Type.BLOCK_FROMTO, this, Priority.Normal, plugin);
pm.registerEvent(Event.Type.BLOCK_IGNITE, this, Priority.High, plugin);
@ -75,6 +76,29 @@ protected WorldConfiguration getWorldConfig(Player player) {
return plugin.getGlobalConfiguration().get(player.getWorld());
}
/**
* Called when a block is damaged.
*/
@Override
public void onBlockDamage(BlockDamageEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
Block blockDamaged = event.getBlock();
// Cake are damaged and not broken when they are eaten, so we must
// handle them a bit separately
if (blockDamaged.getType() == Material.CAKE_BLOCK) {
if (!plugin.getGlobalRegionManager().canBuild(player, blockDamaged)) {
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
event.setCancelled(true);
return;
}
}
}
/**
* Called when a block is broken.
*/