From 63f8482c4b9defaba7f6a2fee252a890d21779f0 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 21 Sep 2017 13:34:02 +0300 Subject: [PATCH] Fixed UserInfoTable being cleared on V8->10 transfer --- .../djrapitops/plan/database/tables/SessionsTable.java | 3 ++- .../database/tables/move/Version8TransferTable.java | 5 +++-- .../plan/systems/info/parsing/InspectPageParser.java | 10 ++++++++-- .../plan/systems/webserver/webapi/WebAPI.java | 6 +++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java index 5aece2ecc..0c8ca50c6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java @@ -299,7 +299,8 @@ public class SessionsTable extends UserIDTable { columnServerID + " FROM " + tableName + " WHERE " + columnSessionStart + ">?" + - " AND " + columnUserID + "=" + usersTable.statementSelectID); + " AND " + columnUserID + "=" + usersTable.statementSelectID + + " GROUP BY " + columnServerID); statement.setLong(1, afterDate); statement.setString(2, uuid.toString()); set = statement.executeQuery(); diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/Version8TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/move/Version8TransferTable.java index 5ad5d4601..d47cc8f78 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/move/Version8TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/move/Version8TransferTable.java @@ -54,6 +54,7 @@ public class Version8TransferTable extends Table { copyTPS(); + execute(dropTableSql("plan_user_info")); copyUsers(); execute(dropTableSql("plan_ips")); @@ -62,10 +63,10 @@ public class Version8TransferTable extends Table { execute(dropTableSql("plan_worlds")); db.getWorldTable().createTable(); db.getWorldTimesTable().createTable(); - execute(dropTableSql("plan_user_info")); + execute(dropTableSql("plan_actions")); db.getActionsTable().createTable(); - db.getUserInfoTable().createTable(); + execute(dropTableSql("plan_gamemodetimes")); execute(dropTableSql("temp_nicks")); execute(dropTableSql("temp_kills")); diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index 91869c73f..f8e927dae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -63,8 +63,13 @@ public class InspectPageParser extends PageParser { addValue("version", MiscUtils.getPlanVersion()); addValue("timeZone", MiscUtils.getTimeZoneOffsetHours()); - addValue("playerName", userInfo.getName()); - addValue("registered", FormatUtils.formatTimeStampYear(userInfo.getRegistered())); + if (userInfo != null) { + addValue("playerName", userInfo.getName()); + addValue("registered", FormatUtils.formatTimeStampYear(userInfo.getRegistered())); + } else { + addValue("playerName", "Error occurred."); + addValue("registered", "Error occurred."); + } long lastSeen = sessionsTable.getLastSeen(uuid); if (lastSeen != 0) { addValue("lastSeen", FormatUtils.formatTimeStampYear(lastSeen)); @@ -171,6 +176,7 @@ public class InspectPageParser extends PageParser { return HtmlUtils.replacePlaceholders(FileUtil.getStringFromResource("player.html"), placeHolders); } catch (Exception e) { + Log.toLog(this.getClass().getName(), e); throw new ParseException(e); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java index 56259faf3..e16003423 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/webserver/webapi/WebAPI.java @@ -166,7 +166,11 @@ public abstract class WebAPI { } protected Response fail(String reason) { - return PageCache.loadPage("fail", () -> new NotFoundResponse(reason)); + return PageCache.loadPage("fail", () -> { + NotFoundResponse notFoundResponse = new NotFoundResponse(""); + notFoundResponse.setContent(reason); + return notFoundResponse; + }); } protected Response badRequest(String error) {