Now Compiles (again) with APF 3.0.0

This commit is contained in:
Rsl1122 2017-11-04 21:13:39 +02:00
parent d5415e1018
commit 09a0b47bc8
109 changed files with 506 additions and 914 deletions

View File

@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>com.djrapitops</groupId> <groupId>com.djrapitops</groupId>
<artifactId>abstract-plugin-framework</artifactId> <artifactId>abstract-plugin-framework</artifactId>
<version>2.0.5</version> <version>3.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Connection Pool --> <!-- Connection Pool -->

View File

@ -1,164 +0,0 @@
package main.java.com.djrapitops.plan;
import com.djrapitops.plugin.utilities.log.DebugInfo;
import com.djrapitops.plugin.utilities.log.PluginLog;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.util.Collection;
/**
* This class manages the messages going to the Console Logger.
* <p>
* Methods of Abstract Plugin Framework log utility are used.
*
* @author Rsl1122
* @since 3.0.0
*/
public class Log {
/**
* Constructor used to hide the public constructor
*/
private Log() {
throw new IllegalStateException("Utility Class");
}
/**
* Logs the message to the console as INFO.
*
* @param message "Message" will show up as [INFO][Plan]: Message
*/
public static void info(String message) {
getPluginLogger().info(message);
}
/**
* Sends a message to the console with the ChatColors.
*
* @param message Message to send.
*/
public static void infoColor(String message) {
getPluginLogger().infoColor(message);
}
/**
* Logs an error message to the console as ERROR.
*
* @param message "Message" will show up as [ERROR][Plan]: Message
*/
public static void error(String message) {
getPluginLogger().error(message);
}
/**
* Logs a debug message to the console as INFO if Settings.Debug is true.
*
* @param message "Message" will show up as [INFO][Plan]: [DEBUG] Message
*/
public static void debug(String message) {
getPluginLogger().debug(message);
}
/**
* Used for logging larger debug complexes.
*
* @param task complex this debug message is a part of.
* @param message Single message to add to the debug log.
* @return full debug complex so far.
*/
public static DebugInfo debug(String task, String message) {
return getDebug(task).addLine(message, MiscUtils.getTime());
}
/**
* Used for logging larger debug complexes.
*
* @param task complex this debug message is a part of.
* @param messages All messages to add to the debug log.
* @return full debug complex so far.
*/
public static DebugInfo debug(String task, String... messages) {
DebugInfo debug = getDebug(task);
long time = MiscUtils.getTime();
for (String message : messages) {
debug.addLine(message, time);
}
return debug;
}
/**
* Used for logging larger debug complexes.
*
* @param task complex to get
* @return full debug complex so far.
*/
public static DebugInfo getDebug(String task) {
return getPluginLogger().getDebug(task);
}
/**
* Logs the full debug complex to the debug log.
*
* @param task complex to log.
*/
public static void logDebug(String task) {
getDebug(task).toLog();
}
/**
* Logs the full debug complex to the debug log with an execution time.
*
* @param task complex to log.
* @param time execution time.
*/
public static void logDebug(String task, long time) {
getDebug(task).toLog(time);
}
/**
* Logs trace of caught Exception to Errors.txt and notifies on console.
*
* @param source Class name the exception was caught in.
* @param e {@code Throwable}, eg NullPointerException
*/
public static void toLog(String source, Throwable e) {
getPluginLogger().toLog(source, e);
}
/**
* Logs multiple caught Errors to Errors.txt.
*
* @param source Class name the exception was caught in.
* @param e Collection of {@code Throwable}, eg NullPointerException
*/
public static void toLog(String source, Collection<Throwable> e) {
Plan.getInstance().getPluginLogger().toLog(source, e);
}
private static PluginLog getPluginLogger() {
return MiscUtils.getIPlan().getPluginLogger();
}
public static void logStackTrace(Throwable e) {
error(e.toString());
for (StackTraceElement stackTraceElement : e.getStackTrace()) {
error(" " + stackTraceElement);
}
Throwable cause = e.getCause();
if (cause != null) {
logCause(cause);
}
}
private static void logCause(Throwable e) {
error("caused by: " + e.toString());
for (StackTraceElement stackTraceElement : e.getStackTrace()) {
error(" " + stackTraceElement);
}
Throwable cause = e.getCause();
if (cause != null) {
logCause(cause);
}
}
}

View File

