Fix loading player data

This commit is contained in:
Draycia committed 2022-06-08 15:16:20 -07:00
1 parent 9903e0da2c
commit 751ca43f15
2 files changed
+12 -7

No files matched your search

@@ -67,12 +67,12 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
public CarbonPlayerCommon(
final boolean muted,
final boolean deafened,
final Key selectedChannel,
final @Nullable Key selectedChannel,
final String username,
final UUID uuid,
final Component displayName,
final UUID lastWhisperTarget,
final UUID whisperReplyTarget,
final @Nullable Component displayName,
final @Nullable UUID lastWhisperTarget,
final @Nullable UUID whisperReplyTarget,
final boolean spying
) {
this.muted = muted;
@@ -25,6 +25,7 @@ import java.util.UUID;
import net.draycia.carbon.common.users.CarbonPlayerCommon;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jdbi.v3.core.mapper.RowMapper;
import org.jdbi.v3.core.statement.StatementContext;
@@ -32,15 +33,19 @@ public class CarbonPlayerCommonRowMapper implements RowMapper<CarbonPlayerCommon
@Override
public CarbonPlayerCommon map(final ResultSet rs, final StatementContext ctx) throws SQLException {
final String id = rs.getString("id");
final @Nullable String lastWhisperTarget = rs.getString("lastwhispertarget");
final @Nullable String whisperreplytarget = rs.getString("whisperreplytarget");
return new CarbonPlayerCommon(
rs.getBoolean("muted"),
rs.getBoolean("deafened"),
rs.getObject("selectedchannel", Key.class),
rs.getString("username"),
rs.getObject("uuid", UUID.class),
UUID.fromString(id),
rs.getObject("displayname", Component.class),
rs.getObject("lastwhispertarget", UUID.class),
rs.getObject("whisperreplytarget", UUID.class),
lastWhisperTarget == null ? null : UUID.fromString(lastWhisperTarget),
whisperreplytarget == null ? null : UUID.fromString(whisperreplytarget),
rs.getBoolean("spying")
);
}