Remove adventure usage in API

Unfortunately due to various platforms we support not having adventure support, we are unable to fully implement adventure into our API without having issues with shading or conflicts with other plugins. May look into what we can do in regards to classloading in the future but unfortunately it may not be a possibility at this point in time to support adventure inside of the API.
This commit is contained in:
RednedEpic 2022-01-16 15:58:47 -06:00
parent 4c297092a5
commit ac18ef6054
3 changed files with 20 additions and 29 deletions

View file

@ -33,9 +33,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>${adventure.version}</version>
<groupId>org.geysermc</groupId>
<artifactId>base-api</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -44,11 +44,5 @@
<version>1.27</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.geysermc</groupId>
<artifactId>base-api</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View file

@ -25,10 +25,8 @@
package org.geysermc.geyser.api.extension;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Map;
@ -45,7 +43,7 @@ public abstract class ExtensionManager {
* @return an extension with the given name
*/
@Nullable
public abstract Extension extension(@NotNull String name);
public abstract Extension extension(@NonNull String name);
/**
* Enables the given {@link Extension}.
@ -68,7 +66,7 @@ public abstract class ExtensionManager {
* @return the extension loader for loading the given extension
*/
@Nullable
public abstract ExtensionLoader extensionLoader(@NotNull Extension extension);
public abstract ExtensionLoader extensionLoader(@NonNull Extension extension);
/**
* Gets all the {@link Extension}s currently loaded.
@ -85,7 +83,7 @@ public abstract class ExtensionManager {
* @return the extension loader at the given identifier
*/
@Nullable
public abstract ExtensionLoader extensionLoader(@NonNull Key identifier);
public abstract ExtensionLoader extensionLoader(@NonNull String identifier);
/**
* Registers an {@link ExtensionLoader} with the given identifier.
@ -93,7 +91,7 @@ public abstract class ExtensionManager {
* @param identifier the identifier
* @param extensionLoader the extension loader
*/
public abstract void registerExtensionLoader(@NonNull Key identifier, @NotNull ExtensionLoader extensionLoader);
public abstract void registerExtensionLoader(@NonNull String identifier, @NonNull ExtensionLoader extensionLoader);
/**
* Gets all the currently registered {@link ExtensionLoader}s.
@ -101,7 +99,7 @@ public abstract class ExtensionManager {
* @return all the currently registered extension loaders
*/
@NonNull
public abstract Map<Key, ExtensionLoader> extensionLoaders();
public abstract Map<String, ExtensionLoader> extensionLoaders();
/**
* Registers an {@link Extension} with the given {@link ExtensionLoader}.
@ -109,12 +107,12 @@ public abstract class ExtensionManager {
* @param extension the extension
* @param loader the loader
*/
public abstract void register(@NotNull Extension extension, @NotNull ExtensionLoader loader);
public abstract void register(@NonNull Extension extension, @NonNull ExtensionLoader loader);
/**
* Loads all extensions from the given {@link ExtensionLoader}.
*/
protected final void loadAllExtensions(@NotNull ExtensionLoader extensionLoader) {
protected final void loadAllExtensions(@NonNull ExtensionLoader extensionLoader) {
extensionLoader.loadAllExtensions(this);
}
}

View file

@ -34,12 +34,12 @@ import org.geysermc.geyser.api.extension.ExtensionManager;
import org.geysermc.geyser.api.extension.ExtensionLoader;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.text.GeyserLocale;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.stream.Collectors;
public class GeyserExtensionManager extends ExtensionManager {
private static final Key BASE_KEY = Key.key("geysermc", "base");
private static final Key BASE_EXTENSION_LOADER_KEY = Key.key("geysermc", "base");
private final Map<String, Extension> extensions = new LinkedHashMap<>();
private final Map<Extension, ExtensionLoader> extensionsLoaders = new LinkedHashMap<>();
@ -47,8 +47,7 @@ public class GeyserExtensionManager extends ExtensionManager {
public void init() {
GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.loading"));
this.registerExtensionLoader(BASE_KEY, new GeyserExtensionLoader());
Registries.EXTENSION_LOADERS.register(BASE_EXTENSION_LOADER_KEY, new GeyserExtensionLoader());
for (ExtensionLoader loader : this.extensionLoaders().values()) {
this.loadAllExtensions(loader);
}
@ -130,23 +129,23 @@ public class GeyserExtensionManager extends ExtensionManager {
@Nullable
@Override
public ExtensionLoader extensionLoader(@NonNull Key identifier) {
return Registries.EXTENSION_LOADERS.get(identifier);
public ExtensionLoader extensionLoader(@NonNull String identifier) {
return Registries.EXTENSION_LOADERS.get(Key.key(identifier));
}
@Override
public void registerExtensionLoader(@NonNull Key identifier, @NotNull ExtensionLoader extensionLoader) {
Registries.EXTENSION_LOADERS.register(identifier, extensionLoader);
public void registerExtensionLoader(@NonNull String identifier, @NonNull ExtensionLoader extensionLoader) {
Registries.EXTENSION_LOADERS.register(Key.key(identifier), extensionLoader);
}
@NonNull
@Override
public Map<Key, ExtensionLoader> extensionLoaders() {
return Collections.unmodifiableMap(Registries.EXTENSION_LOADERS.get());
public Map<String, ExtensionLoader> extensionLoaders() {
return Registries.EXTENSION_LOADERS.get().entrySet().stream().collect(Collectors.toMap(key -> key.getKey().asString(), Map.Entry::getValue));
}
@Override
public void register(@NotNull Extension extension, @NotNull ExtensionLoader loader) {
public void register(@NonNull Extension extension, @NonNull ExtensionLoader loader) {
this.extensionsLoaders.put(extension, loader);
this.extensions.put(extension.name(), extension);
}