forked from LogBlock/LogBlock
add config option if natural entity spawns should be logged
This commit is contained in:
@@ -360,6 +360,11 @@ public class Config {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLoggingNatualSpawns(World world) {
|
||||
final WorldConfig wcfg = worldConfigs.get(world.getName());
|
||||
return wcfg != null && wcfg.logNaturalEntitySpawns;
|
||||
}
|
||||
}
|
||||
|
||||
class LoggingEnabledMapping {
|
||||
|
@@ -34,6 +34,7 @@ public class WorldConfig extends LoggingEnabledMapping {
|
||||
public final String updateEntityUUIDString;
|
||||
|
||||
private final EnumMap<EntityLogging, EntityLoggingList> entityLogging = new EnumMap<>(EntityLogging.class);
|
||||
public final boolean logNaturalEntitySpawns;
|
||||
|
||||
public WorldConfig(String world, File file) throws IOException {
|
||||
this.world = world;
|
||||
@@ -56,6 +57,10 @@ public class WorldConfig extends LoggingEnabledMapping {
|
||||
}
|
||||
entityLogging.put(el, new EntityLoggingList(config.getStringList("entity." + el.name().toLowerCase())));
|
||||
}
|
||||
if (!config.isBoolean("entity.logNaturalSpawns")) {
|
||||
config.set("entity.logNaturalSpawns", false);
|
||||
}
|
||||
logNaturalEntitySpawns = config.getBoolean("entity.logNaturalSpawns");
|
||||
config.save(file);
|
||||
table = config.getString("table");
|
||||
for (final Logging l : Logging.values()) {
|
||||
|
@@ -159,6 +159,9 @@ public class AdvancedEntityLogging extends LoggingListener {
|
||||
}
|
||||
}
|
||||
if (actor == null) {
|
||||
if (event.getSpawnReason() == SpawnReason.NATURAL && !Config.isLoggingNatualSpawns(entity.getWorld())) {
|
||||
return;
|
||||
}
|
||||
actor = new Actor(event.getSpawnReason().toString());
|
||||
}
|
||||
queueEntitySpawnOrKill(entity, actor, EntityChange.EntityChangeType.CREATE);
|
||||
|
Reference in New Issue
Block a user