Package com.viaversion.viaversion.api
Interface ViaAPI<T>
- Type Parameters:
T- player type for the specific platform
public interface ViaAPI<T>
General api point. For more specialized api methods, see
Via.getManager().-
Method Summary
Modifier and TypeMethodDescriptiondefault intReturns an internally based API version incremented with meaningful API changes.@Nullable UserConnectiongetConnection(UUID uuid) Returns the injected UserConnection if present.Returns the supported protocol versions, including blocked protocols.Deprecated.getPlayerProtocolVersion(UUID uuid) Returns the protocol version of a player.getPlayerProtocolVersion(T player) Returns the protocol version of a player.default intgetPlayerVersion(UUID uuid) Returns the protocol version of a player.default intgetPlayerVersion(T player) Returns the protocol version of a player.Returns the server's protocol version info.Returns the supported protocol versions.Deprecated.Returns the version of the plugin.booleanisInjected(UUID uuid) Returns whether Via injected into this player connection.Returns legacy api only applicable on/to legacy versions.default intReturns the major version matchinggetVersion().voidsendRawPacket(UUID uuid, io.netty.buffer.ByteBuf packet) Sends a raw packet to the player.voidsendRawPacket(T player, io.netty.buffer.ByteBuf packet) Sends a raw packet to the player.
-
Method Details
-
majorVersion
default int majorVersion()Returns the major version matchinggetVersion(). It is highly advised to check against the major version and to disable/not initiate any hooks into ViaVersion if given and expected versions do not match.- Returns:
- major plugin version
- Since:
- 4.0.2
-
apiVersion
default int apiVersion()Returns an internally based API version incremented with meaningful API changes. This includes breaking changes to existing API and larger additions.- Returns:
- API version incremented with meaningful API changes
-
getServerVersion
ServerProtocolVersion getServerVersion()Returns the server's protocol version info.- Returns:
- the server's protocol version info
-
getPlayerVersion
Returns the protocol version of a player.- Parameters:
player- the platform's player object, e.g. Bukkit this is Player- Returns:
- protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if no longer connected
-
getPlayerProtocolVersion
Returns the protocol version of a player.- Parameters:
player- the platform's player object, e.g. Bukkit this is Player- Returns:
- the protocol version object (see
ProtocolVersion), or ProtocolVersion.unknown if not connected
-
getPlayerVersion
Returns the protocol version of a player.- Parameters:
uuid- UUID of a player- Returns:
- protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if not connected
-
getPlayerProtocolVersion
Returns the protocol version of a player.- Parameters:
uuid- UUID of a player- Returns:
- the protocol version object (see
ProtocolVersion), or ProtocolVersion.unknown if not connected
-
isInjected
Returns whether Via injected into this player connection. Note that this method may not work on clientside implementations and is generally not recommended to be used. UseConnectionManagerinstead.- Parameters:
uuid- uuid of the player- Returns:
- whether Via has a cached a UserConnection for this player
-
getConnection
Returns the injected UserConnection if present. Note that this method may not work on clientside implementations and is generally not recommended to be used. UseConnectionManagerinstead.- Parameters:
uuid- uuid of the player- Returns:
- user connection if present
-
getVersion
String getVersion()Returns the version of the plugin.- Returns:
- plugin version
-
sendRawPacket
Sends a raw packet to the player.- Parameters:
player- the platform's player object, e.g. for Bukkit this is Playerpacket- the packet; you need a VarInt id, then the packet contents- Throws:
IllegalArgumentException- if the player is not injected by Via
-
sendRawPacket
Sends a raw packet to the player.- Parameters:
uuid- the uuid from the player to send packetpacket- the packet; you need a VarInt id, then the packet contents- Throws:
IllegalArgumentException- if the player is not injected by Via
-
getSupportedVersions
Deprecated. -
getFullSupportedVersions
Deprecated. -
getSupportedProtocolVersions
SortedSet<ProtocolVersion> getSupportedProtocolVersions()Returns the supported protocol versions. This method removes any blocked protocol versions.- Returns:
- a sorted set of protocol versions
- See Also:
-
getFullSupportedProtocolVersions
SortedSet<ProtocolVersion> getFullSupportedProtocolVersions()Returns the supported protocol versions, including blocked protocols.- Returns:
- a sorted set of protocol versions
-
legacyAPI
LegacyViaAPI<T> legacyAPI()Returns legacy api only applicable on/to legacy versions.These methods are safe to use and are unlikely to be removed, but it is important to be aware of their limited use.
- Returns:
- legacy api only applicable on/to legacy versions
-