@ -20,7 +20,12 @@
package main.java.com.djrapitops.plan; package main.java.com.djrapitops.plan;
import com.djrapitops.plugin.BukkitPlugin; import com.djrapitops.plugin.BukkitPlugin;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.config.Config;
import com.djrapitops.plugin.api.utility.Version;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.ITask; import com.djrapitops.plugin.task.ITask;
@ -41,7 +46,6 @@ import main.java.com.djrapitops.plan.systems.cache.GeolocationCache;
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager; import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
import main.java.com.djrapitops.plan.systems.info.ImporterManager; import main.java.com.djrapitops.plan.systems.info.ImporterManager;
import main.java.com.djrapitops.plan.systems.info.InformationManager; import main.java.com.djrapitops.plan.systems.info.InformationManager;
import main.java.com.djrapitops.plan.systems.info.pluginchannel.BukkitPluginChannelListener;
import main.java.com.djrapitops.plan.systems.info.server.BukkitServerInfoManager; import main.java.com.djrapitops.plan.systems.info.server.BukkitServerInfoManager;
import main.java.com.djrapitops.plan.systems.listeners.*; import main.java.com.djrapitops.plan.systems.listeners.*;
import main.java.com.djrapitops.plan.systems.processing.Processor; import main.java.com.djrapitops.plan.systems.processing.Processor;
@ -50,11 +54,12 @@ import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer; import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
import main.java.com.djrapitops.plan.systems.webserver.PageCache; import main.java.com.djrapitops.plan.systems.webserver.PageCache;
import main.java.com.djrapitops.plan.systems.webserver.WebServer; import main.java.com.djrapitops.plan.systems.webserver.WebServer;
import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.file.FileUtil;
import main.java.com.djrapitops.plan.utilities.metrics.BStats; import main.java.com.djrapitops.plan.utilities.metrics.BStats;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import java.io.File;
import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -69,11 +74,12 @@ import java.util.UUID;
* @author Rsl1122 * @author Rsl1122
* @since 1.0.0 * @since 1.0.0
*/ */
public class Plan extends BukkitPlugin<Plan> implements IPlan { public class Plan extends BukkitPlugin implements IPlan {
private boolean reloading = false;
private API api; private API api;
private Config config;
private ProcessingQueue processingQueue; private ProcessingQueue processingQueue;
private HookHandler hookHandler; // Manages 3rd party data sources private HookHandler hookHandler; // Manages 3rd party data sources
@ -111,7 +117,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
* @return this object. * @return this object.
*/ */
public static Plan getInstance() { public static Plan getInstance() {
return (Plan) getPluginInstance(Plan.class); return (Plan) StaticHolder.getInstance(Plan.class);
} }
public static UUID getServerUUID() { public static UUID getServerUUID() {
@ -129,18 +135,21 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
*/ */
@Override @Override
public void onEnable() { public void onEnable() {
super.onEnable();
Log.setDebugMode(Settings.DEBUG.toString());
String currentVersion = getVersion();
String githubVersionUrl = "https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml";
String spigotUrl = "https://www.spigotmc.org/resources/plan-player-analytics.32536/";
try {
if (Version.checkVersion(currentVersion, githubVersionUrl) || Version.checkVersion(currentVersion, spigotUrl)) {
Log.infoColor("§a----------------------------------------");
Log.infoColor("§aNew version is available at https://www.spigotmc.org/resources/plan-player-analytics.32536/");
Log.infoColor("§a----------------------------------------");
}
} catch (IOException e) {
Log.error("Failed to check newest version number");
}
try { try {
// Sets the Required variables for BukkitPlugin instance to function correctly
setInstance(this);
super.setDebugMode(Settings.DEBUG.toString());
initColorScheme();
super.setLogPrefix("[Plan]");
super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
super.setUpdateUrl("https://www.spigotmc.org/resources/plan-player-analytics.32536/");
// Initializes BukkitPlugin variables, Checks version & Logs the debug header
super.onEnableDefaultTasks();
Benchmark.start("Enable"); Benchmark.start("Enable");
GeolocationCache.checkDB(); GeolocationCache.checkDB();
@ -149,19 +158,19 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
Benchmark.start("Reading server variables"); Benchmark.start("Reading server variables");
serverVariableHolder = new ServerVariableHolder(getServer()); serverVariableHolder = new ServerVariableHolder(getServer());
Benchmark.stop("Enable", "Reading server variables"); Log.logDebug("Enable", Benchmark.stopAndFormat("Reading server variables"));
Benchmark.start("Copy default config"); Benchmark.start("Copy default config");
getConfig().options().copyDefaults(true); File configFile = new File(getDataFolder(), "config.yml");
getConfig().options().header("Plan Config | More info at https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/documentation/Configuration.md"); config = new Config(configFile, FileUtil.lines(this, configFile, "config.yml"));
saveConfig(); config.save();
Benchmark.stop("Enable", "Copy default config"); Log.logDebug("Enable", Benchmark.stopAndFormat("Copy default config"));
Benchmark.start("Init Database"); Benchmark.start("Init Database");
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString()); Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
initDatabase(); initDatabase();
Benchmark.stop("Enable", "Init Database"); Log.logDebug("Enable", Benchmark.stopAndFormat("Init Database"));
Benchmark.start("WebServer Initialization"); Benchmark.start("WebServer Initialization");
webServer = new WebServer(this); webServer = new WebServer(this);
@ -177,7 +186,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
} }
serverInfoManager.updateServerInfo(); serverInfoManager.updateServerInfo();
Benchmark.stop("Enable", "WebServer Initialization"); Log.logDebug("Enable", Benchmark.stopAndFormat("WebServer Initialization"));
if (!reloading) { if (!reloading) {
registerListeners(); registerListeners();
@ -197,45 +206,35 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
Log.info("Make sure that the alternative IP points to the Bukkit Server: " + Settings.ALTERNATIVE_IP.toString()); Log.info("Make sure that the alternative IP points to the Bukkit Server: " + Settings.ALTERNATIVE_IP.toString());
} }
registerCommand(new PlanCommand(this)); registerCommand("plan", new PlanCommand(this));
Benchmark.start("Hook to 3rd party plugins"); Benchmark.start("Hook to 3rd party plugins");
hookHandler = new HookHandler(this); hookHandler = new HookHandler(this);
Benchmark.stop("Enable", "Hook to 3rd party plugins"); Log.logDebug("Enable", Benchmark.stopAndFormat("Hook to 3rd party plugins"));
ImporterManager.registerImporter(new OfflinePlayerImporter()); ImporterManager.registerImporter(new OfflinePlayerImporter());
// if (Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isFalse()) {
// registerPluginChannelListener();
// }
BStats bStats = new BStats(this); BStats bStats = new BStats(this);
bStats.registerMetrics(); bStats.registerMetrics();
Log.debug("Verbose debug messages are enabled."); Log.debug("Verbose debug messages are enabled.");
Log.logDebug("Enable", Benchmark.stop("Enable", "Enable")); Log.logDebug("Enable", Benchmark.stopAndFormat("Enable"));
Log.info(Locale.get(Msg.ENABLED).toString()); Log.info(Locale.get(Msg.ENABLED).toString());
new ShutdownHook(this); new ShutdownHook(this);
} catch (Exception e) { } catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly."); Log.error("Plugin Failed to Initialize Correctly.");
Log.logStackTrace(e); Log.toLog(this.getClass().getName(), e);
disablePlugin(); onDisable();
} }
} }
private void registerPluginChannelListener() {
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "Plan", new BukkitPluginChannelListener(this));
}
private void registerTasks() { private void registerTasks() {
RunnableFactory runnableFactory = getRunnableFactory();
String bootAnalysisMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_INFO).toString(); String bootAnalysisMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_INFO).toString();
String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString(); String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString();
Benchmark.start("Task Registration"); Benchmark.start("Task Registration");
tpsCountTimer = new TPSCountTimer(this); tpsCountTimer = new TPSCountTimer(this);
runnableFactory.createNew(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks()); RunnableFactory.createNew(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks());
// Analysis refresh settings // Analysis refresh settings
int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber(); int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber();
@ -244,7 +243,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
Log.info(bootAnalysisMsg); Log.info(bootAnalysisMsg);
ITask bootAnalysisTask = runnableFactory.createNew("BootAnalysisTask", new AbsRunnable() { ITask bootAnalysisTask = RunnableFactory.createNew("BootAnalysisTask", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
Log.info(bootAnalysisRunMsg); Log.info(bootAnalysisRunMsg);
@ -256,7 +255,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
bootAnalysisTaskID = bootAnalysisTask.getTaskId(); bootAnalysisTaskID = bootAnalysisTask.getTaskId();
if (analysisRefreshTaskIsEnabled) { if (analysisRefreshTaskIsEnabled) {
runnableFactory.createNew("PeriodicalAnalysisTask", new AbsRunnable() { RunnableFactory.createNew("PeriodicalAnalysisTask", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
infoManager.refreshAnalysis(getServerUUID()); infoManager.refreshAnalysis(getServerUUID());
@ -264,25 +263,26 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
}).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod); }).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod);
} }
runnableFactory.createNew("PeriodicNetworkBoxRefreshTask", new AbsRunnable() { RunnableFactory.createNew("PeriodicNetworkBoxRefreshTask", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
infoManager.updateNetworkPageContent(); infoManager.updateNetworkPageContent();
} }
}).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks(), TimeAmount.MINUTE.ticks() * 5L); }).runTaskTimerAsynchronously(TimeAmount.SECOND.ticks(), TimeAmount.MINUTE.ticks() * 5L);
Benchmark.stop("Enable", "Task Registration"); Log.logDebug("Enable", Benchmark.stopAndFormat("Task Registration"));
} }
private void initColorScheme() { @Override
public ColorScheme getColorScheme() {
try { try {
ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1)); ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1));
ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1)); ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1));
ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1)); ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1));
super.setColorScheme(new ColorScheme(mainColor, secColor, terColor)); return new ColorScheme(mainColor, secColor, terColor);
} catch (Exception e) { } catch (Exception e) {
Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults."); Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults.");
super.setColorScheme(new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE)); return new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE);
} }
} }
@ -308,7 +308,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
processor.process(); processor.process();
} }
} else { } else {
getRunnableFactory().createNew("Re-Add processors", new AbsRunnable() { RunnableFactory.createNew("Re-Add processors", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
addToProcessQueue(processors.toArray(new Processor[processors.size()])); addToProcessQueue(processors.toArray(new Processor[processors.size()]));
@ -317,17 +317,20 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L); }).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L);
} }
} }
super.onDisable();
getServer().getScheduler().cancelTasks(this);
if (Verify.notNull(infoManager, db)) {
taskStatus().cancelAllKnownTasks();
}
getPluginLogger().endAllDebugs();
Log.info(Locale.get(Msg.DISABLED).toString()); Log.info(Locale.get(Msg.DISABLED).toString());
} }
@Override
public String getVersion() {
return getDescription().getVersion();
}
@Override
public void onReload() {
reloadConfig();
}
private void registerListeners() { private void registerListeners() {
Benchmark.start("Register Listeners"); Benchmark.start("Register Listeners");
registerListener(new PlanPlayerListener(this)); registerListener(new PlanPlayerListener(this));
@ -336,7 +339,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
registerListener(new PlanWorldChangeListener(this)); registerListener(new PlanWorldChangeListener(this));
registerListener(new PlanCommandPreprocessListener(this)); registerListener(new PlanCommandPreprocessListener(this));
registerListener(new PlanDeathEventListener(this)); registerListener(new PlanDeathEventListener(this));
Benchmark.stop("Enable", "Register Listeners"); Log.logDebug("Enable", Benchmark.stopAndFormat("Register Listeners"));
} }
/** /**
@ -460,7 +463,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
processingQueue.addToQueue(processor); processingQueue.addToQueue(processor);
} }
} else { } else {
getRunnableFactory().createNew("Re-Add processors", new AbsRunnable() { RunnableFactory.createNew("Re-Add processors", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
addToProcessQueue(processors); addToProcessQueue(processors);
@ -470,16 +473,13 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
} }
} }
public InformationManager getInfoManager() { @Override
return infoManager; public Config getMainConfig() {
return null;
} }
public void restart() { public InformationManager getInfoManager() {
reloading = true; return infoManager;
onDisable();
reloadConfig();
onEnable();
reloading = false;
} }
public boolean isReloading() { public boolean isReloading() {

View File

@ -5,9 +5,15 @@
package main.java.com.djrapitops.plan; package main.java.com.djrapitops.plan;
import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.BungeePlugin;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.config.Config;
import com.djrapitops.plugin.api.utility.Version;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.command.PlanBungeeCommand; import main.java.com.djrapitops.plan.command.PlanBungeeCommand;
@ -23,9 +29,9 @@ import main.java.com.djrapitops.plan.systems.processing.Processor;
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue; import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer; import main.java.com.djrapitops.plan.systems.tasks.TPSCountTimer;
import main.java.com.djrapitops.plan.systems.webserver.WebServer; import main.java.com.djrapitops.plan.systems.webserver.WebServer;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
@ -35,7 +41,9 @@ import java.util.UUID;
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan { public class PlanBungee extends BungeePlugin implements IPlan {
private Config config;
private WebServer webServer; private WebServer webServer;
private Database db; private Database db;
@ -47,18 +55,21 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
@Override @Override
public void onEnable() { public void onEnable() {
super.onEnable();
Log.setDebugMode(Settings.DEBUG.toString());
String currentVersion = getVersion();
String githubVersionUrl = "https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml";
String spigotUrl = "https://www.spigotmc.org/resources/plan-player-analytics.32536/";
try {
if (Version.checkVersion(currentVersion, githubVersionUrl) || Version.checkVersion(currentVersion, spigotUrl)) {
Log.infoColor("§a----------------------------------------");
Log.infoColor("§aNew version is available at https://www.spigotmc.org/resources/plan-player-analytics.32536/");
Log.infoColor("§a----------------------------------------");
}
} catch (IOException e) {
Log.error("Failed to check newest version number");
}
try { try {
super.setInstance(this);
super.copyDefaultConfig("Plan Config | More info at https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/documentation/Configuration.md");
super.setDebugMode(Settings.DEBUG.toString());
super.getPluginLogger().setFolder(getDataFolder());
super.setColorScheme(new ColorScheme(ChatColor.GREEN, ChatColor.GRAY, ChatColor.WHITE));
super.setLogPrefix("[Plan]");
super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
super.setUpdateUrl("https://www.spigotmc.org/resources/plan-player-analytics.32536/");
super.onEnableDefaultTasks();
variableHolder = new ServerVariableHolder(getProxy()); variableHolder = new ServerVariableHolder(getProxy());
new Locale(this).loadLocale(); new Locale(this).loadLocale();
@ -66,7 +77,7 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString()); Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
initDatabase(); initDatabase();
registerCommand(new PlanBungeeCommand(this)); registerCommand("planbungee", new PlanBungeeCommand(this));
String ip = variableHolder.getIp(); String ip = variableHolder.getIp();
if ("0.0.0.0".equals(ip)) { if ("0.0.0.0".equals(ip)) {
@ -86,44 +97,41 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
if (!webServer.isEnabled()) { if (!webServer.isEnabled()) {
Log.error("WebServer was not successfully initialized."); Log.error("WebServer was not successfully initialized.");
disablePlugin(); onDisable();
return; return;
} }
getRunnableFactory().createNew("Enable Bukkit Connection Task", new AbsRunnable() { RunnableFactory.createNew("Enable Bukkit Connection Task", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
infoManager.attemptConnection(); infoManager.attemptConnection();
infoManager.sendConfigSettings(); infoManager.sendConfigSettings();
} }
}).runTaskAsynchronously(); }).runTaskAsynchronously();
getRunnableFactory().createNew("Player Count task", new TPSCountTimer(this)) RunnableFactory.createNew("Player Count task", new TPSCountTimer(this))
.runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks()); .runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks());
getRunnableFactory().createNew("NetworkPageContentUpdateTask", new AbsRunnable("NetworkPageContentUpdateTask") { RunnableFactory.createNew("NetworkPageContentUpdateTask", new AbsRunnable("NetworkPageContentUpdateTask") {
@Override @Override
public void run() { public void run() {
infoManager.updateNetworkPageContent(); infoManager.updateNetworkPageContent();
} }
}).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks()); }).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks());
// getProxy().registerChannel("Plan");
// registerListener(new BungeePluginChannelListener(this));
processingQueue = new ProcessingQueue(); processingQueue = new ProcessingQueue();
registerListener(new BungeePlayerListener(this)); registerListener(new BungeePlayerListener(this));
Benchmark.stop("Enable", "WebServer Initialization"); Log.logDebug("Enable", "WebServer Initialization");
Log.info(Locale.get(Msg.ENABLED).toString()); Log.info(Locale.get(Msg.ENABLED).toString());
} catch (Exception e) { } catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly."); Log.error("Plugin Failed to Initialize Correctly.");
Log.logStackTrace(e); Log.toLog(this.getClass().getName(), e);
disablePlugin(); onDisable();
} }
} }
public static PlanBungee getInstance() { public static PlanBungee getInstance() {
return getInstance(PlanBungee.class); return (PlanBungee) StaticHolder.getInstance(PlanBungee.class);
} }
@Override @Override
@ -148,6 +156,16 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
Log.info(Locale.get(Msg.DISABLED).toString()); Log.info(Locale.get(Msg.DISABLED).toString());
} }
@Override
public String getVersion() {
return null;
}
@Override
public void onReload() {
}
private void initDatabase() throws DatabaseInitException { private void initDatabase() throws DatabaseInitException {
db = new MySQLDB(this); db = new MySQLDB(this);
db.init(); db.init();
@ -190,6 +208,24 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
return getResourceAsStream(resource); return getResourceAsStream(resource);
} }
@Override
public Config getMainConfig() {
return config;
}
@Override
public ColorScheme getColorScheme() {
try {
ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1));
ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1));
ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1));
return new ColorScheme(mainColor, secColor, terColor);
} catch (Exception e) {
Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults.");
return new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE);
}
}
@Override @Override
public ServerVariableHolder getVariable() { public ServerVariableHolder getVariable() {
return variableHolder; return variableHolder;
@ -202,10 +238,4 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
public UUID getServerUuid() { public UUID getServerUuid() {
return serverInfoManager.getServerUUID(); return serverInfoManager.getServerUUID();
} }
@Override
public void restart() {
onDisable();
onEnable();
}
} }

View File

@ -4,10 +4,9 @@
*/ */
package main.java.com.djrapitops.plan; package main.java.com.djrapitops.plan;
import com.djrapitops.plugin.config.IConfig; import com.djrapitops.plugin.api.config.Config;
import com.djrapitops.plugin.config.fileconfig.IFileConfig; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import org.bukkit.configuration.file.FileConfiguration;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
@ -25,15 +24,14 @@ public class ServerSpecificSettings {
public void addOriginalBukkitSettings(PlanBungee plugin, UUID serverUUID, Map<String, Object> settings) { public void addOriginalBukkitSettings(PlanBungee plugin, UUID serverUUID, Map<String, Object> settings) {
try { try {
IConfig iConfig = plugin.getIConfig(); Config config = plugin.getMainConfig();
IFileConfig config = iConfig.getConfig();
if (!Verify.isEmpty(config.getString("Servers." + serverUUID + ".ServerName"))) { if (!Verify.isEmpty(config.getString("Servers." + serverUUID + ".ServerName"))) {
return; return;
} }
for (Map.Entry<String, Object> entry : settings.entrySet()) { for (Map.Entry<String, Object> entry : settings.entrySet()) {
config.set("Servers." + serverUUID + "." + entry.getKey(), entry.getValue()); config.set("Servers." + serverUUID + "." + entry.getKey(), entry.getValue());
} }
iConfig.save(); config.save();
} catch (IOException e) { } catch (IOException e) {
Log.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
} }
@ -41,7 +39,7 @@ public class ServerSpecificSettings {
public static void updateSettings(Plan plugin, Map<String, String> settings) { public static void updateSettings(Plan plugin, Map<String, String> settings) {
Log.debug("Checking new settings.."); Log.debug("Checking new settings..");
FileConfiguration config = plugin.getConfig(); Config config = plugin.getMainConfig();
boolean changedSomething = false; boolean changedSomething = false;
for (Map.Entry<String, String> setting : settings.entrySet()) { for (Map.Entry<String, String> setting : settings.entrySet()) {
@ -52,7 +50,7 @@ public class ServerSpecificSettings {
} }
String stringValue = setting.getValue(); String stringValue = setting.getValue();
Object value = getValue(stringValue); Object value = getValue(stringValue);
String currentValue = config.get(path).toString(); String currentValue = config.getString(path);
if (stringValue.equals(currentValue)) { if (stringValue.equals(currentValue)) {
continue; continue;
} }
@ -64,11 +62,15 @@ public class ServerSpecificSettings {
} }
if (changedSomething) { if (changedSomething) {
plugin.saveConfig(); try {
config.save();
} catch (IOException e) {
Log.toLog("ServerSpecificSettings / ConfigSave", e);
}
Log.info("----------------------------------"); Log.info("----------------------------------");
Log.info("The Received Bungee Settings changed the config values, restarting Plan.."); Log.info("The Received Bungee Settings changed the config values, restarting Plan..");
Log.info("----------------------------------"); Log.info("----------------------------------");
plugin.restart(); plugin.reloadPlugin(true);
} else { } else {
Log.debug("Settings up to date"); Log.debug("Settings up to date");
} }
@ -105,63 +107,28 @@ public class ServerSpecificSettings {
return path; return path;
} }
public Object get(UUID serverUUID, Settings setting) {
try {
IFileConfig config = PlanBungee.getInstance().getIConfig().getConfig();
String path = getPath(serverUUID, setting);
String value = config.getString(path);
try {
return Boolean.parseBoolean(value);
} catch (Exception e) {
if (Verify.isEmpty(value)) {
return config.getInt(value);
}
return value;
}
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
}
return null;
}
public boolean getBoolean(UUID serverUUID, Settings setting) { public boolean getBoolean(UUID serverUUID, Settings setting) {
try { Config config = PlanBungee.getInstance().getMainConfig();
IFileConfig config = PlanBungee.getInstance().getIConfig().getConfig(); String path = getPath(serverUUID, setting);
String path = getPath(serverUUID, setting); return config.getBoolean(path);
return config.getBoolean(path);
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
}
return false;
} }
public String getString(UUID serverUUID, Settings setting) { public String getString(UUID serverUUID, Settings setting) {
try { Config config = PlanBungee.getInstance().getMainConfig();
IFileConfig config = PlanBungee.getInstance().getIConfig().getConfig(); String path = getPath(serverUUID, setting);
String path = getPath(serverUUID, setting); return config.getString(path);
return config.getString(path);
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
}
return null;
} }
public Integer getInt(UUID serverUUID, Settings setting) { public Integer getInt(UUID serverUUID, Settings setting) {
try { Config config = PlanBungee.getInstance().getMainConfig();
IFileConfig config = PlanBungee.getInstance().getIConfig().getConfig(); String path = getPath(serverUUID, setting);
String path = getPath(serverUUID, setting); return config.getInt(path);
return config.getInt(path);
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
}
return null;
} }
public void set(UUID serverUUID, Settings setting, Object value) throws IOException { public void set(UUID serverUUID, Settings setting, Object value) throws IOException {
IConfig iConfig = PlanBungee.getInstance().getIConfig(); Config config = PlanBungee.getInstance().getMainConfig();
IFileConfig config = iConfig.getConfig();
String path = getPath(serverUUID, setting); String path = getPath(serverUUID, setting);
config.set(path, value); config.set(path, value);
iConfig.save(); config.save();
} }
} }

View File

@ -1,10 +1,9 @@
package main.java.com.djrapitops.plan; package main.java.com.djrapitops.plan;
import com.djrapitops.plugin.config.fileconfig.BukkitFileConfig; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.config.fileconfig.IFileConfig; import com.djrapitops.plugin.api.config.Config;
import com.djrapitops.plugin.utilities.Compatibility; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
@ -124,7 +123,7 @@ public enum Settings {
if (value != null) { if (value != null) {
return value; return value;
} }
return getConfig().getBoolean(configPath); return getConfig().getConfigNode(configPath).getBoolean();
} }
public boolean isFalse() { public boolean isFalse() {
@ -142,7 +141,7 @@ public enum Settings {
*/ */
@Override @Override
public String toString() { public String toString() {
return getConfig().getString(configPath); return getConfig().getConfigNode(configPath).getString();
} }
/** /**
@ -151,11 +150,11 @@ public enum Settings {
* @return Integer value of the config setting * @return Integer value of the config setting
*/ */
public int getNumber() { public int getNumber() {
return getConfig().getInt(configPath); return getConfig().getConfigNode(configPath).getInt();
} }
public List<String> getStringList() { public List<String> getStringList() {
return getConfig().getStringList(configPath); return getConfig().getConfigNode(configPath).getStringList();
} }
/** /**
@ -168,20 +167,12 @@ public enum Settings {
return configPath; return configPath;
} }
private IFileConfig getConfig() { private Config getConfig() {
try { return MiscUtils.getIPlan().getMainConfig();
if (Compatibility.isBukkitAvailable()) {
return new BukkitFileConfig(Plan.getInstance().getConfig());
} else {
return PlanBungee.getInstance().getIConfig().getConfig();
}
} catch (IOException e) {
throw new IllegalStateException("Config could not be loaded.", e);
}
} }
public static ServerSpecificSettings serverSpecific() { public static ServerSpecificSettings serverSpecific() {
if (!Compatibility.isBungeeAvailable()) { if (!Check.isBungeeAvailable()) {
throw new IllegalStateException("Not supposed to call this method on Bukkit"); throw new IllegalStateException("Not supposed to call this method on Bukkit");
} }

View File

@ -4,6 +4,7 @@
*/ */
package main.java.com.djrapitops.plan; package main.java.com.djrapitops.plan;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.data.Action; import main.java.com.djrapitops.plan.data.Action;
import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.Session;

View File

@ -1,19 +1,20 @@
package main.java.com.djrapitops.plan.api; package main.java.com.djrapitops.plan.api;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import com.djrapitops.plugin.utilities.player.Fetch;
import com.djrapitops.plugin.utilities.player.IOfflinePlayer;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.AnalysisData; import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData; import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager; import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility; import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
import org.bukkit.OfflinePlayer;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import static org.bukkit.Bukkit.getOfflinePlayer;
/** /**
* This class contains the API methods for Bukkit version of the plugin. * This class contains the API methods for Bukkit version of the plugin.
* <p> * <p>
@ -43,7 +44,7 @@ public class API {
} }
/** /**
* Check whether or not the plugin enabled successfully. * Condition whether or not the plugin enabled successfully.
* *
* @return true if plugin is enabled correctly. * @return true if plugin is enabled correctly.
*/ */
@ -86,7 +87,7 @@ public class API {
} }
/** /**
* Check if Players's Inspect page is cached to PageCache. * Condition if Players's Inspect page is cached to PageCache.
* *
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @return true/false * @return true/false
@ -98,7 +99,7 @@ public class API {
} }
/** /**
* Check if Players's Inspect page is cached to PageCache of the providing WebServer. * Condition if Players's Inspect page is cached to PageCache of the providing WebServer.
* <p> * <p>
* Using BungeeCord: Will send a {@code IsCachedWebAPI} request to check if the page is in Bungee's PageCache. * Using BungeeCord: Will send a {@code IsCachedWebAPI} request to check if the page is in Bungee's PageCache.
* Only Bukkit: Checks PageCache for page. * Only Bukkit: Checks PageCache for page.
@ -147,7 +148,7 @@ public class API {
} }
/** /**
* Check if the Analysis has been run and is cached to the AnalysisCache. * Condition if the Analysis has been run and is cached to the AnalysisCache.
* *
* @return true/false * @return true/false
*/ */
@ -165,7 +166,7 @@ public class API {
/** /**
* Used to get the full HTML of the Analysis page as a string. * Used to get the full HTML of the Analysis page as a string.
* <p> * <p>
* Check if the data is cached to AnalysisCache before calling this. * Condition if the data is cached to AnalysisCache before calling this.
* *
* @return server.html with all placeholders replaced. * @return server.html with all placeholders replaced.
* @throws NullPointerException if AnalysisData has not been cached. * @throws NullPointerException if AnalysisData has not been cached.
@ -177,7 +178,7 @@ public class API {
/** /**
* Used to get the AnalysisData object. * Used to get the AnalysisData object.
* <p> * <p>
* Check if the data is cached to AnalysisCache before calling this. * Condition if the data is cached to AnalysisCache before calling this.
* *
* @return AnalysisData object. * @return AnalysisData object.
* @see AnalysisData * @see AnalysisData
@ -201,7 +202,7 @@ public class API {
if (playerName != null) { if (playerName != null) {
return playerName; return playerName;
} }
IOfflinePlayer offlinePlayer = Fetch.getIOfflinePlayer(uuid); OfflinePlayer offlinePlayer = getOfflinePlayer(uuid);
if (offlinePlayer != null) { if (offlinePlayer != null) {
return offlinePlayer.getName(); return offlinePlayer.getName();
} }

View File

@ -5,7 +5,8 @@
package main.java.com.djrapitops.plan.api; package main.java.com.djrapitops.plan.api;
import com.djrapitops.plugin.IPlugin; import com.djrapitops.plugin.IPlugin;
import com.djrapitops.plugin.config.IConfig; import com.djrapitops.plugin.api.config.Config;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.ServerVariableHolder; import main.java.com.djrapitops.plan.ServerVariableHolder;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.systems.info.InformationManager; import main.java.com.djrapitops.plan.systems.info.InformationManager;
@ -14,7 +15,6 @@ import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
import main.java.com.djrapitops.plan.systems.webserver.WebServer; import main.java.com.djrapitops.plan.systems.webserver.WebServer;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.UUID; import java.util.UUID;
@ -42,7 +42,7 @@ public interface IPlan extends IPlugin {
InputStream getResource(String resource); InputStream getResource(String resource);
IConfig getIConfig() throws IOException; Config getMainConfig();
void restart(); ColorScheme getColorScheme();
} }

View File

@ -21,12 +21,12 @@ public class ConditionUtils {
} }
/** /**
* Check if the player has played. * Condition if the player has played.
* *
* @param uuid UUID of player * @param uuid UUID of player
* @return has the player played before, false if uuid is null. * @return has the player played before, false if uuid is null.
*/ */
public static boolean playerHasPlayed(UUID uuid) { public static boolean playerHasPlayed(UUID uuid) {
return Verify.notNull(uuid) && Plan.getInstance().fetch().hasPlayedBefore(uuid); return Verify.notNull(uuid) && Plan.getInstance().getServer().getOfflinePlayer(uuid).hasPlayedBefore();
} }
} }

View File

@ -39,7 +39,7 @@ public class PlanBungeeCommand extends TreeCommand<PlanBungee> {
@Override @Override
public void addCommands() { public void addCommands() {
commands.add(new ReloadCommand(plugin)); commands.add(new ReloadCommand(plugin));
commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission())); commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()));
commands.add(new ListCommand()); commands.add(new ListCommand());
RegisterCommand registerCommand = new RegisterCommand(plugin); RegisterCommand registerCommand = new RegisterCommand(plugin);
commands.add(registerCommand); commands.add(registerCommand);

View File

@ -45,7 +45,7 @@ public class PlanCommand extends TreeCommand<Plan> {
commands.add(new InfoCommand(plugin)); commands.add(new InfoCommand(plugin));
commands.add(new ReloadCommand(plugin)); commands.add(new ReloadCommand(plugin));
commands.add(new ManageCommand(plugin)); commands.add(new ManageCommand(plugin));
commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission())); commands.add(new StatusCommand<>(plugin, Permissions.MANAGE.getPermission(), plugin.getColorScheme()));
commands.add(new ListCommand()); commands.add(new ListCommand());
RegisterCommand registerCommand = new RegisterCommand(plugin); RegisterCommand registerCommand = new RegisterCommand(plugin);
commands.add(registerCommand); commands.add(registerCommand);

View File

@ -1,12 +1,12 @@
package main.java.com.djrapitops.plan.command.commands; package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;

View File

@ -13,7 +13,7 @@ import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI; import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI;
import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebAPI; import main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit.InspectWebAPI;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@ -28,19 +28,19 @@ public class DevCommand extends SubCommand {
private final Plan plugin; private final Plan plugin;
public DevCommand(Plan plugin) { public DevCommand(Plan plugin) {
super("dev", CommandType.CONSOLE_WITH_ARGUMENTS, "plan.*", "Test Plugin functions not testable with unit tests.", "<feature to test>"); super("dev", CommandType.PLAYER_OR_ARGS, "plan.*", "Test Plugin functions not testable with unit tests.", "<feature to test>");
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public boolean onCommand(ISender sender, String cmd, String[] args) { public boolean onCommand(ISender sender, String cmd, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return true;
} }
String feature = args[0]; String feature = args[0];
switch (feature) { switch (feature) {
case "webapi": case "webapi":
if (!Check.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
break; break;
} }
if (!webapi(args[1] + "webapi", args.length >= 3)) { if (!webapi(args[1] + "webapi", args.length >= 3)) {

View File

@ -4,7 +4,6 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.settings.Version;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
@ -40,11 +39,11 @@ public class InfoCommand extends SubCommand {
String mColor = cs.getMainColor(); String mColor = cs.getMainColor();
String sColor = cs.getSecondaryColor(); String sColor = cs.getSecondaryColor();
String tColor = cs.getTertiaryColor(); String tColor = cs.getTertiaryColor();
String ball = Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString();
String[] messages = { String[] messages = {
Locale.get(Msg.CMD_HEADER_INFO).toString(), Locale.get(Msg.CMD_HEADER_INFO).toString(),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + mColor + " Version: " + sColor + plugin.getDescription().getVersion(), ball + mColor + " Version: " + sColor + plugin.getDescription().getVersion(),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + tColor + " " + Version.checkVersion(plugin), ball + mColor + " Active Database: " + tColor + plugin.getDB().getConfigName(),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + mColor + " Active Database: " + tColor + plugin.getDB().getConfigName(),
Locale.get(Msg.CMD_CONSTANT_FOOTER).toString() Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()
}; };
sender.sendMessage(messages); sender.sendMessage(messages);

View File

@ -1,19 +1,19 @@
package main.java.com.djrapitops.plan.command.commands; package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.command.ConditionUtils; import main.java.com.djrapitops.plan.command.ConditionUtils;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor; import main.java.com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility; import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -38,7 +38,7 @@ public class InspectCommand extends SubCommand {
*/ */
public InspectCommand(Plan plugin) { public InspectCommand(Plan plugin) {
super("inspect", super("inspect",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.INSPECT.getPermission(), Permissions.INSPECT.getPermission(),
Locale.get(Msg.CMD_USG_INSPECT).toString(), Locale.get(Msg.CMD_USG_INSPECT).toString(),
"<player>"); "<player>");
@ -66,13 +66,13 @@ public class InspectCommand extends SubCommand {
public void run() { public void run() {
try { try {
UUID uuid = UUIDUtility.getUUIDOf(playerName); UUID uuid = UUIDUtility.getUUIDOf(playerName);
if (!Check.isTrue(Verify.notNull(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString(), sender)) { if (!Condition.isTrue(Verify.notNull(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString(), sender)) {
return; return;
} }
if (!Check.isTrue(ConditionUtils.playerHasPlayed(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_SEEN).toString(), sender)) { if (!Condition.isTrue(ConditionUtils.playerHasPlayed(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_SEEN).toString(), sender)) {
return; return;
} }
if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) { if (!Condition.isTrue(plugin.getDB().wasSeenBefore(uuid), Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(), sender)) {
return; return;
} }
if (CommandUtils.isPlayer(sender) && plugin.getWebServer().isAuthRequired()) { if (CommandUtils.isPlayer(sender) && plugin.getWebServer().isAuthRequired()) {

View File

@ -1,10 +1,10 @@
package main.java.com.djrapitops.plan.command.commands; package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;

View File

@ -1,19 +1,20 @@
package main.java.com.djrapitops.plan.command.commands; package main.java.com.djrapitops.plan.command.commands;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Compatibility; import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.data.WebUser; import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.database.tables.SecurityTable; import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil; import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
/** /**
@ -34,12 +35,12 @@ public class RegisterCommand extends SubCommand {
public RegisterCommand(IPlan plugin) { public RegisterCommand(IPlan plugin) {
super("register", super("register",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
"", // No Permission Requirement "", // No Permission Requirement
Locale.get(Msg.CMD_USG_WEB_REGISTER).toString(), Locale.get(Msg.CMD_USG_WEB_REGISTER).toString(),
"<password> [name] [access lvl]"); "<password> [name] [access lvl]");
this.plugin = plugin; this.plugin = plugin;
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
setupFilter(); setupFilter();
} }
} }
@ -73,7 +74,7 @@ public class RegisterCommand extends SubCommand {
} }
private void consoleRegister(String[] args, ISender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException { private void consoleRegister(String[] args, ISender sender, String notEnoughArgsMsg) throws PassEncryptUtil.CannotPerformOperationException {
if (Check.isTrue(args.length >= 3, notEnoughArgsMsg, sender)) { if (Condition.isTrue(args.length >= 3, notEnoughArgsMsg, sender)) {
int permLevel; int permLevel;
permLevel = Integer.parseInt(args[2]); permLevel = Integer.parseInt(args[2]);
String passHash = PassEncryptUtil.createHash(args[0]); String passHash = PassEncryptUtil.createHash(args[0]);
@ -113,7 +114,7 @@ public class RegisterCommand extends SubCommand {
} }
private void registerUser(WebUser webUser, ISender sender) { private void registerUser(WebUser webUser, ISender sender) {
plugin.getRunnableFactory().createNew(new AbsRunnable("Register WebUser Task") { RunnableFactory.createNew(new AbsRunnable("Register WebUser Task") {
@Override @Override
public void run() { public void run() {
final String existsMsg = "§cUser Already Exists!"; final String existsMsg = "§cUser Already Exists!";
@ -122,7 +123,7 @@ public class RegisterCommand extends SubCommand {
try { try {
SecurityTable securityTable = plugin.getDB().getSecurityTable(); SecurityTable securityTable = plugin.getDB().getSecurityTable();
boolean userExists = securityTable.userExists(userName); boolean userExists = securityTable.userExists(userName);
if (!Check.isTrue(!userExists, existsMsg, sender)) { if (!Condition.isTrue(!userExists, existsMsg, sender)) {
return; return;
} }
securityTable.addNewUser(webUser); securityTable.addNewUser(webUser);

View File

@ -34,7 +34,7 @@ public class ReloadCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
plugin.restart(); plugin.reloadPlugin(true);
sender.sendMessage(Locale.get(Msg.CMD_INFO_RELOAD_COMPLETE).toString()); sender.sendMessage(Locale.get(Msg.CMD_INFO_RELOAD_COMPLETE).toString());
return true; return true;
} }

View File

@ -4,13 +4,14 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.FormattingUtils; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.FormatUtils;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.util.Arrays; import java.util.Arrays;
@ -33,7 +34,7 @@ public class SearchCommand extends SubCommand {
*/ */
public SearchCommand(Plan plugin) { public SearchCommand(Plan plugin) {
super("search", super("search",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.SEARCH.getPermission(), Permissions.SEARCH.getPermission(),
Locale.get(Msg.CMD_USG_SEARCH).toString(), Locale.get(Msg.CMD_USG_SEARCH).toString(),
"<part of playername>"); "<part of playername>");
@ -48,7 +49,7 @@ public class SearchCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return true;
} }
sender.sendMessage(Locale.get(Msg.CMD_INFO_SEARCHING).toString()); sender.sendMessage(Locale.get(Msg.CMD_INFO_SEARCHING).toString());
@ -58,7 +59,7 @@ public class SearchCommand extends SubCommand {
} }
private void runSearchTask(String[] args, ISender sender) { private void runSearchTask(String[] args, ISender sender) {
plugin.getRunnableFactory().createNew(new AbsRunnable("SearchTask: " + Arrays.toString(args)) { RunnableFactory.createNew(new AbsRunnable("SearchTask: " + Arrays.toString(args)) {
@Override @Override
public void run() { public void run() {
try { try {
@ -71,7 +72,7 @@ public class SearchCommand extends SubCommand {
if (empty) { if (empty) {
sender.sendMessage(Locale.get(Msg.CMD_INFO_NO_RESULTS).parse(Arrays.toString(args))); sender.sendMessage(Locale.get(Msg.CMD_INFO_NO_RESULTS).parse(Arrays.toString(args)));
} else { } else {
sender.sendMessage(Locale.get(Msg.CMD_INFO_RESULTS).toString() + FormattingUtils.collectionToStringNoBrackets(names)); sender.sendMessage(Locale.get(Msg.CMD_INFO_RESULTS).toString() + FormatUtils.collectionToStringNoBrackets(names));
} }
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());

View File

@ -1,18 +1,18 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.ManageUtils; import main.java.com.djrapitops.plan.utilities.ManageUtils;
/** /**
@ -44,19 +44,19 @@ public class ManageBackupCommand extends SubCommand {
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
try { try {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return true;
} }
String dbName = args[0].toLowerCase(); String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName); boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true; return true;
} }
final Database database = ManageUtils.getDB(plugin, dbName); final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return // If DB is null return
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!"); Log.error(dbName + " was null!");
return true; return true;
} }

View File

@ -1,11 +1,11 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
@ -15,7 +15,7 @@ import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.cache.DataCache; import main.java.com.djrapitops.plan.systems.cache.DataCache;
import main.java.com.djrapitops.plan.systems.cache.SessionCache; import main.java.com.djrapitops.plan.systems.cache.SessionCache;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.ManageUtils; import main.java.com.djrapitops.plan.utilities.ManageUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
@ -38,7 +38,7 @@ public class ManageClearCommand extends SubCommand {
*/ */
public ManageClearCommand(Plan plugin) { public ManageClearCommand(Plan plugin) {
super("clear", super("clear",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString(), Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString(),
"<DB> [-a]"); "<DB> [-a]");
@ -54,18 +54,18 @@ public class ManageClearCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return true;
} }
String dbName = args[0].toLowerCase(); String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName); boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true; return true;
} }
if (!Check.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[0])), sender)) { if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[0])), sender)) {
return true; return true;
} }

View File

@ -7,7 +7,7 @@ import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.listeners.PlanPlayerListener; import main.java.com.djrapitops.plan.systems.listeners.PlanPlayerListener;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
/** /**
* This manage SubCommand is used to disable some features of the plugin temporarily. * This manage SubCommand is used to disable some features of the plugin temporarily.
@ -21,7 +21,7 @@ public class ManageDisableCommand extends SubCommand {
*/ */
public ManageDisableCommand() { public ManageDisableCommand() {
super("disable", super("disable",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
"Used to disable some features of the Plugin temporarily", "Used to disable some features of the Plugin temporarily",
"<feature>"); "<feature>");
@ -29,7 +29,7 @@ public class ManageDisableCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return true;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {

View File

@ -1,16 +1,16 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.ManageUtils; import main.java.com.djrapitops.plan.utilities.ManageUtils;
/** /**
@ -31,7 +31,7 @@ public class ManageHotswapCommand extends SubCommand {
*/ */
public ManageHotswapCommand(Plan plugin) { public ManageHotswapCommand(Plan plugin) {
super("hotswap", super("hotswap",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString(), Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString(),
"<DB>"); "<DB>");
@ -47,17 +47,17 @@ public class ManageHotswapCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return true;
} }
String dbName = args[0].toLowerCase(); String dbName = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName); boolean isCorrectDB = "sqlite".equals(dbName) || "mysql".equals(dbName);
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + dbName, sender)) {
return true; return true;
} }
if (Check.isTrue(dbName.equals(plugin.getDB().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) { if (Condition.isTrue(dbName.equals(plugin.getDB().getConfigName()), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
return true; return true;
} }
@ -65,7 +65,7 @@ public class ManageHotswapCommand extends SubCommand {
final Database database = ManageUtils.getDB(plugin, dbName); final Database database = ManageUtils.getDB(plugin, dbName);
// If DB is null return // If DB is null return
if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) { if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
Log.error(dbName + " was null!"); Log.error(dbName + " was null!");
return true; return true;
} }

View File

@ -1,16 +1,16 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.info.ImporterManager; import main.java.com.djrapitops.plan.systems.info.ImporterManager;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import java.sql.SQLException; import java.sql.SQLException;
@ -49,7 +49,7 @@ public class ManageImportCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG) + " " + this.getArguments(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG) + " " + this.getArguments(), sender)) {
return true; return true;
} }

View File

@ -1,17 +1,17 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.ManageUtils; import main.java.com.djrapitops.plan.utilities.ManageUtils;
/** /**
@ -33,7 +33,7 @@ public class ManageMoveCommand extends SubCommand {
*/ */
public ManageMoveCommand(Plan plugin) { public ManageMoveCommand(Plan plugin) {
super("move", super("move",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_MOVE).toString(), Locale.get(Msg.CMD_USG_MANAGE_MOVE).toString(),
"<fromDB> <toDB> [-a]"); "<fromDB> <toDB> [-a]");
@ -43,29 +43,29 @@ public class ManageMoveCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return true;
} }
String fromDB = args[0].toLowerCase(); String fromDB = args[0].toLowerCase();
boolean isCorrectDB = "sqlite".equals(fromDB) || "mysql".equals(fromDB); boolean isCorrectDB = "sqlite".equals(fromDB) || "mysql".equals(fromDB);
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + fromDB, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + fromDB, sender)) {
return true; return true;
} }
String toDB = args[1].toLowerCase(); String toDB = args[1].toLowerCase();
isCorrectDB = "sqlite".equals(toDB) || "mysql".equals(toDB); isCorrectDB = "sqlite".equals(toDB) || "mysql".equals(toDB);
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + toDB, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + toDB, sender)) {
return true; return true;
} }
if (!Check.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) { if (!Condition.isTrue(!Verify.equalsIgnoreCase(fromDB, toDB), Locale.get(Msg.MANAGE_FAIL_SAME_DB).toString(), sender)) {
return true; return true;
} }
if (!Check.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[1])), sender)) { if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(args[1])), sender)) {
return true; return true;
} }
@ -90,7 +90,7 @@ public class ManageMoveCommand extends SubCommand {
ManageUtils.clearAndCopy(toDatabase, fromDatabase); ManageUtils.clearAndCopy(toDatabase, fromDatabase);
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_MOVE_SUCCESS).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_MOVE_SUCCESS).toString());
boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName()); boolean movedToCurrentDatabase = Verify.equalsIgnoreCase(toDatabase.getConfigName(), plugin.getDB().getConfigName());
Check.isTrue(!movedToCurrentDatabase, Locale.get(Msg.MANAGE_INFO_CONFIG_REMINDER).toString(), sender); Condition.isTrue(!movedToCurrentDatabase, Locale.get(Msg.MANAGE_INFO_CONFIG_REMINDER).toString(), sender);
} catch (Exception e) { } catch (Exception e) {
Log.toLog(this.getClass().getName() + " " + getTaskName(), e); Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());

