Removed many deprecated Log & BenchMark usages

Where possible replaced with PluginLogger or ErrorHandler calls,
some places removed a catch clause and added throws,
some places removed the log or benchmark completely.

Some places still need to be modified so that the required dependencies
can be injected.
This commit is contained in:
Rsl1122 2018-09-13 19:44:45 +03:00
parent c67f0475a0
commit cb351c80f1
25 changed files with 83 additions and 108 deletions

View File

@ -35,7 +35,6 @@ import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
import com.djrapitops.plan.utilities.metrics.BStatsBukkit; import com.djrapitops.plan.utilities.metrics.BStatsBukkit;
import com.djrapitops.plugin.BukkitPlugin; import com.djrapitops.plugin.BukkitPlugin;
import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.utility.log.DebugLog;
import com.djrapitops.plugin.benchmarking.Benchmark; import com.djrapitops.plugin.benchmarking.Benchmark;
import com.djrapitops.plugin.command.ColorScheme; import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.command.CommandNode; import com.djrapitops.plugin.command.CommandNode;
@ -162,7 +161,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
} }
logger.info(locale != null ? locale.getString(PluginLang.DISABLED) : PluginLang.DISABLED.getDefault()); logger.info(locale != null ? locale.getString(PluginLang.DISABLED) : PluginLang.DISABLED.getDefault());
DebugLog.pluginDisabled(Plan.class);
} }
@Override @Override

View File

@ -19,8 +19,6 @@ import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
import com.djrapitops.plan.utilities.metrics.BStatsBungee; import com.djrapitops.plan.utilities.metrics.BStatsBungee;
import com.djrapitops.plugin.BungeePlugin; import com.djrapitops.plugin.BungeePlugin;
import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.DebugLog;
import com.djrapitops.plugin.command.ColorScheme; import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.command.CommandNode; import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.logging.L; import com.djrapitops.plugin.logging.L;
@ -129,8 +127,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
system.disable(); system.disable();
logger.info(locale.getString(PluginLang.DISABLED)); logger.info(locale.getString(PluginLang.DISABLED));
Benchmark.pluginDisabled(PlanBungee.class);
DebugLog.pluginDisabled(PlanBungee.class);
} }
@Override @Override

View File

@ -16,9 +16,6 @@ import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
import com.djrapitops.plan.utilities.metrics.BStatsSponge; import com.djrapitops.plan.utilities.metrics.BStatsSponge;
import com.djrapitops.plugin.SpongePlugin; import com.djrapitops.plugin.SpongePlugin;
import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.DebugLog;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.command.ColorScheme; import com.djrapitops.plugin.command.ColorScheme;
import com.djrapitops.plugin.command.CommandNode; import com.djrapitops.plugin.command.CommandNode;
import com.djrapitops.plugin.logging.L; import com.djrapitops.plugin.logging.L;
@ -152,9 +149,7 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
system.disable(); system.disable();
} }
Log.info(locale.getString(PluginLang.DISABLED)); logger.info(locale.getString(PluginLang.DISABLED));
Benchmark.pluginDisabled(PlanSponge.class);
DebugLog.pluginDisabled(PlanSponge.class);
} }
@Override @Override

View File

@ -1,7 +1,6 @@
package com.djrapitops.plan.data.plugin; package com.djrapitops.plan.data.plugin;
import com.djrapitops.plan.system.settings.config.PlanConfig; import com.djrapitops.plan.system.settings.config.PlanConfig;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.config.ConfigNode; import com.djrapitops.plugin.config.ConfigNode;
import java.io.IOException; import java.io.IOException;
@ -17,7 +16,9 @@ public class PluginsConfigSection {
private final PlanConfig config; private final PlanConfig config;
public PluginsConfigSection(PlanConfig config) { public PluginsConfigSection(
PlanConfig config
) {
this.config = config; this.config = config;
} }
@ -32,17 +33,13 @@ public class PluginsConfigSection {
return config.getConfigNode("Plugins"); return config.getConfigNode("Plugins");
} }
public void createSection(PluginData dataSource) { public void createSection(PluginData dataSource) throws IOException {
ConfigNode section = getPluginsSection(); ConfigNode section = getPluginsSection();
String pluginName = dataSource.getSourcePlugin(); String pluginName = dataSource.getSourcePlugin();
section.set(pluginName + ".Enabled", true); section.set(pluginName + ".Enabled", true);
try {
section.sort(); section.sort();
section.save(); section.save();
} catch (IOException e) {
Log.toLog(this.getClass(), e);
}
} }
public boolean isEnabled(PluginData dataSource) { public boolean isEnabled(PluginData dataSource) {

View File

@ -7,7 +7,6 @@ import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.keys.ServerKeys; import com.djrapitops.plan.data.store.keys.ServerKeys;
import com.djrapitops.plan.data.store.mutators.*; import com.djrapitops.plan.data.store.mutators.*;
import com.djrapitops.plan.data.store.mutators.combiners.MultiBanCombiner; import com.djrapitops.plan.data.store.mutators.combiners.MultiBanCombiner;
import com.djrapitops.plan.utilities.formatting.Formatters;
import com.djrapitops.plan.data.store.mutators.health.HealthInformation; import com.djrapitops.plan.data.store.mutators.health.HealthInformation;
import com.djrapitops.plan.data.time.WorldTimes; import com.djrapitops.plan.data.time.WorldTimes;
import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.Database;
@ -18,6 +17,7 @@ import com.djrapitops.plan.system.settings.theme.Theme;
import com.djrapitops.plan.system.settings.theme.ThemeVal; import com.djrapitops.plan.system.settings.theme.ThemeVal;
import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.analysis.ServerBanDataReader; import com.djrapitops.plan.utilities.analysis.ServerBanDataReader;
import com.djrapitops.plan.utilities.formatting.Formatters;
import com.djrapitops.plan.utilities.html.graphs.ActivityStackGraph; import com.djrapitops.plan.utilities.html.graphs.ActivityStackGraph;
import com.djrapitops.plan.utilities.html.graphs.PunchCardGraph; import com.djrapitops.plan.utilities.html.graphs.PunchCardGraph;
import com.djrapitops.plan.utilities.html.graphs.WorldMap; import com.djrapitops.plan.utilities.html.graphs.WorldMap;
@ -36,6 +36,7 @@ import com.djrapitops.plan.utilities.html.tables.ServerSessionTable;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -90,9 +91,9 @@ public class AnalysisContainer extends DataContainer {
private void addConstants() { private void addConstants() {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
putRawData(AnalysisKeys.ANALYSIS_TIME, now); putRawData(AnalysisKeys.ANALYSIS_TIME, now);
putRawData(AnalysisKeys.ANALYSIS_TIME_DAY_AGO, now - TimeAmount.DAY.ms()); putRawData(AnalysisKeys.ANALYSIS_TIME_DAY_AGO, now - TimeUnit.DAYS.toMillis(1L));
putRawData(AnalysisKeys.ANALYSIS_TIME_WEEK_AGO, now - TimeAmount.WEEK.ms()); putRawData(AnalysisKeys.ANALYSIS_TIME_WEEK_AGO, now - TimeAmount.WEEK.toMillis(1L));
putRawData(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO, now - TimeAmount.MONTH.ms()); putRawData(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO, now - TimeAmount.MONTH.toMillis(1L));
putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> Formatters.second_Old().apply(() -> getUnsafe(AnalysisKeys.ANALYSIS_TIME))); putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> Formatters.second_Old().apply(() -> getUnsafe(AnalysisKeys.ANALYSIS_TIME)));
putRawData(AnalysisKeys.VERSION, version); putRawData(AnalysisKeys.VERSION, version);

View File

@ -125,7 +125,7 @@ public class PlayersMutator {
public TreeMap<Long, Map<String, Set<UUID>>> toActivityDataMap(long date) { public TreeMap<Long, Map<String, Set<UUID>>> toActivityDataMap(long date) {
TreeMap<Long, Map<String, Set<UUID>>> activityData = new TreeMap<>(); TreeMap<Long, Map<String, Set<UUID>>> activityData = new TreeMap<>();
for (long time = date; time >= date - TimeAmount.MONTH.ms() * 2L; time -= TimeAmount.WEEK.ms()) { for (long time = date; time >= date - TimeAmount.MONTH.toMillis(2L); time -= TimeAmount.WEEK.toMillis(1L)) {
Map<String, Set<UUID>> map = activityData.getOrDefault(time, new HashMap<>()); Map<String, Set<UUID>> map = activityData.getOrDefault(time, new HashMap<>());
if (!players.isEmpty()) { if (!players.isEmpty()) {
for (PlayerContainer player : players) { for (PlayerContainer player : players) {
@ -189,8 +189,8 @@ public class PlayersMutator {
continue; continue;
} }
long monthAfterRegister = registered + TimeAmount.MONTH.ms(); long monthAfterRegister = registered + TimeAmount.MONTH.toMillis(1L);
long half = registered + (TimeAmount.MONTH.ms() / 2L); long half = registered + (TimeAmount.MONTH.toMillis(1L) / 2L);
if (player.playedBetween(registered, half) && player.playedBetween(half, monthAfterRegister)) { if (player.playedBetween(registered, half) && player.playedBetween(half, monthAfterRegister)) {
retainedAfterMonth.add(player); retainedAfterMonth.add(player);
} else { } else {

View File

@ -10,6 +10,7 @@ public class DebugChannels {
public static final String INFO_REQUESTS = "InfoRequests"; public static final String INFO_REQUESTS = "InfoRequests";
public static final String CONNECTIONS = "Connections"; public static final String CONNECTIONS = "Connections";
public static final String WEB_REQUESTS = "Web Requests"; public static final String WEB_REQUESTS = "Web Requests";
public static final String IMPORTING = "Importing";
public static final String SQL = "SQL"; public static final String SQL = "SQL";
} }

View File

@ -22,7 +22,8 @@ import com.djrapitops.plan.system.settings.config.ConfigSystem;
import com.djrapitops.plan.system.tasks.TaskSystem; import com.djrapitops.plan.system.tasks.TaskSystem;
import com.djrapitops.plan.system.update.VersionCheckSystem; import com.djrapitops.plan.system.update.VersionCheckSystem;
import com.djrapitops.plan.system.webserver.WebServerSystem; import com.djrapitops.plan.system.webserver.WebServerSystem;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -55,6 +56,7 @@ public class PlanSystem implements SubSystem {
private final ExportSystem exportSystem; private final ExportSystem exportSystem;
private final HookHandler hookHandler; private final HookHandler hookHandler;
private final PlanAPI planAPI; private final PlanAPI planAPI;
private final ErrorHandler errorHandler;
@Inject @Inject
public PlanSystem( public PlanSystem(
@ -73,7 +75,8 @@ public class PlanSystem implements SubSystem {
ImportSystem importSystem, ImportSystem importSystem,
ExportSystem exportSystem, ExportSystem exportSystem,
HookHandler hookHandler, HookHandler hookHandler,
PlanAPI planAPI PlanAPI planAPI,
ErrorHandler errorHandler
) { ) {
this.fileSystem = fileSystem; this.fileSystem = fileSystem;
this.configSystem = configSystem; this.configSystem = configSystem;
@ -91,6 +94,7 @@ public class PlanSystem implements SubSystem {
this.exportSystem = exportSystem; this.exportSystem = exportSystem;
this.hookHandler = hookHandler; this.hookHandler = hookHandler;
this.planAPI = planAPI; this.planAPI = planAPI;
this.errorHandler = errorHandler;
} }
@Deprecated @Deprecated
@ -151,7 +155,7 @@ public class PlanSystem implements SubSystem {
system.disable(); system.disable();
} }
} catch (Exception e) { } catch (Exception e) {
Log.toLog(this.getClass(), e); errorHandler.log(L.WARN, this.getClass(), e);
} }
} }
} }

View File

@ -5,7 +5,6 @@ import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.database.databases.sql.SQLDB; import com.djrapitops.plan.system.database.databases.sql.SQLDB;
import com.djrapitops.plan.system.database.databases.sql.tables.*; import com.djrapitops.plan.system.database.databases.sql.tables.*;
import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plugin.api.Benchmark;
import java.util.Optional; import java.util.Optional;
@ -37,7 +36,6 @@ public class Version10Patch extends Patch {
} }
public void alterTablesToV10() throws DBInitException { public void alterTablesToV10() throws DBInitException {
Benchmark.start("Schema copy from 8 to 10");
copyCommandUsage(); copyCommandUsage();
copyTPS(); copyTPS();
@ -56,7 +54,6 @@ public class Version10Patch extends Patch {
dropTable("temp_nicks"); dropTable("temp_nicks");
dropTable("temp_kills"); dropTable("temp_kills");
dropTable("temp_users"); dropTable("temp_users");
Benchmark.stop("Schema copy from 8 to 10");
} }
private void copyUsers() throws DBInitException { private void copyUsers() throws DBInitException {

View File

@ -10,7 +10,6 @@ import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plan.system.tasks.LogsFolderCleanTask; import com.djrapitops.plan.system.tasks.LogsFolderCleanTask;
import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.file.FileUtil;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import javax.inject.Inject; import javax.inject.Inject;
@ -18,6 +17,7 @@ import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
/** /**
* Abstracts File methods of Plugin classes so that they can be tested without Mocks. * Abstracts File methods of Plugin classes so that they can be tested without Mocks.
@ -47,6 +47,12 @@ public class FileSystem implements SubSystem {
return dataFolder; return dataFolder;
} }
private File getLogsFolder() {
File folder = getFileFromPluginFolder("logs");
folder.mkdirs();
return folder;
}
public File getConfigFile() { public File getConfigFile() {
return configFile; return configFile;
} }
@ -67,8 +73,9 @@ public class FileSystem implements SubSystem {
Verify.isTrue((configFile.exists() && configFile.isFile()) || configFile.createNewFile(), Verify.isTrue((configFile.exists() && configFile.isFile()) || configFile.createNewFile(),
() -> new EnableException("Could not create config file at " + configFile.getAbsolutePath())); () -> new EnableException("Could not create config file at " + configFile.getAbsolutePath()));
plugin.getRunnableFactory().create("Logs folder Clean Task", new LogsFolderCleanTask(Log.getLogsFolder())) plugin.getRunnableFactory().create("Logs folder Clean Task",
.runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 30L); new LogsFolderCleanTask(getLogsFolder(), plugin.getPluginLogger())
).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
} catch (IOException e) { } catch (IOException e) {
throw new EnableException("Failed to create config.yml", e); throw new EnableException("Failed to create config.yml", e);
} }

View File

@ -5,9 +5,9 @@
package com.djrapitops.plan.system.importing.data; package com.djrapitops.plan.system.importing.data;
import com.djrapitops.plan.Plan; import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.api.Benchmark; import com.djrapitops.plan.system.DebugChannels;
import com.djrapitops.plugin.api.utility.UUIDFetcher; import com.djrapitops.plugin.api.utility.UUIDFetcher;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.benchmarking.Timings;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
@ -25,6 +25,7 @@ import java.util.stream.Collectors;
public class UserImportRefiner { public class UserImportRefiner {
private final Plan plugin; private final Plan plugin;
private final Timings timings;
private final boolean onlineMode; private final boolean onlineMode;
private final List<UserImportData> importers = new ArrayList<>(); private final List<UserImportData> importers = new ArrayList<>();
@ -39,6 +40,7 @@ public class UserImportRefiner {
public UserImportRefiner(Plan plugin, List<UserImportData> importers) { public UserImportRefiner(Plan plugin, List<UserImportData> importers) {
this.plugin = plugin; this.plugin = plugin;
this.timings = plugin.getTimings();
this.importers.addAll(importers); this.importers.addAll(importers);
onlineMode = plugin.getServer().getOnlineMode(); onlineMode = plugin.getServer().getOnlineMode();
@ -47,10 +49,10 @@ public class UserImportRefiner {
public List<UserImportData> refineData() { public List<UserImportData> refineData() {
String benchmarkName = "Refining UserImportData"; String benchmarkName = "Refining UserImportData";
Benchmark.start(benchmarkName); timings.start(benchmarkName);
processMissingIdentifiers(); processMissingIdentifiers();
processOldWorlds(); processOldWorlds();
Benchmark.stop(benchmarkName); timings.end(DebugChannels.IMPORTING, benchmarkName);
return importers; return importers;
} }
@ -58,7 +60,7 @@ public class UserImportRefiner {
private void processOldWorlds() { private void processOldWorlds() {
String benchmarkName = "Processing old worlds"; String benchmarkName = "Processing old worlds";
Benchmark.start(benchmarkName); timings.start(benchmarkName);
importers.parallelStream() importers.parallelStream()
.flatMap(importer -> importer.getWorldTimes().keySet().stream()) .flatMap(importer -> importer.getWorldTimes().keySet().stream())
@ -73,7 +75,7 @@ public class UserImportRefiner {
importers.parallelStream() importers.parallelStream()
.forEach(importer -> importer.getWorldTimes().keySet().removeAll(worlds.keySet())); .forEach(importer -> importer.getWorldTimes().keySet().removeAll(worlds.keySet()));
Benchmark.stop(benchmarkName); timings.end(DebugChannels.IMPORTING, benchmarkName);
} }
private void checkOldWorld(String worldName) { private void checkOldWorld(String worldName) {
@ -90,7 +92,7 @@ public class UserImportRefiner {
private void processMissingIdentifiers() { private void processMissingIdentifiers() {
String benchmarkName = "Processing missing identifiers"; String benchmarkName = "Processing missing identifiers";
Benchmark.start(benchmarkName); timings.start(benchmarkName);
List<UserImportData> invalidData = new ArrayList<>(); List<UserImportData> invalidData = new ArrayList<>();
@ -115,13 +117,13 @@ public class UserImportRefiner {
processMissingUUIDs(); processMissingUUIDs();
processMissingNames(); processMissingNames();
Benchmark.stop(benchmarkName); timings.end(DebugChannels.IMPORTING, benchmarkName);
} }
private void processMissingUUIDs() { private void processMissingUUIDs() {
String benchmarkName = "Processing missing UUIDs"; String benchmarkName = "Processing missing UUIDs";
Benchmark.start(benchmarkName); timings.start(benchmarkName);
if (onlineMode) { if (onlineMode) {
addMissingUUIDsOverFetcher(); addMissingUUIDsOverFetcher();
@ -141,7 +143,7 @@ public class UserImportRefiner {
importers.removeAll(uuidsMissing.keySet()); importers.removeAll(uuidsMissing.keySet());
Benchmark.stop(benchmarkName); timings.end(DebugChannels.IMPORTING, benchmarkName);
} }
private void addMissingUUIDsOverFetcher() { private void addMissingUUIDsOverFetcher() {
@ -153,7 +155,6 @@ public class UserImportRefiner {
result = uuidFetcher.call().entrySet().parallelStream() result = uuidFetcher.call().entrySet().parallelStream()
.collect(Collectors.toMap(entry -> entry.getValue().toString(), Map.Entry::getKey)); .collect(Collectors.toMap(entry -> entry.getValue().toString(), Map.Entry::getKey));
} catch (Exception e) { } catch (Exception e) {
Log.toLog(this.getClass(), e);
return; return;
} }
@ -206,7 +207,7 @@ public class UserImportRefiner {
private void processMissingNames() { private void processMissingNames() {
String benchmarkNames = "Processing missing names"; String benchmarkNames = "Processing missing names";
Benchmark.start(benchmarkNames); timings.start(benchmarkNames);
addMissingNames(); addMissingNames();
@ -214,7 +215,7 @@ public class UserImportRefiner {
importers.removeAll(namesMissing.keySet()); importers.removeAll(namesMissing.keySet());
Benchmark.stop(benchmarkNames); timings.end(DebugChannels.IMPORTING, benchmarkNames);
} }
private void addMissingNames() { private void addMissingNames() {

View File

@ -20,7 +20,6 @@ import com.djrapitops.plan.system.importing.data.UserImportData;
import com.djrapitops.plan.system.importing.data.UserImportRefiner; import com.djrapitops.plan.system.importing.data.UserImportRefiner;
import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.utilities.SHA256Hash; import com.djrapitops.plan.utilities.SHA256Hash;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -82,7 +81,6 @@ public abstract class Importer {
ServerImportData serverImportData = getServerImportData(); ServerImportData serverImportData = getServerImportData();
if (serverImportData == null) { if (serverImportData == null) {
Log.debug("Server Import Data null, skipping");
return; return;
} }

View File

@ -1,15 +1,12 @@
package com.djrapitops.plan.system.listeners; package com.djrapitops.plan.system.listeners;
import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plugin.api.Benchmark;
public abstract class ListenerSystem implements SubSystem { public abstract class ListenerSystem implements SubSystem {
@Override @Override
public void enable() { public void enable() {
Benchmark.start("Register Listeners");
registerListeners(); registerListeners();
Benchmark.stop("Enable", "Register Listeners");
} }
@Override @Override
@ -21,5 +18,4 @@ public abstract class ListenerSystem implements SubSystem {
protected abstract void unregisterListeners(); protected abstract void unregisterListeners();
} }

View File

@ -2,7 +2,7 @@ package com.djrapitops.plan.system.tasks;
import com.djrapitops.plan.system.settings.Settings; import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import java.io.File; import java.io.File;
@ -18,9 +18,11 @@ import java.util.Objects;
public class LogsFolderCleanTask extends AbsRunnable { public class LogsFolderCleanTask extends AbsRunnable {
private final File folder; private final File folder;
private final PluginLogger logger;
public LogsFolderCleanTask(File folder) { public LogsFolderCleanTask(File folder, PluginLogger logger) {
this.folder = folder; this.folder = folder;
this.logger = logger;
} }
@Override @Override
@ -45,7 +47,7 @@ public class LogsFolderCleanTask extends AbsRunnable {
try { try {
Files.delete(file.toPath()); Files.delete(file.toPath());
} catch (IOException e) { } catch (IOException e) {
Log.warn("Could not delete log file at: " + file.getAbsolutePath() + ", " + e.getMessage()); logger.warn("Could not delete log file at: " + file.getAbsolutePath() + ", " + e.getMessage());
} }
} }
} }

View File

@ -7,7 +7,6 @@ import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.Processors; import com.djrapitops.plan.system.processing.processors.Processors;
import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plan.system.tasks.TPSCountTimer;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.logging.console.PluginLogger; import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.logging.error.ErrorHandler; import com.djrapitops.plugin.logging.error.ErrorHandler;
import org.bukkit.World; import org.bukkit.World;
@ -46,7 +45,7 @@ public class BukkitTPSCountTimer extends TPSCountTimer {
lastCheckNano = nanoTime; lastCheckNano = nanoTime;
if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible. if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible.
Log.debug("First run of TPSCountTimer Task."); logger.debug("First run of TPSCountTimer Task.");
return; return;
} }

View File

@ -28,7 +28,6 @@ import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.Processors; import com.djrapitops.plan.system.processing.processors.Processors;
import com.djrapitops.plan.utilities.java.Reflection; import com.djrapitops.plan.utilities.java.Reflection;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.task.RunnableFactory; import com.djrapitops.plugin.task.RunnableFactory;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -45,6 +44,8 @@ import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Task that handles player ping calculation on Bukkit based servers. * Task that handles player ping calculation on Bukkit based servers.
@ -82,7 +83,11 @@ public class PingCountTimer extends AbsRunnable implements Listener {
localPing = lookup.findGetter(entityPlayer, "ping", Integer.TYPE); localPing = lookup.findGetter(entityPlayer, "ping", Integer.TYPE);
} catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException reflectiveEx) { } catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException reflectiveEx) {
Log.toLog(PingCountTimer.class, reflectiveEx); Logger.getGlobal().log(
Level.WARNING,
"Reflective exception in static initializer of Plan PingCountTimer",
reflectiveEx
);
} }
} }

View File

@ -6,7 +6,6 @@ import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.processing.Processing; import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.Processors; import com.djrapitops.plan.system.processing.processors.Processors;
import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plan.system.tasks.TPSCountTimer;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.logging.console.PluginLogger; import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.logging.error.ErrorHandler; import com.djrapitops.plugin.logging.error.ErrorHandler;
import org.spongepowered.api.Sponge; import org.spongepowered.api.Sponge;
@ -43,7 +42,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer {
lastCheckNano = nanoTime; lastCheckNano = nanoTime;
if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible. if (diff > nanoTime) { // First run's diff = nanoTime + 1, no calc possible.
Log.debug("First run of TPSCountTimer Task."); logger.debug("First run of TPSCountTimer Task.");
return; return;
} }

View File

@ -11,6 +11,9 @@ import java.util.*;
public class ServerBanDataReader { public class ServerBanDataReader {
public ServerBanDataReader() {
}
public Set<UUID> readBanDataForContainer(DataContainer container) { public Set<UUID> readBanDataForContainer(DataContainer container) {
return readBanData( return readBanData(
container.getValue(AnalysisKeys.PLAYERS_MUTATOR) container.getValue(AnalysisKeys.PLAYERS_MUTATOR)

View File

@ -1,6 +1,5 @@
package com.djrapitops.plan.utilities.file.export; package com.djrapitops.plan.utilities.file.export;
import com.djrapitops.plugin.api.utility.log.Log;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@ -36,7 +35,7 @@ public class Hastebin {
* @return The link to the Dump Log * @return The link to the Dump Log
* @see #split(String) * @see #split(String)
*/ */
public static String safeUpload(String content) { public static String safeUpload(String content) throws ParseException, IOException {
List<String> parts = ImmutableList.copyOf(split(content)).reverse(); List<String> parts = ImmutableList.copyOf(split(content)).reverse();
String lastLink = null; String lastLink = null;
@ -52,10 +51,7 @@ public class Hastebin {
if (e.getMessage().contains("503")) { if (e.getMessage().contains("503")) {
return "Hastebin unavailable"; return "Hastebin unavailable";
} }
throw e;
Log.toLog("DumpLog.upload", e);
} catch (ParseException e) {
Log.toLog("DumpLog.upload", e);
} }
return lastLink; return lastLink;

View File

@ -4,7 +4,6 @@
*/ */
package com.djrapitops.plan.utilities.html; package com.djrapitops.plan.utilities.html;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.info.server.Server; import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo;
@ -14,7 +13,6 @@ import com.djrapitops.plan.utilities.html.graphs.line.OnlineActivityGraph;
import com.djrapitops.plan.utilities.html.icon.Color; import com.djrapitops.plan.utilities.html.icon.Color;
import com.djrapitops.plan.utilities.html.icon.Icon; import com.djrapitops.plan.utilities.html.icon.Icon;
import com.djrapitops.plan.utilities.html.icon.Icons; import com.djrapitops.plan.utilities.html.icon.Icons;
import com.djrapitops.plugin.api.utility.log.Log;
import org.apache.commons.text.TextStringBuilder; import org.apache.commons.text.TextStringBuilder;
import java.util.UUID; import java.util.UUID;
@ -82,12 +80,8 @@ public class HtmlStructure {
int playerCount = 0; int playerCount = 0;
String playerData = "[]"; String playerData = "[]";
try {
playerCount = db.count().getServerPlayerCount(serverUUID); playerCount = db.count().getServerPlayerCount(serverUUID);
playerData = new OnlineActivityGraph(db.fetch().getTPSData(serverUUID)).toHighChartsSeries(); playerData = new OnlineActivityGraph(db.fetch().getTPSData(serverUUID)).toHighChartsSeries();
} catch (DBOpException e) {
Log.toLog(HtmlStructure.class, e);
}
return "<div class=\"col-xs-12 col-sm-12 col-md-6 col-lg-6\">" + return "<div class=\"col-xs-12 col-sm-12 col-md-6 col-lg-6\">" +
"<div class=\"card\">" + "<div class=\"card\">" +

View File

@ -2,8 +2,6 @@ package com.djrapitops.plan.utilities.html.pages;
import com.djrapitops.plan.data.container.Session; import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.keys.SessionKeys; import com.djrapitops.plan.data.store.keys.SessionKeys;
import com.djrapitops.plan.utilities.formatting.Formatter;
import com.djrapitops.plan.utilities.formatting.Formatters;
import com.djrapitops.plan.data.store.objects.DateHolder; import com.djrapitops.plan.data.store.objects.DateHolder;
import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.cache.SessionCache;
import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.system.database.databases.Database;
@ -14,11 +12,12 @@ import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.info.server.properties.ServerProperties; import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.webserver.cache.ResponseCache; import com.djrapitops.plan.system.webserver.cache.ResponseCache;
import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plan.utilities.file.FileUtil;
import com.djrapitops.plan.utilities.formatting.Formatter;
import com.djrapitops.plan.utilities.formatting.Formatters;
import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plan.utilities.html.Html;
import com.djrapitops.plan.utilities.html.HtmlStructure; import com.djrapitops.plan.utilities.html.HtmlStructure;
import com.djrapitops.plan.utilities.html.icon.Icon; import com.djrapitops.plan.utilities.html.icon.Icon;
import com.djrapitops.plan.utilities.html.structure.TabsElement; import com.djrapitops.plan.utilities.html.structure.TabsElement;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.benchmarking.Benchmark; import com.djrapitops.plugin.benchmarking.Benchmark;
import com.djrapitops.plugin.benchmarking.Timings; import com.djrapitops.plugin.benchmarking.Timings;
import com.djrapitops.plugin.logging.FolderTimeStampFileLogger; import com.djrapitops.plugin.logging.FolderTimeStampFileLogger;
@ -107,7 +106,7 @@ public class DebugPage implements Page {
} }
content.append("</pre>"); content.append("</pre>");
} catch (Exception e) { } catch (Exception e) {
Log.toLog(this.getClass(), e); errorHandler.log(L.WARN, this.getClass(), e);
} }
} }

View File

@ -5,15 +5,15 @@ import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.containers.PlayerContainer; import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys; import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.keys.SessionKeys; import com.djrapitops.plan.data.store.keys.SessionKeys;
import com.djrapitops.plan.utilities.formatting.Formatter;
import com.djrapitops.plan.utilities.formatting.Formatters;
import com.djrapitops.plan.data.store.objects.DateHolder; import com.djrapitops.plan.data.store.objects.DateHolder;
import com.djrapitops.plan.utilities.comparators.SessionStartComparator; import com.djrapitops.plan.utilities.comparators.SessionStartComparator;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plan.utilities.formatting.Formatter;
import com.djrapitops.plan.utilities.formatting.Formatters;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit;
/** /**
* Utility class for creating recent login list html. * Utility class for creating recent login list html.
@ -81,7 +81,7 @@ public class RecentLoginList {
continue; continue;
} }
long mostRecentStart = session.getUnsafe(SessionKeys.START); long mostRecentStart = session.getUnsafe(SessionKeys.START);
boolean isFirstSession = Math.abs(registerDate - mostRecentStart) < TimeAmount.SECOND.ms() * 10L; boolean isFirstSession = Math.abs(registerDate - mostRecentStart) < TimeUnit.SECONDS.toMillis(10L);
recentLogins.add(new RecentLogin(mostRecentStart, isFirstSession, name)); recentLogins.add(new RecentLogin(mostRecentStart, isFirstSession, name));
} }
return recentLogins; return recentLogins;

View File

@ -2,7 +2,6 @@ package com.djrapitops.plan.utilities.metrics;
import com.djrapitops.plan.Plan; import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.api.Check; import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
public class BStatsBukkit { public class BStatsBukkit {
@ -15,7 +14,6 @@ public class BStatsBukkit {
} }
public void registerMetrics() { public void registerMetrics() {
Log.logDebug("Enable", "Enabling bStats Metrics.");
if (metrics == null) { if (metrics == null) {
metrics = new Metrics(plugin); metrics = new Metrics(plugin);
} }

View File

@ -5,7 +5,6 @@
*/ */
package com.djrapitops.plan.system.database.databases; package com.djrapitops.plan.system.database.databases;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.api.exceptions.database.DBException; import com.djrapitops.plan.api.exceptions.database.DBException;
import com.djrapitops.plan.api.exceptions.database.DBInitException; import com.djrapitops.plan.api.exceptions.database.DBInitException;
import com.djrapitops.plan.data.WebUser; import com.djrapitops.plan.data.WebUser;
@ -26,15 +25,16 @@ import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.info.server.ServerInfo; import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.utilities.Base64Util; import com.djrapitops.plan.utilities.Base64Util;
import com.djrapitops.plan.utilities.SHA256Hash; import com.djrapitops.plan.utilities.SHA256Hash;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.api.utility.log.Log;
import org.junit.*; import org.junit.*;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.junit.rules.Timeout; import org.junit.rules.Timeout;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import utilities.*; import utilities.OptionalAssert;
import utilities.RandomData;
import utilities.Teardown;
import utilities.TestConstants;
import utilities.mocks.SystemMockUtil; import utilities.mocks.SystemMockUtil;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
@ -71,12 +71,6 @@ public class SQLiteTest {
mockUtil.enableDatabaseSystem(db) mockUtil.enableDatabaseSystem(db)
.enableServerInfoSystem(); .enableServerInfoSystem();
StaticHolder.saveInstance(SQLDB.class, Plan.class);
StaticHolder.saveInstance(SQLiteTest.class, Plan.class);
Log.setErrorManager(new TestErrorManager());
Log.setDebugMode("console");
// Settings.DEV_MODE.setTemporaryValue(true);
db.init(); db.init();
System.out.println("--- Class Setup Complete ---\n"); System.out.println("--- Class Setup Complete ---\n");

View File

@ -6,10 +6,7 @@ import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.utility.log.Log; import com.djrapitops.plugin.api.utility.log.Log;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import org.json.simple.parser.ParseException; import org.json.simple.parser.ParseException;
import org.junit.Before; import org.junit.*;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
@ -81,11 +78,9 @@ public class HastebinTest {
} }
@Test @Test
public void testUpload() { public void testUpload() throws IOException, ParseException {
if (!testLink.get()) { // Hastebin not available, skipping testUpload()
Log.info("Hastebin not available, skipping testUpload()"); Assume.assumeTrue(testLink.get());
return;
}
String link = Hastebin.safeUpload(RandomData.randomString(10)); String link = Hastebin.safeUpload(RandomData.randomString(10));
assertNotNull(link); assertNotNull(link);