Restore reader index after processing custom payload
This commit is contained in:
parent
9a562e1e34
commit
d0108af1e6
|
@ -1684,7 +1684,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
|
||||||
private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register");
|
private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register");
|
||||||
private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister");
|
private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister");
|
||||||
|
|
||||||
@Inject(method = "processCustomPayload", at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/fml/network/NetworkHooks;onCustomPayload(Lnet/minecraftforge/fml/network/ICustomPacket;Lnet/minecraft/network/NetworkManager;)Z"))
|
@Inject(method = "processCustomPayload", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/fml/network/NetworkHooks;onCustomPayload(Lnet/minecraftforge/fml/network/ICustomPacket;Lnet/minecraft/network/NetworkManager;)Z"))
|
||||||
private void arclight$customPayload(CCustomPayloadPacket packet, CallbackInfo ci) {
|
private void arclight$customPayload(CCustomPayloadPacket packet, CallbackInfo ci) {
|
||||||
if (packet.channel.equals(CUSTOM_REGISTER)) {
|
if (packet.channel.equals(CUSTOM_REGISTER)) {
|
||||||
try {
|
try {
|
||||||
|
@ -1697,6 +1697,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOGGER.error("Couldn't register custom payload", ex);
|
LOGGER.error("Couldn't register custom payload", ex);
|
||||||
this.disconnect("Invalid payload REGISTER!");
|
this.disconnect("Invalid payload REGISTER!");
|
||||||
|
ci.cancel();
|
||||||
}
|
}
|
||||||
} else if (packet.channel.equals(CUSTOM_UNREGISTER)) {
|
} else if (packet.channel.equals(CUSTOM_UNREGISTER)) {
|
||||||
try {
|
try {
|
||||||
|
@ -1709,15 +1710,19 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOGGER.error("Couldn't unregister custom payload", ex);
|
LOGGER.error("Couldn't unregister custom payload", ex);
|
||||||
this.disconnect("Invalid payload UNREGISTER!");
|
this.disconnect("Invalid payload UNREGISTER!");
|
||||||
|
ci.cancel();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
int readerIndex = packet.data.readerIndex();
|
||||||
final byte[] data = new byte[packet.data.readableBytes()];
|
final byte[] data = new byte[packet.data.readableBytes()];
|
||||||
packet.data.readBytes(data);
|
packet.data.readBytes(data);
|
||||||
this.server.getMessenger().dispatchIncomingMessage(((ServerPlayerEntityBridge) this.player).bridge$getBukkitEntity(), packet.channel.toString(), data);
|
this.server.getMessenger().dispatchIncomingMessage(((ServerPlayerEntityBridge) this.player).bridge$getBukkitEntity(), packet.channel.toString(), data);
|
||||||
|
packet.data.readerIndex(readerIndex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOGGER.error("Couldn't dispatch custom payload", ex);
|
LOGGER.error("Couldn't dispatch custom payload", ex);
|
||||||
this.disconnect("Invalid custom payload!");
|
this.disconnect("Invalid custom payload!");
|
||||||
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user