mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Remove generic usage in Api
This commit is contained in:
parent
83ddbd7d1a
commit
5b415cea68
5 changed files with 48 additions and 15 deletions
|
@ -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!");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue