Fix logging bonemealing moss

This commit is contained in:
Brokkonaut
2021-07-09 06:27:21 +02:00
parent 9399b7062e
commit 7f3837f1fe
3 changed files with 47 additions and 14 deletions

View File

@ -189,9 +189,12 @@ public class LogBlock extends JavaPlugin {
if (isLogging(Logging.WITHER)) {
pm.registerEvents(new WitherLogging(this), this);
}
if (isLogging(Logging.NATURALSTRUCTUREGROW) || isLogging(Logging.BONEMEALSTRUCTUREGROW)) {
if (isLogging(Logging.NATURALSTRUCTUREGROW)) {
pm.registerEvents(new StructureGrowLogging(this), this);
}
if (isLogging(Logging.BONEMEALSTRUCTUREGROW)) {
pm.registerEvents(new BlockFertilizeLogging(this), this);
}
if (isLogging(Logging.GRASSGROWTH) || isLogging(Logging.MYCELIUMSPREAD) || isLogging(Logging.VINEGROWTH) || isLogging(Logging.MUSHROOMSPREAD) || isLogging(Logging.BAMBOOGROWTH) || isLogging(Logging.DRIPSTONEGROWTH)) {
pm.registerEvents(new BlockSpreadLogging(this), this);
}

View File

@ -0,0 +1,36 @@
package de.diddiz.LogBlock.listeners;
import de.diddiz.LogBlock.Actor;
import de.diddiz.LogBlock.LogBlock;
import de.diddiz.LogBlock.Logging;
import de.diddiz.LogBlock.config.WorldConfig;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockFertilizeEvent;
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
public class BlockFertilizeLogging extends LoggingListener {
public BlockFertilizeLogging(LogBlock lb) {
super(lb);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFertilize(BlockFertilizeEvent event) {
final WorldConfig wcfg = getWorldConfig(event.getBlock().getLocation().getWorld());
if (wcfg != null) {
if (!wcfg.isLogging(Logging.BONEMEALSTRUCTUREGROW)) {
return;
}
final Actor actor;
if (event.getPlayer() != null) {
actor = Actor.actorFromEntity(event.getPlayer());
} else {
actor = new Actor("Dispenser");
}
for (final BlockState state : event.getBlocks()) {
consumer.queueBlockReplace(actor, state.getBlock().getState(), state);
}
}
}
}

View File

@ -20,20 +20,14 @@ public class StructureGrowLogging extends LoggingListener {
public void onStructureGrow(StructureGrowEvent event) {
final WorldConfig wcfg = getWorldConfig(event.getWorld());
if (wcfg != null) {
final Actor actor;
if (event.getPlayer() != null) {
if (!wcfg.isLogging(Logging.BONEMEALSTRUCTUREGROW)) {
return;
}
actor = Actor.actorFromEntity(event.getPlayer());
} else {
if (!wcfg.isLogging(Logging.NATURALSTRUCTUREGROW)) {
return;
}
actor = new Actor("NaturalGrow");
if (!wcfg.isLogging(Logging.NATURALSTRUCTUREGROW)) {
return;
}
for (final BlockState state : event.getBlocks()) {
consumer.queueBlockReplace(actor, state.getBlock().getState(), state);
if (!event.isFromBonemeal()) {
final Actor actor = new Actor("NaturalGrow");
for (final BlockState state : event.getBlocks()) {
consumer.queueBlockReplace(actor, state.getBlock().getState(), state);
}
}
}
}