3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

Hold the rest of the primitive Type instances under their actual class

This brings no improvement now, but if primitive read/write methods for manual calls were implemented later, a signature break will have been prevented by this (aka breaking it now)
Dieser Commit ist enthalten in:
KennyTV 2021-04-28 21:12:19 +02:00
Ursprung 00746833ac
Commit 9e59ef4c4a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 32 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -23,11 +23,13 @@
package com.viaversion.viaversion.api;
import com.viaversion.viaversion.api.connection.ConnectionManager;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.legacy.LegacyViaAPI;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.api.protocol.ProtocolManager;
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.SortedSet;
import java.util.UUID;
@ -35,7 +37,7 @@ import java.util.UUID;
/**
* General api point. For more specialized api methods, see {@link Via#getManager()}.
*
* @param <T> The player type for the specific platform, for bukkit it's {@code ViaAPI<Player>}
* @param <T> player type for the specific platform
* @see ViaManager
* @see ProtocolManager
* @see ConnectionManager
@ -51,7 +53,7 @@ public interface ViaAPI<T> {
ServerProtocolVersion getServerVersion();
/**
* Returns the protocol version from a player.
* Returns the protocol version of a player.
* This will also retrieve the version from ProtocolSupport if it's being used.
*
* @param player the platform's player object, e.g. Bukkit this is Player
@ -60,7 +62,7 @@ public interface ViaAPI<T> {
int getPlayerVersion(T player);
/**
* Returns the protocol version from a player.
* Returns the protocol version of a player.
*
* @param uuid UUID of a player
* @return protocol version, for example (47=1.8-1.8.8, 107=1.9, 108=1.9.1), or -1 if not connected
@ -68,12 +70,20 @@ public interface ViaAPI<T> {
int getPlayerVersion(UUID uuid);
/**
* Returns if Via injected into this player connection.
* Returns whether Via injected into this player connection.
*
* @param playerUUID UUID of a player
* @return true if Via has a cached UserConnection for this player
* @param uuid uuid of the player
* @return whether Via has a cached a UserConnection for this player
*/
boolean isInjected(UUID playerUUID);
boolean isInjected(UUID uuid);
/**
* Returns the Via injected UserConnection if present.
*
* @param uuid uuid of the player
* @return user connection if present
*/
@Nullable UserConnection getConnection(UUID uuid);
/**
* Returns the version of the plugin.

Datei anzeigen

@ -77,7 +77,7 @@ import java.util.UUID;
public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
/* Defined Types */
public static final Type<Byte> BYTE = new ByteType();
public static final ByteType BYTE = new ByteType();
/**
* @deprecated unreasonable overhead, use BYTE_ARRAY_PRIMITIVE
*/
@ -87,21 +87,21 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
public static final Type<byte[]> SHORT_BYTE_ARRAY = new ShortByteArrayType();
public static final Type<byte[]> REMAINING_BYTES = new RemainingBytesType();
public static final Type<Short> UNSIGNED_BYTE = new UnsignedByteType();
public static final UnsignedByteType UNSIGNED_BYTE = new UnsignedByteType();
/**
* @deprecated unreasonable overhead
*/
@Deprecated
public static final Type<Short[]> UNSIGNED_BYTE_ARRAY = new ArrayType<>(Type.UNSIGNED_BYTE);
public static final Type<Boolean> BOOLEAN = new BooleanType();
public static final BooleanType BOOLEAN = new BooleanType();
/**
* @deprecated unreasonable overhead
*/
@Deprecated
public static final Type<Boolean[]> BOOLEAN_ARRAY = new ArrayType<>(Type.BOOLEAN);
/* Number Types */
public static final Type<Integer> INT = new IntType();
public static final IntType INT = new IntType();
/**
* @deprecated unreasonable overhead
*/
@ -137,7 +137,7 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
@Deprecated
public static final Type<Short[]> SHORT_ARRAY = new ArrayType<>(Type.SHORT);
public static final Type<Integer> UNSIGNED_SHORT = new UnsignedShortType();
public static final UnsignedShortType UNSIGNED_SHORT = new UnsignedShortType();
/**
* @deprecated unreasonable overhead
*/
@ -159,7 +159,7 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
@Deprecated
public static final Type<Integer[]> VAR_INT_ARRAY = new ArrayType<>(Type.VAR_INT);
public static final Type<int[]> VAR_INT_ARRAY_PRIMITIVE = new VarIntArrayType();
public static final Type<Integer> OPTIONAL_VAR_INT = new OptionalVarIntType();
public static final OptionalVarIntType OPTIONAL_VAR_INT = new OptionalVarIntType();
public static final VarLongType VAR_LONG = new VarLongType();
/**
* @deprecated unreasonable overhead
@ -167,7 +167,7 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
@Deprecated
public static final Type<Long[]> VAR_LONG_ARRAY = new ArrayType<>(Type.VAR_LONG);
/* Special Types */
public static final Type<Void> NOTHING = new VoidType(); // This is purely used for remapping.
public static final VoidType NOTHING = new VoidType(); // This is purely used for remapping.
/* MC Types */
public static final Type<Position> POSITION = new PositionType();
public static final Type<Position> POSITION1_14 = new Position1_14Type();

Datei anzeigen

@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.legacy.LegacyViaAPI;
import com.viaversion.viaversion.api.protocol.version.ServerProtocolVersion;
import com.viaversion.viaversion.legacy.LegacyAPI;
import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.SortedSet;
import java.util.TreeSet;
@ -50,8 +51,13 @@ public abstract class ViaAPIBase<T> implements ViaAPI<T> {
}
@Override
public boolean isInjected(UUID playerUUID) {
return Via.getManager().getConnectionManager().isClientConnected(playerUUID);
public boolean isInjected(UUID uuid) {
return Via.getManager().getConnectionManager().isClientConnected(uuid);
}
@Override
public @Nullable UserConnection getConnection(final UUID uuid) {
return Via.getManager().getConnectionManager().getConnectedClient(uuid);
}
@Override