Added tree and mushroom grow logging

This commit is contained in:
DiddiZ
2011-12-10 14:14:36 +01:00
parent 57b5f5e00b
commit 66922120ac
3 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
package de.diddiz.LogBlock;
import java.util.Map;
import org.bukkit.block.BlockState;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.event.world.WorldListener;
public class LBWorldListener extends WorldListener
{
private final Consumer consumer;
private final Map<Integer, WorldConfig> worlds;
LBWorldListener(LogBlock logblock) {
consumer = logblock.getConsumer();
worlds = logblock.getLBConfig().worlds;
}
@Override
public void onStructureGrow(StructureGrowEvent event) {
final WorldConfig wcfg = worlds.get(event.getWorld().getName().hashCode());
if (!event.isCancelled() && wcfg != null) {
final String playerName;
if (event.getPlayer() != null) {
if (!wcfg.isLogging(Logging.BONEMEALSTRUCTUREGROW))
return;
playerName = event.getPlayer().getName();
} else {
if (!wcfg.isLogging(Logging.NATURALSTRUCTUREGROW))
return;
playerName = "NaturalGrow";
}
for (final BlockState state : event.getBlocks())
consumer.queueBlockReplace(playerName, state.getBlock().getState(), state);
}
}
}

View File

@@ -176,6 +176,8 @@ public class LogBlock extends JavaPlugin
pm.registerEvent(Type.ENDERMAN_PICKUP, lbEntityListener, Priority.Monitor, this);
pm.registerEvent(Type.ENDERMAN_PLACE, lbEntityListener, Priority.Monitor, this);
}
if (config.isLogging(Logging.NATURALSTRUCTUREGROW) || config.isLogging(Logging.BONEMEALSTRUCTUREGROW))
pm.registerEvent(Type.STRUCTURE_GROW, new LBWorldListener(this), Priority.Monitor, this);
if (config.logPlayerInfo) {
pm.registerEvent(Type.PLAYER_JOIN, lbPlayerListener, Priority.Monitor, this);
pm.registerEvent(Type.PLAYER_QUIT, lbPlayerListener, Priority.Monitor, this);

View File

@@ -1,7 +1,7 @@
package de.diddiz.LogBlock;
public enum Logging {
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true), GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION, FIRE(true), LEAVESDECAY, LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT, SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT;
BLOCKPLACE(true), BLOCKBREAK(true), SIGNTEXT, TNTEXPLOSION(true), CREEPEREXPLOSION(true), GHASTFIREBALLEXPLOSION(true), ENDERDRAGON(true), MISCEXPLOSION, FIRE(true), LEAVESDECAY, LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT, SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, NATURALSTRUCTUREGROW, BONEMEALSTRUCTUREGROW;
public static int length = Logging.values().length;