@@ -36,6 +36,7 @@ public class BukkitPluginMessageSender extends AbstractBukkitPluginMessageSender
3636 private boolean useMinecraftKey ;
3737 private boolean usePacketPayload ;
3838 private boolean useDiscardedPayload ;
39+ private boolean useDiscardedPayloadByteArray ;
3940
4041 public BukkitPluginMessageSender (AbstractBukkitBadlionPlugin apiBukkit ) {
4142 this .apiBukkit = apiBukkit ;
@@ -159,6 +160,12 @@ public BukkitPluginMessageSender(AbstractBukkitBadlionPlugin apiBukkit) {
159160
160161 if (this .discardedPayloadConstructor != null ) {
161162 this .useDiscardedPayload = true ;
163+ } else {
164+ this .discardedPayloadConstructor = this .getConstructor (discardedPayloadClass , this .minecraftKeyClass , byte [].class );
165+
166+ if (this .discardedPayloadConstructor != null ) {
167+ this .useDiscardedPayloadByteArray = true ;
168+ }
162169 }
163170 }
164171
@@ -267,6 +274,12 @@ public void sendPluginMessagePacket(Player player, String channel, Object data)
267274 this .wrappedBufferMethod .invoke (null , data )
268275 );
269276 }
277+ } else if (this .useDiscardedPayloadByteArray ) {
278+ // 1.21+
279+ payload = this .discardedPayloadConstructor .newInstance (
280+ this .resourceLocationParseMethod .invoke (null , channel ),
281+ data
282+ );
270283 } else {
271284 // 1.20.2 - 1.20.4
272285 payload = Proxy .newProxyInstance (this .getClass ().getClassLoader (), new Class []{this .customPacketPayloadClass }, (proxy , method , args ) -> {
0 commit comments