diff --git a/Plan/src/main/java/com/djrapitops/plan/Phrase.java b/Plan/src/main/java/com/djrapitops/plan/Phrase.java index 5c406baa9..1623c3ef1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Phrase.java +++ b/Plan/src/main/java/com/djrapitops/plan/Phrase.java @@ -73,6 +73,7 @@ public enum Phrase { ANALYSIS_FAIL_NO_DATA(ANALYSIS + "Analysis failed, no data in the database."), ANALYSIS_BEGIN_ANALYSIS(ANALYSIS + "Data Fetched, beginning Analysis of data.."), ANALYSIS_COMPLETE(ANALYSIS + "Analysis Complete."), + DATA_CORRUPTION_WARN("Some data might be corrupted: "+REPLACE0), // ERROR_PLANLITE("PlanLite not found, if you're have plugins using PlanAPI v1.6.0 download PlanLite."), ERROR_CONSOLE_PLAYER("This point of code should not be accessable on console. Inform author: "+REPLACE0+" Console: REPLACE1"), diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index 22381df6f..fb3efdfb1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -9,7 +9,7 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. +* License for more details. * * You should have received a copy of the License * along with this program. @@ -51,22 +51,15 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -/* TODO 2.5.0 +/* TODO 2.6.0 Placeholder API Database cleaning Play session lenght -- Existing data -- importing - Kills & Deaths 50% - - DB saving & Alter tables Location Analysis to view meaningful locations on Dynmap (Investigate dynmap api) Integrate PlanLite features to Plan and discontinue PlanLite Seperate serverdata and userdata saving Database Cleaning of useless data Fix any bugs that come up - Localization - - Combine the two locale files - Security */ /** * diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index d68659cd2..18842d85f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -80,7 +80,7 @@ public class AnalyzeCommand extends SubCommand { sendAnalysisMessage(sender); this.cancel(); } - if (timesrun > 45) { + if (timesrun > 10) { sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Analysis")); this.cancel(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index 675b160c2..3f8742b66 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -125,7 +125,7 @@ public class InspectCommand extends SubCommand { sender.sendMessage(Phrase.CMD_FOOTER+""); this.cancel(); } - if (timesrun > 45) { + if (timesrun > 10) { sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Inspect")); this.cancel(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index 8b13b8696..94df1ae20 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -515,7 +515,6 @@ public abstract class SQLDB extends Database { statement.setString(1, "" + userId); statement.execute(); statement.close(); - statement = connection.prepareStatement("DELETE FROM " + nicknamesName + " WHERE UPPER(" + nicknamesColumnUserID + ") LIKE UPPER(?)"); statement.setString(1, "" + userId); statement.execute(); @@ -524,7 +523,7 @@ public abstract class SQLDB extends Database { statement.setString(1, "" + userId); statement.execute(); statement.close(); - statement = connection.prepareStatement("DELETE FROM " + ipsName + " WHERE UPPER(" + ipsColumnIP + ") LIKE UPPER(?)"); + statement = connection.prepareStatement("DELETE FROM " + ipsName + " WHERE UPPER(" + ipsColumnUserID + ") LIKE UPPER(?)"); statement.setString(1, "" + userId); statement.execute(); statement.close(); diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/Response.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/Response.java index 88fd9817a..eced0d683 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/Response.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/Response.java @@ -50,7 +50,7 @@ public class Response { } else { securityCode = requestArgs[1]; } - if (!securityCode.equals(Settings.SECURITY_CODE+"")) { + if (!securityCode.equals(Settings.SECURITY_CODE + "")) { forbidden = true; } if (forbidden) { @@ -77,12 +77,22 @@ public class Response { return; } if (requestHandler.checkIfCached(uuid)) { - String dataHtml = requestHandler.getDataHtml(uuid); - String htmlDef = "HTTP/1.1 OK\r\n" - + "Content-Type: text/html; charset=utf-8\r\n" - + "Content-Length: " + dataHtml.length() + "\r\n" - + "\r\n"; - output.write((htmlDef + dataHtml).getBytes()); + try { + String dataHtml = requestHandler.getDataHtml(uuid); + String htmlDef = "HTTP/1.1 OK\r\n" + + "Content-Type: text/html; charset=utf-8\r\n" + + "Content-Length: " + dataHtml.length() + "\r\n" + + "\r\n"; + output.write((htmlDef + dataHtml).getBytes()); + } catch (NullPointerException e) { + e.printStackTrace(); + String errorMessage = "HTTP/1.1 404 Error\r\n" + + "Content-Type: text/html;\r\n" + + "Content-Length: 30\r\n" + + "\r\n" + + "

404 - Error has occurred..

"; + output.write(errorMessage.getBytes()); + } return; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java index 0ff89f774..b88ac2dc8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java @@ -116,7 +116,7 @@ public class Analysis { long totalKills = 0; long totalMobKills = 0; long totalDeaths = 0; - + int ops = 0; List ages = new ArrayList<>(); @@ -131,60 +131,64 @@ public class Analysis { HashMap playtimes = new HashMap<>(); // Fill Dataset with userdata. for (UserData uData : rawData) { - if (planLiteEnabled) { - PlanLitePlayerData litePlayerData = uData.getPlanLiteData(); - String town = litePlayerData.getTown(); - if (!townMap.containsKey(town)) { - townMap.put(town, 0); - } - townMap.replace(town, townMap.get(town) + 1); - String faction = litePlayerData.getFaction(); - if (!factionMap.containsKey(faction)) { - factionMap.put(faction, 0); - } - factionMap.replace(faction, factionMap.get(faction) + 1); - totalVotes += litePlayerData.getVotes(); - totalMoney += litePlayerData.getMoney(); - } - HashMap gmTimes = uData.getGmTimes(); - gmZero += gmTimes.get(GameMode.SURVIVAL); - gmOne += gmTimes.get(GameMode.CREATIVE); - gmTwo += gmTimes.get(GameMode.ADVENTURE); try { - Long gm = gmTimes.get(GameMode.SPECTATOR); - if (gm != null) { - gmThree += gm; + if (planLiteEnabled) { + PlanLitePlayerData litePlayerData = uData.getPlanLiteData(); + String town = litePlayerData.getTown(); + if (!townMap.containsKey(town)) { + townMap.put(town, 0); + } + townMap.replace(town, townMap.get(town) + 1); + String faction = litePlayerData.getFaction(); + if (!factionMap.containsKey(faction)) { + factionMap.put(faction, 0); + } + factionMap.replace(faction, factionMap.get(faction) + 1); + totalVotes += litePlayerData.getVotes(); + totalMoney += litePlayerData.getMoney(); } - } catch (NoSuchFieldError e) { - } - long playTime = uData.getPlayTime(); - totalPlaytime += playTime; - String playerName = uData.getName(); - String url = HtmlUtils.getInspectUrl(playerName); - String html = Html.BUTTON.parse(url, playerName); + HashMap gmTimes = uData.getGmTimes(); + gmZero += gmTimes.get(GameMode.SURVIVAL); + gmOne += gmTimes.get(GameMode.CREATIVE); + gmTwo += gmTimes.get(GameMode.ADVENTURE); + try { + Long gm = gmTimes.get(GameMode.SPECTATOR); + if (gm != null) { + gmThree += gm; + } + } catch (NoSuchFieldError e) { + } + long playTime = uData.getPlayTime(); + totalPlaytime += playTime; + String playerName = uData.getName(); + String url = HtmlUtils.getInspectUrl(playerName); + String html = Html.BUTTON.parse(url, playerName); - latestLogins.put(html, uData.getLastPlayed()); - totalLoginTimes += uData.getLoginTimes(); - int age = uData.getDemData().getAge(); - if (age != -1) { - ages.add(age); + latestLogins.put(html, uData.getLastPlayed()); + totalLoginTimes += uData.getLoginTimes(); + int age = uData.getDemData().getAge(); + if (age != -1) { + ages.add(age); + } + if (uData.isOp()) { + ops++; + } + if (uData.isBanned()) { + totalBanned++; + } else if (uData.getLoginTimes() == 1) { + joinleaver++; + } else if (AnalysisUtils.isActive(uData.getLastPlayed(), playTime, uData.getLoginTimes())) { + active++; + playtimes.put(html, playTime); + } else { + inactive++; + } + totalKills += uData.getPlayerKills(); + totalMobKills += uData.getMobKills(); + totalDeaths += uData.getDeaths(); + } catch (NullPointerException e) { + plugin.logError(Phrase.DATA_CORRUPTION_WARN.parse(uData.getUuid()+"")); } - if (uData.isOp()) { - ops++; - } - if (uData.isBanned()) { - totalBanned++; - } else if (uData.getLoginTimes() == 1) { - joinleaver++; - } else if (AnalysisUtils.isActive(uData.getLastPlayed(), playTime, uData.getLoginTimes())) { - active++; - playtimes.put(html, playTime); - } else { - inactive++; - } - totalKills += uData.getPlayerKills(); - totalMobKills += uData.getMobKills(); - totalDeaths += uData.getDeaths(); } // Save Dataset to AnalysisData @@ -204,7 +208,7 @@ public class Analysis { analyzeAverageAge(ages, data); createGamemodeUsageVisualization(gmZero, gmOne, gmTwo, gmThree, data); createCommandUseTable(data); - + data.setTotaldeaths(totalDeaths); data.setTotalkills(totalKills); data.setTotalmobkills(totalMobKills); diff --git a/Plan/src/main/resources/plugin.yml b/Plan/src/main/resources/plugin.yml index c983bc37c..e005e4258 100644 --- a/Plan/src/main/resources/plugin.yml +++ b/Plan/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Plan author: Rsl1122 main: com.djrapitops.plan.Plan -version: 2.5.0 +version: 2.5.1 commands: plan: