Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-20 15:00:11 +01:00
Remove old jars under different names for the same extensions
Dieser Commit ist enthalten in:
Ursprung
4106d24f2a
Commit
23e6dbc899
@ -166,13 +166,17 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||||||
Pattern[] extensionFilters = this.extensionFilters();
|
Pattern[] extensionFilters = this.extensionFilters();
|
||||||
|
|
||||||
Path updateDirectory = extensionsDirectory.resolve("update");
|
Path updateDirectory = extensionsDirectory.resolve("update");
|
||||||
|
List<Path> extensionPaths;
|
||||||
if (Files.isDirectory(updateDirectory)) {
|
if (Files.isDirectory(updateDirectory)) {
|
||||||
List<Path> extensionUpdatePaths = Files.list(updateDirectory).toList();
|
// Get the current extensions and store them in a map
|
||||||
extensionUpdatePaths.forEach(path -> {
|
Map<String, String> extensionFiles = new HashMap<>();
|
||||||
|
extensionPaths = Files.list(extensionsDirectory).toList();
|
||||||
|
extensionPaths.forEach(path -> {
|
||||||
if (Files.isDirectory(path)) {
|
if (Files.isDirectory(path)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only look at files that meet the extension filter
|
||||||
for (Pattern filter : extensionFilters) {
|
for (Pattern filter : extensionFilters) {
|
||||||
if (!filter.matcher(path.getFileName().toString()).matches()) {
|
if (!filter.matcher(path.getFileName().toString()).matches()) {
|
||||||
return;
|
return;
|
||||||
@ -183,6 +187,36 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||||||
// Try load the description, so we know it's a valid extension
|
// Try load the description, so we know it's a valid extension
|
||||||
GeyserExtensionDescription description = this.extensionDescription(path);
|
GeyserExtensionDescription description = this.extensionDescription(path);
|
||||||
|
|
||||||
|
// Store the file name against ID for later use
|
||||||
|
extensionFiles.put(description.id(), path.getFileName().toString());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Perform the updates
|
||||||
|
List<Path> extensionUpdatePaths = Files.list(updateDirectory).toList();
|
||||||
|
extensionUpdatePaths.forEach(path -> {
|
||||||
|
if (Files.isDirectory(path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only look at files that meet the extension filter
|
||||||
|
for (Pattern filter : extensionFilters) {
|
||||||
|
if (!filter.matcher(path.getFileName().toString()).matches()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Try load the description, so we know it's a valid extension
|
||||||
|
GeyserExtensionDescription description = this.extensionDescription(path);
|
||||||
|
|
||||||
|
// Remove the old extension with the same ID if it exists
|
||||||
|
if (extensionFiles.containsKey(description.id())) {
|
||||||
|
Files.delete(extensionsDirectory.resolve(extensionFiles.get(description.id())));
|
||||||
|
}
|
||||||
|
|
||||||
// Overwrite the extension with the new jar
|
// Overwrite the extension with the new jar
|
||||||
Files.move(path, extensionsDirectory.resolve(path.getFileName()), StandardCopyOption.REPLACE_EXISTING);
|
Files.move(path, extensionsDirectory.resolve(path.getFileName()), StandardCopyOption.REPLACE_EXISTING);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@ -191,7 +225,7 @@ public class GeyserExtensionLoader extends ExtensionLoader {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Path> extensionPaths = Files.list(extensionsDirectory).toList();
|
extensionPaths = Files.list(extensionsDirectory).toList();
|
||||||
extensionPaths.forEach(path -> {
|
extensionPaths.forEach(path -> {
|
||||||
if (Files.isDirectory(path)) {
|
if (Files.isDirectory(path)) {
|
||||||
return;
|
return;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren