mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-27 12:46:22 +01:00
Reduce game arguments to strings where possible
Helps to reduce the size of the manifest a little, and looks nicer!
This commit is contained in:
parent
ec7b1ac2ae
commit
f880192919
@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.skcraft.launcher.model.minecraft.mapper.MinecraftArgumentsDeserializer;
|
import com.skcraft.launcher.model.minecraft.mapper.MinecraftArgumentsDeserializer;
|
||||||
|
import com.skcraft.launcher.model.minecraft.mapper.MinecraftArgumentsSerializer;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -14,11 +16,13 @@ import java.util.List;
|
|||||||
public class MinecraftArguments {
|
public class MinecraftArguments {
|
||||||
@JsonProperty("game")
|
@JsonProperty("game")
|
||||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
|
||||||
|
@JsonSerialize(contentUsing = MinecraftArgumentsSerializer.class)
|
||||||
@JsonDeserialize(contentUsing = MinecraftArgumentsDeserializer.class)
|
@JsonDeserialize(contentUsing = MinecraftArgumentsDeserializer.class)
|
||||||
private List<GameArgument> gameArguments;
|
private List<GameArgument> gameArguments;
|
||||||
|
|
||||||
@JsonProperty("jvm")
|
@JsonProperty("jvm")
|
||||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
|
||||||
|
@JsonSerialize(contentUsing = MinecraftArgumentsSerializer.class)
|
||||||
@JsonDeserialize(contentUsing = MinecraftArgumentsDeserializer.class)
|
@JsonDeserialize(contentUsing = MinecraftArgumentsDeserializer.class)
|
||||||
private List<GameArgument> jvmArguments;
|
private List<GameArgument> jvmArguments;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.skcraft.launcher.model.minecraft.mapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerationException;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||||
|
import com.skcraft.launcher.model.minecraft.GameArgument;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class MinecraftArgumentsSerializer extends StdSerializer<GameArgument> {
|
||||||
|
protected MinecraftArgumentsSerializer() {
|
||||||
|
super(GameArgument.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(GameArgument value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
|
||||||
|
if (value.getValues().size() == 1 && (value.getRules() == null || value.getRules().size() == 0)) {
|
||||||
|
jgen.writeString(value.getValues().get(0));
|
||||||
|
} else {
|
||||||
|
provider.defaultSerializeValue(value, jgen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user