Added logging for various blocks spreading

This commit is contained in:
Dark Arc
2013-05-17 18:34:57 -04:00
parent b8950857c4
commit cc86c4e0e1
3 changed files with 56 additions and 1 deletions

View File

@@ -164,6 +164,8 @@ public class LogBlock extends JavaPlugin
pm.registerEvents(new WitherLogging(this), this); pm.registerEvents(new WitherLogging(this), this);
if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW)) if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW))
pm.registerEvents(new StructureGrowLogging(this), this); pm.registerEvents(new StructureGrowLogging(this), this);
if (isLogging(Logging.GRASSGROWTH) || isLogging(Logging.MYCELIUMSPREAD) || isLogging(Logging.VINEGROWTH) || isLogging(Logging.MUSHROOMSPREAD))
pm.registerEvents(new BlockSpreadLogging(this), this);
if (logPlayerInfo) if (logPlayerInfo)
pm.registerEvents(new PlayerInfoLogging(this), this); pm.registerEvents(new PlayerInfoLogging(this), this);
} }

View File

@@ -7,7 +7,8 @@ public enum Logging
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT, LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, COMPARATORINTERACT, SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, COMPARATORINTERACT,
PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE, PRESUREPLATEINTERACT, TRIPWIREINTERACT, CREATURECROPTRAMPLE, CROPTRAMPLE,
NATURALSTRUCTUREGROW, WITHER(true), WITHER_SKULL(true),BONEMEALSTRUCTUREGROW, NATURALSTRUCTUREGROW, GRASSGROWTH, MYCELIUMSPREAD, VINEGROWTH, MUSHROOMSPREAD,
WITHER(true), WITHER_SKULL(true), BONEMEALSTRUCTUREGROW,
WORLDEDIT, TNTMINECARTEXPLOSION(true); WORLDEDIT, TNTMINECARTEXPLOSION(true);
public static final int length = Logging.values().length; public static final int length = Logging.values().length;

View File

@@ -0,0 +1,52 @@
package de.diddiz.LogBlock.listeners;
import de.diddiz.LogBlock.LogBlock;
import de.diddiz.LogBlock.Logging;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockSpreadEvent;
import static de.diddiz.LogBlock.config.Config.isLogging;
public class BlockSpreadLogging extends LoggingListener
{
public BlockSpreadLogging(LogBlock lb) {
super(lb);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent event) {
String name;
World world = event.getBlock().getWorld();
Material type = event.getSource().getType();
switch (type) {
case GRASS:
if (!isLogging(world, Logging.GRASSGROWTH)) return;
name = "GrassGrowth";
break;
case MYCEL:
if (!isLogging(world, Logging.MYCELIUMSPREAD)) return;
name = "MyceliumSpread";
break;
case VINE:
if (!isLogging(world, Logging.VINEGROWTH)) return;
name = "VineGrowth";
break;
case RED_MUSHROOM:
case BROWN_MUSHROOM:
if (!isLogging(world, Logging.MUSHROOMSPREAD)) return;
name = "MushroomSpread";
break;
default:
return;
}
consumer.queueBlockReplace(name, event.getBlock().getState(), event.getNewState());
}
}