Bolstered error reporting for malformed addon.yml files.

This commit is contained in:
Tastybento 2017-12-28 17:11:49 -08:00
parent 6e6165a301
commit 4d7b5374e5
4 changed files with 23 additions and 5 deletions

View File

@ -186,8 +186,6 @@ public abstract class Addon implements AddonInterface {
}
out.close();
in.close();
} else {
getLogger().warning("Could not save " + outFile.getName() + " to " + outFile + " because " + outFile.getName() + " already exists.");
}
jar.close();
} catch (IOException ex) {

View File

@ -7,6 +7,9 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.Map;
import org.bukkit.plugin.InvalidDescriptionException;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.addons.AddonDescription.AddonDescriptionBuilder;
import us.tastybento.bskyblock.api.addons.exception.InvalidAddonFormatException;
import us.tastybento.bskyblock.api.addons.exception.InvalidAddonInheritException;
@ -18,7 +21,7 @@ public class AddonClassLoader extends URLClassLoader {
public Addon addon;
public AddonClassLoader(Map<String, String>data, File path, BufferedReader reader, ClassLoader loaders) throws InvalidAddonInheritException, MalformedURLException, InvalidAddonFormatException {
public AddonClassLoader(Map<String, String>data, File path, BufferedReader reader, ClassLoader loaders) throws InvalidAddonInheritException, MalformedURLException, InvalidAddonFormatException, InvalidDescriptionException {
super(new URL[]{path.toURI().toURL()}, loaders);
Addon addon = null;
@ -35,7 +38,8 @@ public class AddonClassLoader extends URLClassLoader {
throw new InvalidAddonFormatException("Packages declaration cannot start with 'us.tastybento'");
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
BSkyBlock.getInstance().getLogger().severe("Could not load '" + path.getName() + "' in folder '" + path.getParent() + "'");
throw new InvalidDescriptionException("Invalid addon.yml");
}
Class<? extends Addon> addonClass;

View File

@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import us.tastybento.bskyblock.api.commands.User;
import us.tastybento.bskyblock.listeners.PanelListener;
public class Panel {
@ -45,4 +46,15 @@ public class Panel {
PanelListener.openPanels.put(player.getUniqueId(), this);
}
}
/**
* Open the inventory panel
* @param users
*/
public void open(User... users) {
for (User user : users) {
user.getPlayer().openInventory(inventory);
PanelListener.openPanels.put(user.getUniqueId(), this);
}
}
}

View File

@ -12,6 +12,7 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.bukkit.Bukkit;
import org.bukkit.plugin.InvalidDescriptionException;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.addons.Addon;
@ -36,6 +37,7 @@ public final class AddonsManager {
/**
* Loads all the addons from the addons folder
* @throws InvalidDescriptionException
*/
public void enableAddons() {
File f = new File(BSkyBlock.getInstance().getDataFolder(), "addons");
@ -49,6 +51,8 @@ public final class AddonsManager {
e.printStackTrace();
} catch (InvalidAddonInheritException e) {
e.printStackTrace();
} catch (InvalidDescriptionException e) {
e.printStackTrace();
}
}
}
@ -83,7 +87,7 @@ public final class AddonsManager {
return null;
}
private void loadAddon(File f) throws InvalidAddonFormatException, InvalidAddonInheritException {
private void loadAddon(File f) throws InvalidAddonFormatException, InvalidAddonInheritException, InvalidDescriptionException {
try {
Addon addon = null;