-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed4cb3d
commit 7fd5916
Showing
5 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ arnicalib_version=5.2.0 | |
|
||
champions_cf_file_id=3724097 | ||
|
||
extrachampions_version=1.0.0 | ||
extrachampions_version=1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/org/auioc/mcmod/extrachampions/Initialization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.auioc.mcmod.extrachampions; | ||
|
||
import org.auioc.mcmod.extrachampions.common.affix.AffixRegistry; | ||
import org.auioc.mcmod.extrachampions.common.config.ExAffixConfig; | ||
import net.minecraftforge.eventbus.api.EventPriority; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.fml.ModLoadingContext; | ||
import net.minecraftforge.fml.config.ModConfig; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
|
||
public final class Initialization { | ||
|
||
public static void init() { | ||
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); | ||
register(modEventBus); | ||
handleConfig(modEventBus); | ||
} | ||
|
||
private static void register(final IEventBus modEventBus) { | ||
modEventBus.addListener( | ||
(final FMLCommonSetupEvent event) -> { | ||
AffixRegistry.register(); | ||
} | ||
); | ||
} | ||
|
||
private static void handleConfig(final IEventBus modEventBus) { | ||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ExAffixConfig.SPEC, ExtraChampions.MOD_ID + "-affixes.toml"); | ||
modEventBus.addListener(EventPriority.LOWEST, ExAffixConfig::rebuildAffixSettings); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/org/auioc/mcmod/extrachampions/common/config/ExAffixConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.auioc.mcmod.extrachampions.common.config; | ||
|
||
import static org.auioc.mcmod.extrachampions.ExtraChampions.LOGGER; | ||
import java.util.ArrayList; | ||
import com.electronwill.nightconfig.core.UnmodifiableConfig; | ||
import org.apache.logging.log4j.Marker; | ||
import org.auioc.mcmod.arnicalib.utils.LogUtil; | ||
import org.auioc.mcmod.extrachampions.ExtraChampions; | ||
import org.auioc.mcmod.extrachampions.common.affix.AffixRegistry; | ||
import net.minecraftforge.common.ForgeConfigSpec; | ||
import net.minecraftforge.fml.config.ModConfig; | ||
import net.minecraftforge.fml.event.config.ModConfigEvent; | ||
import top.theillusivec4.champions.common.affix.core.AffixManager; | ||
import top.theillusivec4.champions.common.config.AffixesConfig; | ||
import top.theillusivec4.champions.common.config.ChampionsConfig; | ||
|
||
public class ExAffixConfig { | ||
|
||
private static final Marker MARKER = LogUtil.getMarker(ExAffixConfig.class); | ||
|
||
public static final ForgeConfigSpec SPEC; | ||
|
||
static { | ||
ForgeConfigSpec.Builder b = new ForgeConfigSpec.Builder(); | ||
|
||
AffixRegistry.AFFIXES.forEach((affix) -> { | ||
b.push(affix.getIdentifier()); | ||
{ | ||
b.define("enabled", true); | ||
b.define("minTier", 1); | ||
b.define("maxTier", -1); //? TOML dose not support NULL value | ||
b.defineList("mobList", new ArrayList<String>(), (o) -> o instanceof String); | ||
b.define("mobPermission", "BLACKLIST"); | ||
} | ||
b.pop(); | ||
}); | ||
|
||
SPEC = b.build(); | ||
} | ||
|
||
public static void rebuildAffixSettings(final ModConfigEvent event) { | ||
ModConfig config = event.getConfig(); | ||
if ( | ||
config.getModId().equals(ExtraChampions.MOD_ID) | ||
&& config.getType() == ModConfig.Type.SERVER | ||
&& config.getSpec() == ExAffixConfig.SPEC | ||
) { | ||
LOGGER.info(MARKER, "Rebuild affix settings"); | ||
AffixRegistry.AFFIXES.forEach((affix) -> { | ||
UnmodifiableConfig rawConfig = event.getConfig().getConfigData().get(affix.getIdentifier()); | ||
{ | ||
var affixConfig = new AffixesConfig.AffixConfig(); | ||
{ | ||
affixConfig.identifier = affix.getIdentifier(); | ||
affixConfig.enabled = rawConfig.get("enabled"); | ||
affixConfig.minTier = rawConfig.get("minTier"); | ||
//? TOML dose not support NULL value | ||
affixConfig.maxTier = ((Integer) rawConfig.get("minTier")) == -1 ? null : rawConfig.get("minTier"); | ||
affixConfig.mobList = rawConfig.get("mobList"); | ||
affixConfig.mobPermission = rawConfig.get("mobPermission"); | ||
} | ||
ChampionsConfig.affixes.add(affixConfig); | ||
} | ||
}); | ||
AffixManager.buildAffixSettings(); | ||
} | ||
} | ||
|
||
} |