From 06be7b2cddfcd159dba8b1154f24aba3cce20835 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sun, 2 Aug 2015 05:24:25 -0500 Subject: [PATCH] Fix stats --- .../src/mineplex/core/stats/SecondaryStatHandler.java | 7 ++++--- .../src/mineplex/core/stats/StatsRepository.java | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java index 5901a17e1..eb13e4940 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/SecondaryStatHandler.java @@ -18,6 +18,7 @@ import org.jooq.impl.DSL; import mineplex.core.account.ILoginProcessor; import mineplex.core.database.DBPool; import mineplex.database.Tables; +import org.jooq.types.ULong; public class SecondaryStatHandler implements ILoginProcessor { @@ -58,7 +59,7 @@ public class SecondaryStatHandler implements ILoginProcessor .insertInto(Tables.accountStat) .set(Tables.accountStat.accountId, accountId) .set(Tables.accountStat.statId, statId) - .set(Tables.accountStat.value, Math.max(oldPlayerStats.getStat(statName), 0L)); + .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))); inserts.add(insert); } @@ -99,13 +100,13 @@ public class SecondaryStatHandler implements ILoginProcessor .insertInto(Tables.accountStat) .set(Tables.accountStat.accountId, accountId) .set(Tables.accountStat.statId, statId) - .set(Tables.accountStat.value, Math.max(oldPlayerStats.getStat(statName), 0L)); + .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))); inserts.add(insert); Update update = context .update(Tables.accountStat) - .set(Tables.accountStat.value, Math.max(oldPlayerStats.getStat(statName), 0L)) + .set(Tables.accountStat.value, ULong.valueOf(Math.max(oldPlayerStats.getStat(statName), 0L))) .where(Tables.accountStat.accountId.eq(accountId)) .and(Tables.accountStat.statId.eq(statId)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 683cca93d..e1524436d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -22,6 +22,7 @@ import org.jooq.Result; import org.jooq.SQLDialect; import org.jooq.Update; import org.jooq.impl.DSL; +import org.jooq.types.ULong; public class StatsRepository extends RepositoryBase { @@ -102,7 +103,7 @@ public class StatsRepository extends RepositoryBase .insertInto(Tables.accountStat) .set(Tables.accountStat.accountId, accountId) .set(Tables.accountStat.statId, statId) - .set(Tables.accountStat.value, uploadQueue.get(accountId).get(statId)); + .set(Tables.accountStat.value, ULong.valueOf(uploadQueue.get(accountId).get(statId))); inserts.add(insert); } @@ -137,7 +138,7 @@ public class StatsRepository extends RepositoryBase context = DSL.using(getConnectionPool(), SQLDialect.MYSQL); } - Result> result = context.select(Tables.stats.name, Tables.accountStat.value).from(Tables.accountStat) + Result> result = context.select(Tables.stats.name, Tables.accountStat.value).from(Tables.accountStat) .join(Tables.stats) .on(Tables.stats.id.eq(Tables.accountStat.statId)) .where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id) @@ -149,9 +150,9 @@ public class StatsRepository extends RepositoryBase if (result.isNotEmpty()) { playerStats = new PlayerStats(); - for (Record2 record : result) + for (Record2 record : result) { - playerStats.addStat(record.value1(), record.value2()); + playerStats.addStat(record.value1(), record.value2().longValue()); } }