Fix stats
This commit is contained in:
parent
db15ffad72
commit
06be7b2cdd
@ -18,6 +18,7 @@ import org.jooq.impl.DSL;
|
|||||||
import mineplex.core.account.ILoginProcessor;
|
import mineplex.core.account.ILoginProcessor;
|
||||||
import mineplex.core.database.DBPool;
|
import mineplex.core.database.DBPool;
|
||||||
import mineplex.database.Tables;
|
import mineplex.database.Tables;
|
||||||
|
import org.jooq.types.ULong;
|
||||||
|
|
||||||
public class SecondaryStatHandler implements ILoginProcessor
|
public class SecondaryStatHandler implements ILoginProcessor
|
||||||
{
|
{
|
||||||
@ -58,7 +59,7 @@ public class SecondaryStatHandler implements ILoginProcessor
|
|||||||
.insertInto(Tables.accountStat)
|
.insertInto(Tables.accountStat)
|
||||||
.set(Tables.accountStat.accountId, accountId)
|
.set(Tables.accountStat.accountId, accountId)
|
||||||
.set(Tables.accountStat.statId, statId)
|
.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);
|
inserts.add(insert);
|
||||||
}
|
}
|
||||||
@ -99,13 +100,13 @@ public class SecondaryStatHandler implements ILoginProcessor
|
|||||||
.insertInto(Tables.accountStat)
|
.insertInto(Tables.accountStat)
|
||||||
.set(Tables.accountStat.accountId, accountId)
|
.set(Tables.accountStat.accountId, accountId)
|
||||||
.set(Tables.accountStat.statId, statId)
|
.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);
|
inserts.add(insert);
|
||||||
|
|
||||||
Update update = context
|
Update update = context
|
||||||
.update(Tables.accountStat)
|
.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))
|
.where(Tables.accountStat.accountId.eq(accountId))
|
||||||
.and(Tables.accountStat.statId.eq(statId));
|
.and(Tables.accountStat.statId.eq(statId));
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import org.jooq.Result;
|
|||||||
import org.jooq.SQLDialect;
|
import org.jooq.SQLDialect;
|
||||||
import org.jooq.Update;
|
import org.jooq.Update;
|
||||||
import org.jooq.impl.DSL;
|
import org.jooq.impl.DSL;
|
||||||
|
import org.jooq.types.ULong;
|
||||||
|
|
||||||
public class StatsRepository extends RepositoryBase
|
public class StatsRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
@ -102,7 +103,7 @@ public class StatsRepository extends RepositoryBase
|
|||||||
.insertInto(Tables.accountStat)
|
.insertInto(Tables.accountStat)
|
||||||
.set(Tables.accountStat.accountId, accountId)
|
.set(Tables.accountStat.accountId, accountId)
|
||||||
.set(Tables.accountStat.statId, statId)
|
.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);
|
inserts.add(insert);
|
||||||
}
|
}
|
||||||
@ -137,7 +138,7 @@ public class StatsRepository extends RepositoryBase
|
|||||||
context = DSL.using(getConnectionPool(), SQLDialect.MYSQL);
|
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)
|
.join(Tables.stats)
|
||||||
.on(Tables.stats.id.eq(Tables.accountStat.statId))
|
.on(Tables.stats.id.eq(Tables.accountStat.statId))
|
||||||
.where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id)
|
.where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id)
|
||||||
@ -149,9 +150,9 @@ public class StatsRepository extends RepositoryBase
|
|||||||
if (result.isNotEmpty())
|
if (result.isNotEmpty())
|
||||||
{
|
{
|
||||||
playerStats = new PlayerStats();
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user