Skip to content

Commit

Permalink
Fix DAB entity blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
HaHaWTH committed Feb 14, 2025
1 parent b327661 commit 6cd8523
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,21 @@ public ConfigModules() {
}

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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public String getBasePath() {
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.""",
"""
**实验性功能, 请及时反馈你遇到的问题!**
**实验性功能**
是否在玩家切换世界时尝试使用 "平滑传送".
此项要求源世界和目标世界逻辑高度相同才会生效."""
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class DynamicActivationofBrain extends ConfigModules {

Expand Down Expand Up @@ -69,12 +70,12 @@ public void onLoaded() {
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")

);
}
}
Expand Down

0 comments on commit 6cd8523

Please sign in to comment.