From 49f9784b61c3e587ed62275d10d637bd70dd85b5 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Mon, 19 Nov 2018 09:02:39 +0100 Subject: [PATCH] Moved addon exception to exceptions package and deprecated old ones --- .../bentobox/api/addons/AddonClassLoader.java | 4 +-- .../api/addons/exception/AddonException.java | 4 +++ .../InvalidAddonFormatException.java | 4 +++ .../InvalidAddonInheritException.java | 4 +++ .../api/addons/exceptions/AddonException.java | 14 ++++++++++ .../InvalidAddonFormatException.java | 28 +++++++++++++++++++ .../InvalidAddonInheritException.java | 14 ++++++++++ .../bentobox/managers/AddonsManager.java | 2 +- 8 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 src/main/java/world/bentobox/bentobox/api/addons/exceptions/AddonException.java create mode 100644 src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonFormatException.java create mode 100644 src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonInheritException.java diff --git a/src/main/java/world/bentobox/bentobox/api/addons/AddonClassLoader.java b/src/main/java/world/bentobox/bentobox/api/addons/AddonClassLoader.java index e43868ee9..b5a9b7df5 100644 --- a/src/main/java/world/bentobox/bentobox/api/addons/AddonClassLoader.java +++ b/src/main/java/world/bentobox/bentobox/api/addons/AddonClassLoader.java @@ -17,8 +17,8 @@ import org.bukkit.plugin.InvalidDescriptionException; import org.bukkit.util.permissions.DefaultPermissions; import world.bentobox.bentobox.api.addons.AddonDescription.AddonDescriptionBuilder; -import world.bentobox.bentobox.api.addons.exception.InvalidAddonFormatException; -import world.bentobox.bentobox.api.addons.exception.InvalidAddonInheritException; +import world.bentobox.bentobox.api.addons.exceptions.InvalidAddonFormatException; +import world.bentobox.bentobox.api.addons.exceptions.InvalidAddonInheritException; import world.bentobox.bentobox.managers.AddonsManager; /** diff --git a/src/main/java/world/bentobox/bentobox/api/addons/exception/AddonException.java b/src/main/java/world/bentobox/bentobox/api/addons/exception/AddonException.java index ee4fc1377..4f0321d62 100644 --- a/src/main/java/world/bentobox/bentobox/api/addons/exception/AddonException.java +++ b/src/main/java/world/bentobox/bentobox/api/addons/exception/AddonException.java @@ -1,5 +1,9 @@ package world.bentobox.bentobox.api.addons.exception; +/** + * @deprecated Moved to {@link world.bentobox.bentobox.api.addons.exceptions.AddonException}. + */ +@Deprecated public abstract class AddonException extends Exception { /** diff --git a/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonFormatException.java b/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonFormatException.java index 6004af803..3b8da6f60 100644 --- a/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonFormatException.java +++ b/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonFormatException.java @@ -4,6 +4,10 @@ import java.util.logging.Level; import org.bukkit.Bukkit; +/** + * @deprecated Moved to {@link world.bentobox.bentobox.api.addons.exceptions.InvalidAddonFormatException}. + */ +@Deprecated public class InvalidAddonFormatException extends AddonException { /** diff --git a/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonInheritException.java b/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonInheritException.java index fde97857e..1180952ae 100644 --- a/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonInheritException.java +++ b/src/main/java/world/bentobox/bentobox/api/addons/exception/InvalidAddonInheritException.java @@ -1,5 +1,9 @@ package world.bentobox.bentobox.api.addons.exception; +/** + * @deprecated Moved to {@link world.bentobox.bentobox.api.addons.exceptions.InvalidAddonInheritException}. + */ +@Deprecated public class InvalidAddonInheritException extends AddonException { /** diff --git a/src/main/java/world/bentobox/bentobox/api/addons/exceptions/AddonException.java b/src/main/java/world/bentobox/bentobox/api/addons/exceptions/AddonException.java new file mode 100644 index 000000000..8e0cb56bc --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/api/addons/exceptions/AddonException.java @@ -0,0 +1,14 @@ +package world.bentobox.bentobox.api.addons.exceptions; + +public abstract class AddonException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 4203162022348693854L; + + public AddonException(String errorMessage){ + super("AddonException : " + errorMessage); + } + +} diff --git a/src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonFormatException.java b/src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonFormatException.java new file mode 100644 index 000000000..c6da6a77d --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonFormatException.java @@ -0,0 +1,28 @@ +package world.bentobox.bentobox.api.addons.exceptions; + +import org.bukkit.Bukkit; + +import java.util.logging.Level; + +public class InvalidAddonFormatException extends AddonException { + + /** + * + */ + private static final long serialVersionUID = 7741502900847049986L; + + public InvalidAddonFormatException(String errorMessage) { + super(errorMessage); + } + + @Override + public void printStackTrace(){ + super.printStackTrace(); + + Bukkit.getLogger().log(Level.WARNING, " Basic format : (addon.yml)"); + Bukkit.getLogger().log(Level.WARNING, " main: path.to.your.MainClass"); + Bukkit.getLogger().log(Level.WARNING, " name: "); + Bukkit.getLogger().log(Level.WARNING, " authors: | "); + Bukkit.getLogger().log(Level.WARNING, " version: YourVersion"); + } +} diff --git a/src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonInheritException.java b/src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonInheritException.java new file mode 100644 index 000000000..dec1db6db --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/api/addons/exceptions/InvalidAddonInheritException.java @@ -0,0 +1,14 @@ +package world.bentobox.bentobox.api.addons.exceptions; + +public class InvalidAddonInheritException extends AddonException { + + /** + * + */ + private static final long serialVersionUID = -5847358994397613244L; + + public InvalidAddonInheritException(String errorMessage) { + super(errorMessage); + } + +} diff --git a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java index 4aa2af429..1e60c6208 100644 --- a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java @@ -25,7 +25,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.AddonClassLoader; -import world.bentobox.bentobox.api.addons.exception.InvalidAddonFormatException; +import world.bentobox.bentobox.api.addons.exceptions.InvalidAddonFormatException; import world.bentobox.bentobox.api.events.addon.AddonEvent; /**