From 9dd334851075a29f4ec9bd54e486a76d645800d4 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 24 Apr 2024 20:11:05 +0200 Subject: [PATCH] Move appendClientbound/Serverbound methods to Protocol interface --- .../com/viaversion/viaversion/api/ViaAPI.java | 2 +- .../api/protocol/AbstractProtocol.java | 2 ++ .../viaversion/api/protocol/Protocol.java | 27 +++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java index c69d01d20..d0bcb8c8b 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java +++ b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java @@ -66,7 +66,7 @@ public interface ViaAPI { * @return API version incremented with meaningful API changes */ default int apiVersion() { - return 25; + return 26; } /** diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java index a7cd7da21..8b7d929af 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/AbstractProtocol.java @@ -146,6 +146,7 @@ public abstract class AbstractProtocol + * Use {@link PacketWrapper#set(Type, int, Object)} to change individual parts, or call + * {@link PacketWrapper#resetReader()} to reset the reader index. + * + * @param type clientbound packet type + * @param handler packet handler + */ + void appendClientbound(CU type, PacketHandler handler); + + /** + * Appends a serverbound packet type handler with another, as opposed to replacing it entirely. + *

+ * Use {@link PacketWrapper#set(Type, int, Object)} to change individual parts, or call + * {@link PacketWrapper#resetReader()} to reset the reader index. + * + * @param type serverbound packet type + * @param handler packet handler + */ + void appendServerbound(SU type, PacketHandler handler); + /** * Transform a packet using this protocol * @@ -268,7 +290,8 @@ public interface Protocol T get(Class objectClass); + @Nullable + T get(Class objectClass); /** * Caches an object, retrievable by using {@link #get(Class)}.