mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-25 09:59:15 +00:00
Fix DAB entity blacklist & Fix config modules (#227)
This commit is contained in:
@@ -21,24 +21,21 @@ public abstract class ConfigModules extends LeafConfig {
|
||||
}
|
||||
|
||||
public static void initModules() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
|
||||
List<Class<?>> enabledExperimentalModules = new ArrayList<>();
|
||||
List<Field> enabledExperimentalModules = new ArrayList<>();
|
||||
for (Class<?> clazz : LeafConfig.getClasses(LeafConfig.I_CONFIG_PKG)) {
|
||||
ConfigModules module = (ConfigModules) clazz.getConstructor().newInstance();
|
||||
module.onLoaded();
|
||||
|
||||
modules.add(module);
|
||||
for (Field field : getAnnotatedStaticFields(clazz, Experimental.class)) {
|
||||
Object obj = field.get(null);
|
||||
if (!(obj instanceof Boolean)) continue;
|
||||
boolean enabled = (Boolean) obj;
|
||||
if (!(field.get(null) instanceof Boolean enabled)) continue;
|
||||
if (enabled) {
|
||||
enabledExperimentalModules.add(clazz);
|
||||
break;
|
||||
enabledExperimentalModules.add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!enabledExperimentalModules.isEmpty()) {
|
||||
LeafConfig.LOGGER.warn("You have following experimental module(s) enabled: {}, please report any bugs you found!", enabledExperimentalModules.stream().map(Class::getSimpleName).toList());
|
||||
LeafConfig.LOGGER.warn("You have following experimental module(s) enabled: {}, please proceed with caution!", enabledExperimentalModules.stream().map(f -> f.getClass().getSimpleName() + "." + f.getName()).toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ public class SmoothTeleport extends ConfigModules {
|
||||
public void onLoaded() {
|
||||
enabled = config.getBoolean(getBasePath(), enabled, config.pickStringRegionBased(
|
||||
"""
|
||||
**Experimental feature, report any bugs you encounter!**
|
||||
**Experimental feature**
|
||||
Whether to make a "smooth teleport" when players changing dimension.
|
||||
This requires original world and target world have same logical height to work.""",
|
||||
"""
|
||||
**实验性功能, 请及时反馈你遇到的问题!**
|
||||
**实验性功能**
|
||||
是否在玩家切换世界时尝试使用 "平滑传送".
|
||||
此项要求源世界和目标世界逻辑高度相同才会生效."""
|
||||
));
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.dreeam.leaf.config.LeafConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class DynamicActivationofBrain extends ConfigModules {
|
||||
|
||||
@@ -69,12 +70,12 @@ public class DynamicActivationofBrain extends ConfigModules {
|
||||
for (String name : blackedEntities) {
|
||||
// Be compatible with both `minecraft:example` and `example` syntax
|
||||
// If unknown, show user config value in the logger instead of parsed result
|
||||
String typeId = name.toLowerCase().startsWith(DEFAULT_PREFIX) ? name : DEFAULT_PREFIX + name;
|
||||
String lowerName = name.toLowerCase(Locale.ROOT);
|
||||
String typeId = lowerName.startsWith(DEFAULT_PREFIX) ? lowerName : DEFAULT_PREFIX + lowerName;
|
||||
|
||||
EntityType.byString(typeId).ifPresentOrElse(entityType ->
|
||||
entityType.dabEnabled = false,
|
||||
() -> LeafConfig.LOGGER.warn("Skip unknown entity {}, in {}", name, getBasePath() + ".blacklisted-entities")
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user