Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
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.
Dieser Commit ist enthalten in:
Ursprung
4c297092a5
Commit
ac18ef6054
@ -33,9 +33,9 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>org.geysermc</groupId>
|
||||||
<artifactId>adventure-api</artifactId>
|
<artifactId>base-api</artifactId>
|
||||||
<version>${adventure.version}</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -44,11 +44,5 @@
|
|||||||
<version>1.27</version>
|
<version>1.27</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.geysermc</groupId>
|
|
||||||
<artifactId>base-api</artifactId>
|
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -25,10 +25,8 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.api.extension;
|
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.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -45,7 +43,7 @@ public abstract class ExtensionManager {
|
|||||||
* @return an extension with the given name
|
* @return an extension with the given name
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract Extension extension(@NotNull String name);
|
public abstract Extension extension(@NonNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the given {@link Extension}.
|
* Enables the given {@link Extension}.
|
||||||
@ -68,7 +66,7 @@ public abstract class ExtensionManager {
|
|||||||
* @return the extension loader for loading the given extension
|
* @return the extension loader for loading the given extension
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract ExtensionLoader extensionLoader(@NotNull Extension extension);
|
public abstract ExtensionLoader extensionLoader(@NonNull Extension extension);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the {@link Extension}s currently loaded.
|
* Gets all the {@link Extension}s currently loaded.
|
||||||
@ -85,7 +83,7 @@ public abstract class ExtensionManager {
|
|||||||
* @return the extension loader at the given identifier
|
* @return the extension loader at the given identifier
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public abstract ExtensionLoader extensionLoader(@NonNull Key identifier);
|
public abstract ExtensionLoader extensionLoader(@NonNull String identifier);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an {@link ExtensionLoader} with the given identifier.
|
* Registers an {@link ExtensionLoader} with the given identifier.
|
||||||
@ -93,7 +91,7 @@ public abstract class ExtensionManager {
|
|||||||
* @param identifier the identifier
|
* @param identifier the identifier
|
||||||
* @param extensionLoader the extension loader
|
* @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.
|
* Gets all the currently registered {@link ExtensionLoader}s.
|
||||||
@ -101,7 +99,7 @@ public abstract class ExtensionManager {
|
|||||||
* @return all the currently registered extension loaders
|
* @return all the currently registered extension loaders
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
public abstract Map<Key, ExtensionLoader> extensionLoaders();
|
public abstract Map<String, ExtensionLoader> extensionLoaders();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an {@link Extension} with the given {@link ExtensionLoader}.
|
* Registers an {@link Extension} with the given {@link ExtensionLoader}.
|
||||||
@ -109,12 +107,12 @@ public abstract class ExtensionManager {
|
|||||||
* @param extension the extension
|
* @param extension the extension
|
||||||
* @param loader the loader
|
* @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}.
|
* 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);
|
extensionLoader.loadAllExtensions(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,12 @@ import org.geysermc.geyser.api.extension.ExtensionManager;
|
|||||||
import org.geysermc.geyser.api.extension.ExtensionLoader;
|
import org.geysermc.geyser.api.extension.ExtensionLoader;
|
||||||
import org.geysermc.geyser.registry.Registries;
|
import org.geysermc.geyser.registry.Registries;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GeyserExtensionManager extends ExtensionManager {
|
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<String, Extension> extensions = new LinkedHashMap<>();
|
||||||
private final Map<Extension, ExtensionLoader> extensionsLoaders = new LinkedHashMap<>();
|
private final Map<Extension, ExtensionLoader> extensionsLoaders = new LinkedHashMap<>();
|
||||||
@ -47,8 +47,7 @@ public class GeyserExtensionManager extends ExtensionManager {
|
|||||||
public void init() {
|
public void init() {
|
||||||
GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.loading"));
|
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()) {
|
for (ExtensionLoader loader : this.extensionLoaders().values()) {
|
||||||
this.loadAllExtensions(loader);
|
this.loadAllExtensions(loader);
|
||||||
}
|
}
|
||||||
@ -130,23 +129,23 @@ public class GeyserExtensionManager extends ExtensionManager {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ExtensionLoader extensionLoader(@NonNull Key identifier) {
|
public ExtensionLoader extensionLoader(@NonNull String identifier) {
|
||||||
return Registries.EXTENSION_LOADERS.get(identifier);
|
return Registries.EXTENSION_LOADERS.get(Key.key(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerExtensionLoader(@NonNull Key identifier, @NotNull ExtensionLoader extensionLoader) {
|
public void registerExtensionLoader(@NonNull String identifier, @NonNull ExtensionLoader extensionLoader) {
|
||||||
Registries.EXTENSION_LOADERS.register(identifier, extensionLoader);
|
Registries.EXTENSION_LOADERS.register(Key.key(identifier), extensionLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Map<Key, ExtensionLoader> extensionLoaders() {
|
public Map<String, ExtensionLoader> extensionLoaders() {
|
||||||
return Collections.unmodifiableMap(Registries.EXTENSION_LOADERS.get());
|
return Registries.EXTENSION_LOADERS.get().entrySet().stream().collect(Collectors.toMap(key -> key.getKey().asString(), Map.Entry::getValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.extensionsLoaders.put(extension, loader);
|
||||||
this.extensions.put(extension.name(), extension);
|
this.extensions.put(extension.name(), extension);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren