diff --git a/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java b/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java index bf5bb0000..39ea9cf88 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/capability/CapabilityService.java @@ -65,8 +65,12 @@ public interface CapabilityService { } class ListHolder { - volatile static AtomicReference>> ENABLE_LISTENERS = new AtomicReference<>( + static volatile AtomicReference>> ENABLE_LISTENERS = new AtomicReference<>( new CopyOnWriteArrayList<>() ); + + private ListHolder() { + // Hide constructor + } } } diff --git a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java index 04b5d7204..848148f39 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResolverService.java @@ -89,7 +89,7 @@ public interface ResolverService { List getResolvers(String target); class Holder { - volatile static AtomicReference service = new AtomicReference<>(); + static volatile AtomicReference service = new AtomicReference<>(); private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java index bce55088d..48f38e06d 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/delivery/web/ResourceService.java @@ -103,7 +103,7 @@ public interface ResourceService { } class Holder { - volatile static AtomicReference service = new AtomicReference<>(); + static volatile AtomicReference service = new AtomicReference<>(); private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java b/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java index 53eb927e5..5c4290cab 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/extension/ExtensionService.java @@ -71,7 +71,7 @@ public interface ExtensionService { void unregister(DataExtension extension); class Holder { - volatile static AtomicReference service = new AtomicReference<>(); + static volatile AtomicReference service = new AtomicReference<>(); private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/extension/extractor/ExtensionExtractor.java b/Plan/api/src/main/java/com/djrapitops/plan/extension/extractor/ExtensionExtractor.java index a501ab834..664a57877 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/extension/extractor/ExtensionExtractor.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/extension/extractor/ExtensionExtractor.java @@ -172,7 +172,7 @@ public final class ExtensionExtractor { Class methodParameter = parameterTypes[0]; boolean validParameter = false; - for (Class option : parameterOptions) { + for (Class option : parameterOptions) { if (option.equals(methodParameter)) { validParameter = true; break; diff --git a/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java b/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java index ca9227381..b61b4ffe8 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/query/QueryService.java @@ -150,7 +150,7 @@ public interface QueryService { } class Holder { - volatile static AtomicReference service = new AtomicReference<>(); + static volatile AtomicReference service = new AtomicReference<>(); private Holder() { /* Static variable holder */ diff --git a/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java b/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java index 5e10f8fe4..49cd6bfbb 100644 --- a/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java +++ b/Plan/api/src/main/java/com/djrapitops/plan/settings/SettingsService.java @@ -66,7 +66,7 @@ public interface SettingsService { List getStringList(String path, Supplier> defaultValue); class Holder { - volatile static AtomicReference service = new AtomicReference<>(); + static volatile AtomicReference service = new AtomicReference<>(); private Holder() { /* Static variable holder */ diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/BukkitListenerSystem.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/BukkitListenerSystem.java index d406ec27f..71c706346 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/BukkitListenerSystem.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/BukkitListenerSystem.java @@ -39,14 +39,15 @@ public class BukkitListenerSystem extends ListenerSystem { private final BukkitAFKListener afkListener; @Inject - public BukkitListenerSystem(Plan plugin, - Status status, - PlayerOnlineListener playerOnlineListener, - ChatListener chatListener, - GameModeChangeListener gamemodeChangeListener, - WorldChangeListener worldChangeListener, - DeathEventListener deathEventListener, - BukkitAFKListener afkListener + public BukkitListenerSystem( + Plan plugin, + Status status, + PlayerOnlineListener playerOnlineListener, + ChatListener chatListener, + GameModeChangeListener gamemodeChangeListener, + WorldChangeListener worldChangeListener, + DeathEventListener deathEventListener, + BukkitAFKListener afkListener ) { this.plugin = plugin; this.status = status; diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/DeathEventListener.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/DeathEventListener.java index d1b886e01..01fa49d7f 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/DeathEventListener.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/gathering/listeners/bukkit/DeathEventListener.java @@ -58,7 +58,6 @@ public class DeathEventListener implements Listener { this.errorLogger = errorLogger; } - @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.MONITOR) public void onDeath(EntityDeathEvent event) { long time = System.currentTimeMillis(); diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/storage/database/BukkitDBSystem.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/storage/database/BukkitDBSystem.java index e4d1d711e..bc5e1be4d 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/storage/database/BukkitDBSystem.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/storage/database/BukkitDBSystem.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.storage.database; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.paths.DatabaseSettings; import com.djrapitops.plan.settings.locale.Locale; @@ -53,7 +52,7 @@ public class BukkitDBSystem extends DBSystem { } @Override - public void enable() throws EnableException { + public void enable() { String dbType = config.get(DatabaseSettings.TYPE).toLowerCase().trim(); db = getActiveDatabaseByName(dbType); super.enable(); diff --git a/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java b/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java index 5e3f8fe43..27e0f7d18 100644 --- a/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java +++ b/Plan/bukkit/src/test/java/com/djrapitops/plan/BukkitSystemTest.java @@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * * @author Rsl1122 */ -public class BukkitSystemTest { +class BukkitSystemTest { private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500); private PlanSystem system; diff --git a/Plan/bukkit/src/test/java/com/djrapitops/plan/gathering/listeners/BukkitAFKListenerTest.java b/Plan/bukkit/src/test/java/com/djrapitops/plan/gathering/listeners/BukkitAFKListenerTest.java index d89e41878..3e1b5e252 100644 --- a/Plan/bukkit/src/test/java/com/djrapitops/plan/gathering/listeners/BukkitAFKListenerTest.java +++ b/Plan/bukkit/src/test/java/com/djrapitops/plan/gathering/listeners/BukkitAFKListenerTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.*; * @author Rsl1122 */ @ExtendWith(MockitoExtension.class) -public class BukkitAFKListenerTest { +class BukkitAFKListenerTest { private static BukkitAFKListener underTest; private static ErrorLogger errorLogger; diff --git a/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeeCommand.java b/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeeCommand.java index fa3cb9c20..c79f2289e 100644 --- a/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeeCommand.java +++ b/Plan/bungeecord/src/main/java/com/djrapitops/plan/command/use/BungeeCommand.java @@ -31,6 +31,7 @@ import net.md_5.bungee.api.plugin.TabExecutor; import java.util.Arrays; import java.util.Collections; +import java.util.Objects; public class BungeeCommand extends Command implements TabExecutor { @@ -88,4 +89,20 @@ public class BungeeCommand extends Command implements TabExecutor { return Collections.emptyList(); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + BungeeCommand that = (BungeeCommand) o; + return Objects.equals(runnableFactory, that.runnableFactory) && + Objects.equals(errorLogger, that.errorLogger) && + Objects.equals(command, that.command); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), runnableFactory, errorLogger, command); + } } diff --git a/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java b/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java index 91b5c3ffa..3f54dcff9 100644 --- a/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java +++ b/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java @@ -40,7 +40,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; * * @author Rsl1122 */ -public class BungeeSystemTest { +class BungeeSystemTest { private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java index 74969fb30..0bac77e75 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/PlanSystem.java @@ -23,7 +23,6 @@ import com.djrapitops.plan.delivery.web.ResolverSvc; import com.djrapitops.plan.delivery.web.ResourceSvc; import com.djrapitops.plan.delivery.webserver.NonProxyWebserverDisableChecker; import com.djrapitops.plan.delivery.webserver.WebServerSystem; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.extension.ExtensionService; import com.djrapitops.plan.extension.ExtensionSvc; import com.djrapitops.plan.gathering.cache.CacheSystem; @@ -150,7 +149,7 @@ public class PlanSystem implements SubSystem { } @Override - public void enable() throws EnableException { + public void enable() { extensionService.register(); resolverService.register(); resourceService.register(); @@ -184,7 +183,7 @@ public class PlanSystem implements SubSystem { enabled = true; } - private void enableSystems(SubSystem... systems) throws EnableException { + private void enableSystems(SubSystem... systems) { for (SubSystem system : systems) { logger.debug("Enabling: " + system.getClass().getSimpleName()); timings.start("subsystem-enable"); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/TaskSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/TaskSystem.java index 39e23e836..cf062df15 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/TaskSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/TaskSystem.java @@ -31,7 +31,7 @@ public abstract class TaskSystem implements SubSystem { protected final RunnableFactory runnableFactory; - public TaskSystem(RunnableFactory runnableFactory) { + protected TaskSystem(RunnableFactory runnableFactory) { this.runnableFactory = runnableFactory; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/capability/CapabilitySvc.java b/Plan/common/src/main/java/com/djrapitops/plan/capability/CapabilitySvc.java index acb19bb65..655156b4c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/capability/CapabilitySvc.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/capability/CapabilitySvc.java @@ -27,6 +27,15 @@ import java.util.function.Consumer; */ public class CapabilitySvc implements CapabilityService { + private CapabilitySvc() { + // Hide constructor + } + + /** + * Implementation detail. + * + * @param isEnabled Did the plugin enable properly. + */ public static void notifyAboutEnable(boolean isEnabled) { for (Consumer enableListener : CapabilityService.ListHolder.ENABLE_LISTENERS.get()) { enableListener.accept(isEnabled); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/PlanCommand.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/PlanCommand.java index 1e2609b9c..d4ce6d57e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/PlanCommand.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/PlanCommand.java @@ -26,9 +26,7 @@ import com.djrapitops.plan.settings.Permissions; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.lang.DeepHelpLang; import com.djrapitops.plan.settings.locale.lang.HelpLang; -import com.djrapitops.plan.storage.database.DBSystem; import com.djrapitops.plan.storage.database.DBType; -import com.djrapitops.plan.storage.file.PlanFiles; import com.djrapitops.plan.utilities.logging.ErrorContext; import com.djrapitops.plan.utilities.logging.ErrorLogger; import com.djrapitops.plugin.command.ColorScheme; @@ -56,22 +54,18 @@ public class PlanCommand { private final DatabaseCommands databaseCommands; private final DataUtilityCommands dataUtilityCommands; - private final PlanFiles files; private final Locale locale; private final ImportSystem importSystem; - private final DBSystem dbSystem; private final ErrorLogger errorLogger; @Inject public PlanCommand( @Named("mainCommandName") String commandName, - PlanFiles files, Locale locale, ColorScheme colors, Confirmation confirmation, TabCompleteCache tabCompleteCache, ImportSystem importSystem, - DBSystem dbSystem, LinkCommands linkCommands, RegistrationCommands registrationCommands, PluginStatusCommands statusCommands, @@ -80,13 +74,11 @@ public class PlanCommand { ErrorLogger errorLogger ) { this.commandName = commandName; - this.files = files; this.locale = locale; this.colors = colors; this.confirmation = confirmation; this.tabCompleteCache = tabCompleteCache; this.importSystem = importSystem; - this.dbSystem = dbSystem; this.linkCommands = linkCommands; this.registrationCommands = registrationCommands; this.statusCommands = statusCommands; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/Confirmation.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/Confirmation.java index abe99880d..a1e080072 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/Confirmation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/Confirmation.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.commands.subcommands; -import com.djrapitops.plan.commands.use.Arguments; import com.djrapitops.plan.commands.use.CMDSender; import com.djrapitops.plan.settings.locale.Locale; import com.djrapitops.plan.settings.locale.lang.CommandLang; @@ -75,11 +74,11 @@ public class Confirmation { } } - public void onAcceptCommand(CMDSender sender, Arguments arguments) { + public void onAcceptCommand(CMDSender sender) { onConfirm(sender); } - public void onCancelCommand(CMDSender sender, Arguments arguments) { + public void onCancelCommand(CMDSender sender) { onCancel(sender); } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java index 7d1468e1e..5e13e13f9 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/DatabaseCommands.java @@ -49,7 +49,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import java.io.File; import java.io.IOException; -import java.util.Collections; import java.util.UUID; import java.util.concurrent.ExecutionException; @@ -185,7 +184,7 @@ public class DatabaseCommands { } confirmation.confirm(sender, choice -> { - if (choice) { + if (Boolean.TRUE.equals(choice)) { performRestore(sender, backupDBFile, toDB); } else { sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); @@ -238,7 +237,7 @@ public class DatabaseCommands { } confirmation.confirm(sender, choice -> { - if (choice) { + if (Boolean.TRUE.equals(choice)) { performMove(sender, fromDB, toDB); } else { sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); @@ -294,7 +293,7 @@ public class DatabaseCommands { } confirmation.confirm(sender, choice -> { - if (choice) { + if (Boolean.TRUE.equals(choice)) { performClear(sender, fromDB); } else { sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); @@ -316,7 +315,7 @@ public class DatabaseCommands { // Reload plugin to register the server into the database // Otherwise errors will start. - statusCommands.onReload(sender, new Arguments(Collections.emptyList())); + statusCommands.onReload(sender); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (DBOpException | ExecutionException e) { @@ -352,7 +351,7 @@ public class DatabaseCommands { } confirmation.confirm(sender, choice -> { - if (choice) { + if (Boolean.TRUE.equals(choice)) { performRemoval(sender, database, playerUUID); } else { sender.send(colors.getMainColor() + locale.getString(CommandLang.CONFIRM_CANCELLED_DATA)); @@ -420,6 +419,6 @@ public class DatabaseCommands { sender.send(locale.getString(CommandLang.PROGRESS_FAIL, e.getMessage())); return; } - statusCommands.onReload(sender, new Arguments(Collections.emptyList())); + statusCommands.onReload(sender); } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/PluginStatusCommands.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/PluginStatusCommands.java index 3980ae8ff..cc4098417 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/PluginStatusCommands.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/PluginStatusCommands.java @@ -62,7 +62,7 @@ public class PluginStatusCommands { this.errorLogger = errorLogger; } - public void onReload(CMDSender sender, Arguments arguments) { + public void onReload(CMDSender sender) { new Thread(() -> { try { plugin.reloadPlugin(true); @@ -92,7 +92,7 @@ public class PluginStatusCommands { } } - public void onInfo(CMDSender sender, Arguments arguments) { + public void onInfo(CMDSender sender) { String yes = locale.getString(GenericLang.YES); String no = locale.getString(GenericLang.NO); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java index 2aee67087..cce03f8d9 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/subcommands/RegistrationCommands.java @@ -212,7 +212,7 @@ public class RegistrationCommands { } confirmation.confirm(sender, choice -> { - if (choice) { + if (Boolean.TRUE.equals(choice)) { try { sender.send(colors.getMainColor() + locale.getString(CommandLang.UNREGISTER, presentUser.getUsername())); database.executeTransaction(new RemoveWebUserTransaction(username)) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/use/CommandWithSubcommands.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/use/CommandWithSubcommands.java index 200599a03..9cd9658de 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/use/CommandWithSubcommands.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/use/CommandWithSubcommands.java @@ -63,7 +63,7 @@ public class CommandWithSubcommands extends Subcommand { .send(); } - public void onInDepthHelp(CMDSender sender, Arguments arguments) { + public void onInDepthHelp(CMDSender sender) { List hasPermissionFor = getPermittedSubcommands(sender); sender.buildMessage() .addPart(locale.getString(CommandLang.HEADER_HELP, getPrimaryAlias())) @@ -95,7 +95,7 @@ public class CommandWithSubcommands extends Subcommand { onHelp(sender, arguments); return; } else if ("?".equals(alias)) { - onInDepthHelp(sender, arguments); + onInDepthHelp(sender); return; } else { for (Subcommand subcommand : subcommands) { @@ -193,9 +193,10 @@ public class CommandWithSubcommands extends Subcommand { return this; } + @Override public CommandWithSubcommands build() { - onCommand(command::onCommand); - onTabComplete(command::onTabComplete); + super.onCommand(command::onCommand); + super.onTabComplete(command::onTabComplete); super.build(); if (command.fallback == null) fallback(command::onHelp); if (command.exceptionHandler == null) exceptionHandler((error, sender, arguments) -> {throw error;}); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/use/Subcommand.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/use/Subcommand.java index 2b411dd8b..2fb86c2be 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/use/Subcommand.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/use/Subcommand.java @@ -71,7 +71,7 @@ public class Subcommand { } public BiFunction> getArgumentResolver() { - return argumentResolver != null ? argumentResolver : ((sender, arguments) -> Collections.emptyList()); + return argumentResolver != null ? argumentResolver : ((sender, args) -> Collections.emptyList()); } public String getArgumentsAsString() { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/commands/use/SubcommandBuilder.java b/Plan/common/src/main/java/com/djrapitops/plan/commands/use/SubcommandBuilder.java index 334af2354..7388e1978 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/commands/use/SubcommandBuilder.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/commands/use/SubcommandBuilder.java @@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.function.BiConsumer; import java.util.function.BiFunction; +import java.util.function.Consumer; public interface SubcommandBuilder { @@ -49,6 +50,10 @@ public interface SubcommandBuilder { SubcommandBuilder onCommand(BiConsumer executor); + default SubcommandBuilder onCommand(Consumer executor) { + return onCommand((sender, arguments) -> executor.accept(sender)); + } + SubcommandBuilder onTabComplete(BiFunction> resolver); Subcommand build(); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/container/SupplierDataContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/container/SupplierDataContainer.java index 4128c6aab..14dc749c2 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/container/SupplierDataContainer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/container/SupplierDataContainer.java @@ -75,7 +75,7 @@ public class SupplierDataContainer implements DataContainer { } private Supplier getSupplier(Key key) { - return (Supplier) map.get(key); + return map.get(key); } @Override diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/keys/Type.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/keys/Type.java index db3c17d49..40d050f2e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/keys/Type.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/keys/Type.java @@ -29,7 +29,7 @@ public abstract class Type { private final String genericsSuperClass; - public Type() { + protected Type() { genericsSuperClass = getGenericsClass().getGenericSuperclass().getTypeName(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java index 3457f8d61..8fbbb3652 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ExportScheduler.java @@ -24,7 +24,6 @@ import com.djrapitops.plan.storage.database.DBSystem; import com.djrapitops.plan.storage.database.queries.objects.ServerQueries; import com.djrapitops.plan.utilities.logging.ErrorLogger; import com.djrapitops.plugin.api.TimeAmount; -import com.djrapitops.plugin.logging.console.PluginLogger; import javax.inject.Inject; import javax.inject.Singleton; @@ -45,7 +44,6 @@ public class ExportScheduler { private final TaskSystem taskSystem; private final Exporter exporter; - private final PluginLogger logger; private final ErrorLogger errorLogger; @Inject @@ -54,14 +52,12 @@ public class ExportScheduler { DBSystem dbSystem, TaskSystem taskSystem, Exporter exporter, - PluginLogger logger, ErrorLogger errorLogger ) { this.config = config; this.dbSystem = dbSystem; this.taskSystem = taskSystem; this.exporter = exporter; - this.logger = logger; this.errorLogger = errorLogger; } @@ -89,7 +85,7 @@ public class ExportScheduler { Optional proxy = servers.stream().filter(Server::isProxy).findFirst(); proxy.ifPresent(mainServer -> taskSystem.registerTask("Network export", - new ExportTask(exporter, exporter -> exporter.exportServerPage(mainServer), errorLogger)) + new ExportTask(exporter, same -> same.exportServerPage(mainServer), errorLogger)) .runTaskTimerAsynchronously(0L, period) ); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerJSONExporter.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerJSONExporter.java index 990da7473..eddca9e3b 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerJSONExporter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerJSONExporter.java @@ -50,7 +50,9 @@ public class PlayerJSONExporter extends FileExporter { public void export(Path toDirectory, UUID playerUUID, String playerName) throws IOException { Database.State dbState = dbSystem.getDatabase().getState(); if (dbState == Database.State.CLOSED || dbState == Database.State.CLOSING) return; - if (!dbSystem.getDatabase().query(PlayerFetchQueries.isPlayerRegistered(playerUUID))) return; + if (Boolean.FALSE.equals(dbSystem.getDatabase().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)))) { + return; + } Path to = toDirectory.resolve("player/" + toFileName(playerName) + ".json"); exportJSON(to, playerUUID); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerPageExporter.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerPageExporter.java index c4f117480..12b2051e0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerPageExporter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/PlayerPageExporter.java @@ -82,7 +82,9 @@ public class PlayerPageExporter extends FileExporter { public void export(Path toDirectory, UUID playerUUID, String playerName) throws IOException { Database.State dbState = dbSystem.getDatabase().getState(); if (dbState == Database.State.CLOSED || dbState == Database.State.CLOSING) return; - if (!dbSystem.getDatabase().query(PlayerFetchQueries.isPlayerRegistered(playerUUID))) return; + if (Boolean.FALSE.equals(dbSystem.getDatabase().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)))) { + return; + } ExportPaths exportPaths = new ExportPaths(); exportPaths.put("../network", toRelativePathFromRoot("network")); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/formatting/time/DateFormatter.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/formatting/time/DateFormatter.java index 6d02082b7..9a546e024 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/formatting/time/DateFormatter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/formatting/time/DateFormatter.java @@ -37,14 +37,11 @@ public abstract class DateFormatter implements Formatter { protected final PlanConfig config; protected final Locale locale; - public DateFormatter(PlanConfig config, Locale locale) { + protected DateFormatter(PlanConfig config, Locale locale) { this.config = config; this.locale = locale; } - @Override - public abstract String apply(Long value); - protected String format(long epochMs, String format) { String localeSetting = config.get(PluginSettings.LOCALE); java.util.Locale usedLocale = "default".equalsIgnoreCase(localeSetting) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java index 6ef6abe1e..50fd534b2 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/html/Contributors.java @@ -16,6 +16,9 @@ */ package com.djrapitops.plan.delivery.rendering.html; +import java.util.Arrays; +import java.util.Objects; + import static com.djrapitops.plan.delivery.rendering.html.Contributors.For.CODE; import static com.djrapitops.plan.delivery.rendering.html.Contributors.For.LANG; @@ -111,6 +114,22 @@ public class Contributors { html.append(""); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Contributor that = (Contributor) o; + return name.equals(that.name) && + Arrays.equals(contributed, that.contributed); + } + + @Override + public int hashCode() { + int result = Objects.hash(name); + result = 31 * result + Arrays.hashCode(contributed); + return result; + } + @Override public int compareTo(Contributor o) { return String.CASE_INSENSITIVE_ORDER.compare(this.name, o.name); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/JSONFactory.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/JSONFactory.java index 9c99df557..65fb62125 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/JSONFactory.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/JSONFactory.java @@ -209,10 +209,8 @@ public class JSONFactory { server.put("downtime", timeAmount.apply(tpsWeek.serverDownTime())); Optional online = tpsWeek.getLast(); - server.put("online", online.isPresent() ? - online.get().getDate() >= now - TimeUnit.MINUTES.toMillis(3L) ? - online.get().getPlayers() : "Possibly offline" - : locale.get(HtmlLang.UNIT_NO_DATA).toString()); + server.put("online", online.map(point -> point.getDate() >= now - TimeUnit.MINUTES.toMillis(3L) ? point.getPlayers() : "Possibly offline") + .orElse(locale.get(HtmlLang.UNIT_NO_DATA).toString())); servers.add(server); }); return servers; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PlayerJSONCreator.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PlayerJSONCreator.java index 7a6deae4d..37b51d524 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PlayerJSONCreator.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/PlayerJSONCreator.java @@ -268,9 +268,9 @@ public class PlayerJSONCreator { } public static class Nickname { - private final String nickname; - private final String server; - private final String date; + final String nickname; + final String server; + final String date; public Nickname(String nickname, String server, String date) { this.nickname = nickname; @@ -297,8 +297,8 @@ public class PlayerJSONCreator { } public static class ConnectionInfo { - private final String geolocation; - private final String date; + final String geolocation; + final String date; public ConnectionInfo(String geolocation, String date) { this.geolocation = geolocation; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/ServerAccordion.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/ServerAccordion.java index ca8b22bdb..cd03741c0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/ServerAccordion.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/ServerAccordion.java @@ -66,18 +66,18 @@ public class ServerAccordion { for (Map.Entry entry : perServer.entrySet()) { UUID serverUUID = entry.getKey(); - DataContainer perServer = entry.getValue(); + DataContainer ofServer = entry.getValue(); Map server = new HashMap<>(); String serverName = serverNames.getOrDefault(serverUUID, unknown); - WorldTimes worldTimes = perServer.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes()); - SessionsMutator sessionsMutator = SessionsMutator.forContainer(perServer); + WorldTimes worldTimes = ofServer.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes()); + SessionsMutator sessionsMutator = SessionsMutator.forContainer(ofServer); server.put("server_name", serverName); - server.put("banned", perServer.getValue(PerServerKeys.BANNED).orElse(false)); - server.put("operator", perServer.getValue(PerServerKeys.OPERATOR).orElse(false)); - server.put("registered", year.apply(perServer.getValue(PerServerKeys.REGISTERED).orElse(0L))); + server.put("banned", ofServer.getValue(PerServerKeys.BANNED).orElse(false)); + server.put("operator", ofServer.getValue(PerServerKeys.OPERATOR).orElse(false)); + server.put("registered", year.apply(ofServer.getValue(PerServerKeys.REGISTERED).orElse(0L))); server.put("last_seen", year.apply(sessionsMutator.toLastSeen())); server.put("session_count", sessionsMutator.count()); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieWithDrilldown.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieWithDrilldown.java index 9467b5e15..eb1adf6d0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieWithDrilldown.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/pie/PieWithDrilldown.java @@ -25,7 +25,7 @@ import java.util.List; */ public abstract class PieWithDrilldown extends Pie { - public PieWithDrilldown(List slices) { + protected PieWithDrilldown(List slices) { super(slices); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/special/WorldMap.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/special/WorldMap.java index 97d128247..9fbd57be7 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/special/WorldMap.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/graphs/special/WorldMap.java @@ -58,7 +58,7 @@ public class WorldMap { private Map toGeoCodeCounts(Map geolocationCounts) { Map geoCodes = getGeoCodes(); - Map geoCodeCounts = new HashMap<>(); + Map codeCounts = new HashMap<>(); for (Map.Entry entry : geolocationCounts.entrySet()) { String geolocation = entry.getKey().toLowerCase(); @@ -67,10 +67,10 @@ public class WorldMap { continue; } - geoCodeCounts.put(geoCode, entry.getValue()); + codeCounts.put(geoCode, entry.getValue()); } - return geoCodeCounts; + return codeCounts; } private Map toGeoCodeCounts(List geoLocations) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/RequestHandler.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/RequestHandler.java index f01d51915..e63a38b0e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/RequestHandler.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/RequestHandler.java @@ -116,7 +116,7 @@ public class RequestHandler implements HttpHandler { public Response getResponse(HttpExchange exchange) { if (ipWhitelist == null) { - ipWhitelist = config.get(WebserverSettings.IP_WHITELIST) + ipWhitelist = config.isTrue(WebserverSettings.IP_WHITELIST) ? config.get(WebserverSettings.WHITELIST) : Collections.emptyList(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServer.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServer.java index 75087a5bc..a9017a45f 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/WebServer.java @@ -105,7 +105,7 @@ public class WebServer implements SubSystem { } else { logger.error(locale.getString(PluginLang.WEB_SERVER_FAIL_PORT_BIND, port)); } - } else if (config.get(WebserverSettings.IP_WHITELIST)) { + } else if (config.isTrue(WebserverSettings.IP_WHITELIST)) { logger.info(locale.getString(PluginLang.WEB_SERVER_NOTIFY_IP_WHITELIST)); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStore.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStore.java index 8fc84ddfc..51cac70d0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStore.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStore.java @@ -32,6 +32,10 @@ public class ActiveCookieStore { .expireAfterWrite(2, TimeUnit.HOURS) .build(); + private ActiveCookieStore() { + // Hide static cache constructor + } + public static Optional checkCookie(String cookie) { return Optional.ofNullable(USERS_BY_COOKIE.getIfPresent(cookie)); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/RegistrationBin.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/RegistrationBin.java index d24390e16..fe0f316de 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/RegistrationBin.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/auth/RegistrationBin.java @@ -38,6 +38,10 @@ public class RegistrationBin { .expireAfterAccess(15, TimeUnit.MINUTES) .build(); + private RegistrationBin() { + // Hide static cache constructor + } + public static String addInfoForRegistration(String username, String password) { String hash = PassEncryptUtil.createHash(password); String code = DigestUtils.sha256Hex(username + password + System.currentTimeMillis()).substring(0, 12); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/exceptions/database/DBOpException.java b/Plan/common/src/main/java/com/djrapitops/plan/exceptions/database/DBOpException.java index addbced84..2f4870fe4 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/exceptions/database/DBOpException.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/exceptions/database/DBOpException.java @@ -29,14 +29,15 @@ import java.util.Optional; */ public class DBOpException extends IllegalStateException implements ExceptionWithContext { - private ErrorContext context; + private final ErrorContext context; public DBOpException(String message) { super(message); + this.context = null; } public DBOpException(String message, Throwable cause) { - super(message, cause); + this(message, cause, null); } public DBOpException(String message, Throwable cause, ErrorContext context) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/Parameters.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/Parameters.java index 009c302cc..177b001c9 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/Parameters.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/Parameters.java @@ -84,6 +84,7 @@ public interface Parameters { return serverUUID; } + @Override public UUID getPlayerUUID() { return playerUUID; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/BooleanProviderValueGatherer.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/BooleanProviderValueGatherer.java index 0f555592c..7dfe7203c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/BooleanProviderValueGatherer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/providers/gathering/BooleanProviderValueGatherer.java @@ -132,7 +132,7 @@ class BooleanProviderValueGatherer { } if (providedCondition != null) { - if (result) { + if (Boolean.TRUE.equals(result)) { // The condition was fulfilled (true) for this player. conditions.conditionFulfilled(providedCondition); } else { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StoreIconTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StoreIconTransaction.java index 97360393a..d4f424a43 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StoreIconTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/storage/transactions/StoreIconTransaction.java @@ -44,7 +44,7 @@ public class StoreIconTransaction extends ThrowawayTransaction { @Override protected void performOperations() { - if (!query(isIconStored())) { + if (Boolean.FALSE.equals(query(isIconStored()))) { execute(insertIcon()); } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/ServerShutdownSave.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/ServerShutdownSave.java index e7a0ac3f9..ca2f0a446 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/ServerShutdownSave.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/ServerShutdownSave.java @@ -50,7 +50,7 @@ public abstract class ServerShutdownSave { private boolean shuttingDown = false; private boolean startedDatabase = false; - public ServerShutdownSave( + protected ServerShutdownSave( Locale locale, DBSystem dbSystem, PluginLogger logger, diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/TimeKeeper.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/TimeKeeper.java index 9e9f4ff60..69007de7a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/TimeKeeper.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/domain/TimeKeeper.java @@ -23,11 +23,11 @@ import java.util.Map; import java.util.Objects; /** - * Abstract class for keeping track of time spent in each state. + * Keeps track of time spent in each state. * * @author Rsl1122 */ -public abstract class TimeKeeper { +public class TimeKeeper { protected Map times; protected String state; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/ImportSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/ImportSystem.java index 03b3389ee..56403e50e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/ImportSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/importing/ImportSystem.java @@ -24,6 +24,8 @@ import java.util.*; /** * Abstract representation of an ImportSystem. + *

+ * TODO it is possible to remove the abstract part of this class by binding Importers to a Map with Dagger * * @author Rsl1122 */ @@ -31,7 +33,7 @@ public abstract class ImportSystem implements SubSystem { protected final Map importers; - public ImportSystem() { + protected ImportSystem() { importers = new HashMap<>(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/SystemUsageBuffer.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/SystemUsageBuffer.java index 848860519..0454600a8 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/SystemUsageBuffer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/SystemUsageBuffer.java @@ -107,7 +107,7 @@ public class SystemUsageBuffer { @Override public void run() { if (gatherDisk == null) gatherDisk = config.get(DataGatheringSettings.DISK_SPACE); - if (!gatherDisk) return; + if (Boolean.FALSE.equals(gatherDisk)) return; try { buffer.freeDiskSpace = SystemUsage.getFreeDiskSpace(); } catch (SecurityException noPermission) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/TPSCounter.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/TPSCounter.java index fa70c093f..068e35a8d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/TPSCounter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/timed/TPSCounter.java @@ -32,7 +32,7 @@ public abstract class TPSCounter extends AbsRunnable { protected final PluginLogger logger; protected final ErrorLogger errorLogger; - public TPSCounter( + protected TPSCounter( PluginLogger logger, ErrorLogger errorLogger ) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerInfo.java b/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerInfo.java index 842fef367..156970b56 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerInfo.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerInfo.java @@ -35,7 +35,7 @@ public abstract class ServerInfo implements SubSystem { protected Server server; protected final ServerProperties serverProperties; - public ServerInfo(ServerProperties serverProperties) { + protected ServerInfo(ServerProperties serverProperties) { this.serverProperties = serverProperties; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java b/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java index 2a0ecfbae..6a31a379f 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/identification/ServerServerInfo.java @@ -66,12 +66,7 @@ public class ServerServerInfo extends ServerInfo { } @Override - public void enable() throws EnableException { - super.enable(); - } - - @Override - protected void loadServerInfo() throws EnableException { + protected void loadServerInfo() { Optional loaded = fromFile.load(null); server = loaded.orElseGet(this::registerNew); processing.submitNonCritical(this::updateStorage); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerDBLoader.java b/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerDBLoader.java index 5cff4af73..fbc72b0c3 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerDBLoader.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerDBLoader.java @@ -62,7 +62,7 @@ public class ServerDBLoader implements ServerLoader { try { dbSystem.getDatabase().executeTransaction( new StoreServerInformationTransaction(server) - ).get(); // Wait until transaction has completed; + ).get(); // Wait until transaction has completed } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java b/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java index 658a607b2..c668b4b30 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/identification/storage/ServerFileLoader.java @@ -27,6 +27,7 @@ import com.djrapitops.plan.storage.file.PlanFiles; import javax.inject.Inject; import javax.inject.Singleton; import java.io.IOException; +import java.util.Objects; import java.util.Optional; import java.util.UUID; @@ -91,4 +92,19 @@ public class ServerFileLoader extends Config implements ServerLoader { throw new EnableException("Failed to write ServerInfoFile.yml: " + e.getMessage()); } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + ServerFileLoader that = (ServerFileLoader) o; + return Objects.equals(files, that.files) && + Objects.equals(config, that.config); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), files, config); + } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/query/QuerySvc.java b/Plan/common/src/main/java/com/djrapitops/plan/query/QuerySvc.java index 0482728d9..7cdf5294e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/query/QuerySvc.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/query/QuerySvc.java @@ -26,7 +26,6 @@ import com.djrapitops.plan.storage.database.transactions.Transaction; import com.djrapitops.plan.utilities.logging.ErrorContext; import com.djrapitops.plan.utilities.logging.ErrorLogger; import com.djrapitops.plugin.logging.L; -import com.djrapitops.plugin.logging.console.PluginLogger; import javax.inject.Inject; import javax.inject.Singleton; @@ -43,7 +42,6 @@ public class QuerySvc implements QueryService { private final DBSystem dbSystem; private final ServerInfo serverInfo; - private final PluginLogger logger; private final ErrorLogger errorLogger; private final Set> playerRemoveSubscribers; @@ -53,12 +51,10 @@ public class QuerySvc implements QueryService { public QuerySvc( DBSystem dbSystem, ServerInfo serverInfo, - PluginLogger logger, ErrorLogger errorLogger ) { this.dbSystem = dbSystem; this.serverInfo = serverInfo; - this.logger = logger; this.errorLogger = errorLogger; playerRemoveSubscribers = new HashSet<>(); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/BukkitConfigSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/BukkitConfigSystem.java index f8b6a4732..36ec11c1b 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/BukkitConfigSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/BukkitConfigSystem.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.settings; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.settings.config.ConfigReader; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.changes.ConfigUpdater; @@ -60,7 +59,7 @@ public class BukkitConfigSystem extends ConfigSystem { } @Override - public void enable() throws EnableException { + public void enable() { super.enable(); if (config.isTrue(PluginSettings.PROXY_COPY_CONFIG)) { serverSettingsManager.enable(); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/ConfigSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/ConfigSystem.java index 12429a693..9df0b54a0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/ConfigSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/ConfigSystem.java @@ -49,7 +49,7 @@ public abstract class ConfigSystem implements SubSystem { protected final PluginLogger logger; protected final ErrorLogger errorLogger; - public ConfigSystem( + protected ConfigSystem( PlanFiles files, PlanConfig config, Theme theme, @@ -72,7 +72,7 @@ public abstract class ConfigSystem implements SubSystem { } @Override - public void enable() throws EnableException { + public void enable() { try { copyDefaults(); config.reorder(Arrays.asList( diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/NukkitConfigSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/NukkitConfigSystem.java index a5f4d2403..75a15d9f6 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/NukkitConfigSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/NukkitConfigSystem.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.settings; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.settings.config.ConfigReader; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.changes.ConfigUpdater; @@ -62,7 +61,7 @@ public class NukkitConfigSystem extends ConfigSystem { } @Override - public void enable() throws EnableException { + public void enable() { firstInstall = !files.getConfigFile().exists(); super.enable(); if (config.isTrue(PluginSettings.PROXY_COPY_CONFIG)) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/ProxyConfigSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/ProxyConfigSystem.java index bd3ba0849..68ee0fd1a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/ProxyConfigSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/ProxyConfigSystem.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.settings; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.settings.config.ConfigReader; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.changes.ConfigUpdater; @@ -59,7 +58,7 @@ public class ProxyConfigSystem extends ConfigSystem { } @Override - public void enable() throws EnableException { + public void enable() { super.enable(); networkSettingManager.enable(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/SpongeConfigSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/SpongeConfigSystem.java index 92089bf79..8df47ea9d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/SpongeConfigSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/SpongeConfigSystem.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.settings; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.changes.ConfigUpdater; import com.djrapitops.plan.settings.config.paths.DataGatheringSettings; @@ -54,7 +53,7 @@ public class SpongeConfigSystem extends BukkitConfigSystem { } @Override - public void enable() throws EnableException { + public void enable() { firstInstall = !files.getConfigFile().exists(); super.enable(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ConfigNode.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ConfigNode.java index 4df36bc91..d04ec191c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ConfigNode.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/ConfigNode.java @@ -69,13 +69,13 @@ public class ConfigNode { return Optional.empty(); } String[] parts = splitPathInTwo(path); - String key = parts[0]; + String lookingFor = parts[0]; String leftover = parts[1]; if (leftover.isEmpty()) { - return Optional.ofNullable(childNodes.get(key)); + return Optional.ofNullable(childNodes.get(lookingFor)); } else { - return getNode(key).flatMap(child -> child.getNode(leftover)); + return getNode(lookingFor).flatMap(child -> child.getNode(leftover)); } } @@ -95,15 +95,15 @@ public class ConfigNode { ConfigNode newParent = this; if (path != null && !path.isEmpty()) { String[] parts = splitPathInTwo(path); - String key = parts[0]; + String lookingFor = parts[0]; String leftover = parts[1]; // Add a new child ConfigNode child; - if (!childNodes.containsKey(key)) { - child = addChild(new ConfigNode(key, newParent, null)); + if (!childNodes.containsKey(lookingFor)) { + child = addChild(new ConfigNode(lookingFor, newParent, null)); } else { - child = childNodes.get(key); + child = childNodes.get(lookingFor); } // If the path ends return the leaf node @@ -200,9 +200,9 @@ public class ConfigNode { public void reorder(List newOrder) { List oldOrder = nodeOrder; nodeOrder = new ArrayList<>(); - for (String key : newOrder) { - if (childNodes.containsKey(key)) { - nodeOrder.add(key); + for (String childKey : newOrder) { + if (childNodes.containsKey(childKey)) { + nodeOrder.add(childKey); } } // Add those that were not in the new order, but are in the old order. @@ -311,11 +311,11 @@ public class ConfigNode { } // Copy all nodes from 'from' - for (String key : from.nodeOrder) { - ConfigNode newChild = from.childNodes.get(key); + for (String childKey : from.nodeOrder) { + ConfigNode newChild = from.childNodes.get(childKey); // Copy values recursively to children - ConfigNode created = addNode(key); + ConfigNode created = addNode(childKey); created.copyMissing(newChild); } } @@ -326,11 +326,11 @@ public class ConfigNode { value = from.value; // Copy all nodes from 'from' - for (String key : from.nodeOrder) { - ConfigNode newChild = from.childNodes.get(key); + for (String childKey : from.nodeOrder) { + ConfigNode newChild = from.childNodes.get(childKey); // Copy values recursively to children - ConfigNode created = addNode(key); + ConfigNode created = addNode(childKey); created.copyAll(newChild); } } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/key/Setting.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/key/Setting.java index af75c6905..fe49b06ac 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/key/Setting.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/key/Setting.java @@ -31,20 +31,20 @@ public abstract class Setting { protected final String path; private final Predicate validator; - public Setting(String path, Class type) { + protected Setting(String path, Class type) { this(path, type, Setting::nullValidator); } - public Setting(String path, Class type, Predicate validator) { + protected Setting(String path, Class type, Predicate validator) { // null validator has to be called before the actual validator to avoid possible null errors. this(path, Type.ofClass(type), ((Predicate) Setting::nullValidator).and(validator)); } - public Setting(String path, Type type) { + protected Setting(String path, Type type) { this(path, type, Setting::nullValidator); } - public Setting(String path, Type type, Predicate validator) { + protected Setting(String path, Type type, Predicate validator) { this.path = path; this.validator = validator; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/LocaleSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/LocaleSystem.java index 897a933c0..62a486d92 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/LocaleSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/LocaleSystem.java @@ -132,8 +132,8 @@ public class LocaleSystem implements SubSystem { if ("write-all".equalsIgnoreCase(setting)) { for (LangCode code : LangCode.values()) { if (code == LangCode.CUSTOM) continue; - Locale locale = Locale.forLangCode(code, files); - new LocaleFileWriter(locale).writeToFile( + Locale writing = Locale.forLangCode(code, files); + new LocaleFileWriter(writing).writeToFile( files.getDataDirectory().resolve("locale_" + code.name() + ".txt").toFile() ); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/TranslatedString.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/TranslatedString.java index d0150fefb..4c45677a4 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/TranslatedString.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/TranslatedString.java @@ -92,6 +92,7 @@ class TranslatedString { this.translating = translating; } + @Override public void translate(String replace, String with) { translating = StringUtils.replace(translating, replace, with); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/network/NetworkSettingManager.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/network/NetworkSettingManager.java index 2fa9f2856..97e9c5c4d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/network/NetworkSettingManager.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/network/NetworkSettingManager.java @@ -93,7 +93,7 @@ public class NetworkSettingManager implements SubSystem { } @Override - public void enable() throws EnableException { + public void enable() { serverSettingsFolder = createServerSettingsFolder(); watcher = prepareFileWatcher(); @@ -119,9 +119,9 @@ public class NetworkSettingManager implements SubSystem { private FileWatcher prepareFileWatcher() { FileWatcher fileWatcher = new FileWatcher(serverSettingsFolder, errorLogger); - File[] files = getConfigFiles(); - if (files != null) { - for (File file : files) { + File[] configFiles = getConfigFiles(); + if (configFiles != null) { + for (File file : configFiles) { addFileToWatchList(fileWatcher, file); } } @@ -153,7 +153,7 @@ public class NetworkSettingManager implements SubSystem { }).runTaskTimerAsynchronously(checkPeriod, checkPeriod); } - private File createServerSettingsFolder() throws EnableException { + private File createServerSettingsFolder() { try { File serverConfigFolder = files.getFileFromPluginFolder("serverConfiguration"); Files.createDirectories(serverConfigFolder.toPath()); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/theme/Theme.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/theme/Theme.java index 883538d8c..58ed4243c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/theme/Theme.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/theme/Theme.java @@ -70,7 +70,7 @@ public class Theme implements SubSystem { } @Override - public void enable() throws EnableException { + public void enable() { try { themeConfig = new ThemeConfig(files, config, logger); themeConfig.save(); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/AbstractDatabase.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/AbstractDatabase.java index ae4244e4c..e4d4413d3 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/AbstractDatabase.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/AbstractDatabase.java @@ -31,7 +31,7 @@ public abstract class AbstractDatabase implements Database { private State state; private final AtomicInteger heavyLoadDelayMs = new AtomicInteger(0); - public AbstractDatabase() { + protected AbstractDatabase() { state = State.CLOSED; accessLock = new DBAccessLock(this); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/DBSystem.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/DBSystem.java index 75fa695b6..ee6d17ae4 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/DBSystem.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/DBSystem.java @@ -33,7 +33,7 @@ import java.util.Set; * @author Rsl1122 */ @Singleton -public abstract class DBSystem implements SubSystem { +public class DBSystem implements SubSystem { protected final Locale locale; private final SQLiteDB.Factory sqLiteFactory; @@ -87,7 +87,7 @@ public abstract class DBSystem implements SubSystem { } @Override - public void enable() throws EnableException { + public void enable() { try { db.init(); logger.info(locale.getString(PluginLang.ENABLED_DATABASE, db.getType().getName())); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/MySQLDB.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/MySQLDB.java index 06e23f069..566230d55 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/MySQLDB.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/MySQLDB.java @@ -127,7 +127,7 @@ public class MySQLDB extends SQLDB { Connection connection = dataSource.getConnection(); if (!connection.isValid(5)) { connection.close(); - if (dataSource != null) dataSource.close(); + dataSource.close(); try { setupDataSource(); // get new connection after restarting pool diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java index 2f02f0781..f2509d95b 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java @@ -67,7 +67,7 @@ public abstract class SQLDB extends AbstractDatabase { private final boolean devMode; - public SQLDB( + protected SQLDB( Supplier serverUUIDSupplier, Locale locale, PlanConfig config, diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/HasMoreThanZeroQueryStatement.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/HasMoreThanZeroQueryStatement.java index fd9077dec..dbaa8b764 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/HasMoreThanZeroQueryStatement.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/HasMoreThanZeroQueryStatement.java @@ -28,11 +28,11 @@ public abstract class HasMoreThanZeroQueryStatement extends QueryStatement extends QueryStatement { - public QueryAllStatement(String sql) { + protected QueryAllStatement(String sql) { super(sql); } - public QueryAllStatement(String sql, int fetchSize) { + protected QueryAllStatement(String sql, int fetchSize) { super(sql, fetchSize); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/QueryStatement.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/QueryStatement.java index 21489ef90..8424dd43e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/QueryStatement.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/QueryStatement.java @@ -34,11 +34,11 @@ public abstract class QueryStatement implements Query { private final String sql; private final int fetchSize; - public QueryStatement(String sql) { + protected QueryStatement(String sql) { this(sql, 10); } - public QueryStatement(String sql, int fetchSize) { + protected QueryStatement(String sql, int fetchSize) { this.sql = sql; this.fetchSize = fetchSize; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/building/WhereBuilder.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/building/WhereBuilder.java index d2b0baee2..4fdbc09d8 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/building/WhereBuilder.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/sql/building/WhereBuilder.java @@ -25,11 +25,7 @@ public abstract class WhereBuilder extends SqlBuilder { private int conditions = 0; - public WhereBuilder() { - super(); - } - - public WhereBuilder(String start) { + protected WhereBuilder(String start) { super(start); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecBatchStatement.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecBatchStatement.java index 3c758c3a9..6020866b7 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecBatchStatement.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecBatchStatement.java @@ -26,7 +26,7 @@ import java.sql.SQLException; */ public abstract class ExecBatchStatement extends ExecStatement { - public ExecBatchStatement(String sql) { + protected ExecBatchStatement(String sql) { super(sql); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecStatement.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecStatement.java index ec819d3c1..716caea96 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecStatement.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/ExecStatement.java @@ -31,7 +31,7 @@ public abstract class ExecStatement implements Executable { private final String sql; - public ExecStatement(String sql) { + protected ExecStatement(String sql) { this.sql = sql; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreConfigTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreConfigTransaction.java index 966bd6a65..4680a3ec9 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreConfigTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/StoreConfigTransaction.java @@ -56,7 +56,7 @@ public class StoreConfigTransaction extends Transaction { @Override protected void performOperations() { - if (query(isConfigStored())) { + if (Boolean.TRUE.equals(query(isConfigStored()))) { execute(updateConfig()); } else { execute(insertConfig()); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java index 022bef658..6fc11c904 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerRegisterTransaction.java @@ -51,7 +51,7 @@ public class PlayerRegisterTransaction extends Transaction { @Override protected void performOperations() { - if (!query(PlayerFetchQueries.isPlayerRegistered(playerUUID))) { + if (Boolean.FALSE.equals(query(PlayerFetchQueries.isPlayerRegistered(playerUUID)))) { long registerDate = registered.getAsLong(); insertUser(registerDate); SessionCache.getCachedSession(playerUUID).ifPresent(session -> session.setAsFirstSessionIfMatches(registerDate)); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java index ea2c4f561..6c858061f 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/PlayerServerRegisterTransaction.java @@ -41,7 +41,7 @@ public class PlayerServerRegisterTransaction extends PlayerRegisterTransaction { protected void performOperations() { super.performOperations(); long registerDate = registered.getAsLong(); - if (!query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID))) { + if (Boolean.FALSE.equals(query(PlayerFetchQueries.isPlayerRegisteredOnServer(playerUUID, serverUUID)))) { execute(DataStoreQueries.registerUserInfo(playerUUID, registerDate, serverUUID)); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/file/PlanFiles.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/file/PlanFiles.java index 0313b6028..bf3297fee 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/file/PlanFiles.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/file/PlanFiles.java @@ -89,7 +89,7 @@ public class PlanFiles implements SubSystem { } @Override - public void enable() throws EnableException { + public void enable() { ResourceCache.invalidateAll(); ResourceCache.cleanUp(); Verify.isTrue((dataFolder.exists() && dataFolder.isDirectory()) || dataFolder.mkdirs(), diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/chat/ChatFormatter.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/chat/ChatFormatter.java index 85bf8bec2..104cb440d 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/chat/ChatFormatter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/chat/ChatFormatter.java @@ -30,6 +30,10 @@ public class ChatFormatter { private static final int CENTER_PX = 154; private static final int MAX_PX = 260; + private ChatFormatter() { + // Hide utility class constructor + } + public static String leftPad(String message, int spaces) { StringBuilder returnMessage = new StringBuilder(); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/java/ThrowableUtils.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/java/ThrowableUtils.java index ef610fef1..3d3860df0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/java/ThrowableUtils.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/java/ThrowableUtils.java @@ -37,7 +37,7 @@ public class ThrowableUtils { cause.setStackTrace(ArrayUtil.merge(cause.getStackTrace(), originPoint.getStackTrace())); } - public static String findCallerAfterClass(StackTraceElement[] stackTrace, Class afterThis) { + public static String findCallerAfterClass(StackTraceElement[] stackTrace, Class afterThis) { boolean found = false; for (StackTraceElement stackTraceElement : stackTrace) { if (found) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorContext.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorContext.java index f47992546..e4cedb6a1 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorContext.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/logging/ErrorContext.java @@ -16,6 +16,7 @@ */ package com.djrapitops.plan.utilities.logging; +import java.io.Serializable; import java.util.*; /** @@ -23,7 +24,7 @@ import java.util.*; * * @author Rsl1122 */ -public class ErrorContext { +public class ErrorContext implements Serializable { private final List related; private String whatToDo; diff --git a/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java b/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java index b27f17d9b..f64804dfd 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/settings/ConfigSettingKeyTest.java @@ -40,6 +40,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test to check that configs contain all values required to run the plugin. + *

+ * TODO Move public utility methods to an utility to make this class package private * * @author Rsl1122 */ diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java index 61fb128ab..41facc525 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTest.java @@ -134,7 +134,7 @@ public interface DatabaseTest extends DatabaseTestPreparer { system().getConfigSystem().getConfig(), new Locale(), system().getDatabaseSystem(), - new QuerySvc(system().getDatabaseSystem(), system().getServerInfo(), logger, null), + new QuerySvc(system().getDatabaseSystem(), system().getServerInfo(), null), system().getServerInfo(), logger, null diff --git a/Plan/nukkit/src/main/java/com/djrapitops/plan/storage/database/NukkitDBSystem.java b/Plan/nukkit/src/main/java/com/djrapitops/plan/storage/database/NukkitDBSystem.java index 6cb2e95dd..e8e8f7cbf 100644 --- a/Plan/nukkit/src/main/java/com/djrapitops/plan/storage/database/NukkitDBSystem.java +++ b/Plan/nukkit/src/main/java/com/djrapitops/plan/storage/database/NukkitDBSystem.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.storage.database; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.paths.DatabaseSettings; import com.djrapitops.plan.settings.locale.Locale; @@ -53,7 +52,7 @@ public class NukkitDBSystem extends DBSystem { } @Override - public void enable() throws EnableException { + public void enable() { String dbType = config.get(DatabaseSettings.TYPE).toLowerCase().trim(); db = getActiveDatabaseByName(dbType); super.enable(); diff --git a/Plan/nukkit/src/test/java/com/djrapitops/plan/NukkitSystemTest.java b/Plan/nukkit/src/test/java/com/djrapitops/plan/NukkitSystemTest.java index abb10846b..75c472146 100644 --- a/Plan/nukkit/src/test/java/com/djrapitops/plan/NukkitSystemTest.java +++ b/Plan/nukkit/src/test/java/com/djrapitops/plan/NukkitSystemTest.java @@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * * @author Rsl1122 */ -public class NukkitSystemTest { +class NukkitSystemTest { private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500); private PlanSystem system; diff --git a/Plan/nukkit/src/test/java/com/djrapitops/plan/gathering/listeners/NukkitAFKListenerTest.java b/Plan/nukkit/src/test/java/com/djrapitops/plan/gathering/listeners/NukkitAFKListenerTest.java index 9fac92769..75dd82860 100644 --- a/Plan/nukkit/src/test/java/com/djrapitops/plan/gathering/listeners/NukkitAFKListenerTest.java +++ b/Plan/nukkit/src/test/java/com/djrapitops/plan/gathering/listeners/NukkitAFKListenerTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.*; * @author Rsl1122 */ @ExtendWith(MockitoExtension.class) -public class NukkitAFKListenerTest { +class NukkitAFKListenerTest { private static NukkitAFKListener underTest; private static ErrorLogger errorLogger; diff --git a/Plan/sponge/src/main/java/com/djrapitops/plan/storage/database/SpongeDBSystem.java b/Plan/sponge/src/main/java/com/djrapitops/plan/storage/database/SpongeDBSystem.java index bc0b596ec..d6fd59b9d 100644 --- a/Plan/sponge/src/main/java/com/djrapitops/plan/storage/database/SpongeDBSystem.java +++ b/Plan/sponge/src/main/java/com/djrapitops/plan/storage/database/SpongeDBSystem.java @@ -16,7 +16,6 @@ */ package com.djrapitops.plan.storage.database; -import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.settings.config.PlanConfig; import com.djrapitops.plan.settings.config.paths.DatabaseSettings; import com.djrapitops.plan.settings.locale.Locale; @@ -53,7 +52,7 @@ public class SpongeDBSystem extends DBSystem { } @Override - public void enable() throws EnableException { + public void enable() { String dbType = config.get(DatabaseSettings.TYPE).toLowerCase().trim(); db = getActiveDatabaseByName(dbType); super.enable(); diff --git a/Plan/sponge/src/test/java/com/djrapitops/plan/SpongeSystemTest.java b/Plan/sponge/src/test/java/com/djrapitops/plan/SpongeSystemTest.java index 2a86fa4a8..93b33678a 100644 --- a/Plan/sponge/src/test/java/com/djrapitops/plan/SpongeSystemTest.java +++ b/Plan/sponge/src/test/java/com/djrapitops/plan/SpongeSystemTest.java @@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * * @author Rsl1122 */ -public class SpongeSystemTest { +class SpongeSystemTest { private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500); diff --git a/Plan/velocity/src/test/java/com/djrapitops/plan/VelocitySystemTest.java b/Plan/velocity/src/test/java/com/djrapitops/plan/VelocitySystemTest.java index 40d0c6710..5ec85b9d8 100644 --- a/Plan/velocity/src/test/java/com/djrapitops/plan/VelocitySystemTest.java +++ b/Plan/velocity/src/test/java/com/djrapitops/plan/VelocitySystemTest.java @@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; * * @author Rsl1122 */ -public class VelocitySystemTest { +class VelocitySystemTest { private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500); diff --git a/Plan/velocity/src/test/java/com/djrapitops/plan/gathering/timed/VelocityPingCounterTest.java b/Plan/velocity/src/test/java/com/djrapitops/plan/gathering/timed/VelocityPingCounterTest.java index 7343bead0..552ffd9e1 100644 --- a/Plan/velocity/src/test/java/com/djrapitops/plan/gathering/timed/VelocityPingCounterTest.java +++ b/Plan/velocity/src/test/java/com/djrapitops/plan/gathering/timed/VelocityPingCounterTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; * * @author Rsl1122 */ -public class VelocityPingCounterTest { +class VelocityPingCounterTest { private PlanVelocity plugin; private Player player;