Fixed customization string persistence problems

This commit is contained in:
Mads Boddum
2018-03-07 12:32:52 +01:00
parent b7eabab673
commit e6e18188da
2 changed files with 14 additions and 2 deletions
@@ -72,13 +72,18 @@ public class CustomizationString implements Encodable, Persistable {
@Override
public void save(NetBufferStream stream) {
stream.addByte(0);
stream.addRawArray(encode()); // No length is prepended when adding a raw array
stream.addMap(variables, (entry) -> {
stream.addAscii(entry.getKey());
stream.addInt(entry.getValue().getValue()); // Awful coincidence
});
}
@Override
public void read(NetBufferStream stream) {
stream.getByte();
decode(NetBuffer.wrap(stream.array()));
stream.getList((i) -> {
variables.put(stream.getAscii(), new CustomizationVariable(stream.getInt()));
});
}
/**