Split up explosion logging into tnt, creeper, ghat and misc explosion

logging
This commit is contained in:
Robin Kupper
2011-11-20 22:48:55 +01:00
parent 056fb35c1e
commit 7e501eea4f
3 changed files with 19 additions and 8 deletions

View File

@@ -60,22 +60,33 @@ class LBEntityListener extends EntityListener
@Override @Override
public void onEntityExplode(EntityExplodeEvent event) { public void onEntityExplode(EntityExplodeEvent event) {
final WorldConfig wcfg = worlds.get(event.getLocation().getWorld().getName().hashCode()); 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; final String name;
if (event.getEntity() == null) if (event.getEntity() == null) {
if (!wcfg.isLogging(Logging.MISCEXPLOSION))
return;
name = "Explosion"; name = "Explosion";
else if (event.getEntity() instanceof TNTPrimed) } else if (event.getEntity() instanceof TNTPrimed) {
if (!wcfg.isLogging(Logging.TNTEXPLOSION))
return;
name = "TNT"; name = "TNT";
else if (event.getEntity() instanceof Creeper) { } else if (event.getEntity() instanceof Creeper) {
if (!wcfg.isLogging(Logging.CREEPEREXPLOSION))
return;
if (logCreeperExplosionsAsPlayer) { if (logCreeperExplosionsAsPlayer) {
final Entity target = ((Creeper)event.getEntity()).getTarget(); final Entity target = ((Creeper)event.getEntity()).getTarget();
name = target instanceof Player ? ((Player)target).getName() : "Creeper"; name = target instanceof Player ? ((Player)target).getName() : "Creeper";
} else } else
name = "Creeper"; name = "Creeper";
} else if (event.getEntity() instanceof Fireball) } else if (event.getEntity() instanceof Fireball) {
if (!wcfg.isLogging(Logging.GHASTFIREBALLEXPLOSION))
return;
name = "Ghast"; name = "Ghast";
else } else {
if (!wcfg.isLogging(Logging.MISCEXPLOSION))
return;
name = "Explosion"; name = "Explosion";
}
for (final Block block : event.blockList()) { for (final Block block : event.blockList()) {
final int type = block.getTypeId(); final int type = block.getTypeId();
if (wcfg.isLogging(Logging.SIGNTEXT) & (type == 63 || type == 68)) if (wcfg.isLogging(Logging.SIGNTEXT) & (type == 63 || type == 68))

View File

@@ -157,7 +157,7 @@ public class LogBlock extends JavaPlugin
pm.registerEvent(Type.BLOCK_FORM, lbBlockListener, Priority.Monitor, this); pm.registerEvent(Type.BLOCK_FORM, lbBlockListener, Priority.Monitor, this);
if (config.isLogging(Logging.SNOWFADE)) if (config.isLogging(Logging.SNOWFADE))
pm.registerEvent(Type.BLOCK_FADE, lbBlockListener, Priority.Monitor, this); 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); pm.registerEvent(Type.ENTITY_EXPLODE, lbEntityListener, Priority.Monitor, this);
if (config.isLogging(Logging.LEAVESDECAY)) if (config.isLogging(Logging.LEAVESDECAY))
pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Priority.Monitor, this); pm.registerEvent(Type.LEAVES_DECAY, lbBlockListener, Priority.Monitor, this);

View File

@@ -1,7 +1,7 @@
package de.diddiz.LogBlock; package de.diddiz.LogBlock;
public enum Logging { 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; public static int length = Logging.values().length;
} }