mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-27 13:59:56 +01:00
Fixed Players page list not being sorted correctly.
This commit is contained in:
parent
15221d0edb
commit
11c52c4228
@ -7,7 +7,7 @@ import java.sql.SQLException;
|
||||
|
||||
public interface BackupOperations {
|
||||
|
||||
void backup(Database toDatabase) throws DBException, SQLException;
|
||||
void backup(Database toDatabase) throws SQLException;
|
||||
|
||||
void restore(Database fromDatabase) throws DBException, SQLException;
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class MySQLDB extends SQLDB {
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
if (dataSource != null && dataSource instanceof BasicDataSource) {
|
||||
if (dataSource instanceof BasicDataSource) {
|
||||
((BasicDataSource) dataSource).close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
@ -86,7 +86,7 @@ public class ConnectionLog {
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Entry o) {
|
||||
return -Long.compare(this.timeSent, o.timeSent);
|
||||
return Long.compare(o.timeSent, this.timeSent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer<PlanSponge> {
|
||||
*
|
||||
* @return amount of entities
|
||||
*/
|
||||
protected int getEntityCount() {
|
||||
private int getEntityCount() {
|
||||
return Sponge.getGame().getServer().getWorlds().stream().mapToInt(world -> world.getEntities().size()).sum();
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class PlayerPageHandler extends PageHandler {
|
||||
try {
|
||||
if (Database.getActive().check().isPlayerRegistered(uuid)) {
|
||||
Response response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid));
|
||||
if (response == null || !(response instanceof InspectPageResponse)) {
|
||||
if (!(response instanceof InspectPageResponse)) {
|
||||
InfoSystem.getInstance().generateAndCachePlayerPage(uuid);
|
||||
response = ResponseCache.loadResponse(PageId.PLAYER.of(uuid));
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ public class PlayersPageResponse extends Response {
|
||||
PlanSystem system = PlanSystem.getInstance();
|
||||
PlanPlugin plugin = PlanPlugin.getInstance();
|
||||
Database db = system.getDatabaseSystem().getActiveDatabase();
|
||||
List<String> names = new ArrayList<>(db.fetch().getPlayerNames().values());
|
||||
Collections.sort(names);
|
||||
Map<String, String> replace = new HashMap<>();
|
||||
if (Check.isBukkitAvailable()) {
|
||||
replace.put("networkName", Settings.SERVER_NAME.toString().replaceAll("[^a-zA-Z0-9_\\s]", "_"));
|
||||
@ -48,7 +46,7 @@ public class PlayersPageResponse extends Response {
|
||||
replace.put("playersTable", buildPlayersTable(db));
|
||||
replace.put("version", plugin.getVersion());
|
||||
super.setContent(Theme.replaceColors(StringSubstitutor.replace(FileUtil.getStringFromResource("web/players.html"), replace)));
|
||||
} catch (DBException | IOException e) {
|
||||
} catch (IOException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
setContent(new InternalErrorResponse("/players", e).getContent());
|
||||
}
|
||||
@ -57,8 +55,11 @@ public class PlayersPageResponse extends Response {
|
||||
private String buildPlayersTable(Database db) {
|
||||
try {
|
||||
List<UserInfo> users = new ArrayList<>(db.fetch().getUsers().values());
|
||||
users.sort(new UserInfoLastPlayedComparator());
|
||||
|
||||
Map<UUID, Long> lastSeenForAllPlayers = db.fetch().getLastSeenForAllPlayers();
|
||||
users.forEach(user -> user.setLastSeen(lastSeenForAllPlayers.getOrDefault(user.getUuid(), 0L)));
|
||||
users.sort(new UserInfoLastPlayedComparator());
|
||||
|
||||
Map<UUID, List<Session>> sessionsByUser = AnalysisUtils.sortSessionsByUser(db.fetch().getSessionsWithNoExtras());
|
||||
Map<UUID, List<GeoInfo>> geoInfos = db.fetch().getAllGeoInfo();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user