forked from LogBlock/LogBlock
Added logging for various blocks spreading
This commit is contained in:
@@ -164,6 +164,8 @@ public class LogBlock extends JavaPlugin
|
||||
pm.registerEvents(new WitherLogging(this), this);
|
||||
if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW))
|
||||
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)
|
||||
pm.registerEvents(new PlayerInfoLogging(this), this);
|
||||
}
|
||||
|
@@ -7,7 +7,8 @@ public enum Logging
|
||||
LAVAFLOW, WATERFLOW, CHESTACCESS, KILL, CHAT, SNOWFORM, SNOWFADE, DOORINTERACT,
|
||||
SWITCHINTERACT, CAKEEAT, ENDERMEN, NOTEBLOCKINTERACT, DIODEINTERACT, COMPARATORINTERACT,
|
||||
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);
|
||||
|
||||
public static final int length = Logging.values().length;
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user