mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-04-24 18:40:34 +08:00
[3.4.2] Merge pull request #121 from Rsl1122/Version-3.4.2-or-3.5.0
Version 3.4.2 Pull Request
This commit is contained in:
commit
35ea16e5fb
.github
Plan
pom.xml
src
main
java/com/djrapitops/plan
Log.javaPhrase.javaPlan.javaServerVariableHolder.javaSettings.java
api
command
data
additional
cache
handling/importing
database
databases
tables
ui
utilities
resources
test/java
main/java/com/djrapitops/plan
utils
36
.github/ISSUE_TEMPLATE
vendored
36
.github/ISSUE_TEMPLATE
vendored
@ -1,23 +1,41 @@
|
||||
Feel free to use the template below to report your issue, for suggestions you can use whatever works for you :)
|
||||
Remember to use the Preview button to ensure the errors are displayed properly
|
||||
|
||||
**Plan Version:**
|
||||
**Server Version:** eg. Paper-1.11.2 or Spigot-1.9.1
|
||||
**Database Type:**
|
||||
**Command Causing Issue:** (None if thrown without commands)
|
||||
If your issue is about a command timeout, please follow the instructions at the bottom of the issue template.
|
||||
|
||||
----
|
||||
|
||||
**Plan Version:** <Version>
|
||||
**Server Version:** <Server Version>
|
||||
**Database Type:** <Mysql/sqlite>
|
||||
|
||||
**Issue Caused by:** <Caused by>
|
||||
|
||||
----
|
||||
|
||||
**Description:**
|
||||
What happens & When does it happen
|
||||
|
||||
|
||||
**Steps to Reproduce:**
|
||||
|
||||
1. Do this
|
||||
2. Do something else
|
||||
1.
|
||||
2.
|
||||
|
||||
**Proposed Solution:**
|
||||
Possible proposed solution if you have one
|
||||
|
||||
**Stack Trace - Console/Errors.txt contents:**
|
||||
|
||||
----
|
||||
|
||||
**Console/Errors.txt/DebugLog.txt contents:**
|
||||
```
|
||||
Place any stack traces inside these symbols (```)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
Instructions for reporting timeout issues:
|
||||
|
||||
- Enable file debug mode by changing config setting "Debug" to "file"
|
||||
- Reload the plugin
|
||||
- Run the command that causes the timeout message to show
|
||||
- Copy the contents of DebugLog.txt inside the code brackets above
|
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>Plan</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.4.2</version>
|
||||
<packaging>jar</packaging>
|
||||
<repositories>
|
||||
<!-- <repository>
|
||||
|
@ -7,6 +7,7 @@ import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
/**
|
||||
* This class manages the messages going to the Bukkit's Logger.
|
||||
@ -16,6 +17,9 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
*/
|
||||
public class Log {
|
||||
|
||||
final private static String DEBUG = "DebugLog.txt";
|
||||
final private static String ERRORS = "Errors.txt";
|
||||
|
||||
/**
|
||||
* Logs the message to the console as INFO.
|
||||
*
|
||||
@ -26,6 +30,14 @@ public class Log {
|
||||
if (instance != null) {
|
||||
instance.getLogger().info(message);
|
||||
}
|
||||
if (!message.contains("[DEBUG]")) {
|
||||
debug(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void infoColor(String message) {
|
||||
ConsoleCommandSender consoleSender = Plan.getInstance().getServer().getConsoleSender();
|
||||
consoleSender.sendMessage(Phrase.PREFIX + message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,9 +58,16 @@ public class Log {
|
||||
* @param message "Message" will show up as [INFO][Plan]: [DEBUG] Message
|
||||
*/
|
||||
public static void debug(String message) {
|
||||
if (Settings.DEBUG.isTrue()) {
|
||||
String debugMode = Settings.DEBUG.toString().toLowerCase();
|
||||
boolean both = debugMode.equals("true") || debugMode.equals("both");
|
||||
boolean logConsole = Settings.DEBUG.isTrue() || both || debugMode.equals("console");
|
||||
boolean logFile = debugMode.equals("file") || both;
|
||||
if (logConsole) {
|
||||
info("[DEBUG] " + message);
|
||||
}
|
||||
if (logFile) {
|
||||
toLog(message, DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,11 +78,11 @@ public class Log {
|
||||
*/
|
||||
public static void toLog(String source, Throwable e) {
|
||||
error(Phrase.ERROR_LOGGED.parse(e.toString()));
|
||||
toLog(source + " Caught " + e);
|
||||
toLog(source + " Caught " + e, ERRORS);
|
||||
for (StackTraceElement x : e.getStackTrace()) {
|
||||
toLog(" " + x);
|
||||
toLog(" " + x, ERRORS);
|
||||
}
|
||||
toLog("");
|
||||
toLog("", ERRORS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,12 +98,15 @@ public class Log {
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message to the Errors.txt with a timestamp.
|
||||
* Logs a message to the a given file with a timestamp.
|
||||
*
|
||||
* @param message Message to log to Errors.txt [timestamp] Message
|
||||
* @param filename Name of the file to write to.
|
||||
*/
|
||||
public static void toLog(String message) {
|
||||
Log.debug(message);
|
||||
public static void toLog(String message, String filename) {
|
||||
if (filename.equals(ERRORS)) {
|
||||
Log.debug(message);
|
||||
}
|
||||
Plan plan = Plan.getInstance();
|
||||
if (plan == null) {
|
||||
return;
|
||||
@ -93,19 +115,23 @@ public class Log {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdir();
|
||||
}
|
||||
File log = new File(folder, "Errors.txt");
|
||||
File log = new File(folder, filename);
|
||||
try {
|
||||
if (!log.exists()) {
|
||||
log.createNewFile();
|
||||
}
|
||||
FileWriter fw = new FileWriter(log, true);
|
||||
try (PrintWriter pw = new PrintWriter(fw)) {
|
||||
String timestamp = FormatUtils.formatTimeStamp(MiscUtils.getTime());
|
||||
String timestamp = FormatUtils.formatTimeStampSecond(MiscUtils.getTime());
|
||||
pw.println("[" + timestamp + "] " + message);
|
||||
pw.flush();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plan.getLogger().severe("Failed to create Errors.txt file");
|
||||
Log.error("Failed to create" + filename + "file");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getErrorsFilename() {
|
||||
return ERRORS;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,11 @@ public enum Phrase {
|
||||
DB_TYPE_DOES_NOT_EXIST("That database type doesn't exist."),
|
||||
DB_FAILURE_DISABLE("Database initialization has failed, disabling Plan."),
|
||||
NOTIFY_EMPTY_IP(ChatColor.YELLOW + "" + PREFIX + "IP in server.properties is empty & AlternativeServerIP is not used, incorrect links will be given!"),
|
||||
//
|
||||
NOTIFY_DISABLED_CHATLISTENER(ChatColor.YELLOW + "Chat listener disabled, nickname info inaccurate."),
|
||||
NOTIFY_DISABLED_GMLISTENER(ChatColor.YELLOW + "Gamemode change listener disabled, Gm times info inaccurate."),
|
||||
NOTIFY_DISABLED_COMMANDLISTENER(ChatColor.YELLOW + "Command usage listener disabled."),
|
||||
NOTIFY_DISABLED_DEATHLISTENER(ChatColor.YELLOW + "Death listener disabled, player & mob kills not recorded."),
|
||||
//
|
||||
CACHE_SAVETASK_DISABLED("Attempted to schedule data for save after task was shut down."),
|
||||
CACHE_GETTASK_DISABLED("Attempted to schedule data grab after task was shut down."),
|
||||
CACHE_CLEARTASK_DISABLED("Attempted to schedule data for clear after task was shut down."),
|
||||
@ -70,6 +74,7 @@ public enum Phrase {
|
||||
ANALYSIS_FAIL_NO_PLAYERS(ANALYSIS + "Analysis failed, no known players."),
|
||||
ANALYSIS_FAIL_NO_DATA(ANALYSIS + "Analysis failed, no data in the database."),
|
||||
ANALYSIS_BEGIN_ANALYSIS(ANALYSIS + "Data Fetched (REPLACE0 users, took REPLACE1ms), beginning Analysis of data.."),
|
||||
ANALYSIS_THIRD_PARTY(ANALYSIS+"Analyzing additional data sources (3rd party)"),
|
||||
ANALYSIS_COMPLETE(ANALYSIS + "Analysis Complete. (took REPLACE0ms) REPLACE1"),
|
||||
DATA_CORRUPTION_WARN("Some data might be corrupted: " + REPLACE0),
|
||||
//
|
||||
|
@ -40,7 +40,7 @@ import main.java.com.djrapitops.plan.ui.Html;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -83,7 +83,14 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
initLocale();
|
||||
|
||||
variable = new ServerVariableHolder(this);
|
||||
Server server = getServer();
|
||||
variable = new ServerVariableHolder(server);
|
||||
|
||||
Log.debug("-------------------------------------");
|
||||
Log.debug("Debug log, Server Start: Plan v."+getDescription().getVersion());
|
||||
Log.debug("Server: "+server.getBukkitVersion());
|
||||
Log.debug("Version: "+server.getVersion());
|
||||
Log.debug("-------------------------------------");
|
||||
|
||||
databases = new HashSet<>();
|
||||
databases.add(new MySQLDB(this));
|
||||
@ -100,7 +107,7 @@ public class Plan extends JavaPlugin {
|
||||
Log.info(Phrase.DB_ESTABLISHED.parse(db.getConfigName()));
|
||||
} else {
|
||||
Log.error(Phrase.DB_FAILURE_DISABLE.toString());
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
server.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -113,7 +120,6 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
this.api = new API(this);
|
||||
handler.handleReload();
|
||||
ConsoleCommandSender consoleSender = getServer().getConsoleSender();
|
||||
|
||||
bootAnalysisTaskID = -1;
|
||||
if (Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
@ -128,15 +134,15 @@ public class Plan extends JavaPlugin {
|
||||
}
|
||||
} else if (!(Settings.SHOW_ALTERNATIVE_IP.isTrue())
|
||||
|| (Settings.USE_ALTERNATIVE_UI.isTrue())) {
|
||||
consoleSender.sendMessage(Phrase.PREFIX + "" + Phrase.ERROR_NO_DATA_VIEW);
|
||||
Log.infoColor(Phrase.ERROR_NO_DATA_VIEW + "");
|
||||
}
|
||||
if (!Settings.SHOW_ALTERNATIVE_IP.isTrue() && getServer().getIp().isEmpty()) {
|
||||
consoleSender.sendMessage(Phrase.NOTIFY_EMPTY_IP + "");
|
||||
if (!Settings.SHOW_ALTERNATIVE_IP.isTrue() && server.getIp().isEmpty()) {
|
||||
Log.infoColor(Phrase.NOTIFY_EMPTY_IP + "");
|
||||
}
|
||||
|
||||
hookHandler = new HookHandler();
|
||||
|
||||
Log.debug("Verboose debug messages are enabled.");
|
||||
Log.debug("Verboose debug messages are enabled.");
|
||||
Log.info(Phrase.ENABLED + "");
|
||||
}
|
||||
|
||||
@ -165,11 +171,29 @@ public class Plan extends JavaPlugin {
|
||||
|
||||
private void registerListeners() {
|
||||
final PluginManager pluginManager = getServer().getPluginManager();
|
||||
pluginManager.registerEvents(new PlanChatListener(this), this);
|
||||
|
||||
pluginManager.registerEvents(new PlanPlayerListener(this), this);
|
||||
pluginManager.registerEvents(new PlanGamemodeChangeListener(this), this);
|
||||
pluginManager.registerEvents(new PlanCommandPreprocessListener(this), this);
|
||||
pluginManager.registerEvents(new PlanDeathEventListener(this), this);
|
||||
|
||||
if (Settings.GATHERCHAT.isTrue()) {
|
||||
pluginManager.registerEvents(new PlanChatListener(this), this);
|
||||
} else {
|
||||
Log.infoColor(Phrase.NOTIFY_DISABLED_CHATLISTENER + "");
|
||||
}
|
||||
if (Settings.GATHERGMTIMES.isTrue()) {
|
||||
pluginManager.registerEvents(new PlanGamemodeChangeListener(this), this);
|
||||
} else {
|
||||
Log.infoColor(Phrase.NOTIFY_DISABLED_GMLISTENER + "");
|
||||
}
|
||||
if (Settings.GATHERCOMMANDS.isTrue()) {
|
||||
pluginManager.registerEvents(new PlanCommandPreprocessListener(this), this);
|
||||
} else {
|
||||
Log.infoColor(Phrase.NOTIFY_DISABLED_COMMANDLISTENER + "");
|
||||
}
|
||||
if (Settings.GATHERKILLS.isTrue()) {
|
||||
pluginManager.registerEvents(new PlanDeathEventListener(this), this);
|
||||
} else {
|
||||
Log.infoColor(Phrase.NOTIFY_DISABLED_DEATHLISTENER + "");
|
||||
}
|
||||
if (Settings.GATHERLOCATIONS.isTrue()) {
|
||||
pluginManager.registerEvents(new PlanPlayerMoveListener(this), this);
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package main.java.com.djrapitops.plan;
|
||||
|
||||
import org.bukkit.Server;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ServerVariableHolder {
|
||||
|
||||
|
||||
private int maxPlayers;
|
||||
|
||||
public ServerVariableHolder(Plan plugin) {
|
||||
maxPlayers = plugin.getServer().getMaxPlayers();
|
||||
public ServerVariableHolder(Server server) {
|
||||
maxPlayers = server.getMaxPlayers();
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return maxPlayers;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ import java.util.List;
|
||||
* @since 2.3.2
|
||||
*/
|
||||
public enum Settings {
|
||||
// Boolean
|
||||
DEBUG("Settings.Debug"),
|
||||
// Boolean
|
||||
WEBSERVER_ENABLED("Settings.WebServer.Enabled"),
|
||||
ANALYSIS_REFRESH_ON_ENABLE("Settings.Cache.AnalysisCache.RefreshAnalysisCacheOnEnable"),
|
||||
ANALYSIS_LOG_TO_CONSOLE("Settings.Analysis.LogProgressOnConsole"),
|
||||
@ -21,7 +20,12 @@ public enum Settings {
|
||||
SHOW_ALTERNATIVE_IP("Settings.WebServer.ShowAlternativeServerIP"),
|
||||
USE_ALTERNATIVE_UI("Settings.UseTextUI"),
|
||||
GATHERLOCATIONS("Settings.Data.GatherLocations"),
|
||||
GATHERCHAT("Settings.Data.ChatListener"),
|
||||
GATHERKILLS("Settings.Data.GatherKillData"),
|
||||
GATHERGMTIMES("Settings.Data.GamemodeChangeListener"),
|
||||
GATHERCOMMANDS("Settings.Data.GatherCommandUsage"),
|
||||
SECURITY_IP_UUID("Settings.WebServer.Security.DisplayIPsAndUUIDs"),
|
||||
GRAPH_PLAYERS_USEMAXPLAYERS_SCALE("Customization.Graphs.PlayersOnlineGraph.UseMaxPlayersAsScale"),
|
||||
ENABLED_AA("Customization.Plugins.Enabled.AdvancedAchievements"),
|
||||
ENABLED_ESS("Customization.Plugins.Enabled.Essentials"),
|
||||
ENABLED_FAC("Customization.Plugins.Enabled.Factions"),
|
||||
@ -41,6 +45,7 @@ public enum Settings {
|
||||
PROCESS_SAVE_LIMIT("Settings.Cache.Processing.SaveLimit"),
|
||||
PROCESS_CLEAR_LIMIT("Settings.Cache.Processing.ClearLimit"),
|
||||
// String
|
||||
DEBUG("Settings.Debug"),
|
||||
ALTERNATIVE_IP("Settings.WebServer.AlternativeIP"),
|
||||
DB_TYPE("database.type"),
|
||||
DEM_TRIGGERS("Customization.DemographicsTriggers.Trigger"),
|
||||
@ -54,6 +59,8 @@ public enum Settings {
|
||||
//
|
||||
SERVER_NAME("Customization.ServerName"),
|
||||
//
|
||||
FORMAT_YEAR("Customization.Formats.TimeAmount.Year"),
|
||||
FORMAT_YEARS("Customization.Formats.TimeAmount.Years"),
|
||||
FORMAT_DAYS("Customization.Formats.TimeAmount.Days"),
|
||||
FORMAT_HOURS("Customization.Formats.TimeAmount.Hours"),
|
||||
FORMAT_MINUTES("Customization.Formats.TimeAmount.Minutes"),
|
||||
|
@ -1,5 +1,8 @@
|
||||
package main.java.com.djrapitops.plan.api;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
@ -11,7 +14,7 @@ import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDFetcher;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
@ -242,4 +245,33 @@ public class API {
|
||||
public UUID playerNameToUUID(String playerName) throws Exception {
|
||||
return UUIDFetcher.getUUIDOf(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the saved UUIDs in the database.
|
||||
*
|
||||
* Should be called from async thread.
|
||||
*
|
||||
* @return Collection of UUIDs that can be found in the database.
|
||||
* @throws SQLException If database error occurs.
|
||||
* @since 3.4.2
|
||||
*/
|
||||
public Collection<UUID> getSavedUUIDs() throws SQLException {
|
||||
return plugin.getDB().getSavedUUIDs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the saved UserData in the database for a collection of UUIDs.
|
||||
*
|
||||
* Will not contain data for UUIDs not found in the database.
|
||||
*
|
||||
* Should be called from async thread.
|
||||
*
|
||||
* @param uuids Collection of UUIDs that can be found in the database.
|
||||
* @return List of all Data in the database.
|
||||
* @throws SQLException If database error occurs.
|
||||
* @since 3.4.2
|
||||
*/
|
||||
public List<UserData> getUserDataOfUsers(Collection<UUID> uuids) throws SQLException {
|
||||
return plugin.getDB().getUserDataForUUIDS(uuids);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package main.java.com.djrapitops.plan.command;
|
||||
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* This class contains static methods used by the commands to check whether or
|
||||
* not the command should proceed.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.5.0
|
||||
*/
|
||||
public class CommandUtils {
|
||||
|
||||
public static boolean pluginHasViewCapability() {
|
||||
final boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||
final boolean webserverIsOn = Settings.WEBSERVER_ENABLED.isTrue();
|
||||
final boolean usingTextUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
||||
return webserverIsOn || usingAlternativeIP || usingTextUI;
|
||||
}
|
||||
|
||||
public static UUID getUUID(String playerName) {
|
||||
try {
|
||||
return UUIDUtility.getUUIDOf(playerName);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean uuidIsValid(UUID uuid) {
|
||||
return uuid != null;
|
||||
}
|
||||
|
||||
public static boolean playerHasPlayed(UUID uuid) {
|
||||
if (!uuidIsValid(uuid)) {
|
||||
return false;
|
||||
}
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(uuid);
|
||||
return p.hasPlayedBefore();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class Condition {
|
||||
final private String failMsg;
|
||||
final private boolean pass;
|
||||
|
||||
public Condition(boolean pass, String failMsg) {
|
||||
this.failMsg = failMsg;
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
public String getFailMsg() {
|
||||
return failMsg;
|
||||
}
|
||||
|
||||
public boolean pass() {
|
||||
return pass;
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package main.java.com.djrapitops.plan.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.command.commands.*;
|
||||
@ -89,6 +91,7 @@ public class PlanCommand implements CommandExecutor {
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
Log.debug("Registered command with arguments: "+Arrays.toString(args));
|
||||
if (args.length < 1) {
|
||||
sendDefaultCommand(sender, cmd, commandLabel, args);
|
||||
return true;
|
||||
|
@ -1,10 +1,12 @@
|
||||
package main.java.com.djrapitops.plan.command.commands;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.command.CommandType;
|
||||
import main.java.com.djrapitops.plan.command.CommandUtils;
|
||||
import main.java.com.djrapitops.plan.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler;
|
||||
import main.java.com.djrapitops.plan.ui.TextUI;
|
||||
@ -41,26 +43,19 @@ public class AnalyzeCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
if (!Settings.SHOW_ALTERNATIVE_IP.isTrue()) {
|
||||
if (!Settings.USE_ALTERNATIVE_UI.isTrue()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_ANALYSIS + "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!CommandUtils.pluginHasViewCapability()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_ANALYSIS + "");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||
if (!analysisCache.isCached()) {
|
||||
if (!analysisCache.isCached() || MiscUtils.getTime() - analysisCache.getData().getRefreshDate() > 60000) {
|
||||
int bootAnID = plugin.getBootAnalysisTaskID();
|
||||
if (bootAnID != -1) {
|
||||
plugin.getServer().getScheduler().cancelTask(bootAnID);
|
||||
}
|
||||
analysisCache.updateCache();
|
||||
} else if (MiscUtils.getTime() - analysisCache.getData().getRefreshDate() > 60000) {
|
||||
analysisCache.updateCache();
|
||||
}
|
||||
|
||||
BukkitTask analysisMessageSenderTask = new BukkitRunnable() {
|
||||
final BukkitTask analysisMessageSenderTask = new BukkitRunnable() {
|
||||
private int timesrun = 0;
|
||||
|
||||
@Override
|
||||
@ -69,8 +64,10 @@ public class AnalyzeCommand extends SubCommand {
|
||||
if (analysisCache.isCached()) {
|
||||
sendAnalysisMessage(sender);
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
if (timesrun > 10) {
|
||||
Log.debug("Command Timeout Message, Analysis.");
|
||||
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Analysis"));
|
||||
this.cancel();
|
||||
}
|
||||
@ -82,9 +79,11 @@ public class AnalyzeCommand extends SubCommand {
|
||||
/**
|
||||
* Used to send the message after /plan analysis.
|
||||
*
|
||||
* Final because
|
||||
*
|
||||
* @param sender Command sender.
|
||||
*/
|
||||
public void sendAnalysisMessage(CommandSender sender) {
|
||||
final public void sendAnalysisMessage(CommandSender sender) {
|
||||
boolean textUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
|
||||
if (textUI) {
|
||||
|
@ -1,20 +1,22 @@
|
||||
package main.java.com.djrapitops.plan.command.commands;
|
||||
|
||||
import main.java.com.djrapitops.plan.command.CommandUtils;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.command.CommandType;
|
||||
import main.java.com.djrapitops.plan.command.Condition;
|
||||
import main.java.com.djrapitops.plan.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||
import main.java.com.djrapitops.plan.ui.TextUI;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -45,87 +47,74 @@ public class InspectCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
if (!useAlternativeIP) {
|
||||
if (!Settings.USE_ALTERNATIVE_UI.isTrue()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_INSPECT + "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!CommandUtils.pluginHasViewCapability()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_INSPECT + "");
|
||||
return true;
|
||||
}
|
||||
String playerName = MiscUtils.getPlayerName(args, sender);
|
||||
BukkitTask inspectTask = new BukkitRunnable() {
|
||||
final BukkitTask inspectTask = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
if (uuid == null) {
|
||||
throw new Exception("Username doesn't exist.");
|
||||
UUID uuid = CommandUtils.getUUID(playerName);
|
||||
Condition[] preConditions = new Condition[]{
|
||||
new Condition(CommandUtils.uuidIsValid(uuid), Phrase.USERNAME_NOT_VALID.toString()),
|
||||
new Condition(CommandUtils.playerHasPlayed(uuid), Phrase.USERNAME_NOT_SEEN.toString()),
|
||||
new Condition(plugin.getDB().wasSeenBefore(uuid), Phrase.USERNAME_NOT_KNOWN.toString())
|
||||
};
|
||||
|
||||
for (Condition condition : preConditions) {
|
||||
if (!condition.pass()) {
|
||||
sender.sendMessage(condition.getFailMsg());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_VALID.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(uuid);
|
||||
if (!p.hasPlayedBefore()) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_SEEN.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
if (!plugin.getDB().wasSeenBefore(uuid)) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||
inspectCache.cache(uuid);
|
||||
int configValue = Settings.CLEAR_INSPECT_CACHE.getNumber();
|
||||
if (configValue <= 0) {
|
||||
configValue = 4;
|
||||
}
|
||||
final int available = configValue;
|
||||
BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
|
||||
final BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
|
||||
private int timesrun = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public void run() {
|
||||
timesrun++;
|
||||
if (inspectCache.isCached(uuid)) {
|
||||
sender.sendMessage(Phrase.CMD_INSPECT_HEADER + playerName);
|
||||
if (Settings.USE_ALTERNATIVE_UI.isTrue()) {
|
||||
sender.sendMessage(TextUI.getInspectMessages(uuid));
|
||||
} else {
|
||||
// Link
|
||||
String url = HtmlUtils.getInspectUrl(playerName);
|
||||
String message = Phrase.CMD_LINK + "";
|
||||
boolean console = !(sender instanceof Player);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
} else {
|
||||
sender.sendMessage(message);
|
||||
Player player = (Player) sender;
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\"" + Phrase.CMD_CLICK_ME + "\",\"underlined\":true,"
|
||||
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
|
||||
}
|
||||
|
||||
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available + ""));
|
||||
}
|
||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||
sendInspectMsg(sender, playerName, uuid);
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
if (timesrun > 10) {
|
||||
Log.debug("Command Timeout Message, Inspect.");
|
||||
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Inspect"));
|
||||
this.cancel();
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendInspectMsg(CommandSender sender, String playerName, UUID uuid) throws CommandException {
|
||||
sender.sendMessage(Phrase.CMD_INSPECT_HEADER + playerName);
|
||||
if (Settings.USE_ALTERNATIVE_UI.isTrue()) {
|
||||
sender.sendMessage(TextUI.getInspectMessages(uuid));
|
||||
} else {
|
||||
// Link
|
||||
String url = HtmlUtils.getInspectUrl(playerName);
|
||||
String message = Phrase.CMD_LINK + "";
|
||||
boolean console = !(sender instanceof Player);
|
||||
if (console) {
|
||||
sender.sendMessage(message + url);
|
||||
} else {
|
||||
sender.sendMessage(message);
|
||||
Player player = (Player) sender;
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw " + player.getName() + " [\"\",{\"text\":\"" + Phrase.CMD_CLICK_ME + "\",\"underlined\":true,"
|
||||
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.command.commands;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
@ -62,6 +63,7 @@ public class QuickAnalyzeCommand extends SubCommand {
|
||||
this.cancel();
|
||||
}
|
||||
if (timesrun > 10) {
|
||||
Log.debug("Command Timeout Message, QuickAnalyze.");
|
||||
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Analysis"));
|
||||
this.cancel();
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package main.java.com.djrapitops.plan.command.commands;
|
||||
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.command.CommandType;
|
||||
import main.java.com.djrapitops.plan.command.CommandUtils;
|
||||
import main.java.com.djrapitops.plan.command.Condition;
|
||||
import main.java.com.djrapitops.plan.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||
import main.java.com.djrapitops.plan.ui.TextUI;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -45,39 +44,26 @@ public class QuickInspectCommand extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER);
|
||||
BukkitTask inspectTask = new BukkitRunnable() {
|
||||
final BukkitTask inspectTask = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
if (uuid == null) {
|
||||
throw new Exception("Username doesn't exist.");
|
||||
UUID uuid = CommandUtils.getUUID(playerName);
|
||||
Condition[] preConditions = new Condition[]{
|
||||
new Condition(CommandUtils.uuidIsValid(uuid), Phrase.USERNAME_NOT_VALID.toString()),
|
||||
new Condition(CommandUtils.playerHasPlayed(uuid), Phrase.USERNAME_NOT_SEEN.toString()),
|
||||
new Condition(plugin.getDB().wasSeenBefore(uuid), Phrase.USERNAME_NOT_KNOWN.toString())
|
||||
};
|
||||
|
||||
for (Condition condition : preConditions) {
|
||||
if (!condition.pass()) {
|
||||
sender.sendMessage(condition.getFailMsg());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_VALID.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(uuid);
|
||||
if (!p.hasPlayedBefore()) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_SEEN.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
if (!plugin.getDB().wasSeenBefore(uuid)) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||
inspectCache.cache(uuid);
|
||||
int configValue = Settings.CLEAR_INSPECT_CACHE.getNumber();
|
||||
if (configValue <= 0) {
|
||||
configValue = 4;
|
||||
}
|
||||
final int available = configValue;
|
||||
BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
|
||||
final BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
|
||||
private int timesrun = 0;
|
||||
|
||||
@Override
|
||||
@ -90,6 +76,7 @@ public class QuickInspectCommand extends SubCommand {
|
||||
this.cancel();
|
||||
}
|
||||
if (timesrun > 10) {
|
||||
Log.debug("Command Timeout Message, QuickInspect.");
|
||||
sender.sendMessage(Phrase.COMMAND_TIMEOUT.parse("Qinspect"));
|
||||
this.cancel();
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public class ReloadCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
plugin.reloadConfig();
|
||||
plugin.onDisable();
|
||||
plugin.reloadConfig();
|
||||
plugin.onEnable();
|
||||
sender.sendMessage(Phrase.RELOAD_COMPLETE + "");
|
||||
return true;
|
||||
|
@ -7,8 +7,9 @@ import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.command.CommandType;
|
||||
import main.java.com.djrapitops.plan.command.CommandUtils;
|
||||
import main.java.com.djrapitops.plan.command.Condition;
|
||||
import main.java.com.djrapitops.plan.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
@ -45,18 +46,19 @@ public class SearchCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||
if (!CommandUtils.pluginHasViewCapability()) {
|
||||
sender.sendMessage(Phrase.ERROR_WEBSERVER_OFF_ANALYSIS.toString());
|
||||
return true;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString());
|
||||
Condition c = new Condition(args.length != 1, Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE.toString());
|
||||
if (c.pass()) {
|
||||
sender.sendMessage(c.getFailMsg());
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
|
||||
BukkitTask searchTask = new BukkitRunnable() {
|
||||
final BukkitTask searchTask = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Set<UUID> uuids = new HashSet<>();
|
||||
@ -67,13 +69,6 @@ public class SearchCommand extends SubCommand {
|
||||
inspectCache.cache(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
int configValue = Settings.CLEAR_INSPECT_CACHE.getNumber();
|
||||
if (configValue <= 0) {
|
||||
configValue = 4;
|
||||
}
|
||||
final int available = configValue;
|
||||
|
||||
sender.sendMessage(Phrase.CMD_SEARCH_HEADER + args[0]);
|
||||
// Results
|
||||
if (uuids.isEmpty()) {
|
||||
@ -94,7 +89,7 @@ public class SearchCommand extends SubCommand {
|
||||
} else {
|
||||
sender.sendMessage(message);
|
||||
Player player = (Player) sender;
|
||||
BukkitTask link = new BukkitRunnable() {
|
||||
final BukkitTask link = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
@ -107,7 +102,6 @@ public class SearchCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available + ""));
|
||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
|
@ -10,12 +10,10 @@ import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.command.CommandType;
|
||||
import main.java.com.djrapitops.plan.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to remove a single player's data from the
|
||||
@ -47,33 +45,31 @@ public class ManageRemoveCommand extends SubCommand {
|
||||
|
||||
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.MANAGE);
|
||||
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
if (uuid == null) {
|
||||
throw new Exception("Username doesn't exist.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_VALID.toString());
|
||||
return true;
|
||||
}
|
||||
OfflinePlayer p = getOfflinePlayer(uuid);
|
||||
if (!p.hasPlayedBefore()) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_SEEN.toString());
|
||||
return true;
|
||||
}
|
||||
if (!plugin.getDB().wasSeenBefore(uuid)) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
||||
return true;
|
||||
}
|
||||
if (!Arrays.asList(args).contains("-a")) {
|
||||
sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(plugin.getDB().getConfigName())));
|
||||
return true;
|
||||
}
|
||||
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUIDUtility.getUUIDOf(playerName);
|
||||
if (uuid == null) {
|
||||
throw new Exception("Username doesn't exist.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_VALID.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
if (!plugin.getDB().wasSeenBefore(uuid)) {
|
||||
sender.sendMessage(Phrase.USERNAME_NOT_KNOWN.toString());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
if (!Arrays.asList(args).contains("-a")) {
|
||||
sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(plugin.getDB().getConfigName())));
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
|
||||
try {
|
||||
plugin.getHandler().getDataCache().remove(uuid);
|
||||
|
@ -209,7 +209,7 @@ public class HookHandler {
|
||||
} catch (Exception e) {
|
||||
addReplace.put(source.getPlaceholder(""), "Error occurred: " + e);
|
||||
Log.error("PluginDataSource caused an exception: " + source.getSourcePlugin());
|
||||
Log.toLog("PluginDataSource caused an exception: " + source.getSourcePlugin());
|
||||
Log.toLog("PluginDataSource caused an exception: " + source.getSourcePlugin(), Log.getErrorsFilename());
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package main.java.com.djrapitops.plan.data.additional.jobs;
|
||||
import main.java.com.djrapitops.plan.data.additional.Hook;
|
||||
import main.java.com.djrapitops.plan.api.API;
|
||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||
import main.java.com.djrapitops.plan.data.additional.mcmmo.McmmoAnalysisSkillTable;
|
||||
|
||||
/**
|
||||
* A Class responsible for hooking to Jobs and registering data sources.
|
||||
|
@ -192,7 +192,7 @@ public class DataCacheHandler extends LocationCache {
|
||||
public void cache(UserData data) {
|
||||
data.setOnline(true);
|
||||
dataCache.put(data.getUuid(), data);
|
||||
Log.info(Phrase.CACHE_ADD.parse(data.getUuid().toString()));
|
||||
Log.debug(Phrase.CACHE_ADD.parse(data.getUuid().toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -386,7 +386,7 @@ public class DataCacheHandler extends LocationCache {
|
||||
}
|
||||
} else {
|
||||
dataCache.remove(uuid);
|
||||
Log.info(Phrase.CACHE_REMOVE.parse(uuid.toString()));
|
||||
Log.debug(Phrase.CACHE_REMOVE.parse(uuid.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package main.java.com.djrapitops.plan.data.cache.queue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
@ -11,8 +11,8 @@ 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.HandlingInfo;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
|
||||
/**
|
||||
* Abstract class used for importing data from other plugins.
|
||||
|
@ -232,6 +232,9 @@ public abstract class SQLDB extends Database {
|
||||
*/
|
||||
@Override
|
||||
public boolean wasSeenBefore(UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return usersTable.getUserId(uuid.toString()) != -1;
|
||||
} catch (SQLException e) {
|
||||
@ -248,6 +251,9 @@ public abstract class SQLDB extends Database {
|
||||
*/
|
||||
@Override
|
||||
public boolean removeAccount(String uuid) throws SQLException {
|
||||
if (uuid == null || uuid.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Benchmark.start("Database remove Account " + uuid);
|
||||
try {
|
||||
@ -284,7 +290,6 @@ public abstract class SQLDB extends Database {
|
||||
try {
|
||||
checkConnection();
|
||||
} catch (Exception e) {
|
||||
Log.toLog("Preparing for Exception report - Processors: " + processors.toString());
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
return;
|
||||
}
|
||||
@ -376,9 +381,7 @@ public abstract class SQLDB extends Database {
|
||||
if (data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Set<Throwable> exceptions = new HashSet<>();
|
||||
List<UserData> saveLast = usersTable.saveUserDataInformationBatch(data);
|
||||
data.removeAll(saveLast);
|
||||
usersTable.saveUserDataInformationBatch(data);
|
||||
// Transform to map
|
||||
Map<UUID, UserData> userDatas = data.stream().collect(Collectors.toMap(UserData::getUuid, Function.identity()));
|
||||
// Get UserIDs
|
||||
@ -397,7 +400,6 @@ public abstract class SQLDB extends Database {
|
||||
Integer id = userIds.get(uuid);
|
||||
UserData uData = userDatas.get(uuid);
|
||||
if (id == -1) {
|
||||
saveLast.add(uData);
|
||||
Log.debug("User not seen before, saving last: " + uuid);
|
||||
continue;
|
||||
}
|
||||
@ -427,18 +429,6 @@ public abstract class SQLDB extends Database {
|
||||
.forEach(uData -> {
|
||||
uData.stopAccessing();
|
||||
});
|
||||
// Save leftovers
|
||||
saveLast.stream().forEach((userData) -> {
|
||||
try {
|
||||
saveUserData(userData);
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
});
|
||||
if (!exceptions.isEmpty()) {
|
||||
Log.error("SEVERE: MULTIPLE ERRORS OCCURRED: " + exceptions.size());
|
||||
Log.toLog(this.getClass().getName(), exceptions);
|
||||
}
|
||||
Benchmark.stop("DB Save multiple Userdata");
|
||||
}
|
||||
|
||||
|
@ -82,19 +82,59 @@ public class CommandUseTable extends Table {
|
||||
return;
|
||||
}
|
||||
Benchmark.start("Save Commanduse");
|
||||
Map<String, Integer> newData = new HashMap<>(data);
|
||||
Map<String, Integer> saved = getCommandUse();
|
||||
newData.keySet().removeAll(saved.keySet());
|
||||
insertCommands(newData);
|
||||
Map<String, Integer> updateData = new HashMap<>(data);
|
||||
updateData.keySet().removeAll(newData.keySet());
|
||||
for (String cmd : saved.keySet()) {
|
||||
Integer toSave = updateData.get(cmd);
|
||||
if (toSave != null) {
|
||||
if (toSave <= saved.get(cmd)) {
|
||||
updateData.remove(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateCommands(updateData);
|
||||
Benchmark.stop("Save Commanduse");
|
||||
}
|
||||
|
||||
private void updateCommands(Map<String, Integer> data) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
if (!removeAllData()) {
|
||||
Log.debug("CommandUse Table clear failed.");
|
||||
}
|
||||
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
||||
+ columnCommand + ", "
|
||||
+ columnTimesUsed
|
||||
+ ") VALUES (?, ?)");
|
||||
String updateStatement = "UPDATE " + tableName + " SET " + columnTimesUsed + "=? WHERE (" + columnCommand + "=?)";
|
||||
statement = prepareStatement(updateStatement);
|
||||
boolean commitRequired = false;
|
||||
for (String key : data.keySet()) {
|
||||
Integer amount = data.get(key);
|
||||
if (key.length() > 20) {
|
||||
continue;
|
||||
}
|
||||
statement.setInt(1, amount);
|
||||
statement.setString(2, key);
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
}
|
||||
if (commitRequired) {
|
||||
statement.executeBatch();
|
||||
}
|
||||
} finally {
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
|
||||
private void insertCommands(Map<String, Integer> data) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
String insertStatement = "INSERT INTO " + tableName + " ("
|
||||
+ columnCommand + ", "
|
||||
+ columnTimesUsed
|
||||
+ ") VALUES (?, ?)";
|
||||
statement = prepareStatement(insertStatement);
|
||||
boolean commitRequired = false;
|
||||
for (String key : data.keySet()) {
|
||||
Integer amount = data.get(key);
|
||||
// Log.debug("Saving Command: "+key+" "+amount);
|
||||
if (key.length() > 20) {
|
||||
continue;
|
||||
}
|
||||
@ -104,12 +144,10 @@ public class CommandUseTable extends Table {
|
||||
commitRequired = true;
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("CommandUse: Executing batch, size: " + data.size());
|
||||
statement.executeBatch();
|
||||
}
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.stop("Save Commanduse");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,6 +202,7 @@ public class IPsTable extends Table {
|
||||
+ columnIP
|
||||
+ ") VALUES (?, ?)");
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
for (Integer id : ips.keySet()) {
|
||||
Set<InetAddress> ipAddresses = ips.get(id);
|
||||
Set<InetAddress> s = saved.get(id);
|
||||
@ -219,14 +220,16 @@ public class IPsTable extends Table {
|
||||
statement.setString(2, ip.getHostAddress());
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("Executing ips batch: "+i);
|
||||
statement.executeBatch();
|
||||
}
|
||||
Benchmark.stop("Save Ips Multiple " + ips.size());
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.stop("Get Ips Multiple " + ips.size());
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.data.KillData;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
@ -141,7 +142,14 @@ public class KillsTable extends Table {
|
||||
continue;
|
||||
}
|
||||
statement.setInt(1, userId);
|
||||
statement.setInt(2, kill.getVictimUserID());
|
||||
int victimUserID = kill.getVictimUserID();
|
||||
if (victimUserID == -1) {
|
||||
victimUserID = db.getUsersTable().getUserId(kill.getVictim());
|
||||
if (victimUserID == -1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
statement.setInt(2, victimUserID);
|
||||
statement.setString(3, kill.getWeapon());
|
||||
statement.setLong(4, kill.getDate());
|
||||
statement.addBatch();
|
||||
@ -167,7 +175,7 @@ public class KillsTable extends Table {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Benchmark.start("Get Kills multiple "+ids.size());
|
||||
Benchmark.start("Get Kills multiple " + ids.size());
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
try {
|
||||
@ -190,7 +198,7 @@ public class KillsTable extends Table {
|
||||
} finally {
|
||||
close(set);
|
||||
close(statement);
|
||||
Benchmark.stop("Get Kills multiple "+ids.size());
|
||||
Benchmark.stop("Get Kills multiple " + ids.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +212,7 @@ public class KillsTable extends Table {
|
||||
if (kills == null || kills.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Benchmark.start("Save Kills multiple "+kills.size());
|
||||
Benchmark.start("Save Kills multiple " + kills.size());
|
||||
Map<Integer, List<KillData>> saved = getPlayerKills(kills.keySet(), uuids);
|
||||
|
||||
PreparedStatement statement = null;
|
||||
@ -216,6 +224,7 @@ public class KillsTable extends Table {
|
||||
+ columnDate
|
||||
+ ") VALUES (?, ?, ?, ?)");
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
for (Integer id : kills.keySet()) {
|
||||
List<KillData> playerKills = kills.get(id);
|
||||
List<KillData> s = saved.get(id);
|
||||
@ -227,19 +236,32 @@ public class KillsTable extends Table {
|
||||
continue;
|
||||
}
|
||||
statement.setInt(1, id);
|
||||
statement.setInt(2, kill.getVictimUserID());
|
||||
int victimUserID = kill.getVictimUserID();
|
||||
if (victimUserID == -1) {
|
||||
List<Integer> matchingIds = uuids.entrySet()
|
||||
.stream().filter(e -> e.getValue().equals(kill.getVictim()))
|
||||
.map(e -> e.getKey())
|
||||
.collect(Collectors.toList());
|
||||
if (matchingIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
victimUserID = matchingIds.get(0);
|
||||
}
|
||||
statement.setInt(2, victimUserID);
|
||||
statement.setString(3, kill.getWeapon());
|
||||
statement.setLong(4, kill.getDate());
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("Executing kills batch: "+i);
|
||||
statement.executeBatch();
|
||||
}
|
||||
}
|
||||
Benchmark.stop("Save Kills multiple " + kills.size());
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.stop("Save Kills multiple "+kills.size());
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ public class LocationsTable extends Table {
|
||||
+ columnWorld
|
||||
+ ") VALUES (?, ?, ?, ?)");
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
for (Location location : newLocations) {
|
||||
if (location == null) {
|
||||
continue;
|
||||
@ -170,8 +171,10 @@ public class LocationsTable extends Table {
|
||||
statement.setString(4, world.getName());
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("Executing locations batch: "+i);
|
||||
statement.executeBatch();
|
||||
}
|
||||
} finally {
|
||||
@ -199,6 +202,7 @@ public class LocationsTable extends Table {
|
||||
+ columnWorld
|
||||
+ ") VALUES (?, ?, ?, ?)");
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
for (Integer id : locations.keySet()) {
|
||||
List<Location> newLocations = locations.get(id);
|
||||
if (newLocations == null || newLocations.isEmpty()) {
|
||||
@ -215,9 +219,11 @@ public class LocationsTable extends Table {
|
||||
statement.setString(4, world.getName());
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("Executing locations batch: "+i);
|
||||
statement.executeBatch();
|
||||
}
|
||||
} finally {
|
||||
|
@ -156,14 +156,17 @@ public class NicknamesTable extends Table {
|
||||
+ columnNick
|
||||
+ ") VALUES (?, ?, ?)");
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
for (String name : names) {
|
||||
statement.setInt(1, userId);
|
||||
statement.setInt(2, (name.equals(lastNick)) ? 1 : 0);
|
||||
statement.setString(3, name);
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("Executing nicknames batch: "+i);
|
||||
statement.executeBatch();
|
||||
|
||||
}
|
||||
|
@ -209,6 +209,7 @@ public class SessionsTable extends Table {
|
||||
+ ") VALUES (?, ?, ?)");
|
||||
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
for (Integer id : sessions.keySet()) {
|
||||
List<SessionData> sessionList = sessions.get(id);
|
||||
List<SessionData> s = saved.get(id);
|
||||
@ -229,14 +230,16 @@ public class SessionsTable extends Table {
|
||||
statement.setLong(3, end);
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (commitRequired) {
|
||||
statement.executeBatch();
|
||||
Log.debug("Executing session batch: "+i);
|
||||
statement.executeBatch();
|
||||
}
|
||||
Benchmark.stop("Save Sessions multiple " + sessions.size());
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.stop("Save Sessions multiple " + sessions.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import org.bukkit.GameMode;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
|
||||
@ -330,17 +330,20 @@ public class UsersTable extends Table {
|
||||
List<UUID> containsBukkitData = getContainsBukkitData(uuids);
|
||||
List<UserData> datas = new ArrayList<>();
|
||||
datas.addAll(getUserDataForKnown(containsBukkitData));
|
||||
|
||||
uuids.removeAll(containsBukkitData);
|
||||
|
||||
List<UserData> noBukkitData = new ArrayList<>();
|
||||
Benchmark.start("Create UserData objects for No BukkitData players " + uuids.size());
|
||||
for (UUID uuid : uuids) {
|
||||
UserData uData = new UserData(getOfflinePlayer(uuid), new DemographicsData());
|
||||
noBukkitData.add(uData);
|
||||
if (!uuids.isEmpty()) {
|
||||
List<UserData> noBukkitData = new ArrayList<>();
|
||||
Benchmark.start("Create UserData objects for No BukkitData players " + uuids.size());
|
||||
for (UUID uuid : uuids) {
|
||||
UserData uData = new UserData(getOfflinePlayer(uuid), new DemographicsData());
|
||||
noBukkitData.add(uData);
|
||||
}
|
||||
Benchmark.stop("Create UserData objects for No BukkitData players " + uuids.size());
|
||||
addUserInformationToUserData(noBukkitData);
|
||||
datas.addAll(noBukkitData);
|
||||
}
|
||||
Benchmark.stop("Create UserData objects for No BukkitData players " + uuids.size());
|
||||
addUserInformationToUserData(noBukkitData);
|
||||
datas.addAll(noBukkitData);
|
||||
|
||||
Benchmark.stop("Get UserData Multiple " + uuids.size());
|
||||
return datas;
|
||||
}
|
||||
@ -633,11 +636,80 @@ public class UsersTable extends Table {
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public List<UserData> saveUserDataInformationBatch(Collection<UserData> data) throws SQLException {
|
||||
public void saveUserDataInformationBatch(Collection<UserData> data) throws SQLException {
|
||||
Benchmark.start("Save UserInfo multiple " + data.size());
|
||||
try {
|
||||
List<UserData> newUserdata = updateExistingUserData(data);
|
||||
Benchmark.start("Insert new UserInfo multiple " + newUserdata.size());
|
||||
insertNewUserData(newUserdata);
|
||||
Benchmark.stop("Insert new UserInfo multiple " + newUserdata.size());
|
||||
} finally {
|
||||
Benchmark.stop("Save UserInfo multiple " + data.size());
|
||||
}
|
||||
}
|
||||
|
||||
private void insertNewUserData(Collection<UserData> data) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
||||
+ columnUUID + ", "
|
||||
+ columnDemAge + ", "
|
||||
+ columnDemGender + ", "
|
||||
+ columnDemGeoLocation + ", "
|
||||
+ columnLastGM + ", "
|
||||
+ columnLastGMSwapTime + ", "
|
||||
+ columnPlayTime + ", "
|
||||
+ columnLoginTimes + ", "
|
||||
+ columnLastPlayed + ", "
|
||||
+ columnDeaths + ", "
|
||||
+ columnMobKills + ", "
|
||||
+ columnContainsBukkitData + ", "
|
||||
+ columnOP + ", "
|
||||
+ columnBanned + ", "
|
||||
+ columnName + ", "
|
||||
+ columnRegistered
|
||||
+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
boolean commitRequired = false;
|
||||
int i = 0;
|
||||
for (UserData uData : data) {
|
||||
UUID uuid = uData.getUuid();
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setInt(2, uData.getDemData().getAge());
|
||||
statement.setString(3, uData.getDemData().getGender().toString().toLowerCase());
|
||||
statement.setString(4, uData.getDemData().getGeoLocation());
|
||||
GameMode gm = uData.getLastGamemode();
|
||||
if (gm != null) {
|
||||
statement.setString(5, uData.getLastGamemode().name());
|
||||
} else {
|
||||
statement.setString(5, GameMode.SURVIVAL.name());
|
||||
}
|
||||
statement.setLong(6, uData.getLastGmSwapTime());
|
||||
statement.setLong(7, uData.getPlayTime());
|
||||
statement.setInt(8, uData.getLoginTimes());
|
||||
statement.setLong(9, uData.getLastPlayed());
|
||||
statement.setInt(10, uData.getDeaths());
|
||||
statement.setInt(11, uData.getMobKills());
|
||||
statement.setBoolean(12, uData.getName() != null);
|
||||
statement.setBoolean(13, uData.isOp());
|
||||
statement.setBoolean(14, uData.isBanned());
|
||||
statement.setString(15, uData.getName());
|
||||
statement.setLong(16, uData.getRegistered());
|
||||
statement.addBatch();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("Executing session batch: " + i);
|
||||
statement.executeBatch();
|
||||
}
|
||||
} finally {
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
|
||||
private List<UserData> updateExistingUserData(Collection<UserData> data) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
List<UserData> saveLast = new ArrayList<>();
|
||||
@ -661,65 +733,61 @@ public class UsersTable extends Table {
|
||||
statement = prepareStatement(uSQL);
|
||||
boolean commitRequired = false;
|
||||
Set<UUID> savedUUIDs = getSavedUUIDs();
|
||||
int i = 0;
|
||||
for (UserData uData : data) {
|
||||
try {
|
||||
if (uData == null) {
|
||||
continue;
|
||||
}
|
||||
UUID uuid = uData.getUuid();
|
||||
if (uuid == null) {
|
||||
try {
|
||||
uData.setUuid(UUIDFetcher.getUUIDOf(uData.getName()));
|
||||
} catch (Exception ex) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
uuid = uData.getUuid();
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
if (!savedUUIDs.contains(uuid)) {
|
||||
saveLast.add(uData);
|
||||
continue;
|
||||
}
|
||||
uData.access();
|
||||
statement.setInt(1, uData.getDemData().getAge());
|
||||
statement.setString(2, uData.getDemData().getGender().toString().toLowerCase());
|
||||
statement.setString(3, uData.getDemData().getGeoLocation());
|
||||
GameMode gm = uData.getLastGamemode();
|
||||
if (gm != null) {
|
||||
statement.setString(4, uData.getLastGamemode().name());
|
||||
} else {
|
||||
statement.setString(4, GameMode.SURVIVAL.name());
|
||||
}
|
||||
statement.setLong(5, uData.getLastGmSwapTime());
|
||||
statement.setLong(6, uData.getPlayTime());
|
||||
statement.setInt(7, uData.getLoginTimes());
|
||||
statement.setLong(8, uData.getLastPlayed());
|
||||
statement.setInt(9, uData.getDeaths());
|
||||
statement.setInt(10, uData.getMobKills());
|
||||
statement.setBoolean(11, uData.getName() != null);
|
||||
statement.setBoolean(12, uData.isOp());
|
||||
statement.setBoolean(13, uData.isBanned());
|
||||
statement.setString(14, uData.getName());
|
||||
statement.setLong(15, uData.getRegistered());
|
||||
statement.setString(16, uuid.toString());
|
||||
statement.addBatch();
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
saveLast.add(uData);
|
||||
uData.stopAccessing();
|
||||
if (uData == null) {
|
||||
continue;
|
||||
}
|
||||
UUID uuid = uData.getUuid();
|
||||
if (uuid == null) {
|
||||
try {
|
||||
uData.setUuid(UUIDUtility.getUUIDOf(uData.getName(), db));
|
||||
} catch (Exception ex) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
uuid = uData.getUuid();
|
||||
if (uuid == null) {
|
||||
continue;
|
||||
}
|
||||
if (!savedUUIDs.contains(uuid)) {
|
||||
saveLast.add(uData);
|
||||
continue;
|
||||
}
|
||||
uData.access();
|
||||
statement.setInt(1, uData.getDemData().getAge());
|
||||
statement.setString(2, uData.getDemData().getGender().toString().toLowerCase());
|
||||
statement.setString(3, uData.getDemData().getGeoLocation());
|
||||
GameMode gm = uData.getLastGamemode();
|
||||
if (gm != null) {
|
||||
statement.setString(4, uData.getLastGamemode().name());
|
||||
} else {
|
||||
statement.setString(4, GameMode.SURVIVAL.name());
|
||||
}
|
||||
statement.setLong(5, uData.getLastGmSwapTime());
|
||||
statement.setLong(6, uData.getPlayTime());
|
||||
statement.setInt(7, uData.getLoginTimes());
|
||||
statement.setLong(8, uData.getLastPlayed());
|
||||
statement.setInt(9, uData.getDeaths());
|
||||
statement.setInt(10, uData.getMobKills());
|
||||
statement.setBoolean(11, uData.getName() != null);
|
||||
statement.setBoolean(12, uData.isOp());
|
||||
statement.setBoolean(13, uData.isBanned());
|
||||
statement.setString(14, uData.getName());
|
||||
statement.setLong(15, uData.getRegistered());
|
||||
statement.setString(16, uuid.toString());
|
||||
statement.addBatch();
|
||||
uData.stopAccessing();
|
||||
commitRequired = true;
|
||||
i++;
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("Executing userinfo batch update: " + i);
|
||||
statement.executeBatch();
|
||||
}
|
||||
return saveLast;
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.stop("Save UserInfo multiple " + data.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -755,8 +823,7 @@ public class UsersTable extends Table {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @return @throws SQLException
|
||||
*/
|
||||
public Map<UUID, Integer> getAllUserIds() throws SQLException {
|
||||
Benchmark.start("Get User IDS ALL");
|
||||
@ -786,4 +853,23 @@ public class UsersTable extends Table {
|
||||
public String getColumnID() {
|
||||
return columnID;
|
||||
}
|
||||
|
||||
public UUID getUuidOf(String playername) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
try {
|
||||
statement = prepareStatement("SELECT " + columnUUID + " FROM " + tableName + " WHERE (UPPER(" + columnName + ")=UPPER(?))");
|
||||
statement.setString(1, playername);
|
||||
set = statement.executeQuery();
|
||||
while (set.next()) {
|
||||
String uuidS = set.getString(columnUUID);
|
||||
UUID uuid = UUID.fromString(uuidS);
|
||||
return uuid;
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
close(set);
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class TextUI {
|
||||
String ball = sec + " " + Phrase.BALL + main;
|
||||
return new String[]{
|
||||
sec + " " + Phrase.BALL + (banned ? ChatColor.DARK_RED + " Banned" : ter + (active ? " Active" : " Inactive")) + (online ? ChatColor.GREEN + " Online" : ChatColor.RED + " Offline"),
|
||||
ball + " Registered: " + sec + FormatUtils.formatTimeStamp(d.getRegistered()),
|
||||
ball + " Registered: " + sec + FormatUtils.formatTimeStampYear(d.getRegistered()),
|
||||
ball + " Last seen: " + sec + FormatUtils.formatTimeStamp(d.getLastPlayed()),
|
||||
ball + " Playtime: " + sec + FormatUtils.formatTimeAmount(d.getPlayTime()),
|
||||
ball + " Login times: " + sec + d.getLoginTimes(),
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.ui.graphs;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -41,10 +40,6 @@ public class PunchCardGraphCreator {
|
||||
private static StringBuilder buildString(int[][] scaled) {
|
||||
StringBuilder arrayBuilder = new StringBuilder();
|
||||
arrayBuilder.append("[");
|
||||
// arrayBuilder.append("{").append("x:").append(-1).append(", y:").append(-1).append(", r:").append(1).append("}");
|
||||
// arrayBuilder.append(",");
|
||||
// arrayBuilder.append("{").append("x:").append(25).append(", y:").append(7).append(", r:").append(1).append("}");
|
||||
// arrayBuilder.append(",");
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int j = 0; j < 24; j++) {
|
||||
int value = scaled[i][j];
|
||||
|
@ -32,7 +32,7 @@ public class SortableCommandUseTableCreator {
|
||||
html.append(Html.TABLELINE_2.parse(values[1], values[0]));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.toLog("SortableCommandUseTableCreator", e);
|
||||
Log.toLog("Cause: " + values[0] + " " + values[1]);
|
||||
Log.toLog("Cause: " + values[0] + " " + values[1], Log.getErrorsFilename());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class SortablePlayersTableCreator {
|
||||
banOunknownOactiveOinactive,
|
||||
uData.getPlayTime() + "", FormatUtils.formatTimeAmount(uData.getPlayTime()),
|
||||
uData.getLoginTimes() + "",
|
||||
uData.getRegistered() + "", FormatUtils.formatTimeStamp(uData.getRegistered()),
|
||||
uData.getRegistered() + "", FormatUtils.formatTimeStampYear(uData.getRegistered()),
|
||||
uData.getLastPlayed() + "", FormatUtils.formatTimeStamp(uData.getLastPlayed()),
|
||||
uData.getDemData().getGeoLocation()
|
||||
);
|
||||
|
@ -6,7 +6,8 @@ import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
|
||||
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -36,14 +37,17 @@ public class Response {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void sendStaticResource() throws IOException {
|
||||
Benchmark.start("Webserver Response");
|
||||
try {
|
||||
if (request == null) {
|
||||
return;
|
||||
}
|
||||
if (request.getUri() == null) {
|
||||
String requestUri = request.getUri();
|
||||
if (requestUri == null) {
|
||||
return;
|
||||
}
|
||||
String[] requestArgs = request.getUri().split("/");
|
||||
Log.debug("Request: " + requestUri);
|
||||
String[] requestArgs = requestUri.split("/");
|
||||
boolean forbidden = false;
|
||||
String securityCode = "";
|
||||
if (requestArgs.length <= 2) {
|
||||
@ -65,9 +69,9 @@ public class Response {
|
||||
}
|
||||
String command = requestArgs[2].toLowerCase();
|
||||
if (command.equals("player")) {
|
||||
if (requestArgs.length >= 3) {
|
||||
if (requestArgs.length > 3) {
|
||||
String playerName = requestArgs[3].trim();
|
||||
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
UUID uuid = UUIDUtility.getUUIDOf(playerName);
|
||||
if (uuid == null) {
|
||||
String errorMessage = "HTTP/1.1 500 UUID not Found\r\n"
|
||||
+ "Content-Type: text/html;\r\n"
|
||||
@ -116,6 +120,8 @@ public class Response {
|
||||
output.write(errorMessage.getBytes());
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
} finally {
|
||||
Benchmark.stop("Webserver Response");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.ui.webserver;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -63,21 +64,30 @@ public class WebSocketServer {
|
||||
@Override
|
||||
public void run() {
|
||||
while (!shutdown) {
|
||||
Socket socket;
|
||||
InputStream input;
|
||||
OutputStream output;
|
||||
Socket socket = null;
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
try {
|
||||
socket = server.accept();
|
||||
input = socket.getInputStream();
|
||||
output = socket.getOutputStream();
|
||||
Request request = new Request(input);
|
||||
request.parse();
|
||||
|
||||
Response response = new Response(output, dataReqHandler);
|
||||
response.setRequest(request);
|
||||
response.sendStaticResource();
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
Closeable[] close = new Closeable[]{input, output, socket};
|
||||
for (Closeable closeable : close) {
|
||||
try {
|
||||
if (closeable != null) {
|
||||
closeable.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cancel();
|
||||
@ -99,7 +109,9 @@ public class WebSocketServer {
|
||||
Log.info(Phrase.WEBSERVER_CLOSE + "");
|
||||
shutdown = true;
|
||||
try {
|
||||
server.close();
|
||||
if (server != null) {
|
||||
server.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
|
@ -36,8 +36,30 @@ public class FormatUtils {
|
||||
* @return
|
||||
*/
|
||||
public static String formatTimeStamp(long epochMs) {
|
||||
Date sfd = new Date(epochMs);
|
||||
return ("" + sfd).substring(4, 19);
|
||||
Date date = new Date(epochMs);
|
||||
String timeStamp = date.toString();
|
||||
// "EEE MMM dd HH:mm:ss zzz yyyy"
|
||||
// "0123456789012345678901234567"
|
||||
String day = timeStamp.substring(4, 10);
|
||||
String clock = timeStamp.substring(11, 16);
|
||||
return day + ", " + clock;
|
||||
}
|
||||
|
||||
public static String formatTimeStampSecond(long epochMs) {
|
||||
Date date = new Date(epochMs);
|
||||
String timeStamp = date.toString();
|
||||
String day = timeStamp.substring(4, 10);
|
||||
String clock = timeStamp.substring(11, 19);
|
||||
return day + ", " + clock;
|
||||
}
|
||||
|
||||
public static String formatTimeStampYear(long epochMs) {
|
||||
Date date = new Date(epochMs);
|
||||
String timeStamp = date.toString();
|
||||
String year = timeStamp.substring(24);
|
||||
String day = timeStamp.substring(4, 10);
|
||||
String clock = timeStamp.substring(11, 16);
|
||||
return day + " " + year + ", " + clock;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,18 +95,27 @@ public class FormatUtils {
|
||||
x /= 60;
|
||||
long hours = x % 24;
|
||||
x /= 24;
|
||||
long days = x;
|
||||
long days = x % 365;
|
||||
x /= 365;
|
||||
long years = x;
|
||||
if (years != 0) {
|
||||
if (years == 1) {
|
||||
builder.append(Settings.FORMAT_YEAR.toString());
|
||||
} else {
|
||||
builder.append(Settings.FORMAT_YEARS.toString().replace("%years%", "" + years));
|
||||
}
|
||||
}
|
||||
if (days != 0) {
|
||||
builder.append(Settings.FORMAT_DAYS.toString().replace("%days%", ""+days));
|
||||
builder.append(Settings.FORMAT_DAYS.toString().replace("%days%", "" + days));
|
||||
}
|
||||
if (hours != 0) {
|
||||
builder.append(Settings.FORMAT_HOURS.toString().replace("%hours%", ""+hours));
|
||||
builder.append(Settings.FORMAT_HOURS.toString().replace("%hours%", "" + hours));
|
||||
}
|
||||
if (minutes != 0) {
|
||||
builder.append(Settings.FORMAT_MINUTES.toString().replace("%minutes%", ""+minutes));
|
||||
builder.append(Settings.FORMAT_MINUTES.toString().replace("%minutes%", "" + minutes));
|
||||
}
|
||||
if (seconds != 0) {
|
||||
builder.append(Settings.FORMAT_SECONDS.toString().replace("%seconds%", ""+seconds));
|
||||
builder.append(Settings.FORMAT_SECONDS.toString().replace("%seconds%", "" + seconds));
|
||||
}
|
||||
String formattedTime = builder.toString();
|
||||
if (formattedTime.isEmpty()) {
|
||||
|
@ -5,7 +5,6 @@ import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
|
@ -130,7 +130,7 @@ public class PlaceholderUtils {
|
||||
replaceMap.put("#" + defaultCols[i], "#" + colors[i]);
|
||||
}
|
||||
}
|
||||
replaceMap.put("%graphmaxplayers%", plugin.getVariable().getMaxPlayers()+"");
|
||||
replaceMap.put("%graphmaxplayers%", Settings.GRAPH_PLAYERS_USEMAXPLAYERS_SCALE.isTrue() ? plugin.getVariable().getMaxPlayers()+"" : "2");
|
||||
replaceMap.put("%refreshlong%", data.getRefreshDate()+"");
|
||||
replaceMap.put("%servername%", Settings.SERVER_NAME.toString());
|
||||
Benchmark.stop("Replace Placeholders Anaysis");
|
||||
@ -151,7 +151,7 @@ public class PlaceholderUtils {
|
||||
boolean showIPandUUID = Settings.SECURITY_IP_UUID.isTrue();
|
||||
UUID uuid = data.getUuid();
|
||||
replaceMap.put("%uuid%", (showIPandUUID ? "" + uuid : Html.HIDDEN.parse()));
|
||||
replaceMap.put("%lastseen%", FormatUtils.formatTimeStamp(data.getLastPlayed()));
|
||||
replaceMap.put("%lastseen%", FormatUtils.formatTimeStampYear(data.getLastPlayed()));
|
||||
replaceMap.put("%logintimes%", "" + data.getLoginTimes());
|
||||
replaceMap.put("%geoloc%", data.getDemData().getGeoLocation());
|
||||
long now = MiscUtils.getTime();
|
||||
@ -190,7 +190,7 @@ public class PlaceholderUtils {
|
||||
replaceMap.put("%ips%", (showIPandUUID ? data.getIps().toString() : Html.HIDDEN.parse()));
|
||||
replaceMap.put("%nicknames%", HtmlUtils.removeXSS(HtmlUtils.swapColorsToSpan(data.getNicknames().toString())));
|
||||
replaceMap.put("%name%", data.getName());
|
||||
replaceMap.put("%registered%", FormatUtils.formatTimeStamp(data.getRegistered()));
|
||||
replaceMap.put("%registered%", FormatUtils.formatTimeStampYear(data.getRegistered()));
|
||||
replaceMap.put("%timeskicked%", "" + data.getTimesKicked());
|
||||
replaceMap.put("%playtime%", FormatUtils.formatTimeAmount(data.getPlayTime()));
|
||||
replaceMap.put("%banned%", data.isBanned() ? Html.BANNED.parse() : "");
|
||||
|
@ -111,8 +111,8 @@ public class Analysis {
|
||||
* @return
|
||||
*/
|
||||
public boolean analyzeData(List<UserData> rawData, AnalysisCacheHandler analysisCache) {
|
||||
Benchmark.start("Analysis UUID transform");
|
||||
Benchmark.start("Analysis Phase");
|
||||
Benchmark.start("Analysis UUID transform");
|
||||
List<UUID> uuids = rawData.stream().map(d -> d.getUuid()).collect(Collectors.toList());
|
||||
Benchmark.stop("Analysis UUID transform");
|
||||
Benchmark.start("Analysis Create Empty dataset");
|
||||
@ -157,7 +157,8 @@ public class Analysis {
|
||||
analysisData.setPunchCardData(PunchCardGraphCreator.generateDataArray(sorted.getSessiondata()));
|
||||
analysisData.setSessionDistributionData(SessionLengthDistributionGraphCreator.generateDataArraySessions(sorted.getSessiondata()));
|
||||
analysisData.setPlaytimeDistributionData(SessionLengthDistributionGraphCreator.generateDataArray(sorted.getPlaytimes().values()));
|
||||
|
||||
Benchmark.stop("Analysis Phase");
|
||||
log(Phrase.ANALYSIS_THIRD_PARTY + "");
|
||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
|
||||
|
||||
analysisCache.cache(analysisData);
|
||||
|
@ -221,7 +221,7 @@ public class AnalysisUtils {
|
||||
|
||||
private static String logPluginDataCausedError(PluginData source, Throwable e) {
|
||||
Log.error("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""));
|
||||
Log.toLog("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""));
|
||||
Log.toLog("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""), Log.getErrorsFilename());
|
||||
Log.toLog("com.djrapitops.plan.utilities.AnalysisUtils", e);
|
||||
return source.parseContainer("", "Exception during calculation.");
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
package main.java.com.djrapitops.plan.utilities.uuid;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.InputStreamReader;
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.utilities.uuid;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Risto
|
||||
*/
|
||||
public class UUIDUtility {
|
||||
|
||||
public static UUID getUUIDOf(String playername) throws Exception {
|
||||
return getUUIDOf(playername, Plan.getInstance().getDB());
|
||||
}
|
||||
|
||||
public static UUID getUUIDOf(String playername, Database db) throws Exception {
|
||||
UUID uuid = null;
|
||||
try {
|
||||
uuid = db.getUsersTable().getUuidOf(playername);
|
||||
} catch (SQLException e) {
|
||||
Log.toLog("UUIDUtility", e);
|
||||
}
|
||||
if (uuid == null) {
|
||||
uuid = UUIDFetcher.getUUIDOf(playername);
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
}
|
@ -4,6 +4,10 @@ Settings:
|
||||
UseTextUI: false
|
||||
Data:
|
||||
GatherLocations: true
|
||||
ChatListener: true
|
||||
GatherKillData: true
|
||||
GamemodeChangeListener: true
|
||||
GatherCommandUsage: true
|
||||
Analysis:
|
||||
LogProgressOnConsole: false
|
||||
NotifyWhenFinished: true
|
||||
@ -37,8 +41,13 @@ Settings:
|
||||
|
||||
Customization:
|
||||
ServerName: 'Plan'
|
||||
Graphs:
|
||||
PlayersOnlineGraph:
|
||||
UseMaxPlayersAsScale: true
|
||||
Formats:
|
||||
TimeAmount:
|
||||
Year: '1 year, '
|
||||
Years: '%years% years, '
|
||||
Days: '%days%d '
|
||||
Hours: '%hours%h '
|
||||
Minutes: '%minutes%m '
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.Plan
|
||||
version: 3.4.1
|
||||
version: 3.4.2
|
||||
|
||||
softdepend:
|
||||
- OnTime
|
||||
|
@ -6,8 +6,6 @@
|
||||
package test.java.main.java.com.djrapitops.plan;
|
||||
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import test.java.utils.MockUtils;
|
||||
|
@ -22,8 +22,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -11,7 +11,6 @@ import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.cache.SessionCache;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
1
Plan/src/test/java/main/java/com/djrapitops/plan/data/cache/queue/DataCacheSaveQueueTest.java
vendored
1
Plan/src/test/java/main/java/com/djrapitops/plan/data/cache/queue/DataCacheSaveQueueTest.java
vendored
@ -6,7 +6,6 @@
|
||||
package test.java.main.java.com.djrapitops.plan.data.cache.queue;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
|
@ -29,9 +29,6 @@ import test.java.utils.TestInit;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -26,7 +26,6 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -37,8 +37,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.*;
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -235,12 +233,16 @@ public class DatabaseTest {
|
||||
c.put("/help", 21);
|
||||
c.put("/roiergbnougbierubieugbeigubeigubgierbgeugeg", 3);
|
||||
db.saveCommandUse(c);
|
||||
c.remove("/roiergbnougbierubieugbeigubeigubgierbgeugeg");
|
||||
Map<String, Integer> commandUse = db.getCommandUse();
|
||||
assertTrue("Doesn't contain /plan", commandUse.containsKey("/plan"));
|
||||
assertTrue("Doesn't contain /tp", commandUse.containsKey("/tp"));
|
||||
assertTrue("Doesn't contain /pla", commandUse.containsKey("/pla"));
|
||||
assertTrue("Doesn't contain /help", commandUse.containsKey("/help"));
|
||||
assertTrue("Contains too long cmd", !commandUse.containsKey("/roiergbnougbierubieugbeigubeigubgierbgeugeg"));
|
||||
assertEquals(c, commandUse);
|
||||
c.put("/test", 3);
|
||||
c.put("/tp", 6);
|
||||
c.put("/pla", 4);
|
||||
db.saveCommandUse(c);
|
||||
c.put("/pla", 7);
|
||||
commandUse = db.getCommandUse();
|
||||
assertEquals(c, commandUse);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,10 +70,18 @@ public class FormatUtilsTest {
|
||||
@Test
|
||||
public void testFormatTimeStamp() {
|
||||
long epochZero = 0L;
|
||||
String expResult = "Jan 01 02:00:00";
|
||||
String expResult = "Jan 01, 02:00";
|
||||
String result = FormatUtils.formatTimeStamp(epochZero);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTimeStampYear() {
|
||||
long epochZero = 0L;
|
||||
String expResult = "Jan 01 1970, 02:00";
|
||||
String result = FormatUtils.formatTimeStampYear(epochZero);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -11,7 +11,6 @@ import java.nio.file.Files;
|
||||
import java.util.logging.Logger;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
|
Loading…
x
Reference in New Issue
Block a user