Updates due to Challenges development.

This commit is contained in:
Tastybento 2018-04-08 19:54:37 -07:00
parent a95e869cc9
commit a5cc4c20ea
2 changed files with 24 additions and 1 deletions

View File

@ -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
*

View File

@ -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);
}
}