Added null checks to BlockBreak & BlockDamage events to help with mod

compatibility.
This commit is contained in:
GJ 2012-07-03 07:59:15 -04:00
parent bebcc40987
commit 946b5bb006

View File

@ -153,18 +153,23 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if (event instanceof FakeBlockBreakEvent) {
return;
}
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if (PP == null) {
return;
}
Block block = event.getBlock(); Block block = event.getBlock();
ItemStack inHand = player.getItemInHand(); ItemStack inHand = player.getItemInHand();
Config configInstance = Config.getInstance(); Config configInstance = Config.getInstance();
Permissions permInstance = Permissions.getInstance(); Permissions permInstance = Permissions.getInstance();
if (event instanceof FakeBlockBreakEvent) {
return;
}
/* HERBALISM */ /* HERBALISM */
if (BlockChecks.canBeGreenTerra(block)) { if (BlockChecks.canBeGreenTerra(block)) {
/* Green Terra */ /* Green Terra */
@ -264,6 +269,11 @@ public class BlockListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if (PP == null) {
return;
}
ItemStack inHand = player.getItemInHand(); ItemStack inHand = player.getItemInHand();
Block block = event.getBlock(); Block block = event.getBlock();
Material material = block.getType(); Material material = block.getType();