From ae86d923abb61277cf9c93e3628a9c33ed60f7bb Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sun, 26 Nov 2023 01:19:40 +0100 Subject: [PATCH] Added old version to ChangeProtocolVersionCallback --- .../viafabricplus/event/ChangeProtocolVersionCallback.java | 6 +++--- .../viafabricplus/protocolhack/ProtocolHack.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java b/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java index ff8963336..3ab5dd92d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java +++ b/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java @@ -29,11 +29,11 @@ */ public interface ChangeProtocolVersionCallback { - Event EVENT = EventFactory.createArrayBacked(ChangeProtocolVersionCallback.class, listeners -> version -> { + Event EVENT = EventFactory.createArrayBacked(ChangeProtocolVersionCallback.class, listeners -> (oldVersion, newVersion) -> { for (ChangeProtocolVersionCallback listener : listeners) { - listener.onChangeProtocolVersion(version); + listener.onChangeProtocolVersion(oldVersion, newVersion); } }); - void onChangeProtocolVersion(final VersionEnum protocolVersion); + void onChangeProtocolVersion(final VersionEnum oldVersion, final VersionEnum newVersion); } diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java index ec3972c16..c67c4d745 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java @@ -140,7 +140,9 @@ public static void setTargetVersion(VersionEnum newVersion) { final VersionEnum oldVersion = targetVersion; targetVersion = newVersion; - if (oldVersion != newVersion) ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(targetVersion); + if (oldVersion != newVersion) { + ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(oldVersion, targetVersion); + } } /**