forked from LogBlock/LogBlock
Merge pull request #377 from socram8888/master
Added logging of Minecarts with TNT
This commit is contained in:
@@ -7,7 +7,7 @@ public enum Logging
|
|||||||
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
||||||
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, NATURALSTRUCTUREGROW,
|
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, NATURALSTRUCTUREGROW,
|
||||||
WITHER(true), WITHER_SKULL(true),
|
WITHER(true), WITHER_SKULL(true),
|
||||||
BONEMEALSTRUCTUREGROW, WORLDEDIT;
|
BONEMEALSTRUCTUREGROW, WORLDEDIT, TNTMINECARTEXPLOSION(true);
|
||||||
public static final int length = Logging.values().length;
|
public static final int length = Logging.values().length;
|
||||||
private final boolean defaultEnabled;
|
private final boolean defaultEnabled;
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@ import org.bukkit.entity.EnderDragon;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
import org.bukkit.entity.Ghast;
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.entity.Wither;
|
import org.bukkit.entity.Wither;
|
||||||
@@ -31,25 +32,29 @@ public class ExplosionLogging extends LoggingListener
|
|||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
final WorldConfig wcfg = getWorldConfig(event.getLocation().getWorld());
|
final WorldConfig wcfg = getWorldConfig(event.getLocation().getWorld());
|
||||||
if (wcfg != null) {
|
if (wcfg != null) {
|
||||||
String name = "Unknown";
|
String name = "Explosion";
|
||||||
if (event.getEntity() == null) {
|
Entity source = event.getEntity();
|
||||||
|
if (source == null) {
|
||||||
if (!wcfg.isLogging(Logging.MISCEXPLOSION))
|
if (!wcfg.isLogging(Logging.MISCEXPLOSION))
|
||||||
return;
|
return;
|
||||||
name = "Explosion";
|
} else if (source instanceof TNTPrimed) {
|
||||||
} else if (event.getEntity() instanceof TNTPrimed) {
|
|
||||||
if (!wcfg.isLogging(Logging.TNTEXPLOSION))
|
if (!wcfg.isLogging(Logging.TNTEXPLOSION))
|
||||||
return;
|
return;
|
||||||
name = "TNT";
|
name = "TNT";
|
||||||
} else if (event.getEntity() instanceof Creeper) {
|
} else if (source instanceof ExplosiveMinecart) {
|
||||||
|
if (!wcfg.isLogging(Logging.TNTMINECARTEXPLOSION))
|
||||||
|
return;
|
||||||
|
name = "TNTMinecart";
|
||||||
|
} else if (source instanceof Creeper) {
|
||||||
if (!wcfg.isLogging(Logging.CREEPEREXPLOSION))
|
if (!wcfg.isLogging(Logging.CREEPEREXPLOSION))
|
||||||
return;
|
return;
|
||||||
if (logCreeperExplosionsAsPlayerWhoTriggeredThese) {
|
if (logCreeperExplosionsAsPlayerWhoTriggeredThese) {
|
||||||
final Entity target = ((Creeper)event.getEntity()).getTarget();
|
final Entity target = ((Creeper) source).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 (source instanceof Fireball) {
|
||||||
Fireball fireball = (Fireball) event.getEntity();
|
Fireball fireball = (Fireball) source;
|
||||||
Entity shooter = fireball.getShooter();
|
Entity shooter = fireball.getShooter();
|
||||||
if (shooter == null) {
|
if (shooter == null) {
|
||||||
return;
|
return;
|
||||||
@@ -65,22 +70,21 @@ public class ExplosionLogging extends LoggingListener
|
|||||||
}
|
}
|
||||||
name = "Wither";
|
name = "Wither";
|
||||||
}
|
}
|
||||||
} else if (event.getEntity() instanceof EnderDragon) {
|
} else if (source instanceof EnderDragon) {
|
||||||
if (!wcfg.isLogging(Logging.ENDERDRAGON))
|
if (!wcfg.isLogging(Logging.ENDERDRAGON))
|
||||||
return;
|
return;
|
||||||
name = "EnderDragon";
|
name = "EnderDragon";
|
||||||
} else if (event.getEntity() instanceof Wither) {
|
} else if (source instanceof Wither) {
|
||||||
if(!wcfg.isLogging(Logging.WITHER))
|
if(!wcfg.isLogging(Logging.WITHER))
|
||||||
return;
|
return;
|
||||||
name = "Wither";
|
name = "Wither";
|
||||||
} else if (event.getEntity() instanceof WitherSkull) {
|
} else if (source instanceof WitherSkull) {
|
||||||
if(!wcfg.isLogging(Logging.WITHER_SKULL))
|
if(!wcfg.isLogging(Logging.WITHER_SKULL))
|
||||||
return;
|
return;
|
||||||
name = "WitherSkull";
|
name = "WitherSkull";
|
||||||
} else {
|
} else {
|
||||||
if (!wcfg.isLogging(Logging.MISCEXPLOSION))
|
if (!wcfg.isLogging(Logging.MISCEXPLOSION))
|
||||||
return;
|
return;
|
||||||
name = "Explosion";
|
|
||||||
}
|
}
|
||||||
for (final Block block : event.blockList()) {
|
for (final Block block : event.blockList()) {
|
||||||
final int type = block.getTypeId();
|
final int type = block.getTypeId();
|
||||||
|
Reference in New Issue
Block a user