use of com.voxelgameslib.voxelgameslib.util.Pair in project VoxelGamesLibv2 by VoxelGamesLib.
the class HibernatePersistenceProvider method getTopWithName.
@Override
public List<Pair<Component, Double>> getTopWithName(Trackable type, int amount) {
return session(session -> {
Query query = session.createQuery("select user.displayName, stat.val from StatInstance stat, UserData user\n" + "where user.uuid = stat.uuid\n" + "and stat.statType = :type\n" + "order by stat.val desc");
query.setParameter("type", type);
query.setMaxResults(amount);
List<Pair<Component, Double>> result = new ArrayList<>();
// noinspection unchecked
for (Object[] row : (List<Object[]>) query.getResultList()) {
result.add(new Pair<>((Component) row[0], (Double) row[1]));
}
return result;
});
}
use of com.voxelgameslib.voxelgameslib.util.Pair in project VoxelGamesLibv2 by VoxelGamesLib.
the class HibernatePersistenceProvider method getTopWithUUID.
@Override
public List<Pair<UUID, Double>> getTopWithUUID(Trackable type, int amount) {
return session(session -> {
Query query = session.createQuery("select stat.uuid, stat.val from StatInstance stat\n" + "where stat.statType = :type\n" + "order by stat.val desc");
query.setParameter("type", type);
query.setMaxResults(amount);
List<Pair<UUID, Double>> result = new ArrayList<>();
// noinspection unchecked
for (Object[] row : (List<Object[]>) query.getResultList()) {
result.add(new Pair<>((UUID) row[0], (Double) row[1]));
}
return result;
});
}