3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00

Expose PacketTypesProvider in Protocol

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-02-24 10:07:25 +01:00
Ursprung a6e1cb6534
Commit 5cad29c754
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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.
*