mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-24 09:01:41 +01:00
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:
parent
c67f0475a0
commit
cb351c80f1
@ -35,7 +35,6 @@ import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.utilities.metrics.BStatsBukkit;
|
||||
import com.djrapitops.plugin.BukkitPlugin;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.DebugLog;
|
||||
import com.djrapitops.plugin.benchmarking.Benchmark;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
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());
|
||||
DebugLog.pluginDisabled(Plan.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,8 +19,6 @@ import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.utilities.metrics.BStatsBungee;
|
||||
import com.djrapitops.plugin.BungeePlugin;
|
||||
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.CommandNode;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
@ -129,8 +127,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
||||
system.disable();
|
||||
|
||||
logger.info(locale.getString(PluginLang.DISABLED));
|
||||
Benchmark.pluginDisabled(PlanBungee.class);
|
||||
DebugLog.pluginDisabled(PlanBungee.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,9 +16,6 @@ import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.utilities.metrics.BStatsSponge;
|
||||
import com.djrapitops.plugin.SpongePlugin;
|
||||
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.CommandNode;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
@ -152,9 +149,7 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
||||
system.disable();
|
||||
}
|
||||
|
||||
Log.info(locale.getString(PluginLang.DISABLED));
|
||||
Benchmark.pluginDisabled(PlanSponge.class);
|
||||
DebugLog.pluginDisabled(PlanSponge.class);
|
||||
logger.info(locale.getString(PluginLang.DISABLED));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.djrapitops.plan.data.plugin;
|
||||
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.config.ConfigNode;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -17,7 +16,9 @@ public class PluginsConfigSection {
|
||||
|
||||
private final PlanConfig config;
|
||||
|
||||
public PluginsConfigSection(PlanConfig config) {
|
||||
public PluginsConfigSection(
|
||||
PlanConfig config
|
||||
) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@ -32,17 +33,13 @@ public class PluginsConfigSection {
|
||||
return config.getConfigNode("Plugins");
|
||||
}
|
||||
|
||||
public void createSection(PluginData dataSource) {
|
||||
public void createSection(PluginData dataSource) throws IOException {
|
||||
ConfigNode section = getPluginsSection();
|
||||
String pluginName = dataSource.getSourcePlugin();
|
||||
|
||||
section.set(pluginName + ".Enabled", true);
|
||||
try {
|
||||
section.sort();
|
||||
section.save();
|
||||
} catch (IOException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
}
|
||||
section.sort();
|
||||
section.save();
|
||||
}
|
||||
|
||||
public boolean isEnabled(PluginData dataSource) {
|
||||
|
@ -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.mutators.*;
|
||||
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.time.WorldTimes;
|
||||
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.utilities.MiscUtils;
|
||||
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.PunchCardGraph;
|
||||
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 java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -90,9 +91,9 @@ public class AnalysisContainer extends DataContainer {
|
||||
private void addConstants() {
|
||||
long now = System.currentTimeMillis();
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME, now);
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_DAY_AGO, now - TimeAmount.DAY.ms());
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_WEEK_AGO, now - TimeAmount.WEEK.ms());
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO, now - TimeAmount.MONTH.ms());
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_DAY_AGO, now - TimeUnit.DAYS.toMillis(1L));
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_WEEK_AGO, now - TimeAmount.WEEK.toMillis(1L));
|
||||
putRawData(AnalysisKeys.ANALYSIS_TIME_MONTH_AGO, now - TimeAmount.MONTH.toMillis(1L));
|
||||
putSupplier(AnalysisKeys.REFRESH_TIME_F, () -> Formatters.second_Old().apply(() -> getUnsafe(AnalysisKeys.ANALYSIS_TIME)));
|
||||
|
||||
putRawData(AnalysisKeys.VERSION, version);
|
||||
|
@ -125,7 +125,7 @@ public class PlayersMutator {
|
||||
|
||||
public TreeMap<Long, Map<String, Set<UUID>>> toActivityDataMap(long date) {
|
||||
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<>());
|
||||
if (!players.isEmpty()) {
|
||||
for (PlayerContainer player : players) {
|
||||
@ -189,8 +189,8 @@ public class PlayersMutator {
|
||||
continue;
|
||||
}
|
||||
|
||||
long monthAfterRegister = registered + TimeAmount.MONTH.ms();
|
||||
long half = registered + (TimeAmount.MONTH.ms() / 2L);
|
||||
long monthAfterRegister = registered + TimeAmount.MONTH.toMillis(1L);
|
||||
long half = registered + (TimeAmount.MONTH.toMillis(1L) / 2L);
|
||||
if (player.playedBetween(registered, half) && player.playedBetween(half, monthAfterRegister)) {
|
||||
retainedAfterMonth.add(player);
|
||||
} else {
|
||||
|
@ -10,6 +10,7 @@ public class DebugChannels {
|
||||
public static final String INFO_REQUESTS = "InfoRequests";
|
||||
public static final String CONNECTIONS = "Connections";
|
||||
public static final String WEB_REQUESTS = "Web Requests";
|
||||
public static final String IMPORTING = "Importing";
|
||||
public static final String SQL = "SQL";
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ import com.djrapitops.plan.system.settings.config.ConfigSystem;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
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.Singleton;
|
||||
@ -55,6 +56,7 @@ public class PlanSystem implements SubSystem {
|
||||
private final ExportSystem exportSystem;
|
||||
private final HookHandler hookHandler;
|
||||
private final PlanAPI planAPI;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public PlanSystem(
|
||||
@ -73,7 +75,8 @@ public class PlanSystem implements SubSystem {
|
||||
ImportSystem importSystem,
|
||||
ExportSystem exportSystem,
|
||||
HookHandler hookHandler,
|
||||
PlanAPI planAPI
|
||||
PlanAPI planAPI,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.fileSystem = fileSystem;
|
||||
this.configSystem = configSystem;
|
||||
@ -91,6 +94,7 @@ public class PlanSystem implements SubSystem {
|
||||
this.exportSystem = exportSystem;
|
||||
this.hookHandler = hookHandler;
|
||||
this.planAPI = planAPI;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -151,7 +155,7 @@ public class PlanSystem implements SubSystem {
|
||||
system.disable();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.tables.*;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -37,7 +36,6 @@ public class Version10Patch extends Patch {
|
||||
}
|
||||
|
||||
public void alterTablesToV10() throws DBInitException {
|
||||
Benchmark.start("Schema copy from 8 to 10");
|
||||
copyCommandUsage();
|
||||
|
||||
copyTPS();
|
||||
@ -56,7 +54,6 @@ public class Version10Patch extends Patch {
|
||||
dropTable("temp_nicks");
|
||||
dropTable("temp_kills");
|
||||
dropTable("temp_users");
|
||||
Benchmark.stop("Schema copy from 8 to 10");
|
||||
}
|
||||
|
||||
private void copyUsers() throws DBInitException {
|
||||
|
@ -10,7 +10,6 @@ import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.tasks.LogsFolderCleanTask;
|
||||
import com.djrapitops.plan.utilities.file.FileUtil;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -18,6 +17,7 @@ import javax.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
private File getLogsFolder() {
|
||||
File folder = getFileFromPluginFolder("logs");
|
||||
folder.mkdirs();
|
||||
return folder;
|
||||
}
|
||||
|
||||
public File getConfigFile() {
|
||||
return configFile;
|
||||
}
|
||||
@ -67,8 +73,9 @@ public class FileSystem implements SubSystem {
|
||||
Verify.isTrue((configFile.exists() && configFile.isFile()) || configFile.createNewFile(),
|
||||
() -> new EnableException("Could not create config file at " + configFile.getAbsolutePath()));
|
||||
|
||||
plugin.getRunnableFactory().create("Logs folder Clean Task", new LogsFolderCleanTask(Log.getLogsFolder()))
|
||||
.runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 30L);
|
||||
plugin.getRunnableFactory().create("Logs folder Clean Task",
|
||||
new LogsFolderCleanTask(getLogsFolder(), plugin.getPluginLogger())
|
||||
).runTaskLaterAsynchronously(TimeAmount.toTicks(30L, TimeUnit.SECONDS));
|
||||
} catch (IOException e) {
|
||||
throw new EnableException("Failed to create config.yml", e);
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
package com.djrapitops.plan.system.importing.data;
|
||||
|
||||
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.log.Log;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
|
||||
@ -25,6 +25,7 @@ import java.util.stream.Collectors;
|
||||
public class UserImportRefiner {
|
||||
|
||||
private final Plan plugin;
|
||||
private final Timings timings;
|
||||
private final boolean onlineMode;
|
||||
|
||||
private final List<UserImportData> importers = new ArrayList<>();
|
||||
@ -39,6 +40,7 @@ public class UserImportRefiner {
|
||||
|
||||
public UserImportRefiner(Plan plugin, List<UserImportData> importers) {
|
||||
this.plugin = plugin;
|
||||
this.timings = plugin.getTimings();
|
||||
this.importers.addAll(importers);
|
||||
|
||||
onlineMode = plugin.getServer().getOnlineMode();
|
||||
@ -47,10 +49,10 @@ public class UserImportRefiner {
|
||||
public List<UserImportData> refineData() {
|
||||
String benchmarkName = "Refining UserImportData";
|
||||
|
||||
Benchmark.start(benchmarkName);
|
||||
timings.start(benchmarkName);
|
||||
processMissingIdentifiers();
|
||||
processOldWorlds();
|
||||
Benchmark.stop(benchmarkName);
|
||||
timings.end(DebugChannels.IMPORTING, benchmarkName);
|
||||
|
||||
return importers;
|
||||
}
|
||||
@ -58,7 +60,7 @@ public class UserImportRefiner {
|
||||
private void processOldWorlds() {
|
||||
String benchmarkName = "Processing old worlds";
|
||||
|
||||
Benchmark.start(benchmarkName);
|
||||
timings.start(benchmarkName);
|
||||
|
||||
importers.parallelStream()
|
||||
.flatMap(importer -> importer.getWorldTimes().keySet().stream())
|
||||
@ -73,7 +75,7 @@ public class UserImportRefiner {
|
||||
importers.parallelStream()
|
||||
.forEach(importer -> importer.getWorldTimes().keySet().removeAll(worlds.keySet()));
|
||||
|
||||
Benchmark.stop(benchmarkName);
|
||||
timings.end(DebugChannels.IMPORTING, benchmarkName);
|
||||
}
|
||||
|
||||
private void checkOldWorld(String worldName) {
|
||||
@ -90,7 +92,7 @@ public class UserImportRefiner {
|
||||
private void processMissingIdentifiers() {
|
||||
String benchmarkName = "Processing missing identifiers";
|
||||
|
||||
Benchmark.start(benchmarkName);
|
||||
timings.start(benchmarkName);
|
||||
|
||||
List<UserImportData> invalidData = new ArrayList<>();
|
||||
|
||||
@ -115,13 +117,13 @@ public class UserImportRefiner {
|
||||
processMissingUUIDs();
|
||||
processMissingNames();
|
||||
|
||||
Benchmark.stop(benchmarkName);
|
||||
timings.end(DebugChannels.IMPORTING, benchmarkName);
|
||||
}
|
||||
|
||||
private void processMissingUUIDs() {
|
||||
String benchmarkName = "Processing missing UUIDs";
|
||||
|
||||
Benchmark.start(benchmarkName);
|
||||
timings.start(benchmarkName);
|
||||
|
||||
if (onlineMode) {
|
||||
addMissingUUIDsOverFetcher();
|
||||
@ -141,7 +143,7 @@ public class UserImportRefiner {
|
||||
|
||||
importers.removeAll(uuidsMissing.keySet());
|
||||
|
||||
Benchmark.stop(benchmarkName);
|
||||
timings.end(DebugChannels.IMPORTING, benchmarkName);
|
||||
}
|
||||
|
||||
private void addMissingUUIDsOverFetcher() {
|
||||
@ -153,7 +155,6 @@ public class UserImportRefiner {
|
||||
result = uuidFetcher.call().entrySet().parallelStream()
|
||||
.collect(Collectors.toMap(entry -> entry.getValue().toString(), Map.Entry::getKey));
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -206,7 +207,7 @@ public class UserImportRefiner {
|
||||
private void processMissingNames() {
|
||||
String benchmarkNames = "Processing missing names";
|
||||
|
||||
Benchmark.start(benchmarkNames);
|
||||
timings.start(benchmarkNames);
|
||||
|
||||
addMissingNames();
|
||||
|
||||
@ -214,7 +215,7 @@ public class UserImportRefiner {
|
||||
|
||||
importers.removeAll(namesMissing.keySet());
|
||||
|
||||
Benchmark.stop(benchmarkNames);
|
||||
timings.end(DebugChannels.IMPORTING, benchmarkNames);
|
||||
}
|
||||
|
||||
private void addMissingNames() {
|
||||
|
@ -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.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.SHA256Hash;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@ -82,7 +81,6 @@ public abstract class Importer {
|
||||
ServerImportData serverImportData = getServerImportData();
|
||||
|
||||
if (serverImportData == null) {
|
||||
Log.debug("Server Import Data null, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,12 @@
|
||||
package com.djrapitops.plan.system.listeners;
|
||||
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
|
||||
public abstract class ListenerSystem implements SubSystem {
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
Benchmark.start("Register Listeners");
|
||||
registerListeners();
|
||||
Benchmark.stop("Enable", "Register Listeners");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -21,5 +18,4 @@ public abstract class ListenerSystem implements SubSystem {
|
||||
|
||||
protected abstract void unregisterListeners();
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.djrapitops.plan.system.tasks;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
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 java.io.File;
|
||||
@ -18,9 +18,11 @@ import java.util.Objects;
|
||||
public class LogsFolderCleanTask extends AbsRunnable {
|
||||
|
||||
private final File folder;
|
||||
private final PluginLogger logger;
|
||||
|
||||
public LogsFolderCleanTask(File folder) {
|
||||
public LogsFolderCleanTask(File folder, PluginLogger logger) {
|
||||
this.folder = folder;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,7 +47,7 @@ public class LogsFolderCleanTask extends AbsRunnable {
|
||||
try {
|
||||
Files.delete(file.toPath());
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
||||
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.error.ErrorHandler;
|
||||
import org.bukkit.World;
|
||||
@ -46,7 +45,7 @@ public class BukkitTPSCountTimer extends TPSCountTimer {
|
||||
lastCheckNano = nanoTime;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.processing.processors.Processors;
|
||||
import com.djrapitops.plan.utilities.java.Reflection;
|
||||
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.RunnableFactory;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -45,6 +44,8 @@ import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException reflectiveEx) {
|
||||
Log.toLog(PingCountTimer.class, reflectiveEx);
|
||||
Logger.getGlobal().log(
|
||||
Level.WARNING,
|
||||
"Reflective exception in static initializer of Plan PingCountTimer",
|
||||
reflectiveEx
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.processors.Processors;
|
||||
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.error.ErrorHandler;
|
||||
import org.spongepowered.api.Sponge;
|
||||
@ -43,7 +42,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer {
|
||||
lastCheckNano = nanoTime;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,9 @@ import java.util.*;
|
||||
|
||||
public class ServerBanDataReader {
|
||||
|
||||
public ServerBanDataReader() {
|
||||
}
|
||||
|
||||
public Set<UUID> readBanDataForContainer(DataContainer container) {
|
||||
return readBanData(
|
||||
container.getValue(AnalysisKeys.PLAYERS_MUTATOR)
|
||||
|
@ -1,6 +1,5 @@
|
||||
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.collect.ImmutableList;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -36,7 +35,7 @@ public class Hastebin {
|
||||
* @return The link to the Dump Log
|
||||
* @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();
|
||||
|
||||
String lastLink = null;
|
||||
@ -52,10 +51,7 @@ public class Hastebin {
|
||||
if (e.getMessage().contains("503")) {
|
||||
return "Hastebin unavailable";
|
||||
}
|
||||
|
||||
Log.toLog("DumpLog.upload", e);
|
||||
} catch (ParseException e) {
|
||||
Log.toLog("DumpLog.upload", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
return lastLink;
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
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.info.server.Server;
|
||||
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.Icon;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icons;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -82,12 +80,8 @@ public class HtmlStructure {
|
||||
|
||||
int playerCount = 0;
|
||||
String playerData = "[]";
|
||||
try {
|
||||
playerCount = db.count().getServerPlayerCount(serverUUID);
|
||||
playerData = new OnlineActivityGraph(db.fetch().getTPSData(serverUUID)).toHighChartsSeries();
|
||||
} catch (DBOpException e) {
|
||||
Log.toLog(HtmlStructure.class, e);
|
||||
}
|
||||
playerCount = db.count().getServerPlayerCount(serverUUID);
|
||||
playerData = new OnlineActivityGraph(db.fetch().getTPSData(serverUUID)).toHighChartsSeries();
|
||||
|
||||
return "<div class=\"col-xs-12 col-sm-12 col-md-6 col-lg-6\">" +
|
||||
"<div class=\"card\">" +
|
||||
|
@ -2,8 +2,6 @@ package com.djrapitops.plan.utilities.html.pages;
|
||||
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
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.system.cache.SessionCache;
|
||||
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.webserver.cache.ResponseCache;
|
||||
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.HtmlStructure;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
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.Timings;
|
||||
import com.djrapitops.plugin.logging.FolderTimeStampFileLogger;
|
||||
@ -107,7 +106,7 @@ public class DebugPage implements Page {
|
||||
}
|
||||
content.append("</pre>");
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.keys.PlayerKeys;
|
||||
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.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.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Utility class for creating recent login list html.
|
||||
@ -81,7 +81,7 @@ public class RecentLoginList {
|
||||
continue;
|
||||
}
|
||||
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));
|
||||
}
|
||||
return recentLogins;
|
||||
|
@ -2,7 +2,6 @@ package com.djrapitops.plan.utilities.metrics;
|
||||
|
||||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
public class BStatsBukkit {
|
||||
@ -15,7 +14,6 @@ public class BStatsBukkit {
|
||||
}
|
||||
|
||||
public void registerMetrics() {
|
||||
Log.logDebug("Enable", "Enabling bStats Metrics.");
|
||||
if (metrics == null) {
|
||||
metrics = new Metrics(plugin);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
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.DBInitException;
|
||||
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.utilities.Base64Util;
|
||||
import com.djrapitops.plan.utilities.SHA256Hash;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.rules.Timeout;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import utilities.*;
|
||||
import utilities.OptionalAssert;
|
||||
import utilities.RandomData;
|
||||
import utilities.Teardown;
|
||||
import utilities.TestConstants;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
@ -71,12 +71,6 @@ public class SQLiteTest {
|
||||
|
||||
mockUtil.enableDatabaseSystem(db)
|
||||
.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();
|
||||
System.out.println("--- Class Setup Complete ---\n");
|
||||
|
@ -6,10 +6,7 @@ import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
@ -81,11 +78,9 @@ public class HastebinTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpload() {
|
||||
if (!testLink.get()) {
|
||||
Log.info("Hastebin not available, skipping testUpload()");
|
||||
return;
|
||||
}
|
||||
public void testUpload() throws IOException, ParseException {
|
||||
// Hastebin not available, skipping testUpload()
|
||||
Assume.assumeTrue(testLink.get());
|
||||
|
||||
String link = Hastebin.safeUpload(RandomData.randomString(10));
|
||||
assertNotNull(link);
|
||||
|
Loading…
Reference in New Issue
Block a user