3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-03 08:21:06 +02:00

Address review comments

Dieser Commit ist enthalten in:
rtm516 2024-08-27 17:59:09 +01:00
Ursprung e0df59d31a
Commit 3ada95144e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 331715B8B007C67A

Datei anzeigen

@ -168,13 +168,15 @@ public class GeyserExtensionLoader extends ExtensionLoader {
Path updateDirectory = extensionsDirectory.resolve("update");
if (Files.isDirectory(updateDirectory)) {
// Get the current extensions and store them in a map
// Step 1: Collect the extension files that currently exist so they can be replaced
Map<String, List<Path>> extensionFiles = new HashMap<>();
this.processExtensionsFolder(extensionsDirectory, (path, description) -> extensionFiles.computeIfAbsent(description.id(), k -> new ArrayList<>()).add(path), (path, e) -> {
this.processExtensionsFolder(extensionsDirectory, (path, description) -> {
extensionFiles.computeIfAbsent(description.id(), k -> new ArrayList<>()).add(path);
}, (path, e) -> {
// this file will throw again when we actually try to load extensions, and it will be handled there
});
// Perform the updates
// Step 2: Move the updated/new extensions
this.processExtensionsFolder(updateDirectory, (path, description) -> {
// Remove the old extension files with the same ID if it exists
List<Path> oldExtensionFiles = extensionFiles.get(description.id());
@ -191,6 +193,7 @@ public class GeyserExtensionLoader extends ExtensionLoader {
});
}
// Step 3: Load the extensions
this.processExtensionsFolder(extensionsDirectory, (path, description) -> {
String name = description.name();
String id = description.id();
@ -224,6 +227,7 @@ public class GeyserExtensionLoader extends ExtensionLoader {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_with_name", path.getFileName(), path.toAbsolutePath()), e);
});
// Step 4: Register the extensions
for (GeyserExtensionContainer container : loadedExtensions.values()) {
this.extensionContainers.put(container.extension(), container);
this.register(container.extension(), extensionManager);