Skip to content

Commit

Permalink
Fixes #97
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongmario committed Nov 3, 2024
1 parent 42db892 commit c1a26de
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/zone/rong/mixinbooter/MixinBooterPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.spongepowered.asm.mixin.ModUtil;
import org.spongepowered.asm.mixin.transformer.Config;
import zone.rong.mixinbooter.fix.MixinFixer;
import zone.rong.mixinbooter.util.MockedArtifactVersionAdapter;
import zone.rong.mixinbooter.util.MockedMetadataCollection;

import java.io.InputStreamReader;
Expand Down Expand Up @@ -110,7 +111,7 @@ private void initialize() {
}

private void gatherPresentMods() {
Gson gson = new GsonBuilder().registerTypeAdapter(ArtifactVersion.class, new MetadataCollection.ArtifactVersionAdapter())
Gson gson = new GsonBuilder().registerTypeAdapter(ArtifactVersion.class, new MockedArtifactVersionAdapter())
.setLenient()
.create();
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package zone.rong.mixinbooter.util;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import net.minecraftforge.fml.common.versioning.ArtifactVersion;

import java.io.IOException;

public class MockedArtifactVersionAdapter extends TypeAdapter<ArtifactVersion> {

@Override
public void write(JsonWriter out, ArtifactVersion value) { }

@Override
public ArtifactVersion read(JsonReader in) throws IOException {
in.nextString();
return new MockedArtifactVersion();
}

private static class MockedArtifactVersion implements ArtifactVersion {

@Override
public String getLabel() {
return "";
}

@Override
public String getVersionString() {
return "";
}

@Override
public boolean containsVersion(ArtifactVersion source) {
return false;
}

@Override
public String getRangeString() {
return "";
}

@Override
public int compareTo(ArtifactVersion o) {
return 0;
}

}

}

0 comments on commit c1a26de

Please sign in to comment.