mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-17 21:51:33 +01:00
Ensure proper error when extension.json is missing
This commit is contained in:
parent
15cfea6f9a
commit
4b4c3cda32
@ -29,6 +29,7 @@ import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class ExtensionManager {
|
||||
@ -379,8 +380,14 @@ public class ExtensionManager {
|
||||
*/
|
||||
@Nullable
|
||||
private DiscoveredExtension discoverFromJar(@NotNull File file) {
|
||||
try (ZipFile f = new ZipFile(file);
|
||||
InputStreamReader reader = new InputStreamReader(f.getInputStream(f.getEntry("extension.json")))) {
|
||||
try (ZipFile f = new ZipFile(file);) {
|
||||
|
||||
ZipEntry entry = f.getEntry("extension.json");
|
||||
|
||||
if (entry == null)
|
||||
throw new IllegalStateException("Missing extension.json in extension " + file.getName() + ".");
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(f.getInputStream(entry));
|
||||
|
||||
// Initialize DiscoveredExtension from GSON.
|
||||
DiscoveredExtension extension = GSON.fromJson(reader, DiscoveredExtension.class);
|
||||
|
Loading…
Reference in New Issue
Block a user