Fixed SonarCloud code smells

- Redundancies:
  - MySQLDB: Removed null check
  - DeathEventListener: Removed warning suppression
  - several Test classes: Removed public class identifier
  - Unused private fields
- Constructors of abstract classes should be protected x31
- Added missing Parameterized types x2
- "throws" declerations for runtime EnableException
- Prevented Boxed Boolean from causing NPE in the future x15
- Renamed lesser scope variables that were hiding variables x12

- Some smaller ones that I was too tired to write down
This commit is contained in:
Risto Lahtela 2020-11-05 23:16:01 +02:00
parent e6f879783d
commit 7420e46df2
92 changed files with 234 additions and 179 deletions

View File

@ -65,8 +65,12 @@ public interface CapabilityService {
}
class ListHolder {
volatile static AtomicReference<List<Consumer<Boolean>>> ENABLE_LISTENERS = new AtomicReference<>(
static volatile AtomicReference<List<Consumer<Boolean>>> ENABLE_LISTENERS = new AtomicReference<>(
new CopyOnWriteArrayList<>()
);
private ListHolder() {
// Hide constructor
}
}
}

View File

@ -89,7 +89,7 @@ public interface ResolverService {
List<Resolver> getResolvers(String target);
class Holder {
volatile static AtomicReference<ResolverService> service = new AtomicReference<>();
static volatile AtomicReference<ResolverService> service = new AtomicReference<>();
private Holder() {
/* Static variable holder */

View File

@ -103,7 +103,7 @@ public interface ResourceService {
}
class Holder {
volatile static AtomicReference<ResourceService> service = new AtomicReference<>();
static volatile AtomicReference<ResourceService> service = new AtomicReference<>();
private Holder() {
/* Static variable holder */

View File

@ -71,7 +71,7 @@ public interface ExtensionService {
void unregister(DataExtension extension);
class Holder {
volatile static AtomicReference<ExtensionService> service = new AtomicReference<>();
static volatile AtomicReference<ExtensionService> service = new AtomicReference<>();
private Holder() {
/* Static variable holder */

View File

@ -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;

View File

@ -150,7 +150,7 @@ public interface QueryService {
}
class Holder {
volatile static AtomicReference<QueryService> service = new AtomicReference<>();
static volatile AtomicReference<QueryService> service = new AtomicReference<>();
private Holder() {
/* Static variable holder */

View File

@ -66,7 +66,7 @@ public interface SettingsService {
List<String> getStringList(String path, Supplier<List<String>> defaultValue);
class Holder {
volatile static AtomicReference<SettingsService> service = new AtomicReference<>();
static volatile AtomicReference<SettingsService> service = new AtomicReference<>();
private Holder() {
/* Static variable holder */

View File

@ -39,7 +39,8 @@ public class BukkitListenerSystem extends ListenerSystem {
private final BukkitAFKListener afkListener;
@Inject
public BukkitListenerSystem(Plan plugin,
public BukkitListenerSystem(
Plan plugin,
Status status,
PlayerOnlineListener playerOnlineListener,
ChatListener chatListener,

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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");

View File

@ -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;
}

View File

@ -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<Boolean> enableListener : CapabilityService.ListHolder.ENABLE_LISTENERS.get()) {
enableListener.accept(isEnabled);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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))

View File

@ -63,7 +63,7 @@ public class CommandWithSubcommands extends Subcommand {
.send();
}
public void onInDepthHelp(CMDSender sender, Arguments arguments) {
public void onInDepthHelp(CMDSender sender) {
List<Subcommand> 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;});

View File

@ -71,7 +71,7 @@ public class Subcommand {
}
public BiFunction<CMDSender, Arguments, List<String>> getArgumentResolver() {
return argumentResolver != null ? argumentResolver : ((sender, arguments) -> Collections.emptyList());
return argumentResolver != null ? argumentResolver : ((sender, args) -> Collections.emptyList());
}
public String getArgumentsAsString() {

View File

@ -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<CMDSender, Arguments> executor);
default SubcommandBuilder onCommand(Consumer<CMDSender> executor) {
return onCommand((sender, arguments) -> executor.accept(sender));
}
SubcommandBuilder onTabComplete(BiFunction<CMDSender, Arguments, List<String>> resolver);
Subcommand build();

View File

@ -75,7 +75,7 @@ public class SupplierDataContainer implements DataContainer {
}
private <T> Supplier<T> getSupplier(Key<T> key) {
return (Supplier<T>) map.get(key);
return map.get(key);
}
@Override

View File

@ -29,7 +29,7 @@ public abstract class Type<T> {
private final String genericsSuperClass;
public Type() {
protected Type() {
genericsSuperClass = getGenericsClass().getGenericSuperclass().getTypeName();
}

View File

@ -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<Server> 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)
);

View File

@ -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);

View File

@ -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"));

View File

@ -37,14 +37,11 @@ public abstract class DateFormatter implements Formatter<Long> {
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)

View File

@ -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("</li>");
}
@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);

View File

@ -209,10 +209,8 @@ public class JSONFactory {
server.put("downtime", timeAmount.apply(tpsWeek.serverDownTime()));
Optional<TPS> 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;

View File

@ -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;

View File

@ -66,18 +66,18 @@ public class ServerAccordion {
for (Map.Entry<UUID, DataContainer> entry : perServer.entrySet()) {
UUID serverUUID = entry.getKey();
DataContainer perServer = entry.getValue();
DataContainer ofServer = entry.getValue();
Map<String, Object> 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());

View File

@ -25,7 +25,7 @@ import java.util.List;
*/
public abstract class PieWithDrilldown extends Pie {
public PieWithDrilldown(List<PieSlice> slices) {
protected PieWithDrilldown(List<PieSlice> slices) {
super(slices);
}

View File

@ -58,7 +58,7 @@ public class WorldMap {
private Map<String, Integer> toGeoCodeCounts(Map<String, Integer> geolocationCounts) {
Map<String, String> geoCodes = getGeoCodes();
Map<String, Integer> geoCodeCounts = new HashMap<>();
Map<String, Integer> codeCounts = new HashMap<>();
for (Map.Entry<String, Integer> 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<String, Integer> toGeoCodeCounts(List<String> geoLocations) {

View File

@ -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();
}

View File

@ -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));
}

View File

@ -32,6 +32,10 @@ public class ActiveCookieStore {
.expireAfterWrite(2, TimeUnit.HOURS)
.build();
private ActiveCookieStore() {
// Hide static cache constructor
}
public static Optional<User> checkCookie(String cookie) {
return Optional.ofNullable(USERS_BY_COOKIE.getIfPresent(cookie));
}

View File

@ -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);

View File

@ -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) {

View File

@ -84,6 +84,7 @@ public interface Parameters {
return serverUUID;
}
@Override
public UUID getPlayerUUID() {
return playerUUID;
}

View File

@ -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 {

View File

@ -44,7 +44,7 @@ public class StoreIconTransaction extends ThrowawayTransaction {
@Override
protected void performOperations() {
if (!query(isIconStored())) {
if (Boolean.FALSE.equals(query(isIconStored()))) {
execute(insertIcon());
}
}

View File

@ -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,

View File

@ -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<String, Long> times;
protected String state;

View File

@ -24,6 +24,8 @@ import java.util.*;
/**
* Abstract representation of an ImportSystem.
* <p>
* 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<String, Importer> importers;
public ImportSystem() {
protected ImportSystem() {
importers = new HashMap<>();
}

View File

@ -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) {

View File

@ -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
) {

View File

@ -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;
}

View File

@ -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<Server> loaded = fromFile.load(null);
server = loaded.orElseGet(this::registerNew);
processing.submitNonCritical(this::updateStorage);

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -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<Consumer<UUID>> 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<>();

View File

@ -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();

View File

@ -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(

View File

@ -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)) {

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<String> newOrder) {
List<String> 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);
}
}

View File

@ -31,20 +31,20 @@ public abstract class Setting<T> {
protected final String path;
private final Predicate<T> validator;
public Setting(String path, Class<T> type) {
protected Setting(String path, Class<T> type) {
this(path, type, Setting::nullValidator);
}
public Setting(String path, Class<T> type, Predicate<T> validator) {
protected Setting(String path, Class<T> type, Predicate<T> validator) {
// null validator has to be called before the actual validator to avoid possible null errors.
this(path, Type.ofClass(type), ((Predicate<T>) Setting::nullValidator).and(validator));
}
public Setting(String path, Type<T> type) {
protected Setting(String path, Type<T> type) {
this(path, type, Setting::nullValidator);
}
public Setting(String path, Type<T> type, Predicate<T> validator) {
protected Setting(String path, Type<T> type, Predicate<T> validator) {
this.path = path;
this.validator = validator;
}

View File

@ -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()
);
}

View File

@ -92,6 +92,7 @@ class TranslatedString {
this.translating = translating;
}
@Override
public void translate(String replace, String with) {
translating = StringUtils.replace(translating, replace, with);
}

View File

@ -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());

View File

@ -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();

View File

@ -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);
}

View File

@ -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()));

View File

@ -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

View File

@ -67,7 +67,7 @@ public abstract class SQLDB extends AbstractDatabase {
private final boolean devMode;
public SQLDB(
protected SQLDB(
Supplier<UUID> serverUUIDSupplier,
Locale locale,
PlanConfig config,

View File

@ -28,11 +28,11 @@ public abstract class HasMoreThanZeroQueryStatement extends QueryStatement<Boole
private String countColumnName = "c";
public HasMoreThanZeroQueryStatement(String sql) {
protected HasMoreThanZeroQueryStatement(String sql) {
super(sql);
}
public HasMoreThanZeroQueryStatement(String sql, String countColumnName) {
protected HasMoreThanZeroQueryStatement(String sql, String countColumnName) {
super(sql);
this.countColumnName = countColumnName;
}

View File

@ -26,11 +26,11 @@ import java.sql.SQLException;
* @author Rsl1122
*/
public abstract class QueryAllStatement<T> extends QueryStatement<T> {
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);
}

View File

@ -34,11 +34,11 @@ public abstract class QueryStatement<T> implements Query<T> {
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;
}

View File

@ -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);
}

View File

@ -26,7 +26,7 @@ import java.sql.SQLException;
*/
public abstract class ExecBatchStatement extends ExecStatement {
public ExecBatchStatement(String sql) {
protected ExecBatchStatement(String sql) {
super(sql);
}

View File

@ -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;
}

View File

@ -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());

View File

@ -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));

View File

@ -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));
}

View File

@ -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(),

View File

@ -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();

View File

@ -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) {

View File

@ -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<Object> related;
private String whatToDo;

View File

@ -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.
* <p>
* TODO Move public utility methods to an utility to make this class package private
*
* @author Rsl1122
*/

View File

@ -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

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -36,7 +36,7 @@ import static org.mockito.Mockito.when;
*
* @author Rsl1122
*/
public class VelocityPingCounterTest {
class VelocityPingCounterTest {
private PlanVelocity plugin;
private Player player;