Fix error with cooldown sync

This commit is contained in:
GeorgH93 2021-04-13 01:13:18 +02:00
parent b688cd3022
commit 9d851304f2
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 3 additions and 6 deletions

View File

@ -96,10 +96,7 @@ public void onPlayerJoinEvent(PlayerJoinEvent event)
@Override
public void onResult(Long dbCooldownTime)
{
if(dbCooldownTime > System.currentTimeMillis())
{
cooldowns.put(uuid, dbCooldownTime);
}
cooldowns.put(uuid, dbCooldownTime);
}
@Override

View File

@ -56,7 +56,7 @@ protected void checkDB()
"REFERENCES {TablePlayers} ({FieldPlayerID}) ON DELETE CASCADE ON UPDATE CASCADE\n);"));
if(syncCooldown)
{
DBTools.updateDB(connection, replacePlaceholders("CREATE TABLE IF NOT EXISTS {TableCooldowns} (\n{FieldCDPlayer} INT UNSIGNED NOT NULL,\n{FieldCDTime} LONG NOT NULL,\nPRIMARY KEY ({FieldCDPlayer}),\n" +
DBTools.updateDB(connection, replacePlaceholders("CREATE TABLE IF NOT EXISTS {TableCooldowns} (\n{FieldCDPlayer} INT UNSIGNED NOT NULL,\n{FieldCDTime} DATETIME NOT NULL,\nPRIMARY KEY ({FieldCDPlayer}),\n" +
"CONSTRAINT fk_{TableCooldowns}_{TablePlayers}_{FieldCDPlayer} FOREIGN KEY ({FieldCDPlayer}) " +
"REFERENCES {TablePlayers} ({FieldPlayerID}) ON DELETE CASCADE ON UPDATE CASCADE\n);"));
}

View File

@ -375,7 +375,7 @@ public void getCooldown(final Player player, final Callback<Long> callback)
ps.setString(1, getPlayerFormattedUUID(player));
try(ResultSet rs = ps.executeQuery())
{
final long time = (rs.next()) ? rs.getLong(fieldCdTime) : 0;
final long time = (rs.next()) ? rs.getTimestamp(fieldCdTime).getTime() : 0;
plugin.getServer().getScheduler().runTask(plugin, () -> callback.onResult(time));
}
}