Fixed a few sonar smells

This commit is contained in:
Rsl1122 2019-09-03 18:22:27 +03:00
parent a544b75838
commit fee603a657
44 changed files with 122 additions and 254 deletions

View File

@ -20,7 +20,6 @@ import com.djrapitops.plan.commands.PlanCommand;
import com.djrapitops.plan.gathering.ServerShutdownSave; import com.djrapitops.plan.gathering.ServerShutdownSave;
import com.djrapitops.plan.modules.APFModule; import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule; import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ServerSuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule; import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import com.djrapitops.plan.modules.bukkit.BukkitPlanModule; import com.djrapitops.plan.modules.bukkit.BukkitPlanModule;
import com.djrapitops.plan.modules.bukkit.BukkitServerPropertiesModule; import com.djrapitops.plan.modules.bukkit.BukkitServerPropertiesModule;
@ -42,7 +41,6 @@ import javax.inject.Singleton;
APFModule.class, APFModule.class,
FilesModule.class, FilesModule.class,
BukkitServerPropertiesModule.class, BukkitServerPropertiesModule.class,
ServerSuperClassBindingModule.class,
BukkitSuperClassBindingModule.class BukkitSuperClassBindingModule.class
}) })
public interface PlanBukkitComponent { public interface PlanBukkitComponent {

View File

@ -29,7 +29,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.io.TempDir;
import org.junit.platform.runner.JUnitPlatform; import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import utilities.OptionalAssert;
import utilities.RandomData; import utilities.RandomData;
import utilities.mocks.BukkitMockComponent; import utilities.mocks.BukkitMockComponent;
@ -37,6 +36,7 @@ import java.nio.file.Path;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -77,7 +77,7 @@ public class BukkitSystemTest {
Optional<String> found = database.query(ServerQueries.fetchServerMatchingIdentifier(system.getServerInfo().getServerUUID())) Optional<String> found = database.query(ServerQueries.fetchServerMatchingIdentifier(system.getServerInfo().getServerUUID()))
.map(Server::getWebAddress); .map(Server::getWebAddress);
OptionalAssert.equals(expectedAddress, found); assertEquals(expectedAddress, found.orElse(null));
} finally { } finally {
system.disable(); system.disable();
} }

View File

@ -41,6 +41,7 @@ import java.util.UUID;
* PlanAPI extension for all implementations. * PlanAPI extension for all implementations.
* *
* @author Rsl1122 * @author Rsl1122
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
*/ */
@Singleton @Singleton
@Deprecated @Deprecated

View File

@ -29,6 +29,7 @@ import java.util.UUID;
* Interface for PlanAPI methods. * Interface for PlanAPI methods.
* *
* @author Rsl1122 * @author Rsl1122
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
*/ */
@Deprecated @Deprecated
public interface PlanAPI { public interface PlanAPI {

View File

@ -28,6 +28,7 @@ import java.util.Optional;
* <p> * <p>
* The Keys might change in the future, but the Optional API should help dealing with those cases. * The Keys might change in the future, but the Optional API should help dealing with those cases.
* *
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
* @author Rsl1122 * @author Rsl1122
*/ */
@Deprecated @Deprecated

View File

@ -29,6 +29,7 @@ import java.util.Optional;
* The Keys might change in the future, but the Optional API should help dealing with those cases. * The Keys might change in the future, but the Optional API should help dealing with those cases.
* *
* @author Rsl1122 * @author Rsl1122
* @deprecated Plan API v4 has been deprecated, use the APIv5 instead (https://github.com/plan-player-analytics/Plan/wiki/APIv5).
*/ */
@Deprecated @Deprecated
public class ServerContainer { public class ServerContainer {

View File

@ -27,7 +27,6 @@ import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.Sender; import com.djrapitops.plugin.command.Sender;
import com.djrapitops.plugin.logging.L; import com.djrapitops.plugin.logging.L;
import com.djrapitops.plugin.logging.error.ErrorHandler; import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.task.RunnableFactory;
import javax.inject.Inject; import javax.inject.Inject;
@ -41,15 +40,13 @@ public class ReloadCommand extends CommandNode {
private final PlanPlugin plugin; private final PlanPlugin plugin;
private final Locale locale; private final Locale locale;
private final ErrorHandler errorHandler; private final ErrorHandler errorHandler;
private final RunnableFactory runnableFactory;
@Inject @Inject
public ReloadCommand(PlanPlugin plugin, Locale locale, RunnableFactory runnableFactory, ErrorHandler errorHandler) { public ReloadCommand(PlanPlugin plugin, Locale locale, ErrorHandler errorHandler) {
super("reload", Permissions.RELOAD.getPermission(), CommandType.CONSOLE); super("reload", Permissions.RELOAD.getPermission(), CommandType.CONSOLE);
this.plugin = plugin; this.plugin = plugin;
this.locale = locale; this.locale = locale;
this.runnableFactory = runnableFactory;
this.errorHandler = errorHandler; this.errorHandler = errorHandler;
setShortHelp(locale.getString(CmdHelpLang.RELOAD)); setShortHelp(locale.getString(CmdHelpLang.RELOAD));

View File

@ -133,19 +133,23 @@ public class ManageExportCommand extends CommandNode {
} }
private void exportPlayers(Sender sender) { private void exportPlayers(Sender sender) {
Boolean exportPlayerJSON = config.get(ExportSettings.PLAYER_JSON); boolean exportPlayerJSON = config.get(ExportSettings.PLAYER_JSON);
Boolean exportPlayerHTML = config.get(ExportSettings.PLAYER_PAGES); boolean exportPlayerHTML = config.get(ExportSettings.PLAYER_PAGES);
boolean exportPlayersHtml = config.get(ExportSettings.PLAYERS_PAGE);
if (!exportPlayerJSON && !exportPlayerHTML) { if (!exportPlayerJSON && !exportPlayerHTML) {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL)); sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL));
sender.sendMessage("§c'" + ExportSettings.PLAYER_JSON.getPath() + "' & '" + ExportSettings.PLAYER_PAGES.getPath() + "': false"); sender.sendMessage("§c'" + ExportSettings.PLAYER_JSON.getPath() + "' & '" + ExportSettings.PLAYER_PAGES.getPath() + "': false");
return; return;
} }
processing.submitNonCritical(() -> { if (exportPlayersHtml) {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
if (config.get(ExportSettings.PLAYERS_PAGE)) {
processing.submitNonCritical(exporter::exportPlayersPage); processing.submitNonCritical(exporter::exportPlayersPage);
} }
processing.submitNonCritical(() -> performExport(sender, exportPlayerJSON, exportPlayerHTML));
}
private void performExport(Sender sender, boolean exportPlayerJSON, boolean exportPlayerHTML) {
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
Map<UUID, String> players = dbSystem.getDatabase().query(UserIdentifierQueries.fetchAllPlayerNames()); Map<UUID, String> players = dbSystem.getDatabase().query(UserIdentifierQueries.fetchAllPlayerNames());
int size = players.size(); int size = players.size();
@ -170,6 +174,5 @@ public class ManageExportCommand extends CommandNode {
sender.sendMessage(" §2✔: §f" + (i - failed)); sender.sendMessage(" §2✔: §f" + (i - failed));
sender.sendMessage(" §c✕: §f" + failed); sender.sendMessage(" §c✕: §f" + failed);
} }
});
} }
} }

View File

@ -29,6 +29,4 @@ import com.djrapitops.plan.delivery.domain.keys.PlaceholderKey;
*/ */
@Deprecated @Deprecated
public class AnalysisContainer extends DynamicDataContainer { public class AnalysisContainer extends DynamicDataContainer {
public AnalysisContainer() {
}
} }

View File

@ -58,15 +58,9 @@ public class PerServerContainer extends HashMap<UUID, DataContainer> {
container.putSupplier(PerServerKeys.LAST_SEEN, () -> SessionsMutator.forContainer(container).toLastSeen()); container.putSupplier(PerServerKeys.LAST_SEEN, () -> SessionsMutator.forContainer(container).toLastSeen());
container.putSupplier(PerServerKeys.WORLD_TIMES, () -> SessionsMutator.forContainer(container).toTotalWorldTimes()); container.putSupplier(PerServerKeys.WORLD_TIMES, () -> SessionsMutator.forContainer(container).toTotalWorldTimes());
container.putSupplier(PerServerKeys.PLAYER_DEATHS, () -> SessionsMutator.forContainer(container).toPlayerDeathList()); container.putSupplier(PerServerKeys.PLAYER_KILL_COUNT, () -> SessionsMutator.forContainer(container).toPlayerKillCount());
container.putSupplier(PerServerKeys.PLAYER_KILLS, () -> SessionsMutator.forContainer(container).toPlayerKillList());
container.putSupplier(PerServerKeys.PLAYER_KILL_COUNT, () -> container.getValue(PerServerKeys.PLAYER_KILLS).map(Collection::size).orElse(0));
container.putSupplier(PerServerKeys.MOB_KILL_COUNT, () -> SessionsMutator.forContainer(container).toMobKillCount()); container.putSupplier(PerServerKeys.MOB_KILL_COUNT, () -> SessionsMutator.forContainer(container).toMobKillCount());
container.putSupplier(PerServerKeys.DEATH_COUNT, () -> SessionsMutator.forContainer(container).toDeathCount()); container.putSupplier(PerServerKeys.DEATH_COUNT, () -> SessionsMutator.forContainer(container).toDeathCount());
container.putSupplier(PerServerKeys.PLAYER_DEATH_COUNT, () -> SessionsMutator.forContainer(container).toPlayerDeathCount());
container.putSupplier(PerServerKeys.MOB_DEATH_COUNT, () ->
container.getValue(PerServerKeys.DEATH_COUNT).orElse(0) - container.getValue(PerServerKeys.PLAYER_DEATH_COUNT).orElse(0)
);
} }
} }

View File

@ -33,6 +33,7 @@ import java.util.UUID;
* *
* @author Rsl1122 * @author Rsl1122
* @see com.djrapitops.plan.data.store.containers.AnalysisContainer for Suppliers for each Key. * @see com.djrapitops.plan.data.store.containers.AnalysisContainer for Suppliers for each Key.
* @deprecated AnalysisContainer can no longer be obtained, so this is deprecated.
*/ */
@Deprecated @Deprecated
public class AnalysisKeys { public class AnalysisKeys {

View File

@ -45,8 +45,10 @@ public class PerServerKeys {
@Deprecated @Deprecated
public static final Key<List<PlayerDeath>> PLAYER_DEATHS = CommonKeys.PLAYER_DEATHS; public static final Key<List<PlayerDeath>> PLAYER_DEATHS = CommonKeys.PLAYER_DEATHS;
public static final Key<Integer> PLAYER_KILL_COUNT = CommonKeys.PLAYER_KILL_COUNT; public static final Key<Integer> PLAYER_KILL_COUNT = CommonKeys.PLAYER_KILL_COUNT;
@Deprecated
public static final Key<Integer> PLAYER_DEATH_COUNT = CommonKeys.PLAYER_DEATH_COUNT; public static final Key<Integer> PLAYER_DEATH_COUNT = CommonKeys.PLAYER_DEATH_COUNT;
public static final Key<Integer> MOB_KILL_COUNT = CommonKeys.MOB_KILL_COUNT; public static final Key<Integer> MOB_KILL_COUNT = CommonKeys.MOB_KILL_COUNT;
@Deprecated
public static final Key<Integer> MOB_DEATH_COUNT = CommonKeys.MOB_DEATH_COUNT; public static final Key<Integer> MOB_DEATH_COUNT = CommonKeys.MOB_DEATH_COUNT;
public static final Key<Integer> DEATH_COUNT = CommonKeys.DEATH_COUNT; public static final Key<Integer> DEATH_COUNT = CommonKeys.DEATH_COUNT;
public static final Key<Long> LAST_SEEN = CommonKeys.LAST_SEEN; public static final Key<Long> LAST_SEEN = CommonKeys.LAST_SEEN;

View File

@ -28,7 +28,6 @@ import java.util.UUID;
* Class that holds Key objects for PlayerContainer. * Class that holds Key objects for PlayerContainer.
* *
* @author Rsl1122 * @author Rsl1122
* @see com.djrapitops.plan.storage.database.databases.sql.operation.SQLFetchOps For Suppliers for each key
* @see PlayerContainer For DataContainer. * @see PlayerContainer For DataContainer.
*/ */
public class PlayerKeys { public class PlayerKeys {

View File

@ -52,6 +52,9 @@ public class SessionKeys {
@Deprecated @Deprecated
public static final Key<List<PlayerDeath>> PLAYER_DEATHS = CommonKeys.PLAYER_DEATHS; public static final Key<List<PlayerDeath>> PLAYER_DEATHS = CommonKeys.PLAYER_DEATHS;
/**
* @deprecated use WorldAliasSettings#getLongestWorldPlayed(Session) instead.
*/
@Deprecated @Deprecated
public static final Key<String> LONGEST_WORLD_PLAYED = new Key<>(String.class, "longest_world_played"); public static final Key<String> LONGEST_WORLD_PLAYED = new Key<>(String.class, "longest_world_played");

View File

@ -106,10 +106,7 @@ public class SessionsMutator {
*/ */
@Deprecated @Deprecated
public List<PlayerDeath> toPlayerDeathList() { public List<PlayerDeath> toPlayerDeathList() {
return sessions.stream() return Collections.emptyList();
.map(session -> session.getValue(SessionKeys.PLAYER_DEATHS).orElse(new ArrayList<>()))
.flatMap(Collection::stream)
.collect(Collectors.toList());
} }
public int toMobKillCount() { public int toMobKillCount() {
@ -241,12 +238,8 @@ public class SessionsMutator {
return sorted; return sorted;
} }
/**
* @deprecated Incorrect value, use PlayerVersusMutator instead.
*/
@Deprecated
public int toPlayerDeathCount() { public int toPlayerDeathCount() {
return toPlayerDeathList().size(); return sessions.stream().mapToInt(session -> session.getValue(SessionKeys.DEATH_COUNT).orElse(0)).sum();
} }
public List<Long> toSessionStarts() { public List<Long> toSessionStarts() {

View File

@ -96,9 +96,9 @@ public class ExportScheduler {
int offsetMultiplier = proxy.isPresent() ? 1 : 0; // Delay first server export if on a network. int offsetMultiplier = proxy.isPresent() ? 1 : 0; // Delay first server export if on a network.
for (Server server : servers) { for (Server server : servers) {
taskSystem.registerTask("Server export", taskSystem.registerTask("Server export",
new ExportTask(exporter, exporter -> { new ExportTask(exporter, same -> {
exporter.exportServerPage(server); same.exportServerPage(server);
exporter.exportServerJSON(server); same.exportServerJSON(server);
}, logger, errorHandler)) }, logger, errorHandler))
.runTaskTimerAsynchronously(offset * offsetMultiplier, period); .runTaskTimerAsynchronously(offset * offsetMultiplier, period);
offsetMultiplier++; offsetMultiplier++;

View File

@ -22,6 +22,7 @@ public enum Family {
SOLID(" fa fa-", "\"></i>"), SOLID(" fa fa-", "\"></i>"),
REGULAR(" far fa-", "\"></i>"), REGULAR(" far fa-", "\"></i>"),
BRAND(" fab fa-", "\"></i>"), BRAND(" fab fa-", "\"></i>"),
@Deprecated
LINE(" material-icons\">", "</i>"); LINE(" material-icons\">", "</i>");
private final String middle; private final String middle;

View File

@ -16,6 +16,8 @@
*/ */
package com.djrapitops.plan.delivery.rendering.json.graphs.bar; package com.djrapitops.plan.delivery.rendering.json.graphs.bar;
import java.util.Objects;
public class Bar implements Comparable<Bar> { public class Bar implements Comparable<Bar> {
private final String label; private final String label;
@ -38,4 +40,18 @@ public class Bar implements Comparable<Bar> {
public int compareTo(Bar bar) { public int compareTo(Bar bar) {
return Long.compare(bar.value, this.value); return Long.compare(bar.value, this.value);
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Bar)) return false;
Bar bar = (Bar) o;
return value == bar.value &&
Objects.equals(label, bar.label);
}
@Override
public int hashCode() {
return Objects.hash(label, value);
}
} }

View File

@ -33,7 +33,10 @@ import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import java.util.*; import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -45,13 +48,10 @@ import java.util.concurrent.TimeUnit;
public class NetworkOverviewJSONParser implements NetworkTabJSONParser<Map<String, Object>> { public class NetworkOverviewJSONParser implements NetworkTabJSONParser<Map<String, Object>> {
private final Formatter<Long> day; private final Formatter<Long> day;
private final TimeZone timeZone;
private PlanConfig config; private PlanConfig config;
private DBSystem dbSystem; private DBSystem dbSystem;
private ServerInfo serverInfo; private ServerInfo serverInfo;
private Formatter<Long> timeAmount; private Formatter<Long> timeAmount;
private Formatter<Double> decimals;
private Formatter<Double> percentage;
private Formatter<DateHolder> year; private Formatter<DateHolder> year;
@Inject @Inject
@ -68,9 +68,6 @@ public class NetworkOverviewJSONParser implements NetworkTabJSONParser<Map<Strin
year = formatters.year(); year = formatters.year();
day = formatters.dayLong(); day = formatters.dayLong();
timeAmount = formatters.timeAmount(); timeAmount = formatters.timeAmount();
decimals = formatters.decimals();
percentage = formatters.percentage();
this.timeZone = config.getTimeZone();
} }
public Map<String, Object> createJSONAsMap() { public Map<String, Object> createJSONAsMap() {

View File

@ -16,7 +16,6 @@
*/ */
package com.djrapitops.plan.delivery.rendering.pages; package com.djrapitops.plan.delivery.rendering.pages;
import com.djrapitops.plan.delivery.domain.DateHolder;
import com.djrapitops.plan.delivery.domain.keys.SessionKeys; import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
import com.djrapitops.plan.delivery.formatting.Formatter; import com.djrapitops.plan.delivery.formatting.Formatter;
import com.djrapitops.plan.delivery.formatting.Formatters; import com.djrapitops.plan.delivery.formatting.Formatters;
@ -60,7 +59,6 @@ public class DebugPage implements Page {
private final Timings timings; private final Timings timings;
private final ErrorHandler errorHandler; private final ErrorHandler errorHandler;
private final Formatter<DateHolder> secondFormatter;
private final Formatter<Long> yearFormatter; private final Formatter<Long> yearFormatter;
DebugPage( DebugPage(
@ -79,7 +77,6 @@ public class DebugPage implements Page {
this.timings = timings; this.timings = timings;
this.errorHandler = errorHandler; this.errorHandler = errorHandler;
this.secondFormatter = formatters.second();
this.yearFormatter = formatters.yearLong(); this.yearFormatter = formatters.yearLong();
} }

View File

@ -123,6 +123,7 @@ public class JSONCache {
@Inject @Inject
public CleanTask() { public CleanTask() {
// Dagger requires inject constructor
} }
@Override @Override

View File

@ -31,7 +31,6 @@ import com.djrapitops.plan.storage.database.DBSystem;
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries; import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
import com.djrapitops.plan.storage.file.PlanFiles; import com.djrapitops.plan.storage.file.PlanFiles;
import com.djrapitops.plan.version.VersionCheckSystem; import com.djrapitops.plan.version.VersionCheckSystem;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -51,7 +50,6 @@ public class ResponseFactory {
private final PageFactory pageFactory; private final PageFactory pageFactory;
private final Locale locale; private final Locale locale;
private final DBSystem dbSystem; private final DBSystem dbSystem;
private final ErrorHandler errorHandler;
@Inject @Inject
public ResponseFactory( public ResponseFactory(
@ -59,15 +57,13 @@ public class ResponseFactory {
PlanFiles files, PlanFiles files,
PageFactory pageFactory, PageFactory pageFactory,
Locale locale, Locale locale,
DBSystem dbSystem, DBSystem dbSystem
ErrorHandler errorHandler
) { ) {
this.versionCheckSystem = versionCheckSystem; this.versionCheckSystem = versionCheckSystem;
this.files = files; this.files = files;
this.pageFactory = pageFactory; this.pageFactory = pageFactory;
this.locale = locale; this.locale = locale;
this.dbSystem = dbSystem; this.dbSystem = dbSystem;
this.errorHandler = errorHandler;
} }
public Response debugPageResponse() { public Response debugPageResponse() {

View File

@ -29,7 +29,7 @@ public class DataExtensionMethodCallException extends IllegalStateException {
private final String pluginName; private final String pluginName;
// Non serializable field due to Method not being serializable. // Non serializable field due to Method not being serializable.
private transient final MethodWrapper method; private final transient MethodWrapper method;
public DataExtensionMethodCallException(Throwable cause, String pluginName, MethodWrapper method) { public DataExtensionMethodCallException(Throwable cause, String pluginName, MethodWrapper method) {
super(cause); super(cause);

View File

@ -232,23 +232,6 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
return new ExtensionDescriptive(name, text, description, icon, priority); return new ExtensionDescriptive(name, text, description, icon, priority);
} }
private ExtensionTabData.Factory extractTab(String tabName, ResultSet set, Map<String, ExtensionTabData.Factory> tabData) throws SQLException {
Optional<Integer> tabPriority = Optional.of(set.getInt("tab_priority"));
if (set.wasNull()) {
tabPriority = Optional.empty();
}
Optional<ElementOrder[]> elementOrder = Optional.ofNullable(set.getString(ExtensionTabTable.ELEMENT_ORDER)).map(ElementOrder::deserialize);
Icon tabIcon = extractTabIcon(set);
return tabData.getOrDefault(tabName, new ExtensionTabData.Factory(new TabInformation(
tabName,
tabIcon,
elementOrder.orElse(ElementOrder.values()),
tabPriority.orElse(100)
)));
}
private Icon extractTabIcon(ResultSet set) throws SQLException { private Icon extractTabIcon(ResultSet set) throws SQLException {
Optional<String> iconName = Optional.ofNullable(set.getString("tab_icon_name")); Optional<String> iconName = Optional.ofNullable(set.getString("tab_icon_name"));
if (iconName.isPresent()) { if (iconName.isPresent()) {

View File

@ -114,7 +114,7 @@ public class RemoveUnsatisfiedConditionalPlayerResultsTransaction extends Transa
// Nested query here is required because MySQL limits update statements with nested queries: // Nested query here is required because MySQL limits update statements with nested queries:
// The nested query creates a temporary table that bypasses the same table query-update limit. // The nested query creates a temporary table that bypasses the same table query-update limit.
// Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception. // Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception.
String sql = "DELETE FROM " + playerValueTable + String sql = DELETE_FROM + playerValueTable +
WHERE + ExtensionPlayerValueTable.ID + " IN (" + SELECT + ExtensionPlayerValueTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)"; WHERE + ExtensionPlayerValueTable.ID + " IN (" + SELECT + ExtensionPlayerValueTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)";
return new ExecStatement(sql) { return new ExecStatement(sql) {
@ -142,7 +142,7 @@ public class RemoveUnsatisfiedConditionalPlayerResultsTransaction extends Transa
// Nested query here is required because MySQL limits update statements with nested queries: // Nested query here is required because MySQL limits update statements with nested queries:
// The nested query creates a temporary table that bypasses the same table query-update limit. // The nested query creates a temporary table that bypasses the same table query-update limit.
// Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception. // Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception.
String deleteValuesSQL = "DELETE FROM " + playerTableValueTable + String deleteValuesSQL = DELETE_FROM + playerTableValueTable +
WHERE + ExtensionPlayerTableValueTable.TABLE_ID + " IN (" + SELECT + ExtensionTableProviderTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)"; WHERE + ExtensionPlayerTableValueTable.TABLE_ID + " IN (" + SELECT + ExtensionTableProviderTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)";
return new ExecStatement(deleteValuesSQL) { return new ExecStatement(deleteValuesSQL) {
@ -178,7 +178,7 @@ public class RemoveUnsatisfiedConditionalPlayerResultsTransaction extends Transa
// Nested query here is required because MySQL limits update statements with nested queries: // Nested query here is required because MySQL limits update statements with nested queries:
// The nested query creates a temporary table that bypasses the same table query-update limit. // The nested query creates a temporary table that bypasses the same table query-update limit.
// Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception. // Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception.
String deleteValuesSQL = "DELETE FROM " + groupTable + String deleteValuesSQL = DELETE_FROM + groupTable +
WHERE + ID + " IN (" + SELECT + ID + FROM + '(' + selectUnsatisfiedIDs + ") as ids)"; WHERE + ID + " IN (" + SELECT + ID + FROM + '(' + selectUnsatisfiedIDs + ") as ids)";
return new ExecStatement(deleteValuesSQL) { return new ExecStatement(deleteValuesSQL) {

View File

@ -86,7 +86,7 @@ public class RemoveUnsatisfiedConditionalServerResultsTransaction extends Transa
// Nested query here is required because MySQL limits update statements with nested queries: // Nested query here is required because MySQL limits update statements with nested queries:
// The nested query creates a temporary table that bypasses the same table query-update limit. // The nested query creates a temporary table that bypasses the same table query-update limit.
// Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception. // Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception.
String sql = "DELETE FROM " + serverValueTable + String sql = DELETE_FROM + serverValueTable +
WHERE + ExtensionServerValueTable.ID + " IN (" + SELECT + ExtensionServerValueTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)"; WHERE + ExtensionServerValueTable.ID + " IN (" + SELECT + ExtensionServerValueTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)";
return new ExecStatement(sql) { return new ExecStatement(sql) {
@ -136,7 +136,7 @@ public class RemoveUnsatisfiedConditionalServerResultsTransaction extends Transa
// Nested query here is required because MySQL limits update statements with nested queries: // Nested query here is required because MySQL limits update statements with nested queries:
// The nested query creates a temporary table that bypasses the same table query-update limit. // The nested query creates a temporary table that bypasses the same table query-update limit.
// Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception. // Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception.
String deleteValuesSQL = "DELETE FROM " + serverTableValueTable + String deleteValuesSQL = DELETE_FROM + serverTableValueTable +
WHERE + ExtensionServerTableValueTable.TABLE_ID + " IN (" + SELECT + ExtensionTableProviderTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)"; WHERE + ExtensionServerTableValueTable.TABLE_ID + " IN (" + SELECT + ExtensionTableProviderTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)";
return new ExecStatement(deleteValuesSQL) { return new ExecStatement(deleteValuesSQL) {

View File

@ -27,8 +27,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
import static com.djrapitops.plan.storage.database.sql.parsing.Sql.AND; import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
import static com.djrapitops.plan.storage.database.sql.parsing.Sql.WHERE;
/** /**
* Transaction to store method result of a {@link com.djrapitops.plan.extension.implementation.providers.GroupDataProvider}. * Transaction to store method result of a {@link com.djrapitops.plan.extension.implementation.providers.GroupDataProvider}.
@ -62,7 +61,7 @@ public class StorePlayerGroupsResultTransaction extends Transaction {
} }
private Executable deleteOldValues() { private Executable deleteOldValues() {
String sql = "DELETE FROM " + ExtensionGroupsTable.TABLE_NAME + String sql = DELETE_FROM + ExtensionGroupsTable.TABLE_NAME +
WHERE + ExtensionGroupsTable.USER_UUID + "=?" + WHERE + ExtensionGroupsTable.USER_UUID + "=?" +
AND + ExtensionGroupsTable.PROVIDER_ID + "=" + ExtensionProviderTable.STATEMENT_SELECT_PROVIDER_ID; AND + ExtensionGroupsTable.PROVIDER_ID + "=" + ExtensionProviderTable.STATEMENT_SELECT_PROVIDER_ID;

View File

@ -78,7 +78,7 @@ public class StorePlayerTableResultTransaction extends Transaction {
} }
private Executable deleteOldValues(int tableID) { private Executable deleteOldValues(int tableID) {
String sql = "DELETE FROM " + TABLE_NAME + String sql = DELETE_FROM + TABLE_NAME +
WHERE + TABLE_ID + "=?" + WHERE + TABLE_ID + "=?" +
AND + USER_UUID + "=?"; AND + USER_UUID + "=?";

View File

@ -76,7 +76,7 @@ public class StoreServerTableResultTransaction extends Transaction {
} }
private Executable deleteOldValues(int tableID) { private Executable deleteOldValues(int tableID) {
String sql = "DELETE FROM " + TABLE_NAME + String sql = DELETE_FROM + TABLE_NAME +
WHERE + TABLE_ID + "=?" + WHERE + TABLE_ID + "=?" +
AND + SERVER_UUID + "=?"; AND + SERVER_UUID + "=?";

View File

@ -66,7 +66,6 @@ public class Session extends DynamicDataContainer implements DateHolder {
putSupplier(SessionKeys.START, this::getSessionStart); putSupplier(SessionKeys.START, this::getSessionStart);
putSupplier(SessionKeys.WORLD_TIMES, this::getWorldTimes); putSupplier(SessionKeys.WORLD_TIMES, this::getWorldTimes);
putSupplier(SessionKeys.PLAYER_KILLS, this::getPlayerKills); putSupplier(SessionKeys.PLAYER_KILLS, this::getPlayerKills);
putRawData(SessionKeys.PLAYER_DEATHS, new ArrayList<>());
putSupplier(SessionKeys.MOB_KILL_COUNT, this::getMobKills); putSupplier(SessionKeys.MOB_KILL_COUNT, this::getMobKills);
putSupplier(SessionKeys.DEATH_COUNT, this::getDeaths); putSupplier(SessionKeys.DEATH_COUNT, this::getDeaths);
putSupplier(SessionKeys.AFK_TIME, this::getAfkTime); putSupplier(SessionKeys.AFK_TIME, this::getAfkTime);
@ -75,8 +74,6 @@ public class Session extends DynamicDataContainer implements DateHolder {
putSupplier(SessionKeys.LENGTH, () -> putSupplier(SessionKeys.LENGTH, () ->
getValue(SessionKeys.END).orElse(System.currentTimeMillis()) - getUnsafe(SessionKeys.START)); getValue(SessionKeys.END).orElse(System.currentTimeMillis()) - getUnsafe(SessionKeys.START));
putSupplier(SessionKeys.ACTIVE_TIME, () -> getUnsafe(SessionKeys.LENGTH) - getUnsafe(SessionKeys.AFK_TIME)); putSupplier(SessionKeys.ACTIVE_TIME, () -> getUnsafe(SessionKeys.LENGTH) - getUnsafe(SessionKeys.AFK_TIME));
putRawData(SessionKeys.LONGEST_WORLD_PLAYED, "Key is Deprecated, use WorldAliasSettings#getLongestWorldPlayed(Session) instead.");
} }
/** /**
@ -113,7 +110,6 @@ public class Session extends DynamicDataContainer implements DateHolder {
putRawData(SessionKeys.END, sessionEnd); putRawData(SessionKeys.END, sessionEnd);
putSupplier(SessionKeys.WORLD_TIMES, this::getWorldTimes); putSupplier(SessionKeys.WORLD_TIMES, this::getWorldTimes);
putSupplier(SessionKeys.PLAYER_KILLS, this::getPlayerKills); putSupplier(SessionKeys.PLAYER_KILLS, this::getPlayerKills);
putRawData(SessionKeys.PLAYER_DEATHS, new ArrayList<>());
putSupplier(SessionKeys.MOB_KILL_COUNT, this::getMobKills); putSupplier(SessionKeys.MOB_KILL_COUNT, this::getMobKills);
putSupplier(SessionKeys.DEATH_COUNT, this::getDeaths); putSupplier(SessionKeys.DEATH_COUNT, this::getDeaths);
putSupplier(SessionKeys.AFK_TIME, this::getAfkTime); putSupplier(SessionKeys.AFK_TIME, this::getAfkTime);
@ -123,8 +119,6 @@ public class Session extends DynamicDataContainer implements DateHolder {
putSupplier(SessionKeys.LENGTH, () -> putSupplier(SessionKeys.LENGTH, () ->
getValue(SessionKeys.END).orElse(System.currentTimeMillis()) - getUnsafe(SessionKeys.START)); getValue(SessionKeys.END).orElse(System.currentTimeMillis()) - getUnsafe(SessionKeys.START));
putSupplier(SessionKeys.ACTIVE_TIME, () -> getUnsafe(SessionKeys.LENGTH) - getUnsafe(SessionKeys.AFK_TIME)); putSupplier(SessionKeys.ACTIVE_TIME, () -> getUnsafe(SessionKeys.LENGTH) - getUnsafe(SessionKeys.AFK_TIME));
putRawData(SessionKeys.LONGEST_WORLD_PLAYED, "Key is Deprecated, use WorldAliasSettings#getLongestWorldPlayed(Session) instead.");
} }
/** /**

View File

@ -16,8 +16,6 @@
*/ */
package com.djrapitops.plan.modules; package com.djrapitops.plan.modules;
import com.djrapitops.plan.api.CommonAPI;
import com.djrapitops.plan.api.PlanAPI;
import com.djrapitops.plan.gathering.importing.EmptyImportSystem; import com.djrapitops.plan.gathering.importing.EmptyImportSystem;
import com.djrapitops.plan.gathering.importing.ImportSystem; import com.djrapitops.plan.gathering.importing.ImportSystem;
import com.djrapitops.plan.settings.ConfigSystem; import com.djrapitops.plan.settings.ConfigSystem;
@ -35,9 +33,6 @@ import dagger.Module;
@Module @Module
public interface ProxySuperClassBindingModule { public interface ProxySuperClassBindingModule {
@Binds
PlanAPI bindProxyPlanAPI(CommonAPI proxyAPI);
@Binds @Binds
DBSystem bindProxyDatabaseSystem(ProxyDBSystem proxyDBSystem); DBSystem bindProxyDatabaseSystem(ProxyDBSystem proxyDBSystem);

View File

@ -1,35 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.modules;
import com.djrapitops.plan.api.CommonAPI;
import com.djrapitops.plan.api.PlanAPI;
import dagger.Binds;
import dagger.Module;
/**
* Module for binding Server specific classes to the interface implementations.
*
* @author Rsl1122
*/
@Module
public interface ServerSuperClassBindingModule {
@Binds
PlanAPI bindServerPlanAPI(CommonAPI serverAPI);
}

View File

@ -57,9 +57,9 @@ public class Processing implements SubSystem {
return Executors.newFixedThreadPool(i, return Executors.newFixedThreadPool(i,
new BasicThreadFactory.Builder() new BasicThreadFactory.Builder()
.namingPattern(s) .namingPattern(s)
.uncaughtExceptionHandler((thread, throwable) -> { .uncaughtExceptionHandler((thread, throwable) ->
errorHandler.log(L.WARN, Processing.class, throwable); errorHandler.log(L.WARN, Processing.class, throwable)
}).build()); ).build());
} }
public void submit(Runnable runnable) { public void submit(Runnable runnable) {

View File

@ -30,11 +30,7 @@ import com.djrapitops.plan.settings.config.paths.key.StringSetting;
public class DisplaySettings { public class DisplaySettings {
public static final Setting<String> THEME = new StringSetting("Display_options.Theme"); public static final Setting<String> THEME = new StringSetting("Display_options.Theme");
@Deprecated // Removed in 5.0.0
public static final Setting<Boolean> REPLACE_SESSION_ACCORDION_WITH_TABLE = new BooleanSetting("Display_options.Sessions.Replace_accordion_with_table");
public static final Setting<Integer> SESSIONS_PER_PAGE = new IntegerSetting("Display_options.Sessions.Show_on_page"); public static final Setting<Integer> SESSIONS_PER_PAGE = new IntegerSetting("Display_options.Sessions.Show_on_page");
@Deprecated // Removed in 5.0.0
public static final Setting<Boolean> SESSION_MOST_PLAYED_WORLD_IN_TITLE = new BooleanSetting("Display_options.Sessions.Show_most_played_world_in_title");
public static final Setting<Boolean> ORDER_WORLD_PIE_BY_PERC = new BooleanSetting("Display_options.Sessions.Order_world_pies_by_percentage"); public static final Setting<Boolean> ORDER_WORLD_PIE_BY_PERC = new BooleanSetting("Display_options.Sessions.Order_world_pies_by_percentage");
public static final Setting<Integer> PLAYERS_PER_SERVER_PAGE = new IntegerSetting("Display_options.Players_table.Show_on_server_page"); public static final Setting<Integer> PLAYERS_PER_SERVER_PAGE = new IntegerSetting("Display_options.Players_table.Show_on_server_page");
public static final Setting<Integer> PLAYERS_PER_PLAYERS_PAGE = new IntegerSetting("Display_options.Players_table.Show_on_players_page"); public static final Setting<Integer> PLAYERS_PER_PLAYERS_PAGE = new IntegerSetting("Display_options.Players_table.Show_on_players_page");

View File

@ -110,8 +110,8 @@ public class ServerSettingsManager implements SubSystem {
Database database = dbSystem.getDatabase(); Database database = dbSystem.getDatabase();
try (ConfigReader reader = new ConfigReader(file.toPath())) { try (ConfigReader reader = new ConfigReader(file.toPath())) {
Config config = reader.read(); Config read = reader.read();
database.executeTransaction(new StoreConfigTransaction(serverInfo.getServerUUID(), config, file.lastModified())); database.executeTransaction(new StoreConfigTransaction(serverInfo.getServerUUID(), read, file.lastModified()));
logger.debug("Server config saved to database."); logger.debug("Server config saved to database.");
} catch (IOException e) { } catch (IOException e) {
throw new UncheckedIOException(e); throw new UncheckedIOException(e);

View File

@ -94,15 +94,9 @@ public class AllPlayerContainersQuery implements Query<List<PlayerContainer>> {
container.putSupplier(PerServerKeys.LAST_SEEN, () -> SessionsMutator.forContainer(container).toLastSeen()); container.putSupplier(PerServerKeys.LAST_SEEN, () -> SessionsMutator.forContainer(container).toLastSeen());
container.putSupplier(PerServerKeys.WORLD_TIMES, () -> SessionsMutator.forContainer(container).toTotalWorldTimes()); container.putSupplier(PerServerKeys.WORLD_TIMES, () -> SessionsMutator.forContainer(container).toTotalWorldTimes());
container.putSupplier(PerServerKeys.PLAYER_DEATHS, () -> SessionsMutator.forContainer(container).toPlayerDeathList()); container.putSupplier(PerServerKeys.PLAYER_KILL_COUNT, () -> SessionsMutator.forContainer(container).toPlayerKillCount());
container.putSupplier(PerServerKeys.PLAYER_KILLS, () -> SessionsMutator.forContainer(container).toPlayerKillList());
container.putSupplier(PerServerKeys.PLAYER_KILL_COUNT, () -> container.getValue(PerServerKeys.PLAYER_KILLS).map(Collection::size).orElse(0));
container.putSupplier(PerServerKeys.MOB_KILL_COUNT, () -> SessionsMutator.forContainer(container).toMobKillCount()); container.putSupplier(PerServerKeys.MOB_KILL_COUNT, () -> SessionsMutator.forContainer(container).toMobKillCount());
container.putSupplier(PerServerKeys.DEATH_COUNT, () -> SessionsMutator.forContainer(container).toDeathCount()); container.putSupplier(PerServerKeys.DEATH_COUNT, () -> SessionsMutator.forContainer(container).toDeathCount());
container.putSupplier(PerServerKeys.PLAYER_DEATH_COUNT, () -> SessionsMutator.forContainer(container).toPlayerDeathCount());
container.putSupplier(PerServerKeys.MOB_DEATH_COUNT, () ->
container.getValue(PerServerKeys.DEATH_COUNT).orElse(0) - container.getValue(PerServerKeys.PLAYER_DEATH_COUNT).orElse(0)
);
perServerContainer.put(serverUUID, container); perServerContainer.put(serverUUID, container);
perServerContainers.put(playerUUID, perServerContainer); perServerContainers.put(playerUUID, perServerContainer);
} }

View File

@ -21,7 +21,6 @@ import com.djrapitops.plan.delivery.domain.container.PerServerContainer;
import com.djrapitops.plan.delivery.domain.container.SupplierDataContainer; import com.djrapitops.plan.delivery.domain.container.SupplierDataContainer;
import com.djrapitops.plan.delivery.domain.keys.Key; import com.djrapitops.plan.delivery.domain.keys.Key;
import com.djrapitops.plan.delivery.domain.keys.PerServerKeys; import com.djrapitops.plan.delivery.domain.keys.PerServerKeys;
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
import com.djrapitops.plan.gathering.domain.Session; import com.djrapitops.plan.gathering.domain.Session;
import com.djrapitops.plan.gathering.domain.UserInfo; import com.djrapitops.plan.gathering.domain.UserInfo;
import com.djrapitops.plan.storage.database.SQLDB; import com.djrapitops.plan.storage.database.SQLDB;
@ -55,18 +54,10 @@ public class PerServerContainerQuery implements Query<PerServerContainer> {
userInformation(db, perServerContainer); userInformation(db, perServerContainer);
lastSeen(db, perServerContainer); lastSeen(db, perServerContainer);
playerKillCount(db, perServerContainer); playerKillCount(db, perServerContainer);
playerDeathCount(db, perServerContainer);
mobKillCount(db, perServerContainer); mobKillCount(db, perServerContainer);
totalDeathCount(db, perServerContainer); totalDeathCount(db, perServerContainer);
worldTimes(db, perServerContainer); worldTimes(db, perServerContainer);
// After-values that can be calculated without database.
for (DataContainer serverContainer : perServerContainer.values()) {
serverContainer.putSupplier(PerServerKeys.MOB_DEATH_COUNT, () ->
serverContainer.getValue(PerServerKeys.DEATH_COUNT).orElse(0) - serverContainer.getValue(PerServerKeys.PLAYER_DEATH_COUNT).orElse(0)
);
}
Map<UUID, List<Session>> sessions = db.query(SessionQueries.fetchSessionsOfPlayer(playerUUID)); Map<UUID, List<Session>> sessions = db.query(SessionQueries.fetchSessionsOfPlayer(playerUUID));
for (Map.Entry<UUID, List<Session>> entry : sessions.entrySet()) { for (Map.Entry<UUID, List<Session>> entry : sessions.entrySet()) {
UUID serverUUID = entry.getKey(); UUID serverUUID = entry.getKey();
@ -75,9 +66,6 @@ public class PerServerContainerQuery implements Query<PerServerContainer> {
DataContainer serverContainer = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer()); DataContainer serverContainer = perServerContainer.getOrDefault(serverUUID, new SupplierDataContainer());
serverContainer.putRawData(PerServerKeys.SESSIONS, serverSessions); serverContainer.putRawData(PerServerKeys.SESSIONS, serverSessions);
serverContainer.putSupplier(PerServerKeys.PLAYER_KILLS, () -> SessionsMutator.forContainer(serverContainer).toPlayerKillList());
serverContainer.putSupplier(PerServerKeys.PLAYER_DEATHS, () -> SessionsMutator.forContainer(serverContainer).toPlayerDeathList());
perServerContainer.put(serverUUID, serverContainer); perServerContainer.put(serverUUID, serverContainer);
} }
@ -92,10 +80,6 @@ public class PerServerContainerQuery implements Query<PerServerContainer> {
matchingEntrySet(PerServerKeys.WORLD_TIMES, WorldTimesQueries.fetchPlayerWorldTimesOnServers(playerUUID), db, container); matchingEntrySet(PerServerKeys.WORLD_TIMES, WorldTimesQueries.fetchPlayerWorldTimesOnServers(playerUUID), db, container);
} }
private void playerDeathCount(SQLDB db, PerServerContainer container) {
matchingEntrySet(PerServerKeys.PLAYER_DEATH_COUNT, PerServerAggregateQueries.playerDeathCountOnServers(playerUUID), db, container);
}
private void mobKillCount(SQLDB db, PerServerContainer container) { private void mobKillCount(SQLDB db, PerServerContainer container) {
matchingEntrySet(PerServerKeys.MOB_KILL_COUNT, PerServerAggregateQueries.mobKillCountOnServers(playerUUID), db, container); matchingEntrySet(PerServerKeys.MOB_KILL_COUNT, PerServerAggregateQueries.mobKillCountOnServers(playerUUID), db, container);
} }

View File

@ -86,7 +86,6 @@ public class PlayerContainerQuery implements Query<PlayerContainer> {
container.putSupplier(PlayerKeys.LAST_SEEN, () -> SessionsMutator.forContainer(container).toLastSeen()); container.putSupplier(PlayerKeys.LAST_SEEN, () -> SessionsMutator.forContainer(container).toLastSeen());
container.putSupplier(PlayerKeys.PLAYER_KILLS, () -> db.query(KillQueries.fetchPlayerKillsOfPlayer(uuid))); container.putSupplier(PlayerKeys.PLAYER_KILLS, () -> db.query(KillQueries.fetchPlayerKillsOfPlayer(uuid)));
container.putSupplier(PlayerKeys.PLAYER_DEATHS_KILLS, () -> db.query(KillQueries.fetchPlayerDeathsOfPlayer(uuid))); container.putSupplier(PlayerKeys.PLAYER_DEATHS_KILLS, () -> db.query(KillQueries.fetchPlayerDeathsOfPlayer(uuid)));
container.putSupplier(PlayerKeys.PLAYER_DEATHS, () -> SessionsMutator.forContainer(container).toPlayerDeathList());
container.putSupplier(PlayerKeys.PLAYER_KILL_COUNT, () -> container.getValue(PlayerKeys.PLAYER_KILLS).map(Collection::size).orElse(0)); container.putSupplier(PlayerKeys.PLAYER_KILL_COUNT, () -> container.getValue(PlayerKeys.PLAYER_KILLS).map(Collection::size).orElse(0));
container.putSupplier(PlayerKeys.MOB_KILL_COUNT, () -> SessionsMutator.forContainer(container).toMobKillCount()); container.putSupplier(PlayerKeys.MOB_KILL_COUNT, () -> SessionsMutator.forContainer(container).toMobKillCount());
container.putSupplier(PlayerKeys.DEATH_COUNT, () -> SessionsMutator.forContainer(container).toDeathCount()); container.putSupplier(PlayerKeys.DEATH_COUNT, () -> SessionsMutator.forContainer(container).toDeathCount());

View File

@ -151,7 +151,6 @@ public class PingQueries {
PingTable.MAX_PING + ", " + PingTable.MAX_PING + ", " +
PingTable.MIN_PING + ", " + PingTable.MIN_PING + ", " +
PingTable.AVG_PING + ", " + PingTable.AVG_PING + ", " +
PingTable.USER_UUID + ", " +
PingTable.SERVER_UUID + PingTable.SERVER_UUID +
FROM + PingTable.TABLE_NAME + FROM + PingTable.TABLE_NAME +
WHERE + PingTable.SERVER_UUID + "=?" + WHERE + PingTable.SERVER_UUID + "=?" +
@ -170,7 +169,6 @@ public class PingQueries {
List<Ping> pings = new ArrayList<>(); List<Ping> pings = new ArrayList<>();
while (set.next()) { while (set.next()) {
UUID uuid = UUID.fromString(set.getString(PingTable.USER_UUID));
UUID serverUUID = UUID.fromString(set.getString(PingTable.SERVER_UUID)); UUID serverUUID = UUID.fromString(set.getString(PingTable.SERVER_UUID));
long date = set.getLong(PingTable.DATE); long date = set.getLong(PingTable.DATE);
double avgPing = set.getDouble(PingTable.AVG_PING); double avgPing = set.getDouble(PingTable.AVG_PING);

View File

@ -21,31 +21,31 @@ import java.util.concurrent.TimeUnit;
/** /**
* Duplicate String reducing utility class for SQL language Strings. * Duplicate String reducing utility class for SQL language Strings.
*/ */
public interface Sql { public abstract class Sql {
String ID = "id"; public static final String ID = "id";
String P_UUID = "uuid"; public static final String P_UUID = "uuid";
String INT = "integer"; public static final String INT = "integer";
String DOUBLE = "double"; public static final String DOUBLE = "double";
String LONG = "bigint"; public static final String LONG = "bigint";
String BOOL = "boolean"; public static final String BOOL = "boolean";
String SELECT = "SELECT "; public static final String SELECT = "SELECT ";
String DISTINCT = "DISTINCT "; public static final String DISTINCT = "DISTINCT ";
String FROM = " FROM "; public static final String FROM = " FROM ";
String DELETE_FROM = "DELETE" + FROM; public static final String DELETE_FROM = "DELETE" + FROM;
String WHERE = " WHERE "; public static final String WHERE = " WHERE ";
String GROUP_BY = " GROUP BY "; public static final String GROUP_BY = " GROUP BY ";
String ORDER_BY = " ORDER BY "; public static final String ORDER_BY = " ORDER BY ";
String INNER_JOIN = " JOIN "; public static final String INNER_JOIN = " JOIN ";
String LEFT_JOIN = " LEFT JOIN "; public static final String LEFT_JOIN = " LEFT JOIN ";
String UNION = " UNION "; public static final String UNION = " UNION ";
String AND = " AND "; public static final String AND = " AND ";
String OR = " OR "; public static final String OR = " OR ";
String IS_NULL = " IS NULL"; public static final String IS_NULL = " IS NULL";
String IS_NOT_NULL = " IS NOT NULL"; public static final String IS_NOT_NULL = " IS NOT NULL";
static String varchar(int length) { public static String varchar(int length) {
return "varchar(" + length + ')'; return "varchar(" + length + ')';
} }
@ -57,22 +57,22 @@ public interface Sql {
* @param day 1 = Sunday, 2 = Monday etc.. 7 = Saturday * @param day 1 = Sunday, 2 = Monday etc.. 7 = Saturday
* @return Milliseconds since epoch for this day to be given by {@link java.text.SimpleDateFormat} "EEEE" * @return Milliseconds since epoch for this day to be given by {@link java.text.SimpleDateFormat} "EEEE"
*/ */
static long getDayEpochMs(int day) { public static long getDayEpochMs(int day) {
return TimeUnit.DAYS.toMillis(day + 2); return TimeUnit.DAYS.toMillis(day + 2L);
} }
String epochSecondToDate(String sql); public abstract String epochSecondToDate(String sql);
String dateToEpochSecond(String sql); public abstract String dateToEpochSecond(String sql);
String dateToDayStamp(String sql); public abstract String dateToDayStamp(String sql);
String dateToDayOfWeek(String sql); public abstract String dateToDayOfWeek(String sql);
String dateToHour(String sql); public abstract String dateToHour(String sql);
// https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html // https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html
class MySQL implements Sql { public static class MySQL extends Sql {
@Override @Override
public String epochSecondToDate(String sql) { public String epochSecondToDate(String sql) {
@ -101,7 +101,7 @@ public interface Sql {
} }
// https://h2database.com/html/functions.html // https://h2database.com/html/functions.html
class H2 extends MySQL { public static class H2 extends MySQL {
@Override @Override
public String epochSecondToDate(String sql) { public String epochSecondToDate(String sql) {
@ -125,7 +125,7 @@ public interface Sql {
} }
// https://sqlite.org/lang_datefunc.html // https://sqlite.org/lang_datefunc.html
class SQLite implements Sql { public static class SQLite extends Sql {
@Override @Override
public String epochSecondToDate(String sql) { public String epochSecondToDate(String sql) {

View File

@ -1,35 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.utilities.comparators;
import com.djrapitops.plan.data.plugin.PluginData;
import java.util.Comparator;
/**
* Comparator for PluginData for Alphabetical Name order.
*
* @author Rsl1122
*/
@Deprecated
public class PluginDataNameComparator implements Comparator<PluginData> {
@Override
public int compare(PluginData u1, PluginData u2) {
return u1.getSourcePlugin().compareTo(u2.getSourcePlugin());
}
}

View File

@ -21,7 +21,6 @@ import com.djrapitops.plan.PlanSystem;
import com.djrapitops.plan.commands.PlanCommand; import com.djrapitops.plan.commands.PlanCommand;
import com.djrapitops.plan.modules.APFModule; import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule; import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ServerSuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule; import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import dagger.BindsInstance; import dagger.BindsInstance;
import dagger.Component; import dagger.Component;
@ -40,7 +39,6 @@ import javax.inject.Singleton;
APFModule.class, APFModule.class,
FilesModule.class, FilesModule.class,
PluginServerPropertiesModule.class, PluginServerPropertiesModule.class,
ServerSuperClassBindingModule.class,
PluginSuperClassBindingModule.class PluginSuperClassBindingModule.class
}) })
public interface PlanPluginComponent { public interface PlanPluginComponent {

View File

@ -105,7 +105,7 @@ public class ExtensionRegister {
) { ) {
try { try {
// Creates the extension with factory and registers it // Creates the extension with factory and registers it
createExtension.apply(factory).flatMap(this::register); createExtension.apply(factory).ifPresent(this::register);
} catch (NotReadyException ignore) { } catch (NotReadyException ignore) {
// This exception signals that the extension can not be registered right now (Intended fail). // This exception signals that the extension can not be registered right now (Intended fail).
} catch (Exception | NoClassDefFoundError | IncompatibleClassChangeError e) { } catch (Exception | NoClassDefFoundError | IncompatibleClassChangeError e) {

View File

@ -20,7 +20,6 @@ import com.djrapitops.plan.commands.PlanCommand;
import com.djrapitops.plan.gathering.ServerShutdownSave; import com.djrapitops.plan.gathering.ServerShutdownSave;
import com.djrapitops.plan.modules.APFModule; import com.djrapitops.plan.modules.APFModule;
import com.djrapitops.plan.modules.FilesModule; import com.djrapitops.plan.modules.FilesModule;
import com.djrapitops.plan.modules.ServerSuperClassBindingModule;
import com.djrapitops.plan.modules.SystemObjectProvidingModule; import com.djrapitops.plan.modules.SystemObjectProvidingModule;
import com.djrapitops.plan.modules.sponge.SpongePlanModule; import com.djrapitops.plan.modules.sponge.SpongePlanModule;
import com.djrapitops.plan.modules.sponge.SpongeServerPropertiesModule; import com.djrapitops.plan.modules.sponge.SpongeServerPropertiesModule;
@ -41,7 +40,6 @@ import javax.inject.Singleton;
SystemObjectProvidingModule.class, SystemObjectProvidingModule.class,
APFModule.class, APFModule.class,
FilesModule.class, FilesModule.class,
ServerSuperClassBindingModule.class,
SpongeSuperClassBindingModule.class, SpongeSuperClassBindingModule.class,
SpongeServerPropertiesModule.class SpongeServerPropertiesModule.class
}) })