mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-10-05 01:57:28 +02:00
Re-added cake eat blocking on left click.
This commit is contained in:
parent
08ab359534
commit
af5d0c4b0e
@ -57,6 +57,7 @@ public void registerEvents() {
|
|||||||
|
|
||||||
PluginManager pm = plugin.getServer().getPluginManager();
|
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_BREAK, this, Priority.High, plugin);
|
||||||
pm.registerEvent(Event.Type.BLOCK_FROMTO, this, Priority.Normal, plugin);
|
pm.registerEvent(Event.Type.BLOCK_FROMTO, this, Priority.Normal, plugin);
|
||||||
pm.registerEvent(Event.Type.BLOCK_IGNITE, this, Priority.High, 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());
|
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.
|
* Called when a block is broken.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user