Skip to content

Commit

Permalink
fix: Log error and refuse setting active config to null to both preve…
Browse files Browse the repository at this point in the history
…nt crashes, and debug what code paths lead to it being null TwelveIterationMods/ForgivingVoid#47
  • Loading branch information
BlayTheNinth committed Feb 22, 2025
1 parent 2b9a78d commit ecc19c3
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.lang.reflect.Field;
Expand All @@ -23,6 +25,8 @@

public abstract class AbstractBalmConfig implements BalmConfig {

private static final Logger logger = LoggerFactory.getLogger(AbstractBalmConfig.class);

private final Map<Class<?>, BalmConfigData> activeConfigs = new HashMap<>();
private final Map<Class<?>, BalmConfigData> defaultConfigs = new HashMap<>();
private final Map<Class<?>, Function<?, ?>> syncMessageFactories = new HashMap<>();
Expand Down Expand Up @@ -68,6 +72,11 @@ public <T extends BalmConfigData> Function<BalmConfigData, SyncConfigMessage<Bal
}

public <T extends BalmConfigData> void setActiveConfig(Class<T> clazz, T config) {
if (config == null) {
logger.error("Attempted to set active config to null", new IllegalArgumentException("config must not be null"));
return;
}

activeConfigs.put(clazz, config);
}

Expand Down

0 comments on commit ecc19c3

Please sign in to comment.