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