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>
<groupId>com.djrapitops</groupId>
<artifactId>abstract-plugin-framework</artifactId>
<version>2.0.5</version>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
<!-- 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;
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.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.task.AbsRunnable;
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.ImporterManager;
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.listeners.*;
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.webserver.PageCache;
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 org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -69,11 +74,12 @@ import java.util.UUID;
* @author Rsl1122
* @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 Config config;
private ProcessingQueue processingQueue;
private HookHandler hookHandler; // Manages 3rd party data sources
@ -111,7 +117,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
* @return this object.
*/
public static Plan getInstance() {
return (Plan) getPluginInstance(Plan.class);
return (Plan) StaticHolder.getInstance(Plan.class);
}
public static UUID getServerUUID() {
@ -129,18 +135,21 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
*/
@Override
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 {
// 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");
GeolocationCache.checkDB();
@ -149,19 +158,19 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
Benchmark.start("Reading server variables");
serverVariableHolder = new ServerVariableHolder(getServer());
Benchmark.stop("Enable", "Reading server variables");
Log.logDebug("Enable", Benchmark.stopAndFormat("Reading server variables"));
Benchmark.start("Copy default config");
getConfig().options().copyDefaults(true);
getConfig().options().header("Plan Config | More info at https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/documentation/Configuration.md");
saveConfig();
Benchmark.stop("Enable", "Copy default config");
File configFile = new File(getDataFolder(), "config.yml");
config = new Config(configFile, FileUtil.lines(this, configFile, "config.yml"));
config.save();
Log.logDebug("Enable", Benchmark.stopAndFormat("Copy default config"));
Benchmark.start("Init Database");
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
initDatabase();
Benchmark.stop("Enable", "Init Database");
Log.logDebug("Enable", Benchmark.stopAndFormat("Init Database"));
Benchmark.start("WebServer Initialization");
webServer = new WebServer(this);
@ -177,7 +186,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
}
serverInfoManager.updateServerInfo();
Benchmark.stop("Enable", "WebServer Initialization");
Log.logDebug("Enable", Benchmark.stopAndFormat("WebServer Initialization"));
if (!reloading) {
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());
}
registerCommand(new PlanCommand(this));
registerCommand("plan", new PlanCommand(this));
Benchmark.start("Hook to 3rd party plugins");
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());
// if (Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isFalse()) {
// registerPluginChannelListener();
// }
BStats bStats = new BStats(this);
bStats.registerMetrics();
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());
new ShutdownHook(this);
} catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly.");
Log.logStackTrace(e);
disablePlugin();
Log.toLog(this.getClass().getName(), e);
onDisable();
}
}
private void registerPluginChannelListener() {
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "Plan", new BukkitPluginChannelListener(this));
}
private void registerTasks() {
RunnableFactory runnableFactory = getRunnableFactory();
String bootAnalysisMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_INFO).toString();
String bootAnalysisRunMsg = Locale.get(Msg.ENABLE_BOOT_ANALYSIS_RUN_INFO).toString();
Benchmark.start("Task Registration");
tpsCountTimer = new TPSCountTimer(this);
runnableFactory.createNew(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks());
RunnableFactory.createNew(tpsCountTimer).runTaskTimer(1000, TimeAmount.SECOND.ticks());
// Analysis refresh settings
int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber();
@ -244,7 +243,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
Log.info(bootAnalysisMsg);
ITask bootAnalysisTask = runnableFactory.createNew("BootAnalysisTask", new AbsRunnable() {
ITask bootAnalysisTask = RunnableFactory.createNew("BootAnalysisTask", new AbsRunnable() {
@Override
public void run() {
Log.info(bootAnalysisRunMsg);
@ -256,7 +255,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
bootAnalysisTaskID = bootAnalysisTask.getTaskId();
if (analysisRefreshTaskIsEnabled) {
runnableFactory.createNew("PeriodicalAnalysisTask", new AbsRunnable() {
RunnableFactory.createNew("PeriodicalAnalysisTask", new AbsRunnable() {
@Override
public void run() {
infoManager.refreshAnalysis(getServerUUID());
@ -264,25 +263,26 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
}).runTaskTimerAsynchronously(analysisPeriod, analysisPeriod);
}
runnableFactory.createNew("PeriodicNetworkBoxRefreshTask", new AbsRunnable() {
RunnableFactory.createNew("PeriodicNetworkBoxRefreshTask", new AbsRunnable() {
@Override
public void run() {
infoManager.updateNetworkPageContent();
}
}).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 {
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));
super.setColorScheme(new ColorScheme(mainColor, secColor, terColor));
return new ColorScheme(mainColor, secColor, terColor);
} catch (Exception e) {
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();
}
} else {
getRunnableFactory().createNew("Re-Add processors", new AbsRunnable() {
RunnableFactory.createNew("Re-Add processors", new AbsRunnable() {
@Override
public void run() {
addToProcessQueue(processors.toArray(new Processor[processors.size()]));
@ -317,17 +317,20 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L);
}
}
getServer().getScheduler().cancelTasks(this);
if (Verify.notNull(infoManager, db)) {
taskStatus().cancelAllKnownTasks();
}
getPluginLogger().endAllDebugs();
super.onDisable();
Log.info(Locale.get(Msg.DISABLED).toString());
}
@Override
public String getVersion() {
return getDescription().getVersion();
}
@Override
public void onReload() {
reloadConfig();
}
private void registerListeners() {
Benchmark.start("Register Listeners");
registerListener(new PlanPlayerListener(this));
@ -336,7 +339,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
registerListener(new PlanWorldChangeListener(this));
registerListener(new PlanCommandPreprocessListener(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);
}
} else {
getRunnableFactory().createNew("Re-Add processors", new AbsRunnable() {
RunnableFactory.createNew("Re-Add processors", new AbsRunnable() {
@Override
public void run() {
addToProcessQueue(processors);
@ -470,16 +473,13 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
}
}
public InformationManager getInfoManager() {
return infoManager;
@Override
public Config getMainConfig() {
return null;
}
public void restart() {
reloading = true;
onDisable();
reloadConfig();
onEnable();
reloading = false;
public InformationManager getInfoManager() {
return infoManager;
}
public boolean isReloading() {

View File

@ -5,9 +5,15 @@
package main.java.com.djrapitops.plan;
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.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.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
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.tasks.TPSCountTimer;
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 java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.UUID;
@ -35,7 +41,9 @@ import java.util.UUID;
*
* @author Rsl1122
*/
public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
public class PlanBungee extends BungeePlugin implements IPlan {
private Config config;
private WebServer webServer;
private Database db;
@ -47,18 +55,21 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
@Override
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 {
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());
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());
initDatabase();
registerCommand(new PlanBungeeCommand(this));
registerCommand("planbungee", new PlanBungeeCommand(this));
String ip = variableHolder.getIp();
if ("0.0.0.0".equals(ip)) {
@ -86,44 +97,41 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
if (!webServer.isEnabled()) {
Log.error("WebServer was not successfully initialized.");
disablePlugin();
onDisable();
return;
}
getRunnableFactory().createNew("Enable Bukkit Connection Task", new AbsRunnable() {
RunnableFactory.createNew("Enable Bukkit Connection Task", new AbsRunnable() {
@Override
public void run() {
infoManager.attemptConnection();
infoManager.sendConfigSettings();
}
}).runTaskAsynchronously();
getRunnableFactory().createNew("Player Count task", new TPSCountTimer(this))
RunnableFactory.createNew("Player Count task", new TPSCountTimer(this))
.runTaskTimerAsynchronously(1000, TimeAmount.SECOND.ticks());
getRunnableFactory().createNew("NetworkPageContentUpdateTask", new AbsRunnable("NetworkPageContentUpdateTask") {
RunnableFactory.createNew("NetworkPageContentUpdateTask", new AbsRunnable("NetworkPageContentUpdateTask") {
@Override
public void run() {
infoManager.updateNetworkPageContent();
}
}).runTaskTimerAsynchronously(1500, TimeAmount.MINUTE.ticks());
// getProxy().registerChannel("Plan");
// registerListener(new BungeePluginChannelListener(this));
processingQueue = new ProcessingQueue();
registerListener(new BungeePlayerListener(this));
Benchmark.stop("Enable", "WebServer Initialization");
Log.logDebug("Enable", "WebServer Initialization");
Log.info(Locale.get(Msg.ENABLED).toString());
} catch (Exception e) {
Log.error("Plugin Failed to Initialize Correctly.");
Log.logStackTrace(e);
disablePlugin();
Log.toLog(this.getClass().getName(), e);
onDisable();
}
}
public static PlanBungee getInstance() {
return getInstance(PlanBungee.class);
return (PlanBungee) StaticHolder.getInstance(PlanBungee.class);
}
@Override
@ -148,6 +156,16 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
Log.info(Locale.get(Msg.DISABLED).toString());
}
@Override
public String getVersion() {
return null;
}
@Override
public void onReload() {
}
private void initDatabase() throws DatabaseInitException {
db = new MySQLDB(this);
db.init();
@ -190,6 +208,24 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
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
public ServerVariableHolder getVariable() {
return variableHolder;
@ -202,10 +238,4 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
public UUID getServerUuid() {
return serverInfoManager.getServerUUID();
}
@Override
public void restart() {
onDisable();
onEnable();
}
}

View File

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

View File

@ -1,10 +1,9 @@
package main.java.com.djrapitops.plan;
import com.djrapitops.plugin.config.fileconfig.BukkitFileConfig;
import com.djrapitops.plugin.config.fileconfig.IFileConfig;
import com.djrapitops.plugin.utilities.Compatibility;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.config.Config;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.io.IOException;
import java.util.List;
/**
@ -124,7 +123,7 @@ public enum Settings {
if (value != null) {
return value;
}
return getConfig().getBoolean(configPath);
return getConfig().getConfigNode(configPath).getBoolean();
}
public boolean isFalse() {
@ -142,7 +141,7 @@ public enum Settings {
*/
@Override
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
*/
public int getNumber() {
return getConfig().getInt(configPath);
return getConfig().getConfigNode(configPath).getInt();
}
public List<String> getStringList() {
return getConfig().getStringList(configPath);
return getConfig().getConfigNode(configPath).getStringList();
}
/**
@ -168,20 +167,12 @@ public enum Settings {
return configPath;
}
private IFileConfig getConfig() {
try {
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);
}
private Config getConfig() {
return MiscUtils.getIPlan().getMainConfig();
}
public static ServerSpecificSettings serverSpecific() {
if (!Compatibility.isBungeeAvailable()) {
if (!Check.isBungeeAvailable()) {
throw new IllegalStateException("Not supposed to call this method on Bukkit");
}

View File

@ -4,6 +4,7 @@
*/
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.data.Action;
import main.java.com.djrapitops.plan.data.Session;

View File

@ -1,19 +1,20 @@
package main.java.com.djrapitops.plan.api;
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.data.AnalysisData;
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
import org.bukkit.OfflinePlayer;
import java.sql.SQLException;
import java.util.Collection;
import java.util.UUID;
import static org.bukkit.Bukkit.getOfflinePlayer;
/**
* This class contains the API methods for Bukkit version of the plugin.
* <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.
*/
@ -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.
* @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>
* Using BungeeCord: Will send a {@code IsCachedWebAPI} request to check if the page is in Bungee's PageCache.
* 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
*/
@ -165,7 +166,7 @@ public class API {
/**
* Used to get the full HTML of the Analysis page as a string.
* <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.
* @throws NullPointerException if AnalysisData has not been cached.
@ -177,7 +178,7 @@ public class API {
/**
* Used to get the AnalysisData object.
* <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.
* @see AnalysisData
@ -201,7 +202,7 @@ public class API {
if (playerName != null) {
return playerName;
}
IOfflinePlayer offlinePlayer = Fetch.getIOfflinePlayer(uuid);
OfflinePlayer offlinePlayer = getOfflinePlayer(uuid);
if (offlinePlayer != null) {
return offlinePlayer.getName();
}

View File

@ -5,7 +5,8 @@
package main.java.com.djrapitops.plan.api;
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.database.Database;
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 java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;
@ -42,7 +42,7 @@ public interface IPlan extends IPlugin {
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
* @return has the player played before, false if uuid is null.
*/
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
public void addCommands() {
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());
RegisterCommand registerCommand = new RegisterCommand(plugin);
commands.add(registerCommand);

View File

@ -45,7 +45,7 @@ public class PlanCommand extends TreeCommand<Plan> {
commands.add(new InfoCommand(plugin));
commands.add(new ReloadCommand(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());
RegisterCommand registerCommand = new RegisterCommand(plugin);
commands.add(registerCommand);

View File

@ -1,12 +1,12 @@
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.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
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.systems.webserver.webapi.WebAPI;
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.UUID;
@ -28,19 +28,19 @@ public class DevCommand extends SubCommand {
private final 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;
}
@Override
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;
}
String feature = args[0];
switch (feature) {
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;
}
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.SubCommand;
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.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
@ -40,11 +39,11 @@ public class InfoCommand extends SubCommand {
String mColor = cs.getMainColor();
String sColor = cs.getSecondaryColor();
String tColor = cs.getTertiaryColor();
String ball = Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString();
String[] messages = {
Locale.get(Msg.CMD_HEADER_INFO).toString(),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + mColor + " Version: " + sColor + plugin.getDescription().getVersion(),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + tColor + " " + Version.checkVersion(plugin),
Locale.get(Msg.CMD_CONSTANT_LIST_BALL).toString() + mColor + " Active Database: " + tColor + plugin.getDB().getConfigName(),
ball + mColor + " Version: " + sColor + plugin.getDescription().getVersion(),
ball + mColor + " Active Database: " + tColor + plugin.getDB().getConfigName(),
Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()
};
sender.sendMessage(messages);

View File

@ -1,19 +1,19 @@
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.CommandUtils;
import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
import main.java.com.djrapitops.plan.command.ConditionUtils;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
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.uuid.UUIDUtility;
import org.bukkit.ChatColor;
@ -38,7 +38,7 @@ public class InspectCommand extends SubCommand {
*/
public InspectCommand(Plan plugin) {
super("inspect",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.INSPECT.getPermission(),
Locale.get(Msg.CMD_USG_INSPECT).toString(),
"<player>");
@ -66,13 +66,13 @@ public class InspectCommand extends SubCommand {
public void run() {
try {
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;
}
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;
}
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;
}
if (CommandUtils.isPlayer(sender) && plugin.getWebServer().isAuthRequired()) {

View File

@ -1,10 +1,10 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
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.api.IPlan;
import main.java.com.djrapitops.plan.locale.Locale;

View File

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

View File

@ -34,7 +34,7 @@ public class ReloadCommand extends SubCommand {
@Override
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
plugin.restart();
plugin.reloadPlugin(true);
sender.sendMessage(Locale.get(Msg.CMD_INFO_RELOAD_COMPLETE).toString());
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.SubCommand;
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 main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
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 java.util.Arrays;
@ -33,7 +34,7 @@ public class SearchCommand extends SubCommand {
*/
public SearchCommand(Plan plugin) {
super("search",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.SEARCH.getPermission(),
Locale.get(Msg.CMD_USG_SEARCH).toString(),
"<part of playername>");
@ -48,7 +49,7 @@ public class SearchCommand extends SubCommand {
@Override
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;
}
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) {
plugin.getRunnableFactory().createNew(new AbsRunnable("SearchTask: " + Arrays.toString(args)) {
RunnableFactory.createNew(new AbsRunnable("SearchTask: " + Arrays.toString(args)) {
@Override
public void run() {
try {
@ -71,7 +72,7 @@ public class SearchCommand extends SubCommand {
if (empty) {
sender.sendMessage(Locale.get(Msg.CMD_INFO_NO_RESULTS).parse(Arrays.toString(args)));
} 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());

View File

@ -1,18 +1,18 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
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;
/**
@ -44,19 +44,19 @@ public class ManageBackupCommand extends SubCommand {
public boolean onCommand(ISender sender, String commandLabel, String[] args) {
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;
}
String dbName = args[0].toLowerCase();
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;
}
final Database database = ManageUtils.getDB(plugin, dbName);
// 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!");
return true;
}

View File

@ -1,11 +1,11 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
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.systems.cache.DataCache;
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.MiscUtils;
@ -38,7 +38,7 @@ public class ManageClearCommand extends SubCommand {
*/
public ManageClearCommand(Plan plugin) {
super("clear",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_CLEAR).toString(),
"<DB> [-a]");
@ -54,18 +54,18 @@ public class ManageClearCommand extends SubCommand {
@Override
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;
}
String dbName = args[0].toLowerCase();
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;
}
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;
}

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.Msg;
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.
@ -21,7 +21,7 @@ public class ManageDisableCommand extends SubCommand {
*/
public ManageDisableCommand() {
super("disable",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(),
"Used to disable some features of the Plugin temporarily",
"<feature>");
@ -29,7 +29,7 @@ public class ManageDisableCommand extends SubCommand {
@Override
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;
}
switch (args[0].toLowerCase()) {

View File

@ -1,16 +1,16 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
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.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
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;
/**
@ -31,7 +31,7 @@ public class ManageHotswapCommand extends SubCommand {
*/
public ManageHotswapCommand(Plan plugin) {
super("hotswap",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_HOTSWAP).toString(),
"<DB>");
@ -47,17 +47,17 @@ public class ManageHotswapCommand extends SubCommand {
@Override
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;
}
String dbName = args[0].toLowerCase();
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;
}
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;
}
@ -65,7 +65,7 @@ public class ManageHotswapCommand extends SubCommand {
final Database database = ManageUtils.getDB(plugin, dbName);
// 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!");
return true;
}

View File

@ -1,16 +1,16 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
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.Plan;
import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg;
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;
@ -49,7 +49,7 @@ public class ManageImportCommand extends SubCommand {
@Override
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;
}

View File

@ -1,17 +1,17 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.locale.Locale;
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;
/**
@ -33,7 +33,7 @@ public class ManageMoveCommand extends SubCommand {
*/
public ManageMoveCommand(Plan plugin) {
super("move",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_MOVE).toString(),
"<fromDB> <toDB> [-a]");
@ -43,29 +43,29 @@ public class ManageMoveCommand extends SubCommand {
@Override
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;
}
String fromDB = args[0].toLowerCase();
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;
}
String toDB = args[1].toLowerCase();
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;
}
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;
}
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;
}
@ -90,7 +90,7 @@ public class ManageMoveCommand extends SubCommand {
ManageUtils.clearAndCopy(toDatabase, fromDatabase);
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_MOVE_SUCCESS).toString());
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) {
Log.toLog(this.getClass().getName() + " " + getTaskName(), e);
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());

View File

@ -1,11 +1,11 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
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.systems.cache.DataCache;
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.uuid.UUIDUtility;
import org.bukkit.entity.Player;
@ -40,7 +40,7 @@ public class ManageRemoveCommand extends SubCommand {
*/
public ManageRemoveCommand(Plan plugin) {
super("remove",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(),
Locale.get(Msg.CMD_USG_MANAGE_REMOVE).toString(),
"<player> [-a]");
@ -56,7 +56,7 @@ public class ManageRemoveCommand extends SubCommand {
@Override
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;
}
@ -74,17 +74,17 @@ public class ManageRemoveCommand extends SubCommand {
UUID uuid = UUIDUtility.getUUIDOf(playerName);
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;
}
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;
}
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;
}

View File

@ -1,18 +1,18 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable;
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.Plan;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.locale.Locale;
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 java.io.File;
@ -44,18 +44,18 @@ public class ManageRestoreCommand extends SubCommand {
@Override
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;
}
String db = args[1].toLowerCase();
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;
}
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;
}
@ -78,7 +78,7 @@ public class ManageRestoreCommand extends SubCommand {
boolean containsDBFileExtension = backupDBName.endsWith(".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;
}

View File

@ -1,9 +1,9 @@
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.ISender;
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.Plan;
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.systems.webserver.webapi.bungee.RequestSetupWebAPI;
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
@ -31,7 +31,7 @@ public class ManageSetupCommand extends SubCommand {
*/
public ManageSetupCommand(Plan plugin) {
super("setup",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE.getPermission(),
"Set-Up Bungee WebServer connection",
"<Bungee WebServer address>");
@ -47,7 +47,7 @@ public class ManageSetupCommand extends SubCommand {
@Override
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;
}
if (!plugin.getWebServer().isEnabled()) {

View File

@ -1,17 +1,18 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
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.api.IPlan;
import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale;
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;
/**
@ -26,7 +27,7 @@ public class WebCheckCommand extends SubCommand {
public WebCheckCommand(IPlan plugin) {
super("check",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_CHECK).toString(),
"<username>");
@ -35,17 +36,17 @@ public class WebCheckCommand extends SubCommand {
@Override
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;
}
SecurityTable table = plugin.getDB().getSecurityTable();
String user = args[0];
plugin.getRunnableFactory().createNew(new AbsRunnable("Webuser Check Task: " + user) {
RunnableFactory.createNew(new AbsRunnable("Webuser Check Task: " + user) {
@Override
public void run() {
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;
}
WebUser info = table.getWebUser(user);

View File

@ -1,16 +1,17 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
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.api.IPlan;
import main.java.com.djrapitops.plan.database.tables.SecurityTable;
import main.java.com.djrapitops.plan.locale.Locale;
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;
/**
@ -25,7 +26,7 @@ public class WebDeleteCommand extends SubCommand {
public WebDeleteCommand(IPlan plugin) {
super("delete, remove",
CommandType.CONSOLE_WITH_ARGUMENTS,
CommandType.PLAYER_OR_ARGS,
Permissions.MANAGE_WEB.getPerm(),
Locale.get(Msg.CMD_USG_WEB_DELETE).toString(),
"<username>");
@ -34,17 +35,17 @@ public class WebDeleteCommand extends SubCommand {
@Override
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;
}
SecurityTable table = plugin.getDB().getSecurityTable();
String user = args[0];
plugin.getRunnableFactory().createNew(new AbsRunnable("Webuser Delete Task: " + user) {
RunnableFactory.createNew(new AbsRunnable("Webuser Delete Task: " + user) {
@Override
public void run() {
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;
}
table.removeUser(user);

View File

@ -1,11 +1,12 @@
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.ISender;
import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.settings.ColorScheme;
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.api.IPlan;
import main.java.com.djrapitops.plan.data.WebUser;
@ -32,7 +33,7 @@ public class WebListUsersCommand extends SubCommand {
@Override
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
public void run() {
try {

View File

@ -1,8 +1,8 @@
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.utilities.Benchmark;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
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.
*
* @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() {
return sessionID;

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.data.additional;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.pluginbridge.plan.Bridge;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan;
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.
*/

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.
* @return true/false

View File

@ -1,15 +1,16 @@
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.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
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.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.tables.*;
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 java.sql.Connection;
@ -77,7 +78,7 @@ public abstract class SQLDB extends Database {
}
public void scheduleClean(long secondsDelay) {
dbCleanTask = plugin.getRunnableFactory().createNew("DB Clean Task", new AbsRunnable() {
dbCleanTask = RunnableFactory.createNew("DB Clean Task", new AbsRunnable() {
@Override
public void run() {
try {
@ -116,7 +117,7 @@ public abstract class SQLDB extends Database {
final SQLDB db = this;
if (version < 10) {
plugin.getRunnableFactory().createNew("DB v8 -> v10 Task", new AbsRunnable() {
RunnableFactory.createNew("DB v8 -> v10 Task", new AbsRunnable() {
@Override
public void run() {
try {

View File

@ -1,8 +1,9 @@
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.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.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
@ -85,7 +86,7 @@ public class SQLiteDB extends SQLDB {
stopConnectionPingTask();
// Maintains Connection.
connectionPingTask = plugin.getRunnableFactory().createNew(new AbsRunnable("DBConnectionPingTask " + getName()) {
connectionPingTask = RunnableFactory.createNew(new AbsRunnable("DBConnectionPingTask " + getName()) {
@Override
public void run() {
Statement statement = null;

View File

@ -4,7 +4,7 @@
*/
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.data.UserInfo;
import main.java.com.djrapitops.plan.database.Database;

View File

@ -4,11 +4,11 @@
*/
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.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.tables.*;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import java.sql.SQLException;
import java.util.Optional;

View File

@ -1,13 +1,13 @@
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.DefaultMessages;
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.Settings;
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.StringLengthComparator;
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())
.collect(Collectors.toList());
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) {
@ -150,7 +151,7 @@ public class Locale {
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_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_DATA, analysis + "Analysis failed, no data in the database.");
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;
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.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
* @return true / false

View File

@ -1,6 +1,6 @@
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.data.Session;
import main.java.com.djrapitops.plan.utilities.MiscUtils;

View File

@ -4,7 +4,7 @@
*/
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.Settings;
import main.java.com.djrapitops.plan.api.exceptions.ParseException;

View File

@ -4,7 +4,7 @@
*/
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.api.exceptions.ParseException;
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>
* 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;
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.Settings;
import main.java.com.djrapitops.plan.api.IPlan;
@ -50,8 +51,8 @@ public class AnalysisPageParser extends PageParser {
}
private int getPlayersOnline() {
if (Compatibility.isBukkitAvailable()) {
return plugin.fetch().getOnlinePlayers().size();
if (Check.isBukkitAvailable()) {
return ((Plan) plugin).getServer().getOnlinePlayers().size();
}
return ((PlanBungee) plugin).getProxy().getOnlineCount();
}

View File

@ -4,8 +4,9 @@
*/
package main.java.com.djrapitops.plan.systems.info.parsing;
import com.djrapitops.plugin.api.Benchmark;
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.api.IPlan;
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.tables.SessionsTable;
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.MiscUtils;
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;
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.ServerVariableHolder;
import main.java.com.djrapitops.plan.Settings;
@ -144,7 +144,7 @@ public class BukkitServerInfoManager {
Log.info("----------------------------------");
Log.info("Bungee connection has failed 10 times in a row, assuming Bungee uninstalled - Restarting Plan..");
Log.info("----------------------------------");
plugin.restart();
plugin.reloadPlugin(true);
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
}

View File

@ -5,8 +5,8 @@
package main.java.com.djrapitops.plan.systems.info.server;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
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.ServerVariableHolder;
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;

View File

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

View File

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

View File

@ -4,7 +4,7 @@
*/
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 java.sql.SQLException;

View File

@ -4,7 +4,7 @@
*/
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.data.Action;
import main.java.com.djrapitops.plan.database.tables.Actions;

View File

@ -4,7 +4,7 @@
*/
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.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;

View File

@ -4,10 +4,10 @@
*/
package main.java.com.djrapitops.plan.systems.processing.importing;
import com.djrapitops.plugin.utilities.player.UUIDFetcher;
import main.java.com.djrapitops.plan.Log;
import com.djrapitops.plugin.api.Benchmark;
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.utilities.Benchmark;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;

View File

@ -4,9 +4,10 @@
*/
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.google.common.collect.ImmutableMap;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Session;
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.UserImportData;
import main.java.com.djrapitops.plan.systems.processing.importing.UserImportRefiner;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import java.sql.SQLException;
import java.util.*;

View File

@ -4,7 +4,7 @@
*/
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.systems.processing.Processor;
import org.bukkit.entity.Player;

View File

@ -4,7 +4,7 @@
*/
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 java.sql.SQLException;

View File

@ -4,7 +4,7 @@
*/
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.database.tables.UsersTable;

View File

@ -4,7 +4,7 @@
*/
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.data.Action;
import main.java.com.djrapitops.plan.database.tables.Actions;

View File

@ -4,7 +4,7 @@
*/
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.systems.cache.GeolocationCache;

View File

@ -4,7 +4,7 @@
*/
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 java.sql.SQLException;

View File

@ -4,7 +4,7 @@
*/
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.database.Database;
import main.java.com.djrapitops.plan.database.tables.NicknamesTable;

View File

@ -4,7 +4,7 @@
*/
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.data.Action;
import main.java.com.djrapitops.plan.database.Database;

View File

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

View File

@ -1,8 +1,8 @@
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.utilities.Benchmark;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.systems.queue;
import com.djrapitops.plugin.api.Check;
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.PlanBungee;
@ -27,7 +27,7 @@ public abstract class Setup<T> {
public void go() {
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() {
if (Compatibility.isBukkitAvailable()) {
if (Check.isBukkitAvailable()) {
return Plan.getInstance().getRunnableFactory();
} else {
return PlanBungee.getInstance().getRunnableFactory();

View File

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

View File

@ -4,10 +4,10 @@
*/
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.HttpExchange;
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.webapi.WebAPIManager;

View File

@ -4,7 +4,7 @@
*/
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.api.BadRequestResponse;
import main.java.com.djrapitops.plan.systems.webserver.webapi.WebAPI;

View File

@ -4,7 +4,7 @@
*/
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.exceptions.WebUserAuthException;
import main.java.com.djrapitops.plan.data.WebUser;

View File

@ -1,10 +1,10 @@
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.HttpsConfigurator;
import com.sun.net.httpserver.HttpsParameters;
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.api.IPlan;
import main.java.com.djrapitops.plan.locale.Locale;

View File

@ -4,7 +4,7 @@
*/
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.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.file.FileUtil;

View File

@ -1,6 +1,6 @@
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.systems.webserver.theme.Theme;
import main.java.com.djrapitops.plan.utilities.MiscUtils;

View File

@ -4,7 +4,7 @@
*/
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;
/**

View File

@ -4,7 +4,7 @@
*/
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;
/**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,9 +4,10 @@
*/
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 main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.PlanBungee;
import main.java.com.djrapitops.plan.api.IPlan;
@ -27,7 +28,7 @@ public class RequestSetupWebAPI extends WebAPI {
@Override
public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (!Compatibility.isBungeeAvailable()) {
if (!Check.isBungeeAvailable()) {
return badRequest("Called a Bukkit server.");
}
String serverUUIDS = variables.get("sender");
@ -43,7 +44,7 @@ public class RequestSetupWebAPI extends WebAPI {
@Override
public void sendRequest(String address) throws WebAPIException {
if (!Compatibility.isBukkitAvailable()) {
if (!Check.isBukkitAvailable()) {
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;
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.PlanBungee;
import main.java.com.djrapitops.plan.api.IPlan;
@ -25,7 +26,7 @@ import java.util.UUID;
public class PingWebAPI extends WebAPI {
@Override
public Response onRequest(IPlan plugin, Map<String, String> variables) {
if (Compatibility.isBungeeAvailable()) {
if (Check.isBungeeAvailable()) {
((PlanBungee) plugin).getServerInfoManager().serverConnected(UUID.fromString(variables.get("sender")));
} else if (!plugin.getInfoManager().isUsingAnotherWebServer()) {
try {
@ -44,7 +45,7 @@ public class PingWebAPI extends WebAPI {
@Override
public void sendRequest(String address) throws WebAPIException {
if (Compatibility.isBukkitAvailable()) {
if (Check.isBukkitAvailable()) {
super.sendRequest(address);
} else {
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;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.ISender;
import main.java.com.djrapitops.plan.Log;
/**
* Class containing static check methods with message sending capabilities if
@ -9,12 +9,12 @@ import main.java.com.djrapitops.plan.Log;
*
* @author Rsl1122
*/
public class Check {
public class Condition {
/**
* Constructor used to hide the public constructor
*/
private Check() {
private Condition() {
throw new IllegalStateException("Utility class");
}

View File

@ -1,7 +1,6 @@
package main.java.com.djrapitops.plan.utilities;
import com.djrapitops.plugin.utilities.Format;
import com.djrapitops.plugin.utilities.FormattingUtils;
import main.java.com.djrapitops.plan.Settings;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Location;
@ -44,15 +43,15 @@ public class FormatUtils {
}
public static String formatTimeStamp(long epochMs) {
return FormattingUtils.formatTimeStamp(epochMs);
return com.djrapitops.plugin.utilities.FormatUtils.formatTimeStamp(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) {
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
* @throws NumberFormatException When wrong format
*/
public static int parseVersionNumber(String versionString) {
return FormattingUtils.parseVersionNumber(versionString);
public static long parseVersionNumber(String versionString) {
return com.djrapitops.plugin.utilities.FormatUtils.parseVersionNumber(versionString);
}
/**
@ -190,7 +189,7 @@ public class FormatUtils {
* @return One array with contents of the multiple
*/
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.
*/
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;
import com.djrapitops.plugin.api.utility.log.Log;
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.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.database.Database;

View File

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

View File

@ -1,9 +1,10 @@
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.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable;
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.Settings;
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.webserver.response.ErrorResponse;
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.comparators.UserInfoLastPlayedComparator;
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
@ -113,7 +113,7 @@ public class Analysis {
Benchmark.stop("Analysis", "Create Empty dataset");
fillDataset(analysisData, db);
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
String fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
Benchmark.start("Analysis Phase");
Log.debug("Analysis", "Analysis Phase");
@ -126,7 +126,7 @@ public class Analysis {
Log.debug("Analysis", "Analyzing additional data sources (3rd party)");
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(analysisData.getPlayerCountPart().getUuids()));
((BukkitInformationManager) infoManager).cacheAnalysisData(analysisData);
long time = Benchmark.stop("Analysis", "Analysis");
String time = Benchmark.stop("Analysis", "Analysis");
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)
*/

View File

@ -1,6 +1,6 @@
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.data.Session;
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
@ -255,7 +255,7 @@ public class AnalysisUtils {
day.setTimeInMillis(start);
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
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;
dayOfWeek += 1;
}

View File

@ -1,6 +1,6 @@
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.Settings;
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 {
List<String> lines = new ArrayList<>();
Scanner scanner = null;

View File

@ -1,7 +1,8 @@
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 main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
@ -169,12 +170,10 @@ public class DumpUtils {
*/
private static void addPlanDetails(DumpLog log, Plan plan) {
String planVersion = plan.getVersion();
String apfVersion = plan.getAPFVersion();
log.addHeader("Plan Details");
log.add("Plan Version", planVersion);
log.add("Abstract Plugin Framework Version", apfVersion);
}
/**
@ -228,7 +227,7 @@ public class DumpUtils {
* @param plan The Plan instance
*/
private static void addTimings(DumpLog log, Plan plan) {
String[] timings = plan.benchmark().getTimings().getTimings();
String[] timings = Benchmark.getAverages().asStringArray();
log.addHeader("Timings");
log.addLines(timings);
@ -242,7 +241,7 @@ public class DumpUtils {
* @throws IOException when an error while reading occurred
*/
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)) {
return;
@ -262,7 +261,7 @@ public class DumpUtils {
* @throws IOException when an error while reading occurred
*/
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)) {
return;

View File

@ -1,8 +1,8 @@
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.collect.ImmutableList;
import main.java.com.djrapitops.plan.Log;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

View File

@ -1,6 +1,6 @@
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.html.Html;

View File

@ -1,7 +1,8 @@
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.Settings;
@ -29,7 +30,7 @@ public class BStats {
// TODO Write a Module bar graph
String serverType = plugin.getServer().getName();
if ("CraftBukkit".equals(serverType) && Compatibility.isSpigotAvailable()) {
if ("CraftBukkit".equals(serverType) && Check.isSpigotAvailable()) {
serverType = "Spigot";
}
String databaseType = plugin.getDB().getName();

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