mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-14 22:55:55 +01:00
Fix MailMessageSerializer not handling null UUIDs (#4314)
This commit is contained in:
parent
7e25570344
commit
6535edf4e0
@ -7,18 +7,19 @@ import org.spongepowered.configurate.serialize.SerializationException;
|
|||||||
import org.spongepowered.configurate.serialize.TypeSerializer;
|
import org.spongepowered.configurate.serialize.TypeSerializer;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MailMessageSerializer implements TypeSerializer<MailMessage> {
|
public class MailMessageSerializer implements TypeSerializer<MailMessage> {
|
||||||
@Override
|
@Override
|
||||||
public MailMessage deserialize(Type type, ConfigurationNode node) throws SerializationException {
|
public MailMessage deserialize(Type type, ConfigurationNode node) throws SerializationException {
|
||||||
final boolean legacy = node.node("legacy").getBoolean(true);
|
final boolean legacy = node.node("legacy").getBoolean(true);
|
||||||
|
final String rawUuid = node.node("sender-uuid").getString();
|
||||||
|
final String uuid = (rawUuid == null || rawUuid.equals("null")) ? null : rawUuid;
|
||||||
|
|
||||||
return new MailMessage(node.node("read").getBoolean(false),
|
return new MailMessage(node.node("read").getBoolean(false),
|
||||||
legacy,
|
legacy,
|
||||||
!legacy ? node.node("sender-name").getString() : null,
|
!legacy ? node.node("sender-name").getString() : null,
|
||||||
!legacy ? UUID.fromString(Objects.requireNonNull(node.node("sender-uuid").getString())) : null,
|
uuid == null ? null : UUID.fromString(uuid),
|
||||||
!legacy ? node.node("timestamp").getLong() : 0L,
|
!legacy ? node.node("timestamp").getLong() : 0L,
|
||||||
!legacy ? node.node("expire").getLong() : 0L,
|
!legacy ? node.node("expire").getLong() : 0L,
|
||||||
node.node("message").getString());
|
node.node("message").getString());
|
||||||
@ -36,7 +37,7 @@ public class MailMessageSerializer implements TypeSerializer<MailMessage> {
|
|||||||
node.node("message").set(String.class, obj.getMessage());
|
node.node("message").set(String.class, obj.getMessage());
|
||||||
if (!obj.isLegacy()) {
|
if (!obj.isLegacy()) {
|
||||||
node.node("sender-name").set(String.class, obj.getSenderUsername());
|
node.node("sender-name").set(String.class, obj.getSenderUsername());
|
||||||
node.node("sender-uuid").set(String.class, obj.getSenderUUID().toString());
|
node.node("sender-uuid").set(String.class, obj.getSenderUUID() == null ? "null" : obj.getSenderUUID().toString());
|
||||||
node.node("timestamp").set(Long.class, obj.getTimeSent());
|
node.node("timestamp").set(Long.class, obj.getTimeSent());
|
||||||
node.node("expire").set(Long.class, obj.getTimeExpire());
|
node.node("expire").set(Long.class, obj.getTimeExpire());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user