Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Add even more Javadoc.
Dieser Commit ist enthalten in:
Ursprung
6ccf16cee4
Commit
87ffb1ac2f
@ -8,7 +8,15 @@ import com.velocitypowered.api.server.ServerInfo;
|
|||||||
* Represents a connection to a backend server from the proxy for a client.
|
* Represents a connection to a backend server from the proxy for a client.
|
||||||
*/
|
*/
|
||||||
public interface ServerConnection extends ChannelMessageSource, ChannelMessageSink {
|
public interface ServerConnection extends ChannelMessageSource, ChannelMessageSink {
|
||||||
|
/**
|
||||||
|
* Returns the server that this connection is connected to.
|
||||||
|
* @return the server this connection is connected to
|
||||||
|
*/
|
||||||
ServerInfo getServerInfo();
|
ServerInfo getServerInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player that this connection is associated with.
|
||||||
|
* @return the player for this connection
|
||||||
|
*/
|
||||||
Player getPlayer();
|
Player getPlayer();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
package com.velocitypowered.api.proxy.messages;
|
package com.velocitypowered.api.proxy.messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents something that can send plugin messages.
|
||||||
|
*/
|
||||||
public interface ChannelMessageSink {
|
public interface ChannelMessageSink {
|
||||||
|
/**
|
||||||
|
* Sends a plugin message to this target.
|
||||||
|
* @param identifier the channel identifier to send the message on
|
||||||
|
* @param data the data to send
|
||||||
|
*/
|
||||||
void sendPluginMessage(ChannelIdentifier identifier, byte[] data);
|
void sendPluginMessage(ChannelIdentifier identifier, byte[] data);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
package com.velocitypowered.api.proxy.messages;
|
package com.velocitypowered.api.proxy.messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A marker interface that indicates a source of plugin messages.
|
||||||
|
*/
|
||||||
public interface ChannelMessageSource {
|
public interface ChannelMessageSource {
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,16 @@ package com.velocitypowered.api.proxy.messages;
|
|||||||
* the client or the server.
|
* the client or the server.
|
||||||
*/
|
*/
|
||||||
public interface ChannelRegistrar {
|
public interface ChannelRegistrar {
|
||||||
|
/**
|
||||||
|
* Registers the specified message handler to listen for plugin messages on the specified channels.
|
||||||
|
* @param handler the handler to register
|
||||||
|
* @param identifiers the channel identifiers to register
|
||||||
|
*/
|
||||||
void register(MessageHandler handler, ChannelIdentifier... identifiers);
|
void register(MessageHandler handler, ChannelIdentifier... identifiers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters the handler for the specified channel.
|
||||||
|
* @param identifiers the identifiers to unregister
|
||||||
|
*/
|
||||||
void unregister(ChannelIdentifier... identifiers);
|
void unregister(ChannelIdentifier... identifiers);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
package com.velocitypowered.api.proxy.messages;
|
package com.velocitypowered.api.proxy.messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents from "which side" of the proxy the plugin message came from.
|
||||||
|
*/
|
||||||
public enum ChannelSide {
|
public enum ChannelSide {
|
||||||
|
/**
|
||||||
|
* The plugin message came from a server that a client was connected to.
|
||||||
|
*/
|
||||||
FROM_SERVER,
|
FROM_SERVER,
|
||||||
|
/**
|
||||||
|
* The plugin message came from the client.
|
||||||
|
*/
|
||||||
FROM_CLIENT
|
FROM_CLIENT
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,28 @@
|
|||||||
package com.velocitypowered.api.proxy.messages;
|
package com.velocitypowered.api.proxy.messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a handler for handling plugin messages.
|
||||||
|
*/
|
||||||
public interface MessageHandler {
|
public interface MessageHandler {
|
||||||
|
/**
|
||||||
|
* Handles an incoming plugin message.
|
||||||
|
* @param source the source of the plugin message
|
||||||
|
* @param side from where the plugin message originated
|
||||||
|
* @param identifier the channel on which the message was sent
|
||||||
|
* @param data the data inside the plugin message
|
||||||
|
* @return a {@link ForwardStatus} indicating whether or not to forward this plugin message on
|
||||||
|
*/
|
||||||
ForwardStatus handle(ChannelMessageSource source, ChannelSide side, ChannelIdentifier identifier, byte[] data);
|
ForwardStatus handle(ChannelMessageSource source, ChannelSide side, ChannelIdentifier identifier, byte[] data);
|
||||||
|
|
||||||
enum ForwardStatus {
|
enum ForwardStatus {
|
||||||
|
/**
|
||||||
|
* Forwards this plugin message on to the client or server, depending on the {@link ChannelSide} it originated
|
||||||
|
* from.
|
||||||
|
*/
|
||||||
FORWARD,
|
FORWARD,
|
||||||
|
/**
|
||||||
|
* Discard the plugin message and do not forward it on.
|
||||||
|
*/
|
||||||
HANDLED
|
HANDLED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,22 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an identifier in the default namespace ({@code minecraft}). Plugins are strongly encouraged to provide
|
||||||
|
* their own namespace.
|
||||||
|
* @param name the name in the default namespace to use
|
||||||
|
* @return a new channel identifier
|
||||||
|
*/
|
||||||
public static MinecraftChannelIdentifier forDefaultNamespace(String name) {
|
public static MinecraftChannelIdentifier forDefaultNamespace(String name) {
|
||||||
return new MinecraftChannelIdentifier("minecraft", name);
|
return new MinecraftChannelIdentifier("minecraft", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an identifier in the specified namespace.
|
||||||
|
* @param namespace the namespace to use
|
||||||
|
* @param name the channel name inside the specified namespace
|
||||||
|
* @return a new channel identifier
|
||||||
|
*/
|
||||||
public static MinecraftChannelIdentifier create(String namespace, String name) {
|
public static MinecraftChannelIdentifier create(String namespace, String name) {
|
||||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(namespace), "namespace is null or empty");
|
Preconditions.checkArgument(!Strings.isNullOrEmpty(namespace), "namespace is null or empty");
|
||||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "namespace is null or empty");
|
Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "namespace is null or empty");
|
||||||
|
@ -4,9 +4,21 @@ package com.velocitypowered.api.scheduler;
|
|||||||
* Represents a task that is scheduled to run on the proxy.
|
* Represents a task that is scheduled to run on the proxy.
|
||||||
*/
|
*/
|
||||||
public interface ScheduledTask {
|
public interface ScheduledTask {
|
||||||
|
/**
|
||||||
|
* Returns the plugin that scheduled this task.
|
||||||
|
* @return the plugin that scheduled this task
|
||||||
|
*/
|
||||||
Object plugin();
|
Object plugin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current status of this task.
|
||||||
|
* @return the current status of this task
|
||||||
|
*/
|
||||||
TaskStatus status();
|
TaskStatus status();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels this task. If the task is already running, the thread in which it is running will be interrupted.
|
||||||
|
* If the task is not currently running, Velocity will terminate it safely.
|
||||||
|
*/
|
||||||
void cancel();
|
void cancel();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
package com.velocitypowered.api.scheduler;
|
package com.velocitypowered.api.scheduler;
|
||||||
|
|
||||||
public enum TaskStatus {
|
public enum TaskStatus {
|
||||||
|
/**
|
||||||
|
* The task is scheduled and is currently running.
|
||||||
|
*/
|
||||||
SCHEDULED,
|
SCHEDULED,
|
||||||
|
/**
|
||||||
|
* The task was cancelled with {@link ScheduledTask#cancel()}.
|
||||||
|
*/
|
||||||
CANCELLED,
|
CANCELLED,
|
||||||
|
/**
|
||||||
|
* The task has run to completion. This is applicable only for tasks without a repeat.
|
||||||
|
*/
|
||||||
FINISHED
|
FINISHED
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,17 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a Mojang game profile.
|
||||||
|
*/
|
||||||
public class GameProfile {
|
public class GameProfile {
|
||||||
private final String id;
|
private final String id;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final List<Property> properties;
|
private final List<Property> properties;
|
||||||
|
|
||||||
public GameProfile(@NonNull String id, @NonNull String name, @NonNull List<Property> properties) {
|
public GameProfile(@NonNull String id, @NonNull String name, @NonNull List<Property> properties) {
|
||||||
this.id = id;
|
this.id = Preconditions.checkNotNull(id, "id");
|
||||||
this.name = name;
|
this.name = Preconditions.checkNotNull(name, "name");
|
||||||
this.properties = ImmutableList.copyOf(properties);
|
this.properties = ImmutableList.copyOf(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +34,7 @@ public class GameProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Property> getProperties() {
|
public List<Property> getProperties() {
|
||||||
return ImmutableList.copyOf(properties);
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameProfile forOfflinePlayer(@NonNull String username) {
|
public static GameProfile forOfflinePlayer(@NonNull String username) {
|
||||||
@ -55,9 +58,9 @@ public class GameProfile {
|
|||||||
private final String signature;
|
private final String signature;
|
||||||
|
|
||||||
public Property(@NonNull String name, @NonNull String value, @NonNull String signature) {
|
public Property(@NonNull String name, @NonNull String value, @NonNull String signature) {
|
||||||
this.name = name;
|
this.name = Preconditions.checkNotNull(name, "name");
|
||||||
this.value = value;
|
this.value = Preconditions.checkNotNull(value, "value");
|
||||||
this.signature = signature;
|
this.signature = Preconditions.checkNotNull(signature, "signature");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren