Handle null or empty server/world field in SQL (#2553)

This commit is contained in:
Luck 2020-08-13 11:40:33 +01:00
parent 7fae141e33
commit e2b575dd24
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -25,6 +25,8 @@
package me.lucko.luckperms.common.storage.implementation.sql;
import com.google.common.base.Strings;
import me.lucko.luckperms.common.context.ContextSetJsonSerializer;
import me.lucko.luckperms.common.node.factory.NodeBuilders;
import me.lucko.luckperms.common.util.gson.GsonProvider;
@ -84,6 +86,13 @@ public final class SqlNode {
}
public static SqlNode fromSqlFields(long sqlId, String permission, boolean value, String server, String world, long expiry, String contexts) {
if (Strings.emptyToNull(server) == null) {
server = "global";
}
if (Strings.emptyToNull(world) == null) {
world = "global";
}
return new SqlNode(permission, value, server, world, expiry, ContextSetJsonSerializer.deserializeContextSet(GsonProvider.normal(), contexts).immutableCopy(), sqlId);
}