Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-24 15:20:25 +01:00
Remove generic usage in Api
Dieser Commit ist enthalten in:
Ursprung
83ddbd7d1a
Commit
5b415cea68
@ -34,10 +34,8 @@ import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The base API class.
|
||||
*
|
||||
* @param <S> the session type
|
||||
*/
|
||||
public interface Api<S extends Session> {
|
||||
public interface Api {
|
||||
|
||||
/**
|
||||
* Gets the session from the given
|
||||
@ -47,7 +45,7 @@ public interface Api<S extends Session> {
|
||||
* @return the session from the given UUID, if applicable
|
||||
*/
|
||||
@Nullable
|
||||
S sessionByUuid(@NonNull UUID uuid);
|
||||
Session sessionByUuid(@NonNull UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets the session from the given
|
||||
@ -57,7 +55,7 @@ public interface Api<S extends Session> {
|
||||
* @return the session from the given UUID, if applicable
|
||||
*/
|
||||
@Nullable
|
||||
S sessionByXuid(@NonNull String xuid);
|
||||
Session sessionByXuid(@NonNull String xuid);
|
||||
|
||||
/**
|
||||
* Gets the session from the given
|
||||
@ -67,7 +65,7 @@ public interface Api<S extends Session> {
|
||||
* @return the session from the given name, if applicable
|
||||
*/
|
||||
@Nullable
|
||||
S sessionByName(@NonNull String name);
|
||||
Session sessionByName(@NonNull String name);
|
||||
|
||||
/**
|
||||
* Gets all the online sessions.
|
||||
@ -75,5 +73,5 @@ public interface Api<S extends Session> {
|
||||
* @return all the online sessions
|
||||
*/
|
||||
@NonNull
|
||||
List<S> onlineSessions();
|
||||
List<? extends Session> onlineSessions();
|
||||
}
|
||||
|
@ -32,14 +32,14 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
*/
|
||||
@NonNull
|
||||
public class Geyser {
|
||||
private static Api<?> api;
|
||||
private static Api api;
|
||||
|
||||
/**
|
||||
* Returns the base api.
|
||||
*
|
||||
* @return the base api
|
||||
*/
|
||||
public static Api<?> api() {
|
||||
public static Api api() {
|
||||
if (api == null) {
|
||||
throw new RuntimeException("Api has not been registered yet!");
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class Geyser {
|
||||
* @return the api of the given type
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Api<?>> T api(@NonNull Class<T> apiClass) {
|
||||
public static <T extends Api> T api(@NonNull Class<T> apiClass) {
|
||||
if (apiClass.isInstance(api)) {
|
||||
return (T) api;
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class Geyser {
|
||||
*
|
||||
* @param api the api
|
||||
*/
|
||||
public static void set(@NonNull Api<?> api) {
|
||||
public static void set(@NonNull Api api) {
|
||||
if (Geyser.api != null) {
|
||||
throw new RuntimeException("Cannot redefine already registered api!");
|
||||
}
|
||||
|
@ -17,6 +17,12 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.checkerframework</groupId>
|
||||
<artifactId>checker-qual</artifactId>
|
||||
<version>3.19.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>base-api</artifactId>
|
||||
|
@ -25,14 +25,20 @@
|
||||
|
||||
package org.geysermc.geyser.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.api.Api;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.api.session.Session;
|
||||
import org.geysermc.geyser.api.session.GeyserSession;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents the API used in Geyser.
|
||||
*/
|
||||
public interface GeyserApi extends Api<GeyserSession> {
|
||||
public interface GeyserApi extends Api {
|
||||
|
||||
/**
|
||||
* Shuts down the current Geyser instance.
|
||||
@ -52,6 +58,30 @@ public interface GeyserApi extends Api<GeyserSession> {
|
||||
*/
|
||||
boolean productionEnvironment();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Nullable GeyserSession sessionByUuid(@NonNull UUID uuid);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Nullable GeyserSession sessionByXuid(@NonNull String xuid);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Nullable GeyserSession sessionByName(@NonNull String name);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@NonNull
|
||||
List<? extends GeyserSession> onlineSessions();
|
||||
|
||||
/**
|
||||
* Gets the {@link GeyserApi}.
|
||||
*
|
||||
|
@ -414,9 +414,8 @@ public class GeyserImpl implements GeyserApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public @NonNull List<GeyserSession> onlineSessions() {
|
||||
return (List<GeyserSession>) (List<? extends GeyserSession>) this.sessionManager.getAllSessions();
|
||||
public @NonNull List<GeyserSessionImpl> onlineSessions() {
|
||||
return this.sessionManager.getAllSessions();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren