From a9341bf1e83bc6be08d404ffebc2fda068d8951c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 26 Aug 2017 19:00:45 +0300 Subject: [PATCH] 2.0.4 --- AbstractPluginFramework/pom.xml | 2 +- .../com/djrapitops/plugin/BukkitPlugin.java | 8 --- .../com/djrapitops/plugin/BungeePlugin.java | 8 --- .../java/com/djrapitops/plugin/IPlugin.java | 3 - .../com/djrapitops/plugin/StaticHolder.java | 2 +- .../command/defaultcmds/StatusCommand.java | 14 ++-- .../plugin/utilities/NotificationCenter.java | 10 ++- .../plugin/utilities/log/BukkitLog.java | 2 - .../plugin/utilities/log/BungeeLog.java | 2 - .../plugin/utilities/log/DebugInfo.java | 7 ++ .../plugin/utilities/log/PluginLog.java | 4 ++ .../utilities/status/ProcessStatus.java | 70 ------------------- 12 files changed, 23 insertions(+), 109 deletions(-) delete mode 100644 AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/status/ProcessStatus.java diff --git a/AbstractPluginFramework/pom.xml b/AbstractPluginFramework/pom.xml index eb9cf4a..6de62dd 100644 --- a/AbstractPluginFramework/pom.xml +++ b/AbstractPluginFramework/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.djrapitops AbstractPluginFramework - 2.0.3 + 2.0.4 jar UTF-8 diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BukkitPlugin.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BukkitPlugin.java index c3f1743..c777020 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BukkitPlugin.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BukkitPlugin.java @@ -11,7 +11,6 @@ import com.djrapitops.plugin.utilities.log.BukkitLog; import com.djrapitops.plugin.utilities.log.PluginLog; import com.djrapitops.plugin.utilities.player.Fetch; -import com.djrapitops.plugin.utilities.status.ProcessStatus; import com.djrapitops.plugin.utilities.status.TaskStatus; import org.bukkit.ChatColor; import org.bukkit.event.Listener; @@ -47,7 +46,6 @@ public abstract class BukkitPlugin extends JavaPlugin im private String debugMode = "false"; private ColorScheme colorScheme = new ColorScheme(ChatColor.WHITE, ChatColor.GRAY, ChatColor.DARK_GRAY); - private final ProcessStatus progressStat; private final TaskStatus taskStat; private final BenchUtil benchmark; private PluginLog log; @@ -62,7 +60,6 @@ public BukkitPlugin() { } catch (IOException e) { e.printStackTrace(); } - progressStat = new ProcessStatus(this); taskStat = new TaskStatus(this); benchmark = new BenchUtil(this); factory = new RunnableFactory(this); @@ -179,11 +176,6 @@ public void setLog(PluginLog log) { this.log = log; } - @Override - public ProcessStatus processStatus() { - return progressStat; - } - @Override public TaskStatus taskStatus() { return taskStat; diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BungeePlugin.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BungeePlugin.java index 3971a47..07ec5ee 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BungeePlugin.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/BungeePlugin.java @@ -10,7 +10,6 @@ import com.djrapitops.plugin.utilities.log.BungeeLog; import com.djrapitops.plugin.utilities.log.PluginLog; import com.djrapitops.plugin.utilities.player.Fetch; -import com.djrapitops.plugin.utilities.status.ProcessStatus; import com.djrapitops.plugin.utilities.status.TaskStatus; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.plugin.Listener; @@ -36,7 +35,6 @@ public abstract class BungeePlugin extends Plugin implem private String debugMode = "false"; private ColorScheme colorScheme = new ColorScheme(ChatColor.WHITE, ChatColor.GRAY, ChatColor.DARK_GRAY); - private final ProcessStatus progressStat; private final TaskStatus taskStat; private final BenchUtil benchmark; private PluginLog log; @@ -51,7 +49,6 @@ public BungeePlugin() { } catch (IOException e) { e.printStackTrace(); } - progressStat = new ProcessStatus(this); taskStat = new TaskStatus(this); benchmark = new BenchUtil(this); factory = new RunnableFactory(this); @@ -167,11 +164,6 @@ public void setLog(PluginLog log) { this.log = log; } - @Override - public ProcessStatus processStatus() { - return progressStat; - } - @Override public TaskStatus taskStatus() { return taskStat; diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/IPlugin.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/IPlugin.java index a1f3531..3be5ea8 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/IPlugin.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/IPlugin.java @@ -7,7 +7,6 @@ import com.djrapitops.plugin.utilities.NotificationCenter; import com.djrapitops.plugin.utilities.log.PluginLog; import com.djrapitops.plugin.utilities.player.Fetch; -import com.djrapitops.plugin.utilities.status.ProcessStatus; import com.djrapitops.plugin.utilities.status.TaskStatus; /** @@ -22,8 +21,6 @@ public interface IPlugin { void onEnableDefaultTasks(); - ProcessStatus processStatus(); - TaskStatus taskStatus(); String getVersion(); diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/StaticHolder.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/StaticHolder.java index c92e357..fa6d2ca 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/StaticHolder.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/StaticHolder.java @@ -10,7 +10,7 @@ */ public class StaticHolder { - private static final String apfVersion = "2.0.3"; + private static final String apfVersion = "2.0.4"; private static final Map INSTANCES_BUKKIT = new HashMap<>(); private static final Map INSTANCES_BUNGEE = new HashMap<>(); private static Class utilityProvider = null; diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/command/defaultcmds/StatusCommand.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/command/defaultcmds/StatusCommand.java index 7cd2d85..3d9c1b7 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/command/defaultcmds/StatusCommand.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/command/defaultcmds/StatusCommand.java @@ -7,11 +7,12 @@ import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.DefaultMessages; import com.djrapitops.plugin.utilities.NotificationCenter; -import com.djrapitops.plugin.utilities.status.ProcessStatus; +import com.djrapitops.plugin.utilities.log.DebugInfo; import com.djrapitops.plugin.utilities.status.TaskStatus; import java.util.Arrays; import java.util.List; +import java.util.Map; /** * A Default Command for displaying plugin's task, process and benchmark status. @@ -55,18 +56,15 @@ public boolean onCommand(ISender sender, String commandLabel, String[] args) { sender.sendMessage(" " + notification.replace(plugin.getPrefix() + " ", "")); } } - - TaskStatus taskStatus = plugin.taskStatus(); - ProcessStatus processStatus = plugin.processStatus(); + sender.sendMessage(sColor + " " + DefaultMessages.BALL.toString() + oColor + " Tasks running: " + sColor + taskStatus.getTaskCount()); sender.sendMessage(sColor + " " + DefaultMessages.BALL.toString() + oColor + " Processes: "); - Arrays.stream(processStatus.getProcesses()) - .map(process -> tColor + " " + process) - .forEach(sender::sendMessage); + Map debugs = plugin.getPluginLogger().getAllDebugs(); + debugs.entrySet().forEach(entry -> sender.sendMessage(tColor + " " + entry.getKey() + ": " + entry.getValue().getLastLine())); sender.sendMessage(sColor + " " + DefaultMessages.BALL.toString() + oColor + " Tasks: "); Arrays.stream(taskStatus.getTasks()) - .map(process -> tColor + " " + process) + .map(task -> tColor + " " + task) .forEach(sender::sendMessage); sender.sendMessage(tColor + DefaultMessages.ARROWS_RIGHT.parse()); return true; diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/NotificationCenter.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/NotificationCenter.java index 343cdd3..249fa1c 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/NotificationCenter.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/NotificationCenter.java @@ -34,12 +34,10 @@ public void addNotification(Priority priority, String message) { } public void checkNotifications(IPlayer player) { - if (!player.isOp() || player.hasPermission("apf.notify")) { - return; - } - - for (String msg : getNotifications()) { - player.sendMessage(msg); + if (player.isOp() || player.hasPermission("apf.notify")) { + for (String msg : getNotifications()) { + player.sendMessage(msg); + } } } diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BukkitLog.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BukkitLog.java index 36cb13b..016e453 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BukkitLog.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BukkitLog.java @@ -1,10 +1,8 @@ package com.djrapitops.plugin.utilities.log; import com.djrapitops.plugin.BukkitPlugin; -import com.djrapitops.plugin.utilities.status.ProcessStatus; import org.bukkit.command.ConsoleCommandSender; -import java.io.File; import java.io.IOException; /** diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BungeeLog.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BungeeLog.java index f0e1bab..10edb83 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BungeeLog.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/BungeeLog.java @@ -1,9 +1,7 @@ package com.djrapitops.plugin.utilities.log; import com.djrapitops.plugin.BungeePlugin; -import com.djrapitops.plugin.utilities.status.ProcessStatus; -import java.io.File; import java.io.IOException; /** diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/DebugInfo.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/DebugInfo.java index 7977e38..2e0f583 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/DebugInfo.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/DebugInfo.java @@ -91,4 +91,11 @@ private String getFooter(Long time) { } return footer.toString(); } + + public String getLastLine() { + if (msg.isEmpty()) { + return "No information."; + } + return msg.get(msg.size() - 1); + } } diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/PluginLog.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/PluginLog.java index d7c790f..849b464 100644 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/PluginLog.java +++ b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/log/PluginLog.java @@ -241,4 +241,8 @@ public void setPrefix(String prefix) { public ErrorLogManager getErrorLogManager() { return errorLogManager; } + + public Map getAllDebugs() { + return debugInfoMap; + } } diff --git a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/status/ProcessStatus.java b/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/status/ProcessStatus.java deleted file mode 100644 index bd129ee..0000000 --- a/AbstractPluginFramework/src/main/java/com/djrapitops/plugin/utilities/status/ProcessStatus.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.djrapitops.plugin.utilities.status; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import com.djrapitops.plugin.IPlugin; -import com.djrapitops.plugin.utilities.BenchUtil; -import com.djrapitops.plugin.utilities.FormattingUtils; - -/** - * - * @author Rsl1122 - * @param - */ -@Deprecated -public class ProcessStatus { - - private final T plugin; - private final Map status; - - @Deprecated - public ProcessStatus(T plugin) { - status = new HashMap<>(); - this.plugin = plugin; - } - - @Deprecated - public String getStatus(String process) { - final String state = status.get(process); - if (state == null) { - return "Process not running."; - } - return state; - } - - @Deprecated - public void setStatus(String process, String state) { - status.put(process, state); - } - - @Deprecated - public void startExecution(String process) { - BenchUtil benchmark = plugin.benchmark(); - benchmark.start(process); - setStatus(process, "Started: " + FormattingUtils.formatTimeStampSecond(BenchUtil.getTime())); - } - - @Deprecated - public long finishExecution(String process) { - if (!status.containsKey(process)) { - return -1; - } - BenchUtil benchmark = plugin.benchmark(); - long ms = benchmark.stop(process); - setStatus(process, "Finished (" + FormattingUtils.formatTimeStampSecond(BenchUtil.getTime()) + "), took: " + ms + "ms"); - return ms; - } - - @Deprecated - public String[] getProcesses() { - String[] states = new String[status.size()]; - List processes = new ArrayList<>(status.keySet()); - for (int i = 0; i < status.size(); i++) { - String process = processes.get(i); - states[i] = process + ": " + status.get(process); - } - return states; - } -}