Skip to content

Commit

Permalink
移除 MixinBooter 的 IEarlyMixinLoader 使用 Mixins.addConfiguration 以兼容沟槽…
Browse files Browse the repository at this point in the history
…的特殊环境。
  • Loading branch information
KasumiNova authored Jun 14, 2024
2 parents 8c12bba + 764a7ca commit d6308d0
Showing 1 changed file with 3 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixins;
import zone.rong.mixinbooter.IEarlyMixinLoader;

import javax.annotation.Nullable;
import java.util.*;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.BooleanSupplier;

@SuppressWarnings("unused")
public class StellarCoreEarlyMixinLoader implements IFMLLoadingPlugin, IEarlyMixinLoader {
public class StellarCoreEarlyMixinLoader implements IFMLLoadingPlugin {
public static final Logger LOG = LogManager.getLogger("STELLAR_CORE");
public static final String LOG_PREFIX = "[STELLAR_CORE]" + ' ';
private static final Map<String, BooleanSupplier> MIXIN_CONFIGS = new LinkedHashMap<>();
Expand All @@ -31,29 +31,6 @@ public class StellarCoreEarlyMixinLoader implements IFMLLoadingPlugin, IEarlyMix
addMixinCFG("mixins.stellar_core_forge_asmdatatable.json", () -> StellarCoreConfig.PERFORMANCE.forge.asmDataTable);
}

@Override
public List<String> getMixinConfigs() {
if (mixinInitialized) {
return Collections.emptyList();
}
mixinInitialized = true;
return new ArrayList<>(MIXIN_CONFIGS.keySet());
}

@Override
public boolean shouldMixinConfigQueue(final String mixinConfig) {
BooleanSupplier supplier = MIXIN_CONFIGS.get(mixinConfig);
if (supplier == null) {
LOG.warn(LOG_PREFIX + "Mixin config {} is not found in config map! It will never be loaded.", mixinConfig);
return false;
}
boolean shouldLoad = supplier.getAsBoolean();
if (!shouldLoad) {
LOG.info(LOG_PREFIX + "Mixin config {} is disabled by config or mod is not loaded.", mixinConfig);
}
return shouldLoad;
}

private static void addMixinCFG(final String mixinConfig) {
MIXIN_CONFIGS.put(mixinConfig, () -> true);
}
Expand Down Expand Up @@ -82,12 +59,6 @@ public String getSetupClass() {

@Override
public void injectData(final Map<String, Object> data) {
if (mixinInitialized) {
return;
}
mixinInitialized = true;
// If MixinBooter is not loaded before StellarCore, add the Mixin configuration.
LOG.warn(LOG_PREFIX + "MixinBooter is not loaded before StellarCore, force adding mixin configurations!");
MIXIN_CONFIGS.forEach((config, supplier) -> {
if (supplier == null) {
LOG.warn(LOG_PREFIX + "Mixin config {} is not found in config map! It will never be loaded.", config);
Expand All @@ -99,7 +70,6 @@ public void injectData(final Map<String, Object> data) {
return;
}
Mixins.addConfiguration(config);
LOG.info(LOG_PREFIX + "Adding {} mixin configuration.", config);
});
}

Expand Down

0 comments on commit d6308d0

Please # to comment.