Skip to content
2 changes: 1 addition & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tasks {

val o = options as StandardJavadocDocletOptions
o.encoding = "UTF-8"
o.source = "17"
o.source = "21"

o.use()
o.links(
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ subprojects {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
}
}

Expand Down
20 changes: 10 additions & 10 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
configurate3 = "3.7.3"
configurate4 = "4.1.2"
flare = "2.0.1"
log4j = "2.24.3"
netty = "4.2.5.Final"
log4j = "2.25.2"
netty = "4.2.6.Final"

[plugins]
fill = "io.papermc.fill.gradle:1.0.3"
indra-publishing = "net.kyori.indra.publishing:2.0.6"
shadow = "com.gradleup.shadow:8.3.6"
shadow = "com.gradleup.shadow:9.1.0"
spotless = "com.diffplug.spotless:6.25.0"

[libraries]
adventure-bom = "net.kyori:adventure-bom:4.24.0"
adventure-text-serializer-json-legacy-impl = "net.kyori:adventure-text-serializer-json-legacy-impl:4.24.0"
adventure-facet = "net.kyori:adventure-platform-facet:4.3.4"
adventure-facet = "net.kyori:adventure-platform-facet:4.4.1"
asm = "org.ow2.asm:asm:9.8"
auto-service = "com.google.auto.service:auto-service:1.0.1"
auto-service-annotations = "com.google.auto.service:auto-service-annotations:1.0.1"
brigadier = "com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT"
bstats = "org.bstats:bstats-base:3.0.3"
caffeine = "com.github.ben-manes.caffeine:caffeine:3.1.8"
bstats = "org.bstats:bstats-base:3.1.0"
caffeine = "com.github.ben-manes.caffeine:caffeine:3.2.2"
checker-qual = "org.checkerframework:checker-qual:3.42.0"
checkstyle = "com.puppycrawl.tools:checkstyle:10.9.3"
completablefutures = "com.spotify:completable-futures:0.3.6"
Expand All @@ -34,13 +34,13 @@ disruptor = "com.lmax:disruptor:4.0.0"
fastutil = "it.unimi.dsi:fastutil:8.5.15"
flare-core = { module = "space.vectrix.flare:flare", version.ref = "flare" }
flare-fastutil = { module = "space.vectrix.flare:flare-fastutil", version.ref = "flare" }
jline = "org.jline:jline-terminal-jansi:3.30.2"
jline = "org.jline:jline-terminal-jansi:3.30.6"
jopt = "net.sf.jopt-simple:jopt-simple:5.0.4"
junit = "org.junit.jupiter:junit-jupiter:5.10.2"
jspecify = "org.jspecify:jspecify:0.3.0"
kyori-ansi = "net.kyori:ansi:1.1.1"
guava = "com.google.guava:guava:25.1-jre"
gson = "com.google.code.gson:gson:2.10.1"
guava = "com.google.guava:guava:33.3.1-jre"
gson = "com.google.code.gson:gson:2.11.0"
guice = "com.google.inject:guice:6.0.0"
lmbda = "org.lanternpowered:lmbda:2.0.0"
log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
Expand All @@ -56,7 +56,7 @@ netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
netty-transport-native-epoll = { module = "io.netty:netty-transport-native-epoll", version.ref = "netty" }
netty-transport-native-kqueue = { module = "io.netty:netty-transport-native-kqueue", version.ref = "netty" }
netty-transport-native-iouring = { module = "io.netty:netty-transport-native-io_uring", version.ref = "netty" }
nightconfig = "com.electronwill.night-config:toml:3.6.7"
nightconfig = "com.electronwill.night-config:toml:3.8.3"
slf4j = "org.slf4j:slf4j-api:2.0.17"
snakeyaml = "org.yaml:snakeyaml:1.33"
spotbugs-annotations = "com.github.spotbugs:spotbugs-annotations:4.7.3"
Expand Down
7 changes: 5 additions & 2 deletions proxy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {

application {
mainClass.set("com.velocitypowered.proxy.Velocity")
applicationDefaultJvmArgs += listOf("-Dvelocity.packet-decode-logging=true");
applicationDefaultJvmArgs += listOf("-Dvelocity.packet-decode-logging=true")
}

tasks {
Expand All @@ -28,6 +28,9 @@ tasks {

shadowJar {
transform(Log4j2PluginsCacheFileTransformer::class.java)
filesMatching("META-INF/org/apache/logging/log4j/core/config/plugins/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

// Exclude all the collection types we don"t intend to use
exclude("it/unimi/dsi/fastutil/booleans/**")
Expand Down Expand Up @@ -131,7 +134,6 @@ fill {
dependencies {
implementation(project(":velocity-api"))
implementation(project(":velocity-native"))
implementation(project(":velocity-proxy-log4j2-plugin"))

implementation(libs.bundles.log4j)
implementation(libs.kyori.ansi)
Expand Down Expand Up @@ -168,4 +170,5 @@ dependencies {
testImplementation(libs.mockito)

annotationProcessor(libs.auto.service)
annotationProcessor(libs.log4j.core)
}
4 changes: 0 additions & 4 deletions proxy/log4j2-plugin/build.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private ParseResults<S> parseHints(final CommandNode<S> node, final StringReader
return 0;
});
}
return potentials.get(0);
return potentials.getFirst();
}
return new ParseResults<>(contextSoFar, originalReader, Collections.emptyMap());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void register(final CommandMeta meta, final Command command) {
command + " implements multiple registrable Command subinterfaces: "
+ implementedInterfaces);
} else {
this.internalRegister(commandRegistrars.get(0), command, meta);
this.internalRegister(commandRegistrars.getFirst(), command, meta);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,34 @@ public static CommandNode<CommandSource> wrap(final CommandNode<CommandSource> d
maybeCommand = VelocityBrigadierCommandWrapper.wrap(delegate.getCommand(), registrant);
}

if (delegate instanceof LiteralCommandNode<CommandSource> lcn) {
var literalBuilder = shallowCopyAsBuilder(lcn, delegate.getName(), true);
literalBuilder.executes(maybeCommand);
// we also need to wrap any children
for (final CommandNode<CommandSource> child : delegate.getChildren()) {
literalBuilder.then(wrap(child, registrant));
return switch (delegate) {
case LiteralCommandNode<CommandSource> lcn -> {
var literalBuilder = shallowCopyAsBuilder(lcn, delegate.getName(), true);
literalBuilder.executes(maybeCommand);
// we also need to wrap any children
for (final CommandNode<CommandSource> child : delegate.getChildren()) {
literalBuilder.then(wrap(child, registrant));
}
if (delegate.getRedirect() != null) {
literalBuilder.redirect(wrap(delegate.getRedirect(), registrant));
}
yield literalBuilder.build();
}
if (delegate.getRedirect() != null) {
literalBuilder.redirect(wrap(delegate.getRedirect(), registrant));
case VelocityArgumentCommandNode<CommandSource, ?> vacn -> vacn.withCommand(maybeCommand)
.withRedirect(delegate.getRedirect() != null ? wrap(delegate.getRedirect(), registrant) : null);
case ArgumentCommandNode<CommandSource, ?> node -> {
var argBuilder = node.createBuilder().executes(maybeCommand);
// we also need to wrap any children
for (final CommandNode<CommandSource> child : delegate.getChildren()) {
argBuilder.then(wrap(child, registrant));
}
if (delegate.getRedirect() != null) {
argBuilder.redirect(wrap(delegate.getRedirect(), registrant));
}
yield argBuilder.build();
}
return literalBuilder.build();
} else if (delegate instanceof VelocityArgumentCommandNode<CommandSource, ?> vacn) {
return vacn.withCommand(maybeCommand)
.withRedirect(delegate.getRedirect() != null ? wrap(delegate.getRedirect(), registrant) : null);
} else if (delegate instanceof ArgumentCommandNode) {
var argBuilder = delegate.createBuilder().executes(maybeCommand);
// we also need to wrap any children
for (final CommandNode<CommandSource> child : delegate.getChildren()) {
argBuilder.then(wrap(child, registrant));
}
if (delegate.getRedirect() != null) {
argBuilder.redirect(wrap(delegate.getRedirect(), registrant));
}
return argBuilder.build();
} else {
throw new IllegalArgumentException("Unsupported node type: " + delegate.getClass());
}
default -> throw new IllegalArgumentException("Unsupported node type: " + delegate.getClass());
};
}

// Normalization
Expand Down Expand Up @@ -133,7 +134,7 @@ public static String readAlias(final List<? extends ParsedCommandNode<?>> nodes)
if (nodes.isEmpty()) {
throw new IllegalArgumentException("Cannot read alias from empty node list");
}
return nodes.get(0).getNode().getName();
return nodes.getFirst().getNode().getName();
}

public static final String ARGS_NODE_NAME = "arguments";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,12 @@ public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof VelocityArgumentCommandNode)) {
if (!(o instanceof VelocityArgumentCommandNode that)) {
return false;
}
if (!super.equals(o)) {
if (!super.equals(that)) {
return false;
}

final VelocityArgumentCommandNode<?, ?> that = (VelocityArgumentCommandNode<?, ?>) o;
return this.type.equals(that.type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private TextComponent componentForPlugin(PluginDescription description) {
hoverText.append(Component.newline());
if (description.getAuthors().size() == 1) {
hoverText.append(Component.translatable("velocity.command.plugin-tooltip-author",
Component.text(description.getAuthors().get(0))));
Component.text(description.getAuthors().getFirst())));
} else {
hoverText.append(
Component.translatable("velocity.command.plugin-tooltip-author",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,16 @@ public boolean validate() {
}

switch (playerInfoForwardingMode) {
case NONE:
logger.warn("Player info forwarding is disabled! All players will appear to be connecting "
case NONE -> logger.warn("Player info forwarding is disabled! All players will appear to be connecting "
+ "from the proxy and will have offline-mode UUIDs.");
break;
case MODERN:
case BUNGEEGUARD:
case MODERN, BUNGEEGUARD -> {
if (forwardingSecret == null || forwardingSecret.length == 0) {
logger.error("You don't have a forwarding secret set. This is required for security.");
valid = false;
}
break;
default:
break;
}
default -> {
}
}

if (servers.getServers().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception

if (msg instanceof MinecraftPacket pkt) {
if (!pkt.handle(activeSessionHandler)) {
activeSessionHandler.handleGeneric((MinecraftPacket) msg);
activeSessionHandler.handleGeneric(pkt);
}
} else if (msg instanceof HAProxyMessage proxyMessage) {
this.remoteAddress = new InetSocketAddress(proxyMessage.sourceAddress(),
proxyMessage.sourcePort());
} else if (msg instanceof ByteBuf) {
activeSessionHandler.handleUnknown((ByteBuf) msg);
} else if (msg instanceof ByteBuf buf) {
activeSessionHandler.handleUnknown(buf);
}
} finally {
ReferenceCountUtil.release(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ public boolean handle(ClientboundCookieRequestPacket packet) {

@Override
public void handleGeneric(MinecraftPacket packet) {
if (packet instanceof PluginMessagePacket) {
((PluginMessagePacket) packet).retain();
if (packet instanceof PluginMessagePacket pluginMessage) {
pluginMessage.retain();
}
playerConnection.delayedWrite(packet);
if (++packetsFlushed >= MAXIMUM_PACKETS_TO_FLUSH) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,66 +344,30 @@ boolean process(PluginMessagePacket message) {
return false;
}

ByteBufDataInput in = new ByteBufDataInput(message.content());
String subChannel = in.readUTF();
final ByteBufDataInput in = new ByteBufDataInput(message.content());
final String subChannel = in.readUTF();
switch (subChannel) {
case "GetPlayerServer":
this.processGetPlayerServer(in);
break;
case "ForwardToPlayer":
this.processForwardToPlayer(in);
break;
case "Forward":
this.processForwardToServer(in);
break;
case "Connect":
this.processConnect(in);
break;
case "ConnectOther":
this.processConnectOther(in);
break;
case "IP":
this.processIp(in);
break;
case "PlayerCount":
this.processPlayerCount(in);
break;
case "PlayerList":
this.processPlayerList(in);
break;
case "GetServers":
this.processGetServers();
break;
case "Message":
this.processMessage(in);
break;
case "MessageRaw":
this.processMessageRaw(in);
break;
case "GetServer":
this.processGetServer();
break;
case "UUID":
this.processUuid();
break;
case "UUIDOther":
this.processUuidOther(in);
break;
case "IPOther":
this.processIpOther(in);
break;
case "ServerIP":
this.processServerIp(in);
break;
case "KickPlayer":
this.processKick(in);
break;
case "KickPlayerRaw":
this.processKickRaw(in);
break;
default:
// Do nothing, unknown command
break;
case "GetPlayerServer" -> this.processGetPlayerServer(in);
case "ForwardToPlayer" -> this.processForwardToPlayer(in);
case "Forward" -> this.processForwardToServer(in);
case "Connect" -> this.processConnect(in);
case "ConnectOther" -> this.processConnectOther(in);
case "IP" -> this.processIp(in);
case "PlayerCount" -> this.processPlayerCount(in);
case "PlayerList" -> this.processPlayerList(in);
case "GetServers" -> this.processGetServers();
case "Message" -> this.processMessage(in);
case "MessageRaw" -> this.processMessageRaw(in);
case "GetServer" -> this.processGetServer();
case "UUID" -> this.processUuid();
case "UUIDOther" -> this.processUuidOther(in);
case "IPOther" -> this.processIpOther(in);
case "ServerIP" -> this.processServerIp(in);
case "KickPlayer" -> this.processKick(in);
case "KickPlayerRaw" -> this.processKickRaw(in);
default -> {
// Do nothing, unknown command
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ public boolean handle(JoinGamePacket packet) {
// Change the client to use the ClientPlaySessionHandler if required.
ClientPlaySessionHandler playHandler;
if (player.getConnection()
.getActiveSessionHandler() instanceof ClientPlaySessionHandler) {
playHandler =
(ClientPlaySessionHandler) player.getConnection().getActiveSessionHandler();
.getActiveSessionHandler() instanceof ClientPlaySessionHandler sessionHandler) {
playHandler = sessionHandler;
} else {
playHandler = new ClientPlaySessionHandler(server, player);
player.getConnection().setActiveSessionHandler(StateRegistry.PLAY, playHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ private void startHandshake() {
handshake.setServerAddress(createBungeeGuardForwardingAddress(secret));
} else if (proxyPlayer.getConnection().getType() == ConnectionTypes.LEGACY_FORGE) {
handshake.setServerAddress(playerVhost + HANDSHAKE_HOSTNAME_TOKEN);
} else if (proxyPlayer.getConnection().getType() instanceof ModernForgeConnectionType) {
handshake.setServerAddress(playerVhost + ((ModernForgeConnectionType) proxyPlayer
.getConnection().getType()).getModernToken());
} else if (proxyPlayer.getConnection().getType() instanceof ModernForgeConnectionType forgeConnection) {
handshake.setServerAddress(playerVhost + forgeConnection.getModernToken());
} else {
handshake.setServerAddress(playerVhost);
}
Expand Down
Loading