Fix stats

This commit is contained in:
Shaun Bennett 2015-08-02 05:24:25 -05:00
parent db15ffad72
commit 06be7b2cdd
2 changed files with 9 additions and 7 deletions

View File

@ -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));

View File

@ -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<Record2<String, Long>> result = context.select(Tables.stats.name, Tables.accountStat.value).from(Tables.accountStat)
Result<Record2<String, ULong>> 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<String, Long> record : result)
for (Record2<String, ULong> record : result)
{
playerStats.addStat(record.value1(), record.value2());
playerStats.addStat(record.value1(), record.value2().longValue());
}
}