forked from LogBlock/LogBlock
Added tree and mushroom grow logging
This commit is contained in:
36
src/de/diddiz/LogBlock/LBWorldListener.java
Normal file
36
src/de/diddiz/LogBlock/LBWorldListener.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -176,6 +176,8 @@ public class LogBlock extends JavaPlugin
|
|||||||
pm.registerEvent(Type.ENDERMAN_PICKUP, lbEntityListener, Priority.Monitor, this);
|
pm.registerEvent(Type.ENDERMAN_PICKUP, lbEntityListener, Priority.Monitor, this);
|
||||||
pm.registerEvent(Type.ENDERMAN_PLACE, 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) {
|
if (config.logPlayerInfo) {
|
||||||
pm.registerEvent(Type.PLAYER_JOIN, lbPlayerListener, Priority.Monitor, this);
|
pm.registerEvent(Type.PLAYER_JOIN, lbPlayerListener, Priority.Monitor, this);
|
||||||
pm.registerEvent(Type.PLAYER_QUIT, lbPlayerListener, Priority.Monitor, this);
|
pm.registerEvent(Type.PLAYER_QUIT, lbPlayerListener, Priority.Monitor, this);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package de.diddiz.LogBlock;
|
package de.diddiz.LogBlock;
|
||||||
|
|
||||||
public enum Logging {
|
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;
|
public static int length = Logging.values().length;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user