Expose PacketTypesProvider in Protocol

This commit is contained in:
Nassim Jahnke 2023-02-24 10:07:25 +01:00
parent a6e1cb6534
commit 5cad29c754
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 16 additions and 0 deletions

View File

@ -404,6 +404,11 @@ public abstract class AbstractProtocol<CU extends ClientboundPacketType, CM exte
}
}
@Override
public PacketTypesProvider<CU, CM, SM, SU> getPacketTypesProvider() {
return packetTypesProvider;
}
@Override
public @Nullable <T> T get(Class<T> objectClass) {
//noinspection unchecked

View File

@ -22,6 +22,7 @@
*/
package com.viaversion.viaversion.api.protocol;
import com.google.common.annotations.Beta;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
@ -30,6 +31,7 @@ import com.viaversion.viaversion.api.protocol.packet.Direction;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
@ -236,6 +238,15 @@ public interface Protocol<CU extends ClientboundPacketType, CM extends Clientbou
*/
void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception;
/**
* Returns a packet type provider for this protocol to get packet types by id.
* Depending on the Protocol, not every state may be populated.
*
* @return the packet types provider
*/
@Beta
PacketTypesProvider<CU, CM, SM, SU> getPacketTypesProvider();
/**
* Returns a cached object by the given type if present.
*