mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-29 19:41:24 +01:00
Updates due to Challenges development.
This commit is contained in:
parent
a95e869cc9
commit
a5cc4c20ea
@ -203,6 +203,29 @@ public abstract class Addon implements AddonInterface {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resource from Jar file
|
||||
* @param jarResource
|
||||
* @return resource or null if there is a problem
|
||||
*/
|
||||
public InputStream getResource(String jarResource) {
|
||||
if (jarResource == null || jarResource.equals("")) {
|
||||
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
||||
}
|
||||
|
||||
jarResource = jarResource.replace('\\', '/');
|
||||
try (JarFile jar = new JarFile(file)) {
|
||||
JarEntry jarConfig = jar.getJarEntry(jarResource);
|
||||
if (jarConfig != null) {
|
||||
try (InputStream in = jar.getInputStream(jarConfig)) {
|
||||
return in;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().severe("Could not open from jar file. " + jarResource);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Set the file that contains this addon
|
||||
*
|
||||
|
@ -91,6 +91,6 @@ public class PanelBuilder {
|
||||
* @return Panel
|
||||
*/
|
||||
public Panel build() {
|
||||
return new Panel(name, items, Math.max(size, items.lastKey()), user, listener);
|
||||
return new Panel(name, items, Math.max(size, items.isEmpty() ? size : items.lastKey()), user, listener);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user