mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-29 07:55:07 +02: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.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
public class ExtensionManager {
|
public class ExtensionManager {
|
||||||
|
@ -379,8 +380,14 @@ public class ExtensionManager {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private DiscoveredExtension discoverFromJar(@NotNull File file) {
|
private DiscoveredExtension discoverFromJar(@NotNull File file) {
|
||||||
try (ZipFile f = new ZipFile(file);
|
try (ZipFile f = new ZipFile(file);) {
|
||||||
InputStreamReader reader = new InputStreamReader(f.getInputStream(f.getEntry("extension.json")))) {
|
|
||||||
|
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.
|
// Initialize DiscoveredExtension from GSON.
|
||||||
DiscoveredExtension extension = GSON.fromJson(reader, DiscoveredExtension.class);
|
DiscoveredExtension extension = GSON.fromJson(reader, DiscoveredExtension.class);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user