mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 14:37:43 +01:00
Further API tweaks
This commit is contained in:
@@ -8,8 +8,18 @@
|
||||
package com.velocitypowered.api.network.registry;
|
||||
|
||||
import com.velocitypowered.api.network.PlatformVersion;
|
||||
import java.util.Collection;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ProtocolVersionRegistry {
|
||||
/**
|
||||
* Returns a collection of supported protocol versions for the given {@code platform}. The
|
||||
* collection is expected to be ordered and immutable.
|
||||
*
|
||||
* @param platform the platform to look up the versions for
|
||||
* @return an ordered, immutable collection of supported protocol versions
|
||||
*/
|
||||
Collection<PlatformVersion> supported(Platform platform);
|
||||
|
||||
@Nullable PlatformVersion lookup(Platform platform, int version);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.velocitypowered.api.plugin.PluginManager;
|
||||
import com.velocitypowered.api.proxy.config.ProxyConfig;
|
||||
import com.velocitypowered.api.proxy.connection.Player;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
|
||||
import com.velocitypowered.api.proxy.player.PlayerIdentity;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
import com.velocitypowered.api.scheduler.Scheduler;
|
||||
@@ -60,6 +61,16 @@ public interface ProxyServer extends Audience {
|
||||
*/
|
||||
@Nullable Player player(UUID uuid);
|
||||
|
||||
/**
|
||||
* Retrieves the player currently connected to this proxy by their identity.
|
||||
*
|
||||
* @param identity the identity
|
||||
* @return the player instance, if connected, else {@code null}
|
||||
*/
|
||||
@Nullable default Player player(PlayerIdentity identity) {
|
||||
return player(identity.uuid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all players currently connected to this proxy. This call may or may not be a snapshot
|
||||
* of all players online.
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.velocitypowered.api.proxy.messages.PluginChannelId;
|
||||
import com.velocitypowered.api.proxy.player.ConnectionRequestBuilder;
|
||||
import com.velocitypowered.api.proxy.player.PlatformActions;
|
||||
import com.velocitypowered.api.proxy.player.PlayerIdentity;
|
||||
import com.velocitypowered.api.proxy.player.TabList;
|
||||
import com.velocitypowered.api.proxy.player.java.TabList;
|
||||
import com.velocitypowered.api.proxy.player.java.JavaClientSettings;
|
||||
import com.velocitypowered.api.proxy.player.java.JavaPlayerIdentity;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
@@ -55,13 +55,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
*/
|
||||
@Nullable ServerConnection connectedServer();
|
||||
|
||||
/**
|
||||
* Returns the player's client settings.
|
||||
*
|
||||
* @return the settings
|
||||
*/
|
||||
JavaClientSettings clientSettings();
|
||||
|
||||
/**
|
||||
* Returns the player's mod info if they have a modded client.
|
||||
*
|
||||
@@ -91,13 +84,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
*/
|
||||
ConnectionRequestBuilder createConnectionRequest(RegisteredServer server);
|
||||
|
||||
/**
|
||||
* Sets the player's profile properties.
|
||||
*
|
||||
* @param properties the properties
|
||||
*/
|
||||
void setGameProfileProperties(List<JavaPlayerIdentity.Property> properties);
|
||||
|
||||
/**
|
||||
* Returns the player's identity, which depends on what version of Minecraft they are currently
|
||||
* playing.
|
||||
@@ -105,13 +91,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
@Override
|
||||
@NonNull PlayerIdentity identity();
|
||||
|
||||
/**
|
||||
* Returns the player's tab list.
|
||||
*
|
||||
* @return this player's tab list
|
||||
*/
|
||||
TabList tabList();
|
||||
|
||||
/**
|
||||
* Disconnects the player with the specified reason. Once this method is called, further calls to
|
||||
* other {@link Player} methods will become undefined.
|
||||
@@ -127,25 +106,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
*/
|
||||
void spoofChatInput(String input);
|
||||
|
||||
/**
|
||||
* Sends the specified resource pack from {@code url} to the user. If at all possible, send the
|
||||
* resource pack using {@link #sendResourcePack(String, byte[])}. To monitor the status of the
|
||||
* sent resource pack, subscribe to {@link PlayerResourcePackStatusEvent}.
|
||||
*
|
||||
* @param url the URL for the resource pack
|
||||
*/
|
||||
void sendResourcePack(String url);
|
||||
|
||||
/**
|
||||
* Sends the specified resource pack from {@code url} to the user, using the specified 20-byte
|
||||
* SHA-1 hash. To monitor the status of the sent resource pack, subscribe to
|
||||
* {@link PlayerResourcePackStatusEvent}.
|
||||
*
|
||||
* @param url the URL for the resource pack
|
||||
* @param hash the SHA-1 hash value for the resource pack
|
||||
*/
|
||||
void sendResourcePack(String url, byte[] hash);
|
||||
|
||||
/**
|
||||
* <strong>Note that this method does not send a plugin message to the server the player
|
||||
* is connected to.</strong> You should only use this method if you are trying to communicate
|
||||
|
||||
@@ -7,11 +7,58 @@
|
||||
|
||||
package com.velocitypowered.api.proxy.player;
|
||||
|
||||
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
|
||||
import com.velocitypowered.api.proxy.player.java.JavaClientSettings;
|
||||
import com.velocitypowered.api.proxy.player.java.JavaPlayerIdentity.Property;
|
||||
import com.velocitypowered.api.proxy.player.java.TabList;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Provides certain actions that may be implemented across platforms (or not at all). Similar to
|
||||
* Adventure's {@link net.kyori.adventure.audience.Audience}, methods that are not implemented for
|
||||
* a platform will silently fail.
|
||||
* a platform will silently fail or return no-op instances as appropriate.
|
||||
*/
|
||||
public interface PlatformActions {
|
||||
|
||||
/**
|
||||
* Sets the player's profile properties. This operation is not applicable to Bedrock Edition.
|
||||
*
|
||||
* @param properties the properties
|
||||
*/
|
||||
void setGameProfileProperties(List<Property> properties);
|
||||
|
||||
/**
|
||||
* Returns the player's client settings as sent by the client, for Java Edition clients only.
|
||||
*
|
||||
* @return the settings
|
||||
*/
|
||||
@Nullable JavaClientSettings clientSettings();
|
||||
|
||||
/**
|
||||
* Returns the player's tab list, if supported.
|
||||
*
|
||||
* @return this player's tab list
|
||||
*/
|
||||
TabList tabList();
|
||||
|
||||
/**
|
||||
* Sends the specified resource pack from {@code url} to the user, if supported. If possible,
|
||||
* send the resource pack using {@link #sendResourcePack(String, byte[])}. To monitor the status
|
||||
* of the sent resource pack, subscribe to {@link PlayerResourcePackStatusEvent}.
|
||||
*
|
||||
* @param url the URL for the resource pack
|
||||
*/
|
||||
void sendResourcePack(String url);
|
||||
|
||||
/**
|
||||
* Sends the specified resource pack from {@code url} to the user, if supported, and use the
|
||||
* 20-byte SHA-1 hash as an unique identifier for this resource oack. To monitor the status of
|
||||
* the sent resource pack, subscribe to {@link PlayerResourcePackStatusEvent}.
|
||||
*
|
||||
* @param url the URL for the resource pack
|
||||
* @param hash the SHA-1 hash value for the resource pack
|
||||
*/
|
||||
void sendResourcePack(String url, byte[] hash);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,17 +5,16 @@
|
||||
* reference the LICENSE file in the api top-level directory.
|
||||
*/
|
||||
|
||||
package com.velocitypowered.api.proxy.player;
|
||||
package com.velocitypowered.api.proxy.player.java;
|
||||
|
||||
import com.velocitypowered.api.proxy.connection.Player;
|
||||
import com.velocitypowered.api.proxy.player.java.JavaPlayerIdentity;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the tab list of a {@link Player}.
|
||||
* Represents the tab list of a {@link Player}, specifically for Java players only.
|
||||
*/
|
||||
public interface TabList {
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
* reference the LICENSE file in the api top-level directory.
|
||||
*/
|
||||
|
||||
package com.velocitypowered.api.proxy.player;
|
||||
package com.velocitypowered.api.proxy.player.java;
|
||||
|
||||
import com.velocitypowered.api.proxy.player.java.JavaPlayerIdentity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a single entry in a {@link TabList}.
|
||||
* Represents a single entry in a {@link TabList}, specifically for Java players only.
|
||||
*/
|
||||
public interface TabListEntry {
|
||||
|
||||
Reference in New Issue
Block a user