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