View File

@ -1,11 +1,11 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.Session;
@ -13,7 +13,7 @@ import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.cache.DataCache; import main.java.com.djrapitops.plan.systems.cache.DataCache;
import main.java.com.djrapitops.plan.systems.cache.SessionCache; import main.java.com.djrapitops.plan.systems.cache.SessionCache;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility; import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -40,7 +40,7 @@ public class ManageRemoveCommand extends SubCommand {
*/ */
public ManageRemoveCommand(Plan plugin) { public ManageRemoveCommand(Plan plugin) {
super("remove", super("remove",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_REMOVE).toString(), Locale.get(Msg.CMD_USG_MANAGE_REMOVE).toString(),
"<player> [-a]"); "<player> [-a]");
@ -56,7 +56,7 @@ public class ManageRemoveCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return true;
} }
@ -74,17 +74,17 @@ public class ManageRemoveCommand extends SubCommand {
UUID uuid = UUIDUtility.getUUIDOf(playerName); UUID uuid = UUIDUtility.getUUIDOf(playerName);
String message = Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString(); String message = Locale.get(Msg.CMD_FAIL_USERNAME_NOT_VALID).toString();
if (!Check.isTrue(Verify.notNull(uuid), message, sender)) { if (!Condition.isTrue(Verify.notNull(uuid), message, sender)) {
return; return;
} }
message = Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString(); message = Locale.get(Msg.CMD_FAIL_USERNAME_NOT_KNOWN).toString();
if (!Check.isTrue(plugin.getDB().wasSeenBefore(uuid), message, sender)) { if (!Condition.isTrue(plugin.getDB().wasSeenBefore(uuid), message, sender)) {
return; return;
} }
message = Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(plugin.getDB().getConfigName())); message = Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REMOVE).parse(plugin.getDB().getConfigName()));
if (!Check.isTrue(Verify.contains("-a", args), message, sender)) { if (!Condition.isTrue(Verify.contains("-a", args), message, sender)) {
return; return;
} }

