From c1c77b55a813584e4ab3723f6f77aa9c28fc037f Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 11 May 2017 20:56:31 +0300 Subject: [PATCH] Bugfixes Fix #87 Fix #85 Fix #81 Added suggestion for changing green colors from #65 --- .../src/main/java/com/djrapitops/plan/Settings.java | 5 +++++ .../plan/data/listeners/PlanDeathEventListener.java | 13 ++++++++++++- .../com/djrapitops/plan/ui/webserver/Response.java | 4 ++-- .../com/djrapitops/plan/utilities/ManageUtils.java | 5 +++-- .../djrapitops/plan/utilities/PlaceholderUtils.java | 9 ++++++++- Plan/src/main/resources/config.yml | 6 ++++++ 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/Settings.java b/Plan/src/main/java/com/djrapitops/plan/Settings.java index 691fe082d..1f035ce55 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Settings.java +++ b/Plan/src/main/java/com/djrapitops/plan/Settings.java @@ -45,6 +45,11 @@ public enum Settings { COLOR_SEC("Customization.Colors.Commands.Secondary"), COLOR_TER("Customization.Colors.Commands.Highlight"), // + HCOLOR_MAIN("Customization.HTML.UI.Main"), + HCOLOR_MAIN_DARK("Customization.HTML.UI.MainDark"), + HCOLOR_SEC("Customization.HTML.UI.Secondary"), + HCOLOR_TER("Customization.HTML.UI.Tertiary"), + HCOLOR_TER_DARK("Customization.HTML.UI.TertiaryDark"), HCOLOR_ACT_ONL("Customization.Colors.HTML.ActivityGraph.OnlinePlayers"), HCOLOR_ACT_ONL_FILL("Customization.Colors.HTML.ActivityGraph.OnlinePlayersFill"), HCOLOR_ACTP_ACT("Customization.Colors.HTML.ActivityPie.Active"), diff --git a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java index 4464054e1..9f2f87027 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanDeathEventListener.java @@ -5,6 +5,7 @@ import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.cache.DataCacheHandler; import main.java.com.djrapitops.plan.data.handling.info.DeathInfo; import main.java.com.djrapitops.plan.data.handling.info.KillInfo; +import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -42,7 +43,17 @@ public class PlanDeathEventListener implements Listener { Player killer = dead.getKiller(); boolean killerIsPlayer = killer != null; if (killerIsPlayer) { - handler.addToPool(new KillInfo(killer.getUniqueId(), time, dead, killer.getInventory().getItemInMainHand().getType().name())); + Material itemInHand; + try { + itemInHand = killer.getInventory().getItemInMainHand().getType(); + } catch (Throwable e) { + try { + itemInHand = killer.getInventory().getItemInHand().getType(); + } catch (Throwable e2) { + itemInHand = Material.AIR; + } + } + handler.addToPool(new KillInfo(killer.getUniqueId(), time, dead, itemInHand.name())); } if (dead instanceof Player) { handler.addToPool(new DeathInfo(((Player) dead).getUniqueId())); 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 abdc8e7fc..aeb6c6943 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 @@ -81,7 +81,7 @@ public class Response { try { String dataHtml = requestHandler.getInspectHtml(uuid); String htmlDef = "HTTP/1.1 200 OK\r\n" - + "Content-Type: text/html; charset=utf-8\r\n" + + "Content-Type: text/html;\r\n" + "Content-Length: " + dataHtml.length() + "\r\n" + "\r\n"; output.write((htmlDef + dataHtml).getBytes()); @@ -101,7 +101,7 @@ public class Response { if (requestHandler.checkIfAnalysisIsCached()) { String analysisHtml = requestHandler.getAnalysisHtml(); String htmlDef = "HTTP/1.1 200 OK\r\n" - + "Content-Type: text/html; charset=utf-8\r\n" + + "Content-Type: text/html;\r\n" + "Content-Length: " + analysisHtml.length() + "\r\n" + "\r\n"; output.write((htmlDef + analysisHtml).getBytes()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java index a6ba4e1f9..f80921c1f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java @@ -41,7 +41,8 @@ public class ManageUtils { final Collection uuids = ManageUtils.getUUIDS(copyFromDB); if (uuids.isEmpty()) { return false; - } + } + backupDB.init(); return clearAndCopy(backupDB, copyFromDB, uuids); } @@ -58,7 +59,7 @@ public class ManageUtils { for (UUID uuid : onTimeData.keySet()) { OfflinePlayer player = getOfflinePlayer(uuid); if (!plugin.getDB().wasSeenBefore(uuid)) { - + handler.newPlayer(player); } DBCallableProcessor importer = new DBCallableProcessor() { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java index 663afe9ab..640ed2423 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java @@ -112,6 +112,13 @@ public class PlaceholderUtils { String pluginsTabHtml = plugin.getHookHandler().getPluginsTabLayoutForAnalysis(); String replacedOnce = HtmlUtils.replacePlaceholders(pluginsTabHtml, data.getAdditionalDataReplaceMap()); replaceMap.put("%plugins%", HtmlUtils.replacePlaceholders(replacedOnce, data.getAdditionalDataReplaceMap())); + String[] colors = new String[]{Settings.HCOLOR_MAIN.toString(), Settings.HCOLOR_MAIN_DARK.toString(), Settings.HCOLOR_SEC.toString(), Settings.HCOLOR_TER.toString(), Settings.HCOLOR_TER_DARK.toString()}; + String[] defaultCols = new String[]{"348e0f", "267F00", "5cb239", "89c471", "5da341"}; + for (int i = 0; i < colors.length; i++) { + if (!defaultCols[i].equals(colors[i])) { + replaceMap.put("#"+defaultCols[i], "#"+colors[i]); + } + } return replaceMap; } @@ -194,7 +201,7 @@ public class PlaceholderUtils { String pluginsTabHtml = plugin.getHookHandler().getPluginsTabLayoutForInspect(); Map additionalReplaceRules = plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid); String replacedOnce = HtmlUtils.replacePlaceholders(pluginsTabHtml, additionalReplaceRules); - replaceMap.put("%plugins%", HtmlUtils.replacePlaceholders(replacedOnce, additionalReplaceRules)); + replaceMap.put("%plugins%", HtmlUtils.replacePlaceholders(replacedOnce, additionalReplaceRules)); return replaceMap; } } diff --git a/Plan/src/main/resources/config.yml b/Plan/src/main/resources/config.yml index 7143cc91e..2b2bf1f93 100644 --- a/Plan/src/main/resources/config.yml +++ b/Plan/src/main/resources/config.yml @@ -38,6 +38,12 @@ Customization: Secondary: '&7' Highlight: '&f' HTML: + UI: + Main: 348e0f + MainDark: 267F00 + Secondary: 5cb239 + Tertiary: 89c471 + TertiaryDark: 5da341 ActivityGraph: OnlinePlayers: '1E90FF' OnlinePlayersFill: '75BBFF'