Skip to content

Commit 3442f65

Browse files
committed
Move config parsing (back) to preInit
1 parent 16ceec1 commit 3442f65

File tree

4 files changed

+72
-6
lines changed

4 files changed

+72
-6
lines changed

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ enableGenericInjection = true
5050
# Generate a class with a String field for the mod version named as defined below.
5151
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
5252
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
53-
generateGradleTokenClass =
53+
generateGradleTokenClass = glowredman.defaultserverlist.Tags
5454

5555
# Name of the token containing the project's current version to generate/replace.
56-
gradleTokenVersion =
56+
gradleTokenVersion = VERSION
5757

5858
# [DEPRECATED] Mod ID replacement token.
5959
gradleTokenModId =
@@ -106,7 +106,7 @@ coreModClass = LoadingPlugin
106106

107107
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
108108
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
109-
containsMixinsAndOrCoreModOnly = false
109+
containsMixinsAndOrCoreModOnly = true
110110

111111
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
112112
forceEnableMixins = false

src/main/java/glowredman/defaultserverlist/LoadingPlugin.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
import cpw.mods.fml.relauncher.Side;
2020

2121
@MCVersion("1.7.10")
22-
@Name("DefaultServerList")
22+
@Name("DefaultServerList Core")
2323
@TransformerExclusions("glowredman.defaultserverlist.LoadingPlugin")
2424
public class LoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader {
2525

2626
public static final Logger LOGGER = LogManager.getLogger("DefaultServerList");
2727

28+
static File location;
29+
2830
@Override
2931
public String getMixinConfig() {
3032
return "mixins.defaultserverlist.early.json";
@@ -45,6 +47,9 @@ public String[] getASMTransformerClass() {
4547

4648
@Override
4749
public String getModContainerClass() {
50+
if (FMLLaunchHandler.side() == Side.CLIENT) {
51+
return ModContainer.class.getName();
52+
}
4853
return null;
4954
}
5055

@@ -55,8 +60,9 @@ public String getSetupClass() {
5560

5661
@Override
5762
public void injectData(Map<String, Object> data) {
58-
if (FMLLaunchHandler.side() == Side.CLIENT) {
59-
Config.init(new File((File) data.get("mcLocation"), "config"));
63+
location = (File) data.get("coremodLocation");
64+
if (location == null) {
65+
location = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
6066
}
6167
}
6268

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package glowredman.defaultserverlist;
2+
3+
import java.io.File;
4+
import java.util.Collections;
5+
import java.util.Set;
6+
7+
import com.google.common.eventbus.EventBus;
8+
import com.google.common.eventbus.Subscribe;
9+
10+
import cpw.mods.fml.common.DummyModContainer;
11+
import cpw.mods.fml.common.LoadController;
12+
import cpw.mods.fml.common.ModMetadata;
13+
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
14+
import cpw.mods.fml.common.versioning.ArtifactVersion;
15+
import cpw.mods.fml.common.versioning.VersionParser;
16+
import cpw.mods.fml.common.versioning.VersionRange;
17+
18+
public class ModContainer extends DummyModContainer {
19+
20+
public ModContainer() {
21+
super(new ModMetadata());
22+
ModMetadata md = this.getMetadata();
23+
24+
// NOTE: If you change this, change mcmod.info too!
25+
md.authorList = Collections.singletonList("glowredman");
26+
md.description = "Add default servers to the multiplayer screen.";
27+
md.modId = "defaultserverlist";
28+
md.name = "DefaultServerList";
29+
md.updateUrl = "https://files.data-hole.de/mods/defaultserverlist/updates.json";
30+
md.url = "https://github.com/glowredman/DefaultServerList";
31+
md.version = Tags.VERSION;
32+
}
33+
34+
@Override
35+
public VersionRange acceptableMinecraftVersionRange() {
36+
return VersionParser.parseRange("[1.7.10]");
37+
}
38+
39+
@Override
40+
public Set<ArtifactVersion> getRequirements() {
41+
return Collections.singleton(VersionParser.parseVersionReference("gtnhmixins"));
42+
}
43+
44+
@Override
45+
public File getSource() {
46+
return LoadingPlugin.location;
47+
}
48+
49+
@Override
50+
public boolean registerBus(EventBus bus, LoadController controller) {
51+
bus.register(this);
52+
return true;
53+
}
54+
55+
@Subscribe
56+
public void preInit(FMLPreInitializationEvent event) {
57+
Config.init(event.getModConfigurationDirectory());
58+
}
59+
}

src/main/resources/mcmod.info

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
{
3+
"__comment": "NOTE: If you change this, change ModContainer.java too!",
34
"modid": "${modId}",
45
"name": "${modName}",
56
"description": "Add default servers to the multiplayer screen.",

0 commit comments

Comments
 (0)