Skip to content

Commit 2589432

Browse files
committed
Fix issue produced by velocity 216
1 parent 272013a commit 2589432

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<build.number>unknown</build.number>
2323
<bungeecord.version>1.17-R0.1-SNAPSHOT</bungeecord.version>
24-
<velocity.version>3.0.0</velocity.version>
24+
<velocity.version>3.1.0</velocity.version>
2525
<bytebuddy.version>1.11.13</bytebuddy.version>
2626
<data.version>2.2.4</data.version>
2727
</properties>

protocolize-velocity/src/main/java/dev/simplix/protocolize/velocity/providers/VelocityProtocolRegistrationProvider.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public final class VelocityProtocolRegistrationProvider implements ProtocolRegis
4444
private Constructor<StateRegistry.PacketMapping> packetMappingConstructor;
4545
private Field versionsField;
4646
private Field packetClassToIdField;
47+
private Field serverboundField;
48+
private Field clientboundField;
4749
private Method registerMethod;
4850

4951
{
@@ -56,6 +58,10 @@ public final class VelocityProtocolRegistrationProvider implements ProtocolRegis
5658
versionsField.setAccessible(true);
5759
packetClassToIdField = StateRegistry.PacketRegistry.ProtocolRegistry.class.getDeclaredField("packetClassToId");
5860
packetClassToIdField.setAccessible(true);
61+
clientboundField = StateRegistry.class.getDeclaredField("clientbound");
62+
clientboundField.setAccessible(true);
63+
serverboundField = StateRegistry.class.getDeclaredField("serverbound");
64+
serverboundField.setAccessible(true);
5965
} catch (Exception exception) {
6066
log.error("Exception occurred while initializing VelocityProtocolRegistrationProvider:", exception);
6167
}
@@ -77,7 +83,9 @@ public void registerPacket(List<ProtocolIdMapping> mappings, Protocol protocol,
7783
if (stateRegistry == null) {
7884
return;
7985
}
80-
StateRegistry.PacketRegistry registry = direction == PacketDirection.SERVERBOUND ? stateRegistry.serverbound : stateRegistry.clientbound;
86+
StateRegistry.PacketRegistry registry = direction == PacketDirection.SERVERBOUND ?
87+
(StateRegistry.PacketRegistry) serverboundField.get(stateRegistry) :
88+
(StateRegistry.PacketRegistry) clientboundField.get(stateRegistry);
8189
Class<? extends MinecraftPacket> velocityPacket = generateVelocityPacket(packetClass);
8290
List<StateRegistry.PacketMapping> velocityMappings = new ArrayList<>();
8391

0 commit comments

Comments
 (0)