Skip to content

Commit 41bd8c3

Browse files
committed
Update actions and gradle
1 parent 7d69fa6 commit 41bd8c3

File tree

7 files changed

+42
-35
lines changed

7 files changed

+42
-35
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v3.0.0
16+
uses: actions/checkout@v4.2.2
1717
- name: Set up JDK
18-
uses: actions/setup-java@v3.0.0
18+
uses: actions/setup-java@v4.7.0
1919
with:
2020
distribution: adopt
2121
java-version: 17
2222
- name: Build VelocityTools
2323
run: ./gradlew build
2424
- name: Upload VelocityTools
25-
uses: actions/upload-artifact@v3.0.0
25+
uses: actions/upload-artifact@v4.6.2
2626
with:
2727
name: VelocityTools
2828
path: "build/libs/*.jar"

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v3.0.0
12+
uses: actions/checkout@v4.2.2
1313
- name: Set up JDK
14-
uses: actions/setup-java@v3.0.0
14+
uses: actions/setup-java@v4.7.0
1515
with:
1616
distribution: adopt
1717
java-version: 17
1818
- name: Build VelocityTools
1919
run: ./gradlew build
2020
- name: Upload VelocityTools
21-
uses: actions/upload-artifact@v3.0.0
21+
uses: actions/upload-artifact@v4.6.2
2222
with:
2323
name: VelocityTools
2424
path: "build/libs/*.jar"

build.gradle

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins() {
22
id("java")
33

4-
id("com.github.johnrengelman.shadow").version("8.1.1")
4+
id("com.gradleup.shadow").version("8.3.6")
55

66
id("checkstyle")
7-
id("com.github.spotbugs").version("5.0.14")
7+
id("com.github.spotbugs").version("6.1.7")
88
id("org.cadixdev.licenser").version("0.6.1")
99

1010
id("com.github.gmazzo.buildconfig").version("4.1.2") // Kotlin :skull:
@@ -32,17 +32,12 @@ repositories() {
3232
name = "elytrium-repo"
3333
url = "https://maven.elytrium.net/repo/"
3434
}
35-
maven {
36-
name = "sonatype-oss-snapshots1"
37-
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
38-
}
3935
}
4036

4137
dependencies() {
4238
annotationProcessor("net.java.dev.jna:jna-platform:5.13.0")
43-
annotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:1.0.0")
4439

45-
compileOnly("com.github.spotbugs:spotbugs-annotations:4.7.3")
40+
compileOnly("com.github.spotbugs:spotbugs-annotations:4.9.3")
4641

4742
compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
4843
annotationProcessor("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/net/elytrium/velocitytools/VelocityTools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public VelocityTools(ProxyServer server, @DataDirectory Path dataDirectory, Logg
9292
try {
9393
Files.move(oldDataDirectory, dataDirectory);
9494
} catch (IOException e) {
95-
throw new RuntimeException(e);
95+
logger.error("Failed to migrate data from pre-1.2.0", e);
9696
}
9797
}
9898

src/main/java/net/elytrium/velocitytools/hooks/ChannelInitializerHook.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,42 @@
2222
import io.netty.channel.Channel;
2323
import io.netty.channel.ChannelInitializer;
2424
import io.netty.channel.ChannelPipeline;
25-
import java.lang.reflect.Method;
25+
import java.lang.invoke.MethodHandle;
26+
import java.lang.invoke.MethodHandles;
27+
import java.lang.invoke.MethodType;
2628
import net.elytrium.velocitytools.Settings;
2729
import org.jetbrains.annotations.NotNull;
2830

2931
public class ChannelInitializerHook extends ChannelInitializer<Channel> {
3032

31-
private final Method initChannel;
33+
private static final MethodHandle MH_initChannel;
34+
3235
private final ChannelInitializer<Channel> originalInitializer;
3336

3437
@SuppressFBWarnings("EI_EXPOSE_REP2")
3538
public ChannelInitializerHook(ChannelInitializer<Channel> originalInitializer) {
36-
try {
37-
this.initChannel = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class);
38-
this.initChannel.setAccessible(true);
39-
} catch (NoSuchMethodException e) {
40-
throw new RuntimeException(e);
41-
}
42-
4339
this.originalInitializer = originalInitializer;
4440
}
4541

4642
@Override
4743
protected void initChannel(@NotNull Channel channel) throws Exception {
48-
this.initChannel.invoke(this.originalInitializer, channel);
44+
try {
45+
MH_initChannel.invokeExact(this.originalInitializer, channel);
46+
} catch (Throwable e) {
47+
throw new Exception("failed to initialize channel", e);
48+
}
4949
ChannelPipeline pipeline = channel.pipeline();
5050
if (Settings.IMP.TOOLS.DISABLE_LEGACY_PING && pipeline.names().contains(Connections.LEGACY_PING_DECODER)) {
5151
pipeline.remove(Connections.LEGACY_PING_DECODER);
5252
}
5353
}
54+
55+
static {
56+
try {
57+
MH_initChannel = MethodHandles.privateLookupIn(ChannelInitializer.class, MethodHandles.lookup())
58+
.findVirtual(ChannelInitializer.class, "initChannel", MethodType.methodType(void.class, Channel.class));
59+
} catch (Throwable e) {
60+
throw new ExceptionInInitializerError(e);
61+
}
62+
}
5463
}

src/main/java/net/elytrium/velocitytools/listeners/ProtocolBlockerJoinListener.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
public class ProtocolBlockerJoinListener {
3737

38-
private final MethodHandle delegate;
38+
private static final MethodHandle MH_delegate;
39+
3940
private final boolean whitelist;
4041
private final List<Integer> protocolNumbers;
4142
private final List<ProtocolVersion> protocolVersions;
@@ -44,13 +45,6 @@ public class ProtocolBlockerJoinListener {
4445
private final Component kickReason;
4546

4647
public ProtocolBlockerJoinListener() {
47-
try {
48-
this.delegate = MethodHandles.privateLookupIn(LoginInboundConnection.class, MethodHandles.lookup())
49-
.findGetter(LoginInboundConnection.class, "delegate", InitialInboundConnection.class);
50-
} catch (NoSuchFieldException | IllegalAccessException e) {
51-
throw new RuntimeException(e);
52-
}
53-
5448
this.whitelist = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.WHITELIST;
5549
this.protocolNumbers = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.PROTOCOLS;
5650
this.protocolVersions = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.VERSIONS.stream()
@@ -64,7 +58,7 @@ public ProtocolBlockerJoinListener() {
6458
@Subscribe
6559
public void onJoin(PreLoginEvent event) {
6660
try {
67-
InitialInboundConnection inbound = (InitialInboundConnection) this.delegate.invoke(event.getConnection());
61+
InitialInboundConnection inbound = (InitialInboundConnection) MH_delegate.invoke(event.getConnection());
6862

6963
inbound.getConnection().eventLoop().execute(() -> {
7064
ProtocolVersion playerProtocol = event.getConnection().getProtocolVersion();
@@ -79,4 +73,13 @@ public void onJoin(PreLoginEvent event) {
7973
throw new ReflectionException(e);
8074
}
8175
}
76+
77+
static {
78+
try {
79+
MH_delegate = MethodHandles.privateLookupIn(LoginInboundConnection.class, MethodHandles.lookup())
80+
.findGetter(LoginInboundConnection.class, "delegate", InitialInboundConnection.class);
81+
} catch (NoSuchFieldException | IllegalAccessException e) {
82+
throw new RuntimeException(e);
83+
}
84+
}
8285
}

0 commit comments

Comments
 (0)