13
0
geforkt von Mirrors/Velocity

Add even more Javadoc.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-24 21:50:56 -04:00
Ursprung 6ccf16cee4
Commit 87ffb1ac2f
10 geänderte Dateien mit 97 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -8,7 +8,15 @@ import com.velocitypowered.api.server.ServerInfo;
* Represents a connection to a backend server from the proxy for a client.
*/
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();
/**
* Returns the player that this connection is associated with.
* @return the player for this connection
*/
Player getPlayer();
}

Datei anzeigen

@ -1,5 +1,13 @@
package com.velocitypowered.api.proxy.messages;
/**
* Represents something that can send plugin messages.
*/
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);
}

Datei anzeigen

@ -1,4 +1,7 @@
package com.velocitypowered.api.proxy.messages;
/**
* A marker interface that indicates a source of plugin messages.
*/
public interface ChannelMessageSource {
}

Datei anzeigen

@ -5,7 +5,16 @@ package com.velocitypowered.api.proxy.messages;
* the client or the server.
*/
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);
/**
* Unregisters the handler for the specified channel.
* @param identifiers the identifiers to unregister
*/
void unregister(ChannelIdentifier... identifiers);
}

Datei anzeigen

@ -1,6 +1,15 @@
package com.velocitypowered.api.proxy.messages;
/**
* Represents from "which side" of the proxy the plugin message came from.
*/
public enum ChannelSide {
/**
* The plugin message came from a server that a client was connected to.
*/
FROM_SERVER,
/**
* The plugin message came from the client.
*/
FROM_CLIENT
}

Datei anzeigen

@ -1,10 +1,28 @@
package com.velocitypowered.api.proxy.messages;
/**
* Represents a handler for handling plugin messages.
*/
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);
enum ForwardStatus {
/**
* Forwards this plugin message on to the client or server, depending on the {@link ChannelSide} it originated
* from.
*/
FORWARD,
/**
* Discard the plugin message and do not forward it on.
*/
HANDLED
}
}

Datei anzeigen

@ -20,10 +20,22 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
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) {
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) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(namespace), "namespace is null or empty");
Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "namespace is null or empty");

Datei anzeigen

@ -4,9 +4,21 @@ package com.velocitypowered.api.scheduler;
* Represents a task that is scheduled to run on the proxy.
*/
public interface ScheduledTask {
/**
* Returns the plugin that scheduled this task.
* @return the plugin that scheduled this task
*/
Object plugin();
/**
* Returns the current status of this task.
* @return the current status of this task
*/
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();
}

Datei anzeigen

@ -1,7 +1,16 @@
package com.velocitypowered.api.scheduler;
public enum TaskStatus {
/**
* The task is scheduled and is currently running.
*/
SCHEDULED,
/**
* The task was cancelled with {@link ScheduledTask#cancel()}.
*/
CANCELLED,
/**
* The task has run to completion. This is applicable only for tasks without a repeat.
*/
FINISHED
}

Datei anzeigen

@ -7,14 +7,17 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
import java.util.UUID;
/**
* Represents a Mojang game profile.
*/
public class GameProfile {
private final String id;
private final String name;
private final List<Property> properties;
public GameProfile(@NonNull String id, @NonNull String name, @NonNull List<Property> properties) {
this.id = id;
this.name = name;
this.id = Preconditions.checkNotNull(id, "id");
this.name = Preconditions.checkNotNull(name, "name");
this.properties = ImmutableList.copyOf(properties);
}
@ -31,7 +34,7 @@ public class GameProfile {
}
public List<Property> getProperties() {
return ImmutableList.copyOf(properties);
return properties;
}
public static GameProfile forOfflinePlayer(@NonNull String username) {
@ -55,9 +58,9 @@ public class GameProfile {
private final String signature;
public Property(@NonNull String name, @NonNull String value, @NonNull String signature) {
this.name = name;
this.value = value;
this.signature = signature;
this.name = Preconditions.checkNotNull(name, "name");
this.value = Preconditions.checkNotNull(value, "value");
this.signature = Preconditions.checkNotNull(signature, "signature");
}
public String getName() {