mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-07 00:48:28 +01:00
more
This commit is contained in:
parent
694d05e78a
commit
8f771bb867
@ -151,7 +151,18 @@ public abstract class Extension {
|
|||||||
* @return The file contents, or null if there was an issue reading the file.
|
* @return The file contents, or null if there was an issue reading the file.
|
||||||
*/
|
*/
|
||||||
public @Nullable InputStream getPackagedResource(@NotNull String fileName) {
|
public @Nullable InputStream getPackagedResource(@NotNull String fileName) {
|
||||||
return getPackagedResource(Paths.get(fileName));
|
try {
|
||||||
|
final URL url = getOrigin().getMinestomExtensionClassLoader().getResource(fileName);
|
||||||
|
if (url == null) {
|
||||||
|
getLogger().debug("Resource not found: {}", fileName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url.openConnection().getInputStream();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
getLogger().debug("Failed to load resource {}.", fileName, ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,19 +174,7 @@ public abstract class Extension {
|
|||||||
* @return The file contents, or null if there was an issue reading the file.
|
* @return The file contents, or null if there was an issue reading the file.
|
||||||
*/
|
*/
|
||||||
public @Nullable InputStream getPackagedResource(@NotNull Path target) {
|
public @Nullable InputStream getPackagedResource(@NotNull Path target) {
|
||||||
try {
|
return getPackagedResource(target.toString().replace('\\', '/'));
|
||||||
String path = target.toString().replace('\\', '/');
|
|
||||||
final URL url = getOrigin().getMinestomExtensionClassLoader().getResource(path);
|
|
||||||
if (url == null) {
|
|
||||||
getLogger().debug("Resource not found: {}", target);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return url.openConnection().getInputStream();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
getLogger().debug("Failed to load resource {}.", target, ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user