fix: use own methods in JSON constructor and add javadoc

This commit is contained in:
punchready 2021-07-01 11:28:01 +02:00
parent 07ade1696d
commit a289fee059

View File

@ -94,10 +94,7 @@ public class JSON {
private final ObjectMapper mapper = new ObjectMapper(); private final ObjectMapper mapper = new ObjectMapper();
public JSON (CharacterConfig config) { public JSON (CharacterConfig config) {
// add the config to the mappers InjectableValues, where it is later accessed by the EntityDeserializer setCharacterConfig(config);
this.mapper.setInjectableValues(new InjectableValues
.Std()
.addValue("CharacterConfig", config));
} }
/** Deserializes an incoming network message into a {@link EventMessage}. /** Deserializes an incoming network message into a {@link EventMessage}.
@ -132,6 +129,9 @@ public class JSON {
} }
} }
/**
* Sets the {@link CharacterConfig} to be used during deserialization of Entities.
*/
public void setCharacterConfig(CharacterConfig config) { public void setCharacterConfig(CharacterConfig config) {
this.mapper.setInjectableValues(new InjectableValues this.mapper.setInjectableValues(new InjectableValues
.Std() .Std()