View File

@ -1,18 +1,18 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB; import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import main.java.com.djrapitops.plan.utilities.ManageUtils; import main.java.com.djrapitops.plan.utilities.ManageUtils;
import java.io.File; import java.io.File;
@ -44,18 +44,18 @@ public class ManageRestoreCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) { if (!Condition.isTrue(args.length >= 2, Locale.get(Msg.CMD_FAIL_REQ_ARGS).parse(this.getArguments()), sender)) {
return true; return true;
} }
String db = args[1].toLowerCase(); String db = args[1].toLowerCase();
boolean isCorrectDB = "sqlite".equals(db) || "mysql".equals(db); boolean isCorrectDB = "sqlite".equals(db) || "mysql".equals(db);
if (!Check.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + db, sender)) { if (!Condition.isTrue(isCorrectDB, Locale.get(Msg.MANAGE_FAIL_INCORRECT_DB) + db, sender)) {
return true; return true;
} }
if (!Check.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REWRITE).parse(args[1])), sender)) { if (!Condition.isTrue(Verify.contains("-a", args), Locale.get(Msg.MANAGE_FAIL_CONFIRM).parse(Locale.get(Msg.MANAGE_NOTIFY_REWRITE).parse(args[1])), sender)) {
return true; return true;
} }
@ -78,7 +78,7 @@ public class ManageRestoreCommand extends SubCommand {
boolean containsDBFileExtension = backupDBName.endsWith(".db"); boolean containsDBFileExtension = backupDBName.endsWith(".db");
File backupDBFile = new File(plugin.getDataFolder(), backupDBName + (containsDBFileExtension ? "" : ".db")); File backupDBFile = new File(plugin.getDataFolder(), backupDBName + (containsDBFileExtension ? "" : ".db"));
if (!Check.isTrue(Verify.exists(backupDBFile), Locale.get(Msg.MANAGE_FAIL_FILE_NOT_FOUND) + " " + args[0], sender)) { if (!Condition.isTrue(Verify.exists(backupDBFile), Locale.get(Msg.MANAGE_FAIL_FILE_NOT_FOUND) + " " + args[0], sender)) {
return; return;
} }

View File

@ -1,9 +1,9 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;
@ -11,7 +11,7 @@ import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.systems.webserver.webapi.bungee.RequestSetupWebAPI; import main.java.com.djrapitops.plan.systems.webserver.webapi.bungee.RequestSetupWebAPI;
import main.java.com.djrapitops.plan.systems.webserver.webapi.universal.PingWebAPI; import main.java.com.djrapitops.plan.systems.webserver.webapi.universal.PingWebAPI;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
/** /**
* This manage subcommand is used to swap to a different database and reload the * This manage subcommand is used to swap to a different database and reload the
@ -31,7 +31,7 @@ public class ManageSetupCommand extends SubCommand {
*/ */
public ManageSetupCommand(Plan plugin) { public ManageSetupCommand(Plan plugin) {
super("setup", super("setup",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(), Permissions.MANAGE.getPermission(),
"Set-Up Bungee WebServer connection", "Set-Up Bungee WebServer connection",
"<Bungee WebServer address>"); "<Bungee WebServer address>");
@ -47,7 +47,7 @@ public class ManageSetupCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).toString(), sender)) {
return true; return true;
} }
if (!plugin.getWebServer().isEnabled()) { if (!plugin.getWebServer().isEnabled()) {

View File

@ -1,17 +1,18 @@
package main.java.com.djrapitops.plan.command.commands.webuser; package main.java.com.djrapitops.plan.command.commands.webuser;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.data.WebUser; import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.database.tables.SecurityTable; import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
/** /**
@ -26,7 +27,7 @@ public class WebCheckCommand extends SubCommand {
public WebCheckCommand(IPlan plugin) { public WebCheckCommand(IPlan plugin) {
super("check", super("check",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE_WEB.getPerm(), Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_CHECK).toString(), Locale.get(Msg.CMD_USG_WEB_CHECK).toString(),
"<username>"); "<username>");
@ -35,17 +36,17 @@ public class WebCheckCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) {
return true; return true;
} }
SecurityTable table = plugin.getDB().getSecurityTable(); SecurityTable table = plugin.getDB().getSecurityTable();
String user = args[0]; String user = args[0];
plugin.getRunnableFactory().createNew(new AbsRunnable("Webuser Check Task: " + user) { RunnableFactory.createNew(new AbsRunnable("Webuser Check Task: " + user) {
@Override @Override
public void run() { public void run() {
try { try {
if (!Check.isTrue(table.userExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) { if (!Condition.isTrue(table.userExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) {
return; return;
} }
WebUser info = table.getWebUser(user); WebUser info = table.getWebUser(user);

View File

@ -1,16 +1,17 @@
package main.java.com.djrapitops.plan.command.commands.webuser; package main.java.com.djrapitops.plan.command.commands.webuser;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.database.tables.SecurityTable; import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Condition;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
/** /**
@ -25,7 +26,7 @@ public class WebDeleteCommand extends SubCommand {
public WebDeleteCommand(IPlan plugin) { public WebDeleteCommand(IPlan plugin) {
super("delete, remove", super("delete, remove",
CommandType.CONSOLE_WITH_ARGUMENTS, CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE_WEB.getPerm(), Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_DELETE).toString(), Locale.get(Msg.CMD_USG_WEB_DELETE).toString(),
"<username>"); "<username>");
@ -34,17 +35,17 @@ public class WebDeleteCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
if (!Check.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) { if (!Condition.isTrue(args.length >= 1, Locale.get(Msg.CMD_FAIL_REQ_ONE_ARG).parse() + " <username>", sender)) {
return true; return true;
} }
SecurityTable table = plugin.getDB().getSecurityTable(); SecurityTable table = plugin.getDB().getSecurityTable();
String user = args[0]; String user = args[0];
plugin.getRunnableFactory().createNew(new AbsRunnable("Webuser Delete Task: " + user) { RunnableFactory.createNew(new AbsRunnable("Webuser Delete Task: " + user) {
@Override @Override
public void run() { public void run() {
try { try {
if (!Check.isTrue(table.userExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) { if (!Condition.isTrue(table.userExists(user), ChatColor.RED + "[Plan] User Doesn't exist.", sender)) {
return; return;
} }
table.removeUser(user); table.removeUser(user);

View File

@ -1,11 +1,12 @@
package main.java.com.djrapitops.plan.command.commands.webuser; package main.java.com.djrapitops.plan.command.commands.webuser;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.data.WebUser; import main.java.com.djrapitops.plan.data.WebUser;
@ -32,7 +33,7 @@ public class WebListUsersCommand extends SubCommand {
@Override @Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) { public boolean onCommand(ISender sender, String commandLabel, String[] args) {
plugin.getRunnableFactory().createNew(new AbsRunnable("Webuser List Task") { RunnableFactory.createNew(new AbsRunnable("Webuser List Task") {
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -1,8 +1,8 @@
package main.java.com.djrapitops.plan.data; package main.java.com.djrapitops.plan.data;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.data.analysis.*; import main.java.com.djrapitops.plan.data.analysis.*;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils; import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;

View File

@ -172,7 +172,7 @@ public class Session {
* Used to get the ID of the session in the Database. * Used to get the ID of the session in the Database.
* *
* @return ID if present. * @return ID if present.
* @throws NullPointerException if Session was not fetched from DB. Check using {@code isFetchedFromDB} * @throws NullPointerException if Session was not fetched from DB. Condition using {@code isFetchedFromDB}
*/ */
public int getSessionID() { public int getSessionID() {
return sessionID; return sessionID;

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.data.additional; package main.java.com.djrapitops.plan.data.additional;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.pluginbridge.plan.Bridge; import com.djrapitops.pluginbridge.plan.Bridge;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;

View File

@ -30,7 +30,7 @@ public abstract class RawData {
} }
/** /**
* Check if analyseData() has been called. * Condition if analyseData() has been called.
* *
* @return true if the method has been called. * @return true if the method has been called.
*/ */

View File

@ -57,7 +57,7 @@ public abstract class Database {
} }
/** /**
* Check if the user is saved in the database. * Condition if the user is saved in the database.
* *
* @param uuid UUID of the user. * @param uuid UUID of the user.
* @return true/false * @return true/false

View File

@ -1,15 +1,16 @@
package main.java.com.djrapitops.plan.database.databases; package main.java.com.djrapitops.plan.database.databases;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.ITask; import com.djrapitops.plugin.task.ITask;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.tables.*; import main.java.com.djrapitops.plan.database.tables.*;
import main.java.com.djrapitops.plan.database.tables.move.Version8TransferTable; import main.java.com.djrapitops.plan.database.tables.move.Version8TransferTable;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSource;
import java.sql.Connection; import java.sql.Connection;
@ -77,7 +78,7 @@ public abstract class SQLDB extends Database {
} }
public void scheduleClean(long secondsDelay) { public void scheduleClean(long secondsDelay) {
dbCleanTask = plugin.getRunnableFactory().createNew("DB Clean Task", new AbsRunnable() { dbCleanTask = RunnableFactory.createNew("DB Clean Task", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
try { try {
@ -116,7 +117,7 @@ public abstract class SQLDB extends Database {
final SQLDB db = this; final SQLDB db = this;
if (version < 10) { if (version < 10) {
plugin.getRunnableFactory().createNew("DB v8 -> v10 Task", new AbsRunnable() { RunnableFactory.createNew("DB v8 -> v10 Task", new AbsRunnable() {
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -1,8 +1,9 @@
package main.java.com.djrapitops.plan.database.databases; package main.java.com.djrapitops.plan.database.databases;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.ITask; import com.djrapitops.plugin.task.ITask;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
@ -85,7 +86,7 @@ public class SQLiteDB extends SQLDB {
stopConnectionPingTask(); stopConnectionPingTask();
// Maintains Connection. // Maintains Connection.
connectionPingTask = plugin.getRunnableFactory().createNew(new AbsRunnable("DBConnectionPingTask " + getName()) { connectionPingTask = RunnableFactory.createNew(new AbsRunnable("DBConnectionPingTask " + getName()) {
@Override @Override
public void run() { public void run() {
Statement statement = null; Statement statement = null;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.database.tables.move; package main.java.com.djrapitops.plan.database.tables.move;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.data.UserInfo;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;

View File

@ -4,11 +4,11 @@
*/ */
package main.java.com.djrapitops.plan.database.tables.move; package main.java.com.djrapitops.plan.database.tables.move;
import com.djrapitops.plugin.api.Benchmark;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.tables.*; import main.java.com.djrapitops.plan.database.tables.*;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Optional; import java.util.Optional;

View File

@ -1,13 +1,13 @@
package main.java.com.djrapitops.plan.locale; package main.java.com.djrapitops.plan.locale;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.settings.ColorScheme; import com.djrapitops.plugin.settings.ColorScheme;
import com.djrapitops.plugin.settings.DefaultMessages; import com.djrapitops.plugin.settings.DefaultMessages;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.comparators.LocaleEntryComparator; import main.java.com.djrapitops.plan.utilities.comparators.LocaleEntryComparator;
import main.java.com.djrapitops.plan.utilities.comparators.StringLengthComparator; import main.java.com.djrapitops.plan.utilities.comparators.StringLengthComparator;
import main.java.com.djrapitops.plan.utilities.file.FileUtil; import main.java.com.djrapitops.plan.utilities.file.FileUtil;
@ -97,7 +97,8 @@ public class Locale {
.map(entry -> getSpacedIdentifier(entry.getKey().getIdentifier(), length) + "|| " + entry.getValue().toString()) .map(entry -> getSpacedIdentifier(entry.getKey().getIdentifier(), length) + "|| " + entry.getValue().toString())
.collect(Collectors.toList()); .collect(Collectors.toList());
Files.write(new File(plugin.getDataFolder(), "locale.txt").toPath(), lines, StandardCharsets.UTF_8); Files.write(new File(plugin.getDataFolder(), "locale.txt").toPath(), lines, StandardCharsets.UTF_8);
plugin.getIConfig().getConfig().set(Settings.WRITE_NEW_LOCALE.getPath(), false); plugin.getMainConfig().set(Settings.WRITE_NEW_LOCALE.getPath(), false);
plugin.getMainConfig().save();
} }
private String getSpacedIdentifier(String identifier, int length) { private String getSpacedIdentifier(String identifier, int length) {
@ -150,7 +151,7 @@ public class Locale {
add(Msg.ANALYSIS_FETCH, analysis + "Fetching Data.."); add(Msg.ANALYSIS_FETCH, analysis + "Fetching Data..");
add(Msg.ANALYSIS_PHASE_START, analysis + "Data Fetched (${0} users, took ${1}ms), beginning Analysis of data.."); add(Msg.ANALYSIS_PHASE_START, analysis + "Data Fetched (${0} users, took ${1}ms), beginning Analysis of data..");
add(Msg.ANALYSIS_3RD_PARTY, analysis + "Analyzing additional data sources (3rd party)"); add(Msg.ANALYSIS_3RD_PARTY, analysis + "Analyzing additional data sources (3rd party)");
add(Msg.ANALYSIS_FINISHED, analysis + "Analysis Complete. (took ${0}ms) ${1}"); add(Msg.ANALYSIS_FINISHED, analysis + "Analysis Complete. (${0}) ${1}");
add(Msg.ANALYSIS_FAIL_NO_PLAYERS, analysis + "Analysis failed, no known players."); add(Msg.ANALYSIS_FAIL_NO_PLAYERS, analysis + "Analysis failed, no known players.");
add(Msg.ANALYSIS_FAIL_NO_DATA, analysis + "Analysis failed, no data in the database."); add(Msg.ANALYSIS_FAIL_NO_DATA, analysis + "Analysis failed, no data in the database.");
add(Msg.ANALYSIS_FAIL_FETCH_EXCEPTION, analysis + "Failed to fetch data for Analysis, Exception occurred."); add(Msg.ANALYSIS_FAIL_FETCH_EXCEPTION, analysis + "Failed to fetch data for Analysis, Exception occurred.");

View File

@ -1,6 +1,6 @@
package main.java.com.djrapitops.plan.systems.cache; package main.java.com.djrapitops.plan.systems.cache;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
@ -114,7 +114,7 @@ public class DataCache extends SessionCache {
} }
/** /**
* Check if a session is player's first session on the server. * Condition if a session is player's first session on the server.
* *
* @param uuid UUID of the player * @param uuid UUID of the player
* @return true / false * @return true / false

View File

@ -1,6 +1,6 @@
package main.java.com.djrapitops.plan.systems.cache; package main.java.com.djrapitops.plan.systems.cache;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.info; package main.java.com.djrapitops.plan.systems.info;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.exceptions.ParseException; import main.java.com.djrapitops.plan.api.exceptions.ParseException;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.info; package main.java.com.djrapitops.plan.systems.info;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.api.exceptions.ParseException; import main.java.com.djrapitops.plan.api.exceptions.ParseException;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException;
@ -218,7 +218,7 @@ public class BungeeInformationManager extends InformationManager {
} }
/** /**
* Check if analysis page for an UUID is cached. * Condition if analysis page for an UUID is cached.
* <p> * <p>
* If serverUUID is that of Bungee, network page state is returned. * If serverUUID is that of Bungee, network page state is returned.
* *

View File

@ -4,7 +4,8 @@
*/ */
package main.java.com.djrapitops.plan.systems.info.parsing; package main.java.com.djrapitops.plan.systems.info.parsing;
import com.djrapitops.plugin.utilities.Compatibility; import com.djrapitops.plugin.api.Check;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
@ -50,8 +51,8 @@ public class AnalysisPageParser extends PageParser {
} }
private int getPlayersOnline() { private int getPlayersOnline() {
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
return plugin.fetch().getOnlinePlayers().size(); return ((Plan) plugin).getServer().getOnlinePlayers().size();
} }
return ((PlanBungee) plugin).getProxy().getOnlineCount(); return ((PlanBungee) plugin).getProxy().getOnlineCount();
} }

View File

@ -4,8 +4,9 @@
*/ */
package main.java.com.djrapitops.plan.systems.info.parsing; package main.java.com.djrapitops.plan.systems.info.parsing;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.ParseException; import main.java.com.djrapitops.plan.api.exceptions.ParseException;
@ -17,7 +18,6 @@ import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.tables.SessionsTable; import main.java.com.djrapitops.plan.database.tables.SessionsTable;
import main.java.com.djrapitops.plan.database.tables.UsersTable; import main.java.com.djrapitops.plan.database.tables.UsersTable;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils; import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;

View File

@ -1,65 +0,0 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package main.java.com.djrapitops.plan.systems.info.pluginchannel;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
/**
* //TODO Class Javadoc Comment
*
* @author Rsl1122
*/
public class BukkitPluginChannelListener implements PluginMessageListener {
private static String accessKey;
private final Plan plugin;
public BukkitPluginChannelListener(Plan plugin) {
this.plugin = plugin;
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (plugin.getInfoManager().isUsingAnotherWebServer() || Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isTrue()) {
return;
}
try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(message))) {
String subChannel = in.readUTF();
Log.debug("Received plugin message, channel: " + subChannel);
String[] data = in.readUTF().split("<!>");
String address = data[0];
accessKey = data[1];
if ("bungee_address".equals(subChannel)) {
plugin.getServerInfoManager().saveBungeeConnectionAddress(address);
Log.info("-----------------------------------");
Log.info("Received Bungee WebServer address through plugin channel, restarting Plan.");
Log.info("-----------------------------------");
plugin.restart();
notifyAll();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getAccessKey() {
return accessKey;
}
public static void usedAccessKey() {
accessKey = null;
}
}

View File

@ -1,67 +0,0 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package main.java.com.djrapitops.plan.systems.info.pluginchannel;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.PlanBungee;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.io.*;
/**
* //TODO Class Javadoc Comment
*
* @author Rsl1122
*/
public class BungeePluginChannelListener implements Listener {
private final PlanBungee plugin;
public BungeePluginChannelListener(PlanBungee plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPluginMessage(PluginMessageEvent e) {
String tag = e.getTag();
Log.debug(tag);
if (!tag.equalsIgnoreCase("BungeeCord")) {
return;
}
try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()))) {
String channel = in.readUTF();
Log.debug("Received plugin channel message on channel: " + channel);
if ("bungee_address_get".equals(channel)) {
ServerInfo server = plugin.getProxy().getPlayer(e.getReceiver().toString()).getServer().getInfo();
sendToBukkit(server);
}
} catch (IOException e1) {
e1.printStackTrace();
}
}
private void sendToBukkit(ServerInfo server) {
Log.debug("Sending data to bukkit through plugin channel");
try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
String accessKey = plugin.getWebServer().getWebAPI().generateNewAccessKey();
try (DataOutputStream out = new DataOutputStream(stream)) {
out.writeUTF("Forward");
out.writeUTF(server.getName());
out.writeUTF("Plan");
out.writeUTF("bungee_address");
out.writeUTF(plugin.getWebServer().getAccessAddress() + "<!>" + accessKey);
}
server.sendData("Return", stream.toByteArray());
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
}
}
}

View File

@ -5,7 +5,7 @@
package main.java.com.djrapitops.plan.systems.info.server; package main.java.com.djrapitops.plan.systems.info.server;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.ServerVariableHolder; import main.java.com.djrapitops.plan.ServerVariableHolder;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
@ -144,7 +144,7 @@ public class BukkitServerInfoManager {
Log.info("----------------------------------"); Log.info("----------------------------------");
Log.info("Bungee connection has failed 10 times in a row, assuming Bungee uninstalled - Restarting Plan.."); Log.info("Bungee connection has failed 10 times in a row, assuming Bungee uninstalled - Restarting Plan..");
Log.info("----------------------------------"); Log.info("----------------------------------");
plugin.restart(); plugin.reloadPlugin(true);
} catch (IOException e) { } catch (IOException e) {
Log.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
} }

View File

@ -5,8 +5,8 @@
package main.java.com.djrapitops.plan.systems.info.server; package main.java.com.djrapitops.plan.systems.info.server;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.ServerVariableHolder; import main.java.com.djrapitops.plan.ServerVariableHolder;
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException; import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;

View File

@ -4,18 +4,16 @@
*/ */
package main.java.com.djrapitops.plan.systems.info.server; package main.java.com.djrapitops.plan.systems.info.server;
import com.djrapitops.plugin.config.BukkitConfig; import com.djrapitops.plugin.api.config.Config;
import com.djrapitops.plugin.config.fileconfig.IFileConfig; import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/** /**
* Manages local server info file. * Manages local server info file.
@ -25,38 +23,43 @@ import java.util.UUID;
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class ServerInfoFile extends BukkitConfig { public class ServerInfoFile extends Config {
public ServerInfoFile(Plan plugin) throws IOException { public ServerInfoFile(Plan plugin) throws IOException {
super(plugin, "ServerInfoFile.yml"); this(plugin, new File(plugin.getDataFolder(), "ServerInfoFile.yml"));
IFileConfig config = super.getConfig(); }
config.copyDefaults();
config.addDefault("Server.UUID", ""); ServerInfoFile(Plan plugin, File file) throws IOException {
config.addDefault("Bungee.WebAddress", ""); super(file, FileUtil.lines(file));
config.addDefault("Bungee.Fail", 0); List<String> defaults = new ArrayList<>();
defaults.add("Server:");
defaults.add(" UUID:");
defaults.add("Bungee:");
defaults.add(" WebAddress:");
defaults.add(" Fail:");
copyDefaults(defaults);
save(); save();
} }
public void saveInfo(ServerInfo thisServer, ServerInfo bungee) throws IOException { public void saveInfo(ServerInfo thisServer, ServerInfo bungee) throws IOException {
IFileConfig config = getConfig();
Map<String, Serializable> serverMap = new HashMap<>(); Map<String, Serializable> serverMap = new HashMap<>();
Map<String, Serializable> bungeeMap = new HashMap<>(); Map<String, Serializable> bungeeMap = new HashMap<>();
serverMap.put("UUID", thisServer.getUuid().toString()); serverMap.put("UUID", thisServer.getUuid().toString());
config.set("Server", serverMap); set("Server", serverMap);
String oldAddress = config.getString("Bungee.WebAddress"); String oldAddress = getString("Bungee.WebAddress");
String newAddress = bungee.getWebAddress(); String newAddress = bungee.getWebAddress();
if (!newAddress.equals(oldAddress)) { if (!newAddress.equals(oldAddress)) {
bungeeMap.put("Fail", 0); bungeeMap.put("Fail", 0);
bungeeMap.put("WebAddress", newAddress); bungeeMap.put("WebAddress", newAddress);
config.set("Bungee", bungeeMap); set("Bungee", bungeeMap);
} }
save(); save();
} }
public Optional<UUID> getUUID() { public Optional<UUID> getUUID() {
String uuidString = getConfig().getString("Server.UUID"); String uuidString = getString("Server.UUID");
if (Verify.isEmpty(uuidString)) { if (Verify.isEmpty(uuidString)) {
return Optional.empty(); return Optional.empty();
} }
@ -64,14 +67,13 @@ public class ServerInfoFile extends BukkitConfig {
} }
public String getBungeeWebAddress() { public String getBungeeWebAddress() {
return getConfig().getString("Bungee.WebAddress"); return getString("Bungee.WebAddress");
} }
public int markConnectionFail() { public int markConnectionFail() {
try { try {
IFileConfig config = getConfig(); int fails = getInt("Bungee.Fail");
int fails = config.getInt("Bungee.Fail"); set("Bungee.Fail", fails + 1);
config.set("Bungee.Fail", fails + 1);
save(); save();
return fails; return fails;
} catch (IOException e) { } catch (IOException e) {
@ -82,8 +84,7 @@ public class ServerInfoFile extends BukkitConfig {
public void resetConnectionFails() { public void resetConnectionFails() {
try { try {
IFileConfig config = getConfig(); set("Bungee.Fail", 0);
config.set("Bungee.Fail", 0);
save(); save();
} catch (IOException e) { } catch (IOException e) {
Log.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);

View File

@ -1,6 +1,6 @@
package main.java.com.djrapitops.plan.systems.listeners; package main.java.com.djrapitops.plan.systems.listeners;
import com.djrapitops.plugin.utilities.player.Fetch; import com.djrapitops.plugin.api.systems.NotificationCenter;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.systems.cache.DataCache; import main.java.com.djrapitops.plan.systems.cache.DataCache;
@ -80,7 +80,7 @@ public class PlanPlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
plugin.getNotificationCenter().checkNotifications(Fetch.wrapBukkit(player)); NotificationCenter.checkNotifications(player);
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
long time = MiscUtils.getTime(); long time = MiscUtils.getTime();

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing; package main.java.com.djrapitops.plan.systems.processing;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing; package main.java.com.djrapitops.plan.systems.processing;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Action; import main.java.com.djrapitops.plan.data.Action;
import main.java.com.djrapitops.plan.database.tables.Actions; import main.java.com.djrapitops.plan.database.tables.Actions;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing; package main.java.com.djrapitops.plan.systems.processing;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.data.TPS; import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils; import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;

View File

@ -4,10 +4,10 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.importing; package main.java.com.djrapitops.plan.systems.processing.importing;
import com.djrapitops.plugin.utilities.player.UUIDFetcher; import com.djrapitops.plugin.api.Benchmark;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.UUIDFetcher;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;

View File

@ -4,9 +4,10 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.importing.importers; package main.java.com.djrapitops.plan.systems.processing.importing.importers;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.data.UserInfo;
@ -16,7 +17,6 @@ import main.java.com.djrapitops.plan.systems.cache.GeolocationCache;
import main.java.com.djrapitops.plan.systems.processing.importing.ServerImportData; import main.java.com.djrapitops.plan.systems.processing.importing.ServerImportData;
import main.java.com.djrapitops.plan.systems.processing.importing.UserImportData; import main.java.com.djrapitops.plan.systems.processing.importing.UserImportData;
import main.java.com.djrapitops.plan.systems.processing.importing.UserImportRefiner; import main.java.com.djrapitops.plan.systems.processing.importing.UserImportRefiner;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.*;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.info; package main.java.com.djrapitops.plan.systems.processing.info;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.systems.processing.Processor; import main.java.com.djrapitops.plan.systems.processing.Processor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.player; package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.player; package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.database.tables.UsersTable; import main.java.com.djrapitops.plan.database.tables.UsersTable;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.player; package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Action; import main.java.com.djrapitops.plan.data.Action;
import main.java.com.djrapitops.plan.database.tables.Actions; import main.java.com.djrapitops.plan.database.tables.Actions;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.player; package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.systems.cache.GeolocationCache; import main.java.com.djrapitops.plan.systems.cache.GeolocationCache;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.player; package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.player; package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.tables.NicknamesTable; import main.java.com.djrapitops.plan.database.tables.NicknamesTable;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.processing.player; package main.java.com.djrapitops.plan.systems.processing.player;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Action; import main.java.com.djrapitops.plan.data.Action;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;

View File

@ -1,7 +1,6 @@
package main.java.com.djrapitops.plan.systems.queue; package main.java.com.djrapitops.plan.systems.queue;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
@ -35,7 +34,6 @@ public abstract class Consumer<T> extends AbsRunnable {
consume(queue.take()); consume(queue.take());
} }
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.error("Consumer interrupted: " + ex.getCause());
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }

View File

@ -1,8 +1,8 @@
package main.java.com.djrapitops.plan.systems.queue; package main.java.com.djrapitops.plan.systems.queue;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.systems.processing.Processor; import main.java.com.djrapitops.plan.systems.processing.Processor;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.systems.queue; package main.java.com.djrapitops.plan.systems.queue;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import com.djrapitops.plugin.utilities.Compatibility;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
@ -27,7 +27,7 @@ public abstract class Setup<T> {
public void go() { public void go() {
for (Consumer<T> consumer : consumers) { for (Consumer<T> consumer : consumers) {
getRunnableFactory().createNew(consumer).runTaskAsynchronously(); RunnableFactory.createNew(consumer).runTaskAsynchronously();
} }
} }
@ -38,7 +38,7 @@ public abstract class Setup<T> {
} }
private RunnableFactory getRunnableFactory() { private RunnableFactory getRunnableFactory() {
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
return Plan.getInstance().getRunnableFactory(); return Plan.getInstance().getRunnableFactory();
} else { } else {
return PlanBungee.getInstance().getRunnableFactory(); return PlanBungee.getInstance().getRunnableFactory();

View File

@ -1,9 +1,9 @@
package main.java.com.djrapitops.plan.systems.tasks; package main.java.com.djrapitops.plan.systems.tasks;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Compatibility;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
@ -38,7 +38,7 @@ public class TPSCountTimer extends AbsRunnable {
lastCheckNano = -1; lastCheckNano = -1;
this.plugin = plugin; this.plugin = plugin;
history = new ArrayList<>(); history = new ArrayList<>();
usingBungee = Compatibility.isBungeeAvailable(); usingBungee = Check.isBungeeAvailable();
} }
@Override @Override

View File

@ -4,10 +4,10 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver; package main.java.com.djrapitops.plan.systems.webserver;
import com.djrapitops.plugin.api.utility.log.Log;
import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpHandler;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.systems.webserver.response.Response; import main.java.com.djrapitops.plan.systems.webserver.response.Response;
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPIManager; import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPIManager;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver; package main.java.com.djrapitops.plan.systems.webserver;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.systems.webserver.response.*; import main.java.com.djrapitops.plan.systems.webserver.response.*;
import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse; import main.java.com.djrapitops.plan.systems.webserver.response.api.BadRequestResponse;
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI; import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver; package main.java.com.djrapitops.plan.systems.webserver;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.WebUserAuthException; import main.java.com.djrapitops.plan.api.exceptions.WebUserAuthException;
import main.java.com.djrapitops.plan.data.WebUser; import main.java.com.djrapitops.plan.data.WebUser;

View File

@ -1,10 +1,10 @@
package main.java.com.djrapitops.plan.systems.webserver; package main.java.com.djrapitops.plan.systems.webserver;
import com.djrapitops.plugin.api.utility.log.Log;
import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpsConfigurator; import com.sun.net.httpserver.HttpsConfigurator;
import com.sun.net.httpserver.HttpsParameters; import com.sun.net.httpserver.HttpsParameters;
import com.sun.net.httpserver.HttpsServer; import com.sun.net.httpserver.HttpsServer;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.response; package main.java.com.djrapitops.plan.systems.webserver.response;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.systems.webserver.theme.Theme; import main.java.com.djrapitops.plan.systems.webserver.theme.Theme;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.file.FileUtil; import main.java.com.djrapitops.plan.utilities.file.FileUtil;

View File

@ -1,6 +1,6 @@
package main.java.com.djrapitops.plan.systems.webserver.response; package main.java.com.djrapitops.plan.systems.webserver.response;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.systems.webserver.theme.Theme; import main.java.com.djrapitops.plan.systems.webserver.theme.Theme;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.theme; package main.java.com.djrapitops.plan.systems.webserver.theme;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
/** /**

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.theme; package main.java.com.djrapitops.plan.systems.webserver.theme;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
/** /**

View File

@ -4,8 +4,8 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi; package main.java.com.djrapitops.plan.systems.webserver.webapi;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIConnectionFailException;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;

View File

@ -4,9 +4,13 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit; package main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit;
import com.djrapitops.plugin.utilities.Compatibility; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.*; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.ServerSpecificSettings;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;
import main.java.com.djrapitops.plan.systems.webserver.response.Response; import main.java.com.djrapitops.plan.systems.webserver.response.Response;
@ -23,7 +27,7 @@ public class ConfigurationWebAPI extends WebAPI {
@Override @Override
public Response onRequest(IPlan plugin, Map<String, String> variables) { public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (!Compatibility.isBukkitAvailable()) { if (!Check.isBukkitAvailable()) {
Log.debug("Called a wrong server type"); Log.debug("Called a wrong server type");
return badRequest("Called a Bungee Server"); return badRequest("Called a Bungee Server");
} }
@ -70,7 +74,7 @@ public class ConfigurationWebAPI extends WebAPI {
private Map<String, Object> getConfigValues(UUID serverUUID) throws WebAPIException { private Map<String, Object> getConfigValues(UUID serverUUID) throws WebAPIException {
Map<String, Object> configValues = new HashMap<>(); Map<String, Object> configValues = new HashMap<>();
if (!Compatibility.isBungeeAvailable()) { if (!Check.isBungeeAvailable()) {
throw new WebAPIException("Attempted to send config values from Bukkit to Bungee."); throw new WebAPIException("Attempted to send config values from Bukkit to Bungee.");
} }
addConfigValue(configValues, Settings.DB_TYPE, "mysql"); addConfigValue(configValues, Settings.DB_TYPE, "mysql");

View File

@ -4,7 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit; package main.java.com.djrapitops.plan.systems.webserver.webapi.bukkit;
import com.djrapitops.plugin.utilities.Compatibility; import com.djrapitops.plugin.api.Check;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager; import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
@ -29,7 +29,7 @@ public class RequestInspectPluginsTabBukkitWebAPI extends WebAPI {
@Override @Override
public Response onRequest(IPlan plugin, Map<String, String> variables) { public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (!Compatibility.isBukkitAvailable()) { if (!Check.isBukkitAvailable()) {
return badRequest("Called a Bungee Server"); return badRequest("Called a Bungee Server");
} }

View File

@ -4,7 +4,8 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee; package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee;
import com.djrapitops.plugin.utilities.Compatibility;
import com.djrapitops.plugin.api.Check;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;
import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager; import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager;
@ -22,7 +23,7 @@ import java.util.UUID;
public class PostNetworkPageContentWebAPI extends WebAPI { public class PostNetworkPageContentWebAPI extends WebAPI {
@Override @Override
public Response onRequest(IPlan plugin, Map<String, String> variables) { public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
return badRequest("Called a Bukkit server."); return badRequest("Called a Bukkit server.");
} }

View File

@ -4,7 +4,8 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee; package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee;
import com.djrapitops.plugin.utilities.Compatibility;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
@ -26,7 +27,7 @@ public class PostOriginalBukkitSettingsWebAPI extends WebAPI {
@Override @Override
public Response onRequest(IPlan plugin, Map<String, String> variables) { public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
return badRequest("Called a Bukkit Server"); return badRequest("Called a Bukkit Server");
} }
Map<String, Object> settings = new HashMap<>(); Map<String, Object> settings = new HashMap<>();

View File

@ -4,8 +4,9 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee; package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee;
import com.djrapitops.plugin.utilities.Compatibility;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.WebAPIException; import main.java.com.djrapitops.plan.api.exceptions.WebAPIException;
import main.java.com.djrapitops.plan.systems.info.server.ServerInfo; import main.java.com.djrapitops.plan.systems.info.server.ServerInfo;
@ -33,7 +34,7 @@ import java.util.UUID;
public class RequestPluginsTabWebAPI extends WebAPI { public class RequestPluginsTabWebAPI extends WebAPI {
@Override @Override
public Response onRequest(IPlan plugin, Map<String, String> variables) { public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (!Compatibility.isBungeeAvailable()) { if (!Check.isBungeeAvailable()) {
return badRequest("Called a Bukkit Server"); return badRequest("Called a Bukkit Server");
} }

View File

@ -4,9 +4,10 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee; package main.java.com.djrapitops.plan.systems.webserver.webapi.bungee;
import com.djrapitops.plugin.utilities.Compatibility;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
@ -27,7 +28,7 @@ public class RequestSetupWebAPI extends WebAPI {
@Override @Override
public Response onRequest(IPlan plugin, Map<String, String> variables) { public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (!Compatibility.isBungeeAvailable()) { if (!Check.isBungeeAvailable()) {
return badRequest("Called a Bukkit server."); return badRequest("Called a Bukkit server.");
} }
String serverUUIDS = variables.get("sender"); String serverUUIDS = variables.get("sender");
@ -43,7 +44,7 @@ public class RequestSetupWebAPI extends WebAPI {
@Override @Override
public void sendRequest(String address) throws WebAPIException { public void sendRequest(String address) throws WebAPIException {
if (!Compatibility.isBukkitAvailable()) { if (!Check.isBukkitAvailable()) {
throw new IllegalStateException("Not supposed to be called on Bungee"); throw new IllegalStateException("Not supposed to be called on Bungee");
} }

View File

@ -4,8 +4,9 @@
*/ */
package main.java.com.djrapitops.plan.systems.webserver.webapi.universal; package main.java.com.djrapitops.plan.systems.webserver.webapi.universal;
import com.djrapitops.plugin.utilities.Compatibility;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee; import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
@ -25,7 +26,7 @@ import java.util.UUID;
public class PingWebAPI extends WebAPI { public class PingWebAPI extends WebAPI {
@Override @Override
public Response onRequest(IPlan plugin, Map<String, String> variables) { public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (Compatibility.isBungeeAvailable()) { if (Check.isBungeeAvailable()) {
((PlanBungee) plugin).getServerInfoManager().serverConnected(UUID.fromString(variables.get("sender"))); ((PlanBungee) plugin).getServerInfoManager().serverConnected(UUID.fromString(variables.get("sender")));
} else if (!plugin.getInfoManager().isUsingAnotherWebServer()) { } else if (!plugin.getInfoManager().isUsingAnotherWebServer()) {
try { try {
@ -44,7 +45,7 @@ public class PingWebAPI extends WebAPI {
@Override @Override
public void sendRequest(String address) throws WebAPIException { public void sendRequest(String address) throws WebAPIException {
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
super.sendRequest(address); super.sendRequest(address);
} else { } else {
addVariable("webAddress", PlanBungee.getInstance().getWebServer().getAccessAddress()); addVariable("webAddress", PlanBungee.getInstance().getWebServer().getAccessAddress());

View File

@ -1,55 +0,0 @@
package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.utilities.BenchUtil;
import main.java.com.djrapitops.plan.Log;
/**
* @author Rsl1122
*/
public class Benchmark {
/**
* Constructor used to hide the public constructor
*/
private Benchmark() {
throw new IllegalStateException("Utility class");
}
/**
* Start a benchmark.
*
* @param source Thing to bench.
*/
public static void start(String source) {
getBenchUtil().start(source);
}
/**
* End a benchmark.
*
* @param source Thing to stop benching.
* @return ms it took.
*/
public static long stop(String source) {
long ms = getBenchUtil().stop(source);
if (ms != -1) {
Log.debug(source + " took " + ms + " ms");
}
return ms;
}
/**
* Used to add Benchmark timings to larger Debug log task parts.
*
* @param task Task this benchmark is a part of.
* @param source Bench source
* @return Execution time in ms.
*/
public static long stop(String task, String source) {
return getBenchUtil().stop(task, source);
}
private static BenchUtil getBenchUtil() {
return MiscUtils.getIPlan().benchmark();
}
}

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.utilities; package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import main.java.com.djrapitops.plan.Log;
/** /**
* Class containing static check methods with message sending capabilities if * Class containing static check methods with message sending capabilities if
@ -9,12 +9,12 @@ import main.java.com.djrapitops.plan.Log;
* *
* @author Rsl1122 * @author Rsl1122
*/ */
public class Check { public class Condition {
/** /**
* Constructor used to hide the public constructor * Constructor used to hide the public constructor
*/ */
private Check() { private Condition() {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }

View File

@ -1,7 +1,6 @@
package main.java.com.djrapitops.plan.utilities; package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.utilities.Format; import com.djrapitops.plugin.utilities.Format;
import com.djrapitops.plugin.utilities.FormattingUtils;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bukkit.Location; import org.bukkit.Location;
@ -44,15 +43,15 @@ public class FormatUtils {
} }
public static String formatTimeStamp(long epochMs) { public static String formatTimeStamp(long epochMs) {
return FormattingUtils.formatTimeStamp(epochMs); return com.djrapitops.plugin.utilities.FormatUtils.formatTimeStamp(epochMs);
} }
public static String formatTimeStampSecond(long epochMs) { public static String formatTimeStampSecond(long epochMs) {
return FormattingUtils.formatTimeStampSecond(epochMs); return com.djrapitops.plugin.utilities.FormatUtils.formatTimeStampSecond(epochMs);
} }
public static String formatTimeStampYear(long epochMs) { public static String formatTimeStampYear(long epochMs) {
return FormattingUtils.formatTimeStampYear(epochMs); return com.djrapitops.plugin.utilities.FormatUtils.formatTimeStampYear(epochMs);
} }
/** /**
@ -179,8 +178,8 @@ public class FormatUtils {
* @return parsed double - for example 1,11 * @return parsed double - for example 1,11
* @throws NumberFormatException When wrong format * @throws NumberFormatException When wrong format
*/ */
public static int parseVersionNumber(String versionString) { public static long parseVersionNumber(String versionString) {
return FormattingUtils.parseVersionNumber(versionString); return com.djrapitops.plugin.utilities.FormatUtils.parseVersionNumber(versionString);
} }
/** /**
@ -190,7 +189,7 @@ public class FormatUtils {
* @return One array with contents of the multiple * @return One array with contents of the multiple
*/ */
public static String[] mergeArrays(String[]... arrays) { public static String[] mergeArrays(String[]... arrays) {
return FormattingUtils.mergeArrays(arrays); return com.djrapitops.plugin.utilities.FormatUtils.mergeArrays(arrays);
} }
/** /**
@ -200,7 +199,7 @@ public class FormatUtils {
* @return Readable location format. * @return Readable location format.
*/ */
public static String formatLocation(Location loc) { public static String formatLocation(Location loc) {
return FormattingUtils.formatLocation(loc); return com.djrapitops.plugin.utilities.FormatUtils.formatLocation(loc);
} }
/** /**

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.utilities; package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;

View File

@ -1,10 +1,14 @@
package main.java.com.djrapitops.plan.utilities; package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender; import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.utilities.Compatibility; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.*; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Locale;
@ -133,7 +137,7 @@ public class MiscUtils {
} }
public static String getPlanVersion() { public static String getPlanVersion() {
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
return Plan.getInstance().getDescription().getVersion(); return Plan.getInstance().getDescription().getVersion();
} else { } else {
return PlanBungee.getInstance().getDescription().getVersion(); return PlanBungee.getInstance().getDescription().getVersion();
@ -141,7 +145,7 @@ public class MiscUtils {
} }
public static IPlan getIPlan() { public static IPlan getIPlan() {
if (Compatibility.isBukkitAvailable()) { if (Check.isBukkitAvailable()) {
return Plan.getInstance(); return Plan.getInstance();
} else { } else {
return PlanBungee.getInstance(); return PlanBungee.getInstance();

View File

@ -1,9 +1,10 @@
package main.java.com.djrapitops.plan.utilities.analysis; package main.java.com.djrapitops.plan.utilities.analysis;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.*; import main.java.com.djrapitops.plan.data.*;
@ -21,7 +22,6 @@ import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
import main.java.com.djrapitops.plan.systems.info.InformationManager; import main.java.com.djrapitops.plan.systems.info.InformationManager;
import main.java.com.djrapitops.plan.systems.webserver.response.ErrorResponse; import main.java.com.djrapitops.plan.systems.webserver.response.ErrorResponse;
import main.java.com.djrapitops.plan.systems.webserver.response.InternalErrorResponse; import main.java.com.djrapitops.plan.systems.webserver.response.InternalErrorResponse;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator; import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator;
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure; import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
@ -113,7 +113,7 @@ public class Analysis {
Benchmark.stop("Analysis", "Create Empty dataset"); Benchmark.stop("Analysis", "Create Empty dataset");
fillDataset(analysisData, db); fillDataset(analysisData, db);
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase"); String fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
Benchmark.start("Analysis Phase"); Benchmark.start("Analysis Phase");
Log.debug("Analysis", "Analysis Phase"); Log.debug("Analysis", "Analysis Phase");
@ -126,7 +126,7 @@ public class Analysis {
Log.debug("Analysis", "Analyzing additional data sources (3rd party)"); Log.debug("Analysis", "Analyzing additional data sources (3rd party)");
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(analysisData.getPlayerCountPart().getUuids())); analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(analysisData.getPlayerCountPart().getUuids()));
((BukkitInformationManager) infoManager).cacheAnalysisData(analysisData); ((BukkitInformationManager) infoManager).cacheAnalysisData(analysisData);
long time = Benchmark.stop("Analysis", "Analysis"); String time = Benchmark.stop("Analysis", "Analysis");
Log.logDebug("Analysis", time); Log.logDebug("Analysis", time);
@ -214,7 +214,7 @@ public class Analysis {
} }
/** /**
* Check whether or not analysis is being run. * Condition whether or not analysis is being run.
* *
* @return true / false (state) * @return true / false (state)
*/ */

View File

@ -1,6 +1,6 @@
package main.java.com.djrapitops.plan.utilities.analysis; package main.java.com.djrapitops.plan.utilities.analysis;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.AnalysisType;
@ -255,7 +255,7 @@ public class AnalysisUtils {
day.setTimeInMillis(start); day.setTimeInMillis(start);
int hourOfDay = day.get(Calendar.HOUR_OF_DAY); // 0 AM is 0 int hourOfDay = day.get(Calendar.HOUR_OF_DAY); // 0 AM is 0
int dayOfWeek = day.get(Calendar.DAY_OF_WEEK) - 2; // Monday is 0, Sunday is -1 int dayOfWeek = day.get(Calendar.DAY_OF_WEEK) - 2; // Monday is 0, Sunday is -1
if (hourOfDay == 24) { // Check if hour is 24 (Should be impossible but.) if (hourOfDay == 24) { // Condition if hour is 24 (Should be impossible but.)
hourOfDay = 0; hourOfDay = 0;
dayOfWeek += 1; dayOfWeek += 1;
} }

View File

@ -1,6 +1,6 @@
package main.java.com.djrapitops.plan.utilities.analysis; package main.java.com.djrapitops.plan.utilities.analysis;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.AnalysisData; import main.java.com.djrapitops.plan.data.AnalysisData;

View File

@ -48,6 +48,13 @@ public class FileUtil {
} }
} }
public static List<String> lines(IPlan plugin, File savedFile, String defaults) throws IOException {
if (savedFile.exists()) {
return lines(savedFile);
}
return lines(plugin, defaults);
}
public static List<String> lines(IPlan plugin, String resource) throws IOException { public static List<String> lines(IPlan plugin, String resource) throws IOException {
List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
Scanner scanner = null; Scanner scanner = null;

View File

@ -1,7 +1,8 @@
package main.java.com.djrapitops.plan.utilities.file.dump; package main.java.com.djrapitops.plan.utilities.file.dump;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.utilities.file.FileUtil; import main.java.com.djrapitops.plan.utilities.file.FileUtil;
@ -169,12 +170,10 @@ public class DumpUtils {
*/ */
private static void addPlanDetails(DumpLog log, Plan plan) { private static void addPlanDetails(DumpLog log, Plan plan) {
String planVersion = plan.getVersion(); String planVersion = plan.getVersion();
String apfVersion = plan.getAPFVersion();
log.addHeader("Plan Details"); log.addHeader("Plan Details");
log.add("Plan Version", planVersion); log.add("Plan Version", planVersion);
log.add("Abstract Plugin Framework Version", apfVersion);
} }
/** /**
@ -228,7 +227,7 @@ public class DumpUtils {
* @param plan The Plan instance * @param plan The Plan instance
*/ */
private static void addTimings(DumpLog log, Plan plan) { private static void addTimings(DumpLog log, Plan plan) {
String[] timings = plan.benchmark().getTimings().getTimings(); String[] timings = Benchmark.getAverages().asStringArray();
log.addHeader("Timings"); log.addHeader("Timings");
log.addLines(timings); log.addLines(timings);
@ -242,7 +241,7 @@ public class DumpUtils {
* @throws IOException when an error while reading occurred * @throws IOException when an error while reading occurred
*/ */
private static void addErrorLog(DumpLog log, Plan plan) throws IOException { private static void addErrorLog(DumpLog log, Plan plan) throws IOException {
File errorFile = new File(plan.getDataFolder(), plan.getPluginLogger().getErrorsFilename()); File errorFile = new File(plan.getDataFolder(), Log.ERROR_FILE_NAME);
if (!Verify.exists(errorFile)) { if (!Verify.exists(errorFile)) {
return; return;
@ -262,7 +261,7 @@ public class DumpUtils {
* @throws IOException when an error while reading occurred * @throws IOException when an error while reading occurred
*/ */
private static void addDebugLog(DumpLog log, Plan plan) throws IOException { private static void addDebugLog(DumpLog log, Plan plan) throws IOException {
File debugFile = new File(plan.getDataFolder(), plan.getPluginLogger().getDebugFilename()); File debugFile = new File(plan.getDataFolder(), Log.DEBUG_FILE_NAME);
if (!Verify.exists(debugFile)) { if (!Verify.exists(debugFile)) {
return; return;

View File

@ -1,8 +1,8 @@
package main.java.com.djrapitops.plan.utilities.file.dump; package main.java.com.djrapitops.plan.utilities.file.dump;
import com.djrapitops.plugin.api.utility.log.Log;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import main.java.com.djrapitops.plan.Log;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException; import org.json.simple.parser.ParseException;

View File

@ -1,6 +1,6 @@
package main.java.com.djrapitops.plan.utilities.html.tables; package main.java.com.djrapitops.plan.utilities.html.tables;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.utilities.comparators.MapComparator; import main.java.com.djrapitops.plan.utilities.comparators.MapComparator;
import main.java.com.djrapitops.plan.utilities.html.Html; import main.java.com.djrapitops.plan.utilities.html.Html;

View File

@ -1,7 +1,8 @@
package main.java.com.djrapitops.plan.utilities.metrics; package main.java.com.djrapitops.plan.utilities.metrics;
import com.djrapitops.plugin.utilities.Compatibility;
import main.java.com.djrapitops.plan.Log; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
@ -29,7 +30,7 @@ public class BStats {
// TODO Write a Module bar graph // TODO Write a Module bar graph
String serverType = plugin.getServer().getName(); String serverType = plugin.getServer().getName();
if ("CraftBukkit".equals(serverType) && Compatibility.isSpigotAvailable()) { if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) {
serverType = "Spigot"; serverType = "Spigot";
} }
String databaseType = plugin.getDB().getName(); String databaseType = plugin.getDB().getName();

Some files were not shown because too many files have changed in this diff Show More