Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ repositories {
}

dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:8.6.0")
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.4.2")
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.5.5")
implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:5.1.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:8.10.3")
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.6.1")
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.5.12")
implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:5.1.1")
implementation("org.openrewrite:plugin:7.34.0")
}

Expand Down
20 changes: 10 additions & 10 deletions buildSrc/src/main/kotlin/pq.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ java {
dependencies {
implementation("org.jetbrains:annotations:26.1.0")

errorprone("com.google.errorprone:error_prone_core:2.49.0")
spotbugs("com.github.spotbugs:spotbugs:4.9.8")
rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.36.0")
rewrite("org.openrewrite.recipe:rewrite-migrate-java:3.36.0")
rewrite("org.openrewrite.recipe:rewrite-rewrite:0.26.0")
errorprone("com.google.errorprone:error_prone_core:2.50.0")
spotbugs("com.github.spotbugs:spotbugs:4.10.4")
rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.41.1")
rewrite("org.openrewrite.recipe:rewrite-migrate-java:3.42.1")
rewrite("org.openrewrite.recipe:rewrite-rewrite:0.30.0")

compileOnly("org.projectlombok:lombok:1.18.46")
annotationProcessor("org.projectlombok:lombok:1.18.46")
compileOnly("org.projectlombok:lombok:1.18.48")
annotationProcessor("org.projectlombok:lombok:1.18.48")

testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.junit.jupiter:junit-jupiter:6.1.0")
testImplementation("org.mockito:mockito-core:5.23.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.23.0")
testImplementation("org.junit.jupiter:junit-jupiter:6.1.3")
testImplementation("org.mockito:mockito-core:5.24.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.24.0")
}

tasks {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.0-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
Expand Down
6 changes: 3 additions & 3 deletions placeholder/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ plugins {

dependencies {
compileOnly("org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.12.2")
compileOnly("me.clip:placeholderapi:2.12.3")

compileOnly("org.projectlombok:lombok:1.18.46")
annotationProcessor("org.projectlombok:lombok:1.18.46")
compileOnly("org.projectlombok:lombok:1.18.48")
annotationProcessor("org.projectlombok:lombok:1.18.48")

implementation("net.pistonmaster:PistonUtils:1.4.0")
}
6 changes: 3 additions & 3 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
api("de.exlll:configlib-yaml:4.8.1")
compileOnly("net.pistonmaster:pistonmotd-api:5.2.7")
compileOnly("org.apiguardian:apiguardian-api:1.1.2")
api("com.github.spotbugs:spotbugs-annotations:4.9.8")
compileOnly("com.google.guava:guava:33.6.0-jre")
testImplementation("com.google.guava:guava:33.6.0-jre")
api("com.github.spotbugs:spotbugs-annotations:4.10.4")
compileOnly("com.google.guava:guava:33.7.2-jre")
testImplementation("com.google.guava:guava:33.7.2-jre")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
import net.pistonmaster.pistonqueue.shared.queue.logic.UsernameValidator;
import net.pistonmaster.pistonqueue.shared.wrapper.PlayerWrapper;

import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public abstract class QueueListenerShared {
private final PistonQueuePlugin plugin;

Check warning on line 49 in shared/src/main/java/net/pistonmaster/pistonqueue/shared/queue/QueueListenerShared.java

View workflow job for this annotation

GitHub Actions / build

[UnusedVariable] The field 'plugin' is never read.
@Getter
private final ServerStatusManager serverStatusManager;
private final QueueEnvironment queueEnvironment;

Check warning on line 52 in shared/src/main/java/net/pistonmaster/pistonqueue/shared/queue/QueueListenerShared.java

View workflow job for this annotation

GitHub Actions / build

[UnusedVariable] The field 'queueEnvironment' is never read.
private final QueuePlacementCoordinator queuePlacementCoordinator;
private final QueueMoveProcessor queueMoveProcessor;
private final UsernameValidator usernameValidator;
Expand All @@ -56,26 +57,45 @@
private final KickEventHandler kickEventHandler;

protected QueueListenerShared(PistonQueuePlugin plugin) {
this.plugin = plugin;
Config config = currentConfig();
this.serverStatusManager = new ServerStatusManager(this::currentConfig);
this.queueEnvironment = new QueueEnvironment(plugin, this::currentConfig, serverStatusManager::getOnlineServers);
this.usernameValidator = new UsernameValidator(config);
this.shadowBanKickHandler = new ShadowBanKickHandler(config);
this(prepare(plugin));
}

private QueueListenerShared(PreparedListener prepared) {
this.plugin = prepared.plugin();
this.serverStatusManager = prepared.serverStatusManager();
this.queueEnvironment = prepared.queueEnvironment();
this.queuePlacementCoordinator = prepared.queuePlacementCoordinator();
this.queueMoveProcessor = prepared.queueMoveProcessor();
this.usernameValidator = prepared.usernameValidator();
this.shadowBanKickHandler = prepared.shadowBanKickHandler();
this.kickEventHandler = prepared.kickEventHandler();
}

private static PreparedListener prepare(PistonQueuePlugin plugin) {
Objects.requireNonNull(plugin, "plugin");
Config config = Objects.requireNonNull(plugin.getConfiguration(), "configuration");

ServerStatusManager serverStatusManager = new ServerStatusManager(plugin::getConfiguration);
QueueEnvironment queueEnvironment = new QueueEnvironment(plugin, plugin::getConfiguration, serverStatusManager::getOnlineServers);
UsernameValidator usernameValidator = new UsernameValidator(config);
ShadowBanKickHandler shadowBanKickHandler = new ShadowBanKickHandler(config);

QueueServerSelector queueServerSelector = new QueueServerSelector(queueEnvironment);
this.kickEventHandler = new KickEventHandler(config, queueEnvironment, queueServerSelector);
KickEventHandler kickEventHandler = new KickEventHandler(config, queueEnvironment, queueServerSelector);

QueueAvailabilityCalculator availabilityCalculator = new QueueAvailabilityCalculator();
QueueEntryFactory queueEntryFactory = new QueueEntryFactory(queueEnvironment, queueServerSelector);
ShadowBanService shadowBanService = new StorageShadowBanService();
this.queuePlacementCoordinator = new QueuePlacementCoordinator(queueEnvironment, availabilityCalculator, queueEntryFactory,shadowBanService);
QueuePlacementCoordinator queuePlacementCoordinator = new QueuePlacementCoordinator(queueEnvironment, availabilityCalculator, queueEntryFactory,shadowBanService);
QueueCleaner queueCleaner = new QueueCleaner(queueEnvironment);
QueueRecoveryHandler recoveryHandler = new QueueRecoveryHandler(queueEnvironment);
QueueConnector queueConnector = new QueueConnector(queueEnvironment, availabilityCalculator, shadowBanService);
this.queueMoveProcessor = new QueueMoveProcessor(queueEnvironment, queueCleaner, recoveryHandler, queueConnector);
QueueMoveProcessor queueMoveProcessor = new QueueMoveProcessor(queueEnvironment, queueCleaner, recoveryHandler, queueConnector);
return new PreparedListener(plugin, serverStatusManager, queueEnvironment, queuePlacementCoordinator, queueMoveProcessor, usernameValidator, shadowBanKickHandler, kickEventHandler);
}

private record PreparedListener(PistonQueuePlugin plugin, ServerStatusManager serverStatusManager, QueueEnvironment queueEnvironment, QueuePlacementCoordinator queuePlacementCoordinator, QueueMoveProcessor queueMoveProcessor, UsernameValidator usernameValidator, ShadowBanKickHandler shadowBanKickHandler, KickEventHandler kickEventHandler) {}

protected void onPreLogin(PQPreLoginEvent event) {
usernameValidator.validateUsername(event);
}
Expand All @@ -96,7 +116,4 @@
queueMoveProcessor.processQueues();
}

private Config currentConfig() {
return plugin.getConfiguration();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package net.pistonmaster.pistonqueue.shared.command;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.pistonmaster.pistonqueue.shared.chat.ComponentWrapper;
import net.pistonmaster.pistonqueue.shared.chat.ComponentWrapperFactory;
import net.pistonmaster.pistonqueue.shared.chat.MessageType;
Expand Down Expand Up @@ -387,7 +388,7 @@ void clearMessages() {
}
}

@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
@SuppressFBWarnings(
value = "CT_CONSTRUCTOR_THROW",
justification = "Test class does not need protection from finalizer attacks"
)
Expand Down Expand Up @@ -451,6 +452,7 @@ public Path getDataDirectory() {
}

@Override
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Tests share mutable configuration to exercise reloads.")
public Config getConfiguration() {
return config;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.pistonmaster.pistonqueue.shared.queue.logic;

import net.pistonmaster.pistonqueue.shared.plugin.PistonQueuePlugin;
import net.pistonmaster.pistonqueue.shared.queue.QueueListenerShared;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;

class QueueListenerConstructionTest {
@Test
void statusChecksContinueToUseReloadedConfiguration() {
var config = QueueTestUtils.createConfigWithSingleQueueType(10);
config.setMinOnlineChecks(1);
var plugin = new QueueTestUtils.TestQueuePlugin(config);
var listener = new QueueListenerShared(plugin) {};
var status = listener.getServerStatusManager();
status.online("target");
assertTrue(status.getOnlineServers().contains("target"));
config.setMinOnlineChecks(2);
assertFalse(status.getOnlineServers().contains("target"));
status.online("target");
assertTrue(status.getOnlineServers().contains("target"));
}

@Test
void rejectsMissingConfigurationDuringConstruction() {
var plugin = mock(PistonQueuePlugin.class);
assertThrows(NullPointerException.class, () -> new QueueListenerShared(plugin) {});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void sendsXpSoundWhenMovingQueue() {
TestPlayer player = context.plugin().registerPlayer("XP" + i);
enqueue(context, player, "main");
// Players need to be "connected" to the queue server for XP sound to be sent
queueServer.getConnectedPlayers().add(player);
queueServer.addConnectedPlayer(player);
}

context.processor().processQueues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ void leastPlayersSelectsServerWithFewestPlayers() {
plugin.registerServer("queue3"); // queue3 has no players

// Add players to servers
queue1.getConnectedPlayers().add(plugin.registerPlayer("P1"));
queue1.getConnectedPlayers().add(plugin.registerPlayer("P2"));
queue1.getConnectedPlayers().add(plugin.registerPlayer("P3"));
queue2.getConnectedPlayers().add(plugin.registerPlayer("P4"));
queue1.addConnectedPlayer(plugin.registerPlayer("P1"));
queue1.addConnectedPlayer(plugin.registerPlayer("P2"));
queue1.addConnectedPlayer(plugin.registerPlayer("P3"));
queue2.addConnectedPlayer(plugin.registerPlayer("P4"));

QueueGroup group = new QueueGroup("multi", List.of("queue1", "queue2", "queue3"), List.of("main"), List.of(), List.of());

Expand Down Expand Up @@ -157,7 +157,7 @@ void leastPlayersTreatsOfflineServerAsFullest() {

// Only register queue2, so queue1 and queue3 are "offline" (not found)
TestServer queue2 = plugin.registerServer("queue2");
queue2.getConnectedPlayers().add(plugin.registerPlayer("P1"));
queue2.addConnectedPlayer(plugin.registerPlayer("P1"));

QueueGroup group = new QueueGroup("multi", List.of("queue1", "queue2", "queue3"), List.of("main"), List.of(), List.of());

Expand Down Expand Up @@ -216,7 +216,7 @@ void selectsCorrectlyAfterStrategyChange() {

TestServer queue1 = plugin.registerServer("queue1");
plugin.registerServer("queue2"); // Register queue2 but we don't need to reference it
queue1.getConnectedPlayers().add(plugin.registerPlayer("P1"));
queue1.addConnectedPlayer(plugin.registerPlayer("P1"));

QueueGroup group = new QueueGroup("multi", List.of("queue1", "queue2"), List.of("main"), List.of(), List.of());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package net.pistonmaster.pistonqueue.shared.queue.logic;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.pistonmaster.pistonqueue.shared.chat.MessageType;
import net.pistonmaster.pistonqueue.shared.config.Config;
import net.pistonmaster.pistonqueue.shared.events.PQKickedFromServerEvent;
Expand Down Expand Up @@ -211,6 +212,7 @@ public Path getDataDirectory() {
}

@Override
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Tests share mutable configuration to exercise reloads.")
public Config getConfiguration() {
return config;
}
Expand Down Expand Up @@ -328,7 +330,11 @@ static final class TestServer implements ServerInfoWrapper {

@Override
public List<PlayerWrapper> getConnectedPlayers() {
return connectedPlayers;
return List.copyOf(connectedPlayers);
}

void addConnectedPlayer(PlayerWrapper player) {
connectedPlayers.add(player);
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions velocity/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("pq.platform-conventions")
id("xyz.jpenilla.run-velocity") version "3.0.2"
id("xyz.jpenilla.run-velocity") version "3.1.0"
}

java {
Expand All @@ -16,8 +16,8 @@ dependencies {
implementation("net.pistonmaster:PistonUtils:1.4.0")
implementation("org.bstats:bstats-velocity:3.2.1")

compileOnly("com.velocitypowered:velocity-api:4.0.0")
compileOnly("com.github.spotbugs:spotbugs-annotations:4.9.8")
compileOnly("com.velocitypowered:velocity-api:4.2.0")
compileOnly("com.github.spotbugs:spotbugs-annotations:4.10.4")
}

tasks {
Expand Down
Loading