From 7e501eea4f8d0a151f184d174fc6b32b0118b1a3 Mon Sep 17 00:00:00 2001 From: Robin Kupper Date: Sun, 20 Nov 2011 22:48:55 +0100 Subject: [PATCH] Split up explosion logging into tnt, creeper, ghat and misc explosion logging --- src/de/diddiz/LogBlock/LBEntityListener.java | 23 +++++++++++++++----- src/de/diddiz/LogBlock/LogBlock.java | 2 +- src/de/diddiz/LogBlock/Logging.java | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/de/diddiz/LogBlock/LBEntityListener.java b/src/de/diddiz/LogBlock/LBEntityListener.java index b95c85a..130824d 100644 --- a/src/de/diddiz/LogBlock/LBEntityListener.java +++ b/src/de/diddiz/LogBlock/LBEntityListener.java @@ -60,22 +60,33 @@ class LBEntityListener extends EntityListener @Override public void onEntityExplode(EntityExplodeEvent event) { final WorldConfig wcfg = worlds.get(event.getLocation().getWorld().getName().hashCode()); - if (!event.isCancelled() && wcfg != null && wcfg.isLogging(Logging.EXPLOSION)) { + if (!event.isCancelled() && wcfg != null) { final String name; - if (event.getEntity() == null) + if (event.getEntity() == null) { + if (!wcfg.isLogging(Logging.MISCEXPLOSION)) + return; name = "Explosion"; - else if (event.getEntity() instanceof TNTPrimed) + } else if (event.getEntity() instanceof TNTPrimed) { + if (!wcfg.isLogging(Logging.TNTEXPLOSION)) + return; name = "TNT"; - else if (event.getEntity() instanceof Creeper) { + } else if (event.getEntity() instanceof Creeper) { + if (!wcfg.isLogging(Logging.CREEPEREXPLOSION)) + return; if (logCreeperExplosionsAsPlayer) { final Entity target = ((Creeper)event.getEntity()).getTarget(); name = target instanceof Player ? ((Player)target).getName() : "Creeper"; } else name = "Creeper"; - } else if (event.getEntity() instanceof Fireball) + } else if (event.getEntity() instanceof Fireball) { + if (!wcfg.isLogging(Logging.GHASTFIREBALLEXPLOSION)) + return; name = "Ghast"; - else + } else { + if (!wcfg.isLogging(Logging.MISCEXPLOSION)) + return; name = "Explosion"; + } for (final Block block : event.blockList()) { final int type = block.getTypeId(); if (wcfg.isLogging(Logging.SIGNTEXT) & (type == 63 || type == 68)) diff --git a/src/de/diddiz/LogBlock/LogBlock.java b/src/de/diddiz/LogBlock/LogBlock.java index 81aaec2..85ed29b 100644 --- a/src/de/diddiz/LogBlock/LogBlock.java +++ b/src/de/diddiz/LogBlock/LogBlock.java @@ -157,7 +157,7 @@ public class LogBlock extends JavaPlugin pm.registerEvent(Type.BLOCK_FORM, lbBlockListener, Priority.Monitor, this); if (config.isLogging(Logging.SNOWFADE)) pm.registerEvent(Type.BLOCK_FADE, lbBlockListener, Priority.Monitor, this); - if (config.isLogging(Logging.EXPLOSION)) + if (config.isLogging(Logging.CREEPEREXPLOSION) || config.isLogging(Logging.TNTEXPLOSION) || config.isLogging(Logging.GHASTFIREBALLEXPLOSION) || config.isLogging(Logging.MISCEXPLOSION)) pm.registerEvent(Type.ENTITY_EXPLODE, lbEntityListener, Priority.Monitor, this); if (config.isLogging(Logging.LEAVESDECAY)) pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Priority.Monitor, this); diff --git a/src/de/diddiz/LogBlock/Logging.java b/src/de/diddiz/LogBlock/Logging.java index 483d706..449844b 100644 --- a/src/de/diddiz/LogBlock/Logging.java +++ b/src/de/diddiz/LogBlock/Logging.java @@ -1,7 +1,7 @@ package de.diddiz.LogBlock; public enum Logging { - BLOCKPLACE, BLOCKBREAK, SIGNTEXT, EXPLOSION, FIRE, LEAVESDECAY, LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT, SWITCHINTERACT, CAKEEAT, ENDERMEN; + BLOCKPLACE, BLOCKBREAK, SIGNTEXT, TNTEXPLOSION, CREEPEREXPLOSION, GHASTFIREBALLEXPLOSION, MISCEXPLOSION, FIRE, LEAVESDECAY, LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT, SWITCHINTERACT, CAKEEAT, ENDERMEN; public static int length = Logging.values().length; }