1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-14 02:24:16 +02:00

Added null check to /break

This commit is contained in:
snowleo
2011-12-04 22:06:03 +01:00
parent d9c773270b
commit ec3586c08c

View File

@@ -18,13 +18,17 @@ public class Commandbreak extends EssentialsCommand
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{ {
final Block block = user.getTargetBlock(null, 20); final Block block = user.getTargetBlock(null, 20);
if (block == null)
{
throw new NoChargeException();
}
if (block.getType() == Material.AIR) if (block.getType() == Material.AIR)
{ {
throw new NoChargeException(); throw new NoChargeException();
} }
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock")) if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
{ {
throw new NoChargeException(); throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
} }
final BlockBreakEvent event = new BlockBreakEvent(block, user); final BlockBreakEvent event = new BlockBreakEvent(block, user);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);