forked from LogBlock/LogBlock
@ -8,7 +8,7 @@ public enum Logging {
|
|||||||
PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE,
|
PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE,
|
||||||
NATURALSTRUCTUREGROW, GRASSGROWTH, MYCELIUMSPREAD, VINEGROWTH, MUSHROOMSPREAD,
|
NATURALSTRUCTUREGROW, GRASSGROWTH, MYCELIUMSPREAD, VINEGROWTH, MUSHROOMSPREAD,
|
||||||
WITHER(true), WITHER_SKULL(true), BONEMEALSTRUCTUREGROW,
|
WITHER(true), WITHER_SKULL(true), BONEMEALSTRUCTUREGROW,
|
||||||
WORLDEDIT, TNTMINECARTEXPLOSION(true), ENDERCRYSTALEXPLOSION(true);
|
WORLDEDIT, TNTMINECARTEXPLOSION(true), ENDERCRYSTALEXPLOSION(true), BEDEXPLOSION(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;
|
||||||
|
@ -32,6 +32,7 @@ public class Config {
|
|||||||
public static List<String> autoClearLog;
|
public static List<String> autoClearLog;
|
||||||
public static int autoClearLogDelay;
|
public static int autoClearLogDelay;
|
||||||
public static boolean dumpDeletedLog;
|
public static boolean dumpDeletedLog;
|
||||||
|
public static boolean logBedExplosionsAsPlayerWhoTriggeredThese;
|
||||||
public static boolean logCreeperExplosionsAsPlayerWhoTriggeredThese, logPlayerInfo;
|
public static boolean logCreeperExplosionsAsPlayerWhoTriggeredThese, logPlayerInfo;
|
||||||
public static LogKillsLevel logKillsLevel;
|
public static LogKillsLevel logKillsLevel;
|
||||||
public static Set<Material> dontRollback, replaceAnyway;
|
public static Set<Material> dontRollback, replaceAnyway;
|
||||||
@ -85,6 +86,7 @@ public class Config {
|
|||||||
def.put("clearlog.enableAutoClearLog", false);
|
def.put("clearlog.enableAutoClearLog", false);
|
||||||
def.put("clearlog.auto", Arrays.asList("world \"world\" before 365 days all", "world \"world\" player lavaflow waterflow leavesdecay before 7 days all", "world world_nether before 365 days all", "world world_nether player lavaflow before 7 days all"));
|
def.put("clearlog.auto", Arrays.asList("world \"world\" before 365 days all", "world \"world\" player lavaflow waterflow leavesdecay before 7 days all", "world world_nether before 365 days all", "world world_nether player lavaflow before 7 days all"));
|
||||||
def.put("clearlog.autoClearLogDelay", "6h");
|
def.put("clearlog.autoClearLogDelay", "6h");
|
||||||
|
def.put("logging.logBedExplosionsAsPlayerWhoTriggeredThese", true);
|
||||||
def.put("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
def.put("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
||||||
def.put("logging.logKillsLevel", "PLAYERS");
|
def.put("logging.logKillsLevel", "PLAYERS");
|
||||||
def.put("logging.logEnvironmentalKills", false);
|
def.put("logging.logEnvironmentalKills", false);
|
||||||
@ -155,6 +157,7 @@ public class Config {
|
|||||||
autoClearLog = config.getStringList("clearlog.auto");
|
autoClearLog = config.getStringList("clearlog.auto");
|
||||||
dumpDeletedLog = config.getBoolean("clearlog.dumpDeletedLog", false);
|
dumpDeletedLog = config.getBoolean("clearlog.dumpDeletedLog", false);
|
||||||
autoClearLogDelay = parseTimeSpec(config.getString("clearlog.autoClearLogDelay").split(" "));
|
autoClearLogDelay = parseTimeSpec(config.getString("clearlog.autoClearLogDelay").split(" "));
|
||||||
|
logBedExplosionsAsPlayerWhoTriggeredThese = config.getBoolean("logging.logBedExplosionsAsPlayerWhoTriggeredThese", true);
|
||||||
logCreeperExplosionsAsPlayerWhoTriggeredThese = config.getBoolean("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
logCreeperExplosionsAsPlayerWhoTriggeredThese = config.getBoolean("logging.logCreeperExplosionsAsPlayerWhoTriggeredThese", false);
|
||||||
logPlayerInfo = config.getBoolean("logging.logPlayerInfo", true);
|
logPlayerInfo = config.getBoolean("logging.logPlayerInfo", true);
|
||||||
try {
|
try {
|
||||||
|
@ -3,7 +3,12 @@ package de.diddiz.LogBlock.listeners;
|
|||||||
import de.diddiz.LogBlock.Actor;
|
import de.diddiz.LogBlock.Actor;
|
||||||
import de.diddiz.LogBlock.LogBlock;
|
import de.diddiz.LogBlock.LogBlock;
|
||||||
import de.diddiz.LogBlock.Logging;
|
import de.diddiz.LogBlock.Logging;
|
||||||
|
import de.diddiz.LogBlock.config.Config;
|
||||||
import de.diddiz.LogBlock.config.WorldConfig;
|
import de.diddiz.LogBlock.config.WorldConfig;
|
||||||
|
import de.diddiz.util.BukkitUtils;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -11,15 +16,24 @@ import org.bukkit.entity.*;
|
|||||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockExplodeEvent;
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
||||||
import static de.diddiz.LogBlock.config.Config.logCreeperExplosionsAsPlayerWhoTriggeredThese;
|
import static de.diddiz.LogBlock.config.Config.logCreeperExplosionsAsPlayerWhoTriggeredThese;
|
||||||
import static de.diddiz.util.BukkitUtils.getContainerBlocks;
|
import static de.diddiz.util.BukkitUtils.getContainerBlocks;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ExplosionLogging extends LoggingListener {
|
public class ExplosionLogging extends LoggingListener {
|
||||||
|
|
||||||
|
private UUID lastBedInteractionPlayer;
|
||||||
|
private Location lastBedInteractionLocation;
|
||||||
|
|
||||||
public ExplosionLogging(LogBlock lb) {
|
public ExplosionLogging(LogBlock lb) {
|
||||||
super(lb);
|
super(lb);
|
||||||
}
|
}
|
||||||
@ -111,16 +125,50 @@ public class ExplosionLogging extends LoggingListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasBlock() && BukkitUtils.isBed(event.getClickedBlock().getType())) {
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if (!Config.isLogging(block.getWorld(), Logging.BEDEXPLOSION)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastBedInteractionPlayer = event.getPlayer().getUniqueId();
|
||||||
|
lastBedInteractionLocation = block.getLocation();
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
lastBedInteractionPlayer = null;
|
||||||
|
lastBedInteractionLocation = null;
|
||||||
|
}
|
||||||
|
}.runTask(LogBlock.getInstance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockExplode(BlockExplodeEvent event) {
|
public void onBlockExplode(BlockExplodeEvent event) {
|
||||||
|
Player bedCause = null;
|
||||||
|
if (lastBedInteractionPlayer != null && lastBedInteractionLocation != null) {
|
||||||
|
Location block = event.getBlock().getLocation();
|
||||||
|
if (lastBedInteractionLocation.getWorld() == block.getWorld() && block.distanceSquared(lastBedInteractionLocation) <= 1) {
|
||||||
|
bedCause = Bukkit.getPlayer(lastBedInteractionPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (final Block block : event.blockList()) {
|
for (final Block block : event.blockList()) {
|
||||||
final WorldConfig wcfg = getWorldConfig(block.getLocation().getWorld());
|
final WorldConfig wcfg = getWorldConfig(block.getLocation().getWorld());
|
||||||
|
|
||||||
if (wcfg != null) {
|
if (wcfg != null) {
|
||||||
if (!wcfg.isLogging(Logging.MISCEXPLOSION)) {
|
Actor actor = new Actor("Explosion");
|
||||||
|
if (bedCause != null) {
|
||||||
|
if (!wcfg.isLogging(Logging.BEDEXPLOSION)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Config.logBedExplosionsAsPlayerWhoTriggeredThese) {
|
||||||
|
actor = Actor.actorFromEntity(bedCause);
|
||||||
|
}
|
||||||
|
} else if (!wcfg.isLogging(Logging.MISCEXPLOSION)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Actor actor = new Actor("Explosion");
|
|
||||||
|
|
||||||
final Material type = block.getType();
|
final Material type = block.getType();
|
||||||
if (wcfg.isLogging(Logging.SIGNTEXT) & (type == Material.SIGN || type == Material.WALL_SIGN)) {
|
if (wcfg.isLogging(Logging.SIGNTEXT) & (type == Material.SIGN || type == Material.WALL_SIGN)) {
|
||||||
|
@ -31,12 +31,14 @@ public class BukkitUtils {
|
|||||||
|
|
||||||
private static final Set<Material> cropBlocks;
|
private static final Set<Material> cropBlocks;
|
||||||
private static final Set<Material> containerBlocks;
|
private static final Set<Material> containerBlocks;
|
||||||
|
|
||||||
private static final Set<Material> singleBlockPlants;
|
private static final Set<Material> singleBlockPlants;
|
||||||
private static final Set<Material> doublePlants;
|
private static final Set<Material> doublePlants;
|
||||||
|
|
||||||
private static final Set<Material> nonFluidProofBlocks;
|
private static final Set<Material> nonFluidProofBlocks;
|
||||||
|
|
||||||
|
private static final Set<Material> bedBlocks;
|
||||||
|
|
||||||
private static final Map<EntityType, Material> projectileItems;
|
private static final Map<EntityType, Material> projectileItems;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -203,7 +205,7 @@ public class BukkitUtils {
|
|||||||
projectileItems.put(EntityType.SPLASH_POTION, Material.SPLASH_POTION);
|
projectileItems.put(EntityType.SPLASH_POTION, Material.SPLASH_POTION);
|
||||||
projectileItems.put(EntityType.THROWN_EXP_BOTTLE, Material.EXPERIENCE_BOTTLE);
|
projectileItems.put(EntityType.THROWN_EXP_BOTTLE, Material.EXPERIENCE_BOTTLE);
|
||||||
projectileItems.put(EntityType.WITHER_SKULL, Material.WITHER_SKELETON_SKULL);
|
projectileItems.put(EntityType.WITHER_SKULL, Material.WITHER_SKELETON_SKULL);
|
||||||
|
|
||||||
nonFluidProofBlocks = EnumSet.noneOf(Material.class);
|
nonFluidProofBlocks = EnumSet.noneOf(Material.class);
|
||||||
nonFluidProofBlocks.addAll(singleBlockPlants);
|
nonFluidProofBlocks.addAll(singleBlockPlants);
|
||||||
nonFluidProofBlocks.addAll(doublePlants);
|
nonFluidProofBlocks.addAll(doublePlants);
|
||||||
@ -236,6 +238,23 @@ public class BukkitUtils {
|
|||||||
nonFluidProofBlocks.add(Material.DAYLIGHT_DETECTOR);
|
nonFluidProofBlocks.add(Material.DAYLIGHT_DETECTOR);
|
||||||
nonFluidProofBlocks.addAll(Tag.CARPETS.getValues());
|
nonFluidProofBlocks.addAll(Tag.CARPETS.getValues());
|
||||||
|
|
||||||
|
bedBlocks = EnumSet.noneOf(Material.class);
|
||||||
|
bedBlocks.add(Material.BLACK_BED);
|
||||||
|
bedBlocks.add(Material.BLUE_BED);
|
||||||
|
bedBlocks.add(Material.LIGHT_GRAY_BED);
|
||||||
|
bedBlocks.add(Material.BROWN_BED);
|
||||||
|
bedBlocks.add(Material.CYAN_BED);
|
||||||
|
bedBlocks.add(Material.GRAY_BED);
|
||||||
|
bedBlocks.add(Material.GREEN_BED);
|
||||||
|
bedBlocks.add(Material.LIGHT_BLUE_BED);
|
||||||
|
bedBlocks.add(Material.MAGENTA_BED);
|
||||||
|
bedBlocks.add(Material.LIME_BED);
|
||||||
|
bedBlocks.add(Material.ORANGE_BED);
|
||||||
|
bedBlocks.add(Material.PINK_BED);
|
||||||
|
bedBlocks.add(Material.PURPLE_BED);
|
||||||
|
bedBlocks.add(Material.RED_BED);
|
||||||
|
bedBlocks.add(Material.WHITE_BED);
|
||||||
|
bedBlocks.add(Material.YELLOW_BED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final BlockFace[] relativeBlockFaces = new BlockFace[]{
|
private static final BlockFace[] relativeBlockFaces = new BlockFace[]{
|
||||||
@ -551,4 +570,8 @@ public class BukkitUtils {
|
|||||||
}
|
}
|
||||||
return new String(cap);
|
return new String(cap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBed(Material type) {
|
||||||
|
return bedBlocks.contains(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user