Skip to content

Commit 7acf0cb

Browse files
authored
Fix Mixin Loading (#9)
1 parent c8ee3e1 commit 7acf0cb

File tree

9 files changed

+90
-77
lines changed

9 files changed

+90
-77
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ whitelist.json
2525
*.iml
2626
*.ipr
2727
*.iws
28-
src/main/resources/mixins.*.json
2928
*.bat
3029
*.DS_Store
3130
!gradlew.bat

gradle.properties

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ developmentEnvironmentUserName =
4141

4242
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
4343
# See https://github.com/bsideup/jabel for details on how this works.
44-
enableModernJavaSyntax = false
44+
enableModernJavaSyntax = true
4545

4646
# Enables injecting missing generics into the decompiled source code for a better coding experience.
4747
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
48-
enableGenericInjection = false
48+
enableGenericInjection = true
4949

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.
5353
generateGradleTokenClass =
5454

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

5858
# [DEPRECATED] Mod ID replacement token.
5959
gradleTokenModId =
@@ -70,7 +70,7 @@ gradleTokenGroupName =
7070
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
7171
# version in @Mod([...], version = VERSION, [...]).
7272
# Leave these properties empty to skip individual token replacements.
73-
replaceGradleTokenInFile = ModContainer.java
73+
replaceGradleTokenInFile =
7474

7575
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
7676
# leave this property empty.
@@ -91,18 +91,18 @@ usesMixins = true
9191
separateMixinSourceSet =
9292

9393
# Adds some debug arguments like verbose output and class export.
94-
usesMixinDebug = false
94+
usesMixinDebug = true
9595

9696
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
97-
mixinPlugin = MixinPlugin
97+
mixinPlugin =
9898

9999
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
100100
mixinsPackage = mixins
101101

102102
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
103103
# This parameter is for legacy compatibility only
104104
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
105-
coreModClass =
105+
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!
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package glowredman.defaultserverlist;
2+
3+
import java.io.File;
4+
import java.util.Collections;
5+
import java.util.List;
6+
import java.util.Map;
7+
import java.util.Set;
8+
9+
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
10+
11+
import cpw.mods.fml.relauncher.FMLLaunchHandler;
12+
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
13+
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
14+
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
15+
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
16+
import cpw.mods.fml.relauncher.Side;
17+
18+
@MCVersion("1.7.10")
19+
@Name("DefaultServerList")
20+
@TransformerExclusions("glowredman.defaultserverlist.LoadingPlugin")
21+
public class LoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader {
22+
23+
@Override
24+
public String getMixinConfig() {
25+
return "mixins.defaultserverlist.early.json";
26+
}
27+
28+
@Override
29+
public List<String> getMixins(Set<String> loadedCoreMods) {
30+
if (FMLLaunchHandler.side() == Side.CLIENT) {
31+
return Collections.singletonList("ServerListMixin");
32+
}
33+
return Collections.emptyList();
34+
}
35+
36+
@Override
37+
public String[] getASMTransformerClass() {
38+
return null;
39+
}
40+
41+
@Override
42+
public String getModContainerClass() {
43+
return null;
44+
}
45+
46+
@Override
47+
public String getSetupClass() {
48+
return null;
49+
}
50+
51+
@Override
52+
public void injectData(Map<String, Object> data) {
53+
if (FMLLaunchHandler.side() == Side.CLIENT) {
54+
Config.preInit(new File((File) data.get("mcLocation"), "config"));
55+
}
56+
}
57+
58+
@Override
59+
public String getAccessTransformerClass() {
60+
return null;
61+
}
62+
}

src/main/java/glowredman/defaultserverlist/MixinPlugin.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/main/java/glowredman/defaultserverlist/ModContainer.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/java/glowredman/defaultserverlist/mixins/ServerListMixin.java renamed to src/main/java/glowredman/defaultserverlist/mixins/early/ServerListMixin.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package glowredman.defaultserverlist.mixins;
1+
package glowredman.defaultserverlist.mixins.early;
22

33
import java.util.LinkedHashMap;
44
import java.util.List;
@@ -20,21 +20,19 @@
2020
@Mixin(ServerList.class)
2121
public class ServerListMixin {
2222

23-
@SuppressWarnings("rawtypes")
2423
@Shadow
2524
@Final
26-
private List servers;
25+
private List<ServerData> servers;
2726

2827
/**
2928
* Removes all servers from servers.dat that are already in the default list
3029
*
3130
* @author glowredman
3231
*/
33-
@SuppressWarnings("unchecked")
3432
@Inject(at = @At("TAIL"), method = "loadServerList()V")
3533
private void removeDuplicateServers(CallbackInfo ci) {
3634
servers.removeIf(o -> {
37-
String s1 = ((ServerData) o).serverIP.replace("http://", "").replace("https://", "").replace(":25565", "");
35+
String s1 = o.serverIP.replace("http://", "").replace("https://", "").replace(":25565", "");
3836
for (ServerData s2 : Config.SERVERS) {
3937
if (s1.equals(s2.serverIP.replace("http://", "").replace("https://", "").replace(":25565", ""))) {
4038
return true;
@@ -73,7 +71,7 @@ private void saveDefaultServerList(CallbackInfo ci) {
7371
@Overwrite
7472
public ServerData getServerData(int index) {
7573
if (index < servers.size()) {
76-
return (ServerData) servers.get(index);
74+
return servers.get(index);
7775
}
7876
return Config.SERVERS.get(index - servers.size());
7977
}
@@ -134,7 +132,6 @@ public void saveServerList() {}
134132
* @reason DefaultServerList
135133
* @author glowredman
136134
*/
137-
@SuppressWarnings("unchecked")
138135
@Overwrite
139136
public void func_147413_a(int index, ServerData data) {
140137
if (index < servers.size()) {

src/main/resources/mcmod.info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"version": "${modVersion}",
77
"mcversion": "${minecraftVersion}",
88
"url": "https://github.com/glowredman/DefaultServerList",
9-
"updateUrl": "https://data-hole.ddns.net:8081/mods/defaultserverlist/updates.json",
9+
"updateUrl": "https://files.data-hole.de/mods/defaultserverlist/updates.json",
1010
"authorList": ["glowredman"],
1111
"credits": "",
1212
"logoFile": "",
1313
"screenshots": [],
14-
"dependencies": ["spongemixins"]
14+
"dependencies": []
1515
}
1616
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"required": true,
3+
"minVersion": "0.7.11",
4+
"package": "glowredman.defaultserverlist.mixins.early",
5+
"refmap": "mixins.defaultserverlist.refmap.json",
6+
"target": "@env(DEFAULT)",
7+
"compatibilityLevel": "JAVA_8"
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"required": true,
3+
"minVersion": "0.7.11",
4+
"refmap": "mixins.defaultserverlist.refmap.json",
5+
"target": "@env(DEFAULT)",
6+
"compatibilityLevel": "JAVA_8"
7+
}

0 commit comments

Comments
 (0)