Initial API changes

This commit is contained in:
Tim203 2022-08-09 20:06:53 +02:00
parent 9412458f4a
commit 80588a07bd
No known key found for this signature in database
GPG key ID: 064EE9F5BF7C3EE8
18 changed files with 87 additions and 50 deletions

View file

@ -1 +1,5 @@
provided("net.kyori", "event-api", Versions.eventVersion)
dependencies {
api("org.geysermc.cumulus", "cumulus", Versions.cumulusVersion)
}
provided("net.kyori", "event-api", Versions.eventVersion)

View file

@ -25,9 +25,12 @@
package org.geysermc.api;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.api.connection.Connection;
import org.geysermc.cumulus.form.Form;
import org.geysermc.cumulus.form.util.FormBuilder;
import java.util.List;
import java.util.UUID;
@ -37,52 +40,65 @@ import java.util.UUID;
*/
public interface GeyserApiBase {
/**
* Gets the session from the given UUID, if applicable. The player must be logged in to the Java server
* Gets the connection from the given UUID, if applicable. The player must be logged in to the Java server
* for this to return a non-null value.
*
* @param uuid the UUID of the session
* @return the session from the given UUID, if applicable
* @param uuid the UUID of the connection
* @return the connection from the given UUID, if applicable
*/
@Nullable
Connection connectionByUuid(@NonNull UUID uuid);
/**
* Gets the session from the given
* XUID, if applicable.
* Gets the connection from the given XUID, if applicable. This method only works for online connections.
*
* @param xuid the XUID of the session
* @return the session from the given UUID, if applicable
* @return the connection from the given UUID, if applicable
*/
@Nullable
Connection connectionByXuid(@NonNull String xuid);
/**
* Gets the session from the given
* name, if applicable.
* Method to determine if the given <b>online</b> player is a Bedrock player.
*
* @param name the uuid of the session
* @return the session from the given name, if applicable
* @param uuid the uuid of the online player
* @return true if the given online player is a Bedrock player
*/
@Nullable
Connection connectionByName(@NonNull String name);
boolean isBedrockPlayer(@NonNull UUID uuid);
boolean sendForm(UUID uuid, Form form);
boolean sendForm(UUID uuid, FormBuilder<?, ?, ?> formBuilder);
boolean transfer(UUID uuid, String address, int port);
/**
* Gets all the online sessions.
*
* @return all the online sessions
* Returns all the online connections.
*/
@NonNull
List<? extends Connection> onlineConnections();
/**
* @return the major API version. Bumped whenever a significant breaking change or feature addition is added.
* Returns the amount of online connections.
*/
int onlineConnectionsCount();
/**
* Returns the prefix used by Floodgate. Will be null when the auth-type isn't Floodgate.
*/
@MonotonicNonNull
String usernamePrefix();
/**
* Returns the major API version. Bumped whenever a significant breaking change or feature addition is added.
*/
default int majorApiVersion() {
return 1;
}
/**
* @return the minor API version. May be bumped for new API additions.
* Returns the minor API version. May be bumped for new API additions.
*/
default int minorApiVersion() {
return 0;

View file

@ -25,6 +25,7 @@
package org.geysermc.api.connection;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.common.value.qual.IntRange;
@ -33,27 +34,37 @@ import java.util.UUID;
/**
* Represents a player connection.
*/
@NonNull
public interface Connection {
/**
* Gets the name of the connection.
* Gets the bedrock name of the connection.
*
* @return the name of the connection
* @return the bedrock name of the connection
*/
String name();
@NonNull
String bedrockUsername();
/**
* Gets the java name of the connection.
*
* @return the java name of the connection
*/
@MonotonicNonNull
String javaUsername();
/**
* Gets the {@link UUID} of the connection.
*
* @return the UUID of the connection
*/
UUID uuid();
@MonotonicNonNull
UUID javaUuid();
/**
* Gets the XUID of the connection.
*
* @return the XUID of the connection
*/
@NonNull
String xuid();
/**

View file

@ -59,7 +59,7 @@ public interface GeyserApi extends GeyserApiBase {
* {@inheritDoc}
*/
@Override
@Nullable GeyserConnection connectionByName(@NonNull String name);
@Nullable GeyserConnection connectionByUsername(@NonNull String username);
/**
* {@inheritDoc}