mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-02-02 23:31:49 +01:00
Fix error with cooldown sync
This commit is contained in:
parent
b688cd3022
commit
9d851304f2
@ -95,12 +95,9 @@ public void onPlayerJoinEvent(PlayerJoinEvent event)
|
|||||||
plugin.getDatabase().getCooldown(event.getPlayer(), new Callback<Long>() {
|
plugin.getDatabase().getCooldown(event.getPlayer(), new Callback<Long>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResult(Long dbCooldownTime)
|
public void onResult(Long dbCooldownTime)
|
||||||
{
|
|
||||||
if(dbCooldownTime > System.currentTimeMillis())
|
|
||||||
{
|
{
|
||||||
cooldowns.put(uuid, dbCooldownTime);
|
cooldowns.put(uuid, dbCooldownTime);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFail() {}
|
public void onFail() {}
|
||||||
|
@ -56,7 +56,7 @@ protected void checkDB()
|
|||||||
"REFERENCES {TablePlayers} ({FieldPlayerID}) ON DELETE CASCADE ON UPDATE CASCADE\n);"));
|
"REFERENCES {TablePlayers} ({FieldPlayerID}) ON DELETE CASCADE ON UPDATE CASCADE\n);"));
|
||||||
if(syncCooldown)
|
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}) " +
|
"CONSTRAINT fk_{TableCooldowns}_{TablePlayers}_{FieldCDPlayer} FOREIGN KEY ({FieldCDPlayer}) " +
|
||||||
"REFERENCES {TablePlayers} ({FieldPlayerID}) ON DELETE CASCADE ON UPDATE CASCADE\n);"));
|
"REFERENCES {TablePlayers} ({FieldPlayerID}) ON DELETE CASCADE ON UPDATE CASCADE\n);"));
|
||||||
}
|
}
|
||||||
|
@ -375,7 +375,7 @@ public void getCooldown(final Player player, final Callback<Long> callback)
|
|||||||
ps.setString(1, getPlayerFormattedUUID(player));
|
ps.setString(1, getPlayerFormattedUUID(player));
|
||||||
try(ResultSet rs = ps.executeQuery())
|
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));
|
plugin.getServer().getScheduler().runTask(plugin, () -> callback.onResult(time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user