diff --git a/src/me/staartvin/utils/pluginlibrary/Library.java b/src/me/staartvin/utils/pluginlibrary/Library.java index f2cb8f5..c783876 100644 --- a/src/me/staartvin/utils/pluginlibrary/Library.java +++ b/src/me/staartvin/utils/pluginlibrary/Library.java @@ -1,6 +1,7 @@ package me.staartvin.utils.pluginlibrary; import me.staartvin.utils.pluginlibrary.hooks.*; +import org.bukkit.Bukkit; /** * This class holds all libraries PluginLibrary has. @@ -11,68 +12,70 @@ */ public enum Library { - AUTORANK("Autorank", new AutorankHook(), "Staartvin"), - MCMMO("mcMMO", new McMMOHook(), "t00thpick1"), - FACTIONS("Factions", new FactionsHook(), "Cayorion", "com.massivecraft.factions.Factions"), - ONTIME("OnTime", new OnTimeHook(), "Edge209"), - AFKTERMINATOR("afkTerminator", new AFKTerminatorHook(), "Edge209"), - ROYALCOMMANDS("RoyalCommands", new RoyalCommandsHook(), "WizardCM"), - ULTIMATECORE("UltimateCore", new UltimateCoreHook(), "Bammerbom"), - STATZ("Statz", new StatzHook(), "Staartvin"), - ACIDISLAND("AcidIsland", new AcidIslandHook(), "tastybento"), - ADVANCEDACHIEVEMENTS("AdvancedAchievements", new AdvancedAchievementsHook(), "DarkPyves"), - ASKYBLOCK("ASkyBlock", new ASkyBlockHook(), "tastybento"), - BATTLELEVELS("BattleLevels", new BattleLevelsHook(), "RobiRami"), - GRIEFPREVENTION("GriefPrevention", new GriefPreventionHook(), "RoboMWM"), - JOBS("Jobs", new JobsHook(), "Zrips"), - RPGME("RPGme", new RPGmeHook(), "Flamedek"), - USKYBLOCK("uSkyBlock", new uSkyBlockHook(), "R4zorax"), - VAULT("Vault", new VaultHook(), "Kainzo"), - WORLDGUARD("WorldGuard", new WorldGuardHook(), "sk89q"), - ESSENTIALSX("Essentials", "EssentialsX", new EssentialsXHook(), "drtshock"), - QUESTS("Quests", new QuestsHook(), "PikaMug", "me.blackvein.quests.Quests"), - STATS("Stats", new StatsHook(), "Lolmewn"), - QUESTS_ALTERNATIVE("Quests", new QuestsAlternative(), "LMBishop", "com.leonardobishop.quests.Quests"), - SAVAGE_FACTIONS("Factions", "SavageFactions", new SavageFactionsHook(), "ProSavage", "com.massivecraft.factions" + + AUTORANK("Autorank", AutorankHook.class, "Staartvin"), + MCMMO("mcMMO", McMMOHook.class, "t00thpick1"), + FACTIONS("Factions", FactionsHook.class, "Cayorion", "com.massivecraft.factions.Factions"), + ONTIME("OnTime", OnTimeHook.class, "Edge209"), + AFKTERMINATOR("afkTerminator", AFKTerminatorHook.class, "Edge209"), + ROYALCOMMANDS("RoyalCommands", RoyalCommandsHook.class, "WizardCM"), + ULTIMATECORE("UltimateCore", UltimateCoreHook.class, "Bammerbom"), + STATZ("Statz", StatzHook.class, "Staartvin"), + ACIDISLAND("AcidIsland", AcidIslandHook.class, "tastybento"), + ADVANCEDACHIEVEMENTS("AdvancedAchievements", AdvancedAchievementsHook.class, "DarkPyves"), + ASKYBLOCK("ASkyBlock", ASkyBlockHook.class, "tastybento"), + BATTLELEVELS("BattleLevels", BattleLevelsHook.class, "RobiRami"), + GRIEFPREVENTION("GriefPrevention", GriefPreventionHook.class, "RoboMWM"), + JOBS("Jobs", JobsHook.class, "Zrips"), + RPGME("RPGme", RPGmeHook.class, "Flamedek"), + USKYBLOCK("uSkyBlock", uSkyBlockHook.class, "R4zorax"), + VAULT("Vault", VaultHook.class, "Kainzo"), + WORLDGUARD("WorldGuard", WorldGuardHook.class, "sk89q"), + ESSENTIALSX("Essentials", "EssentialsX", EssentialsXHook.class, "drtshock"), + QUESTS("Quests", QuestsHook.class, "PikaMug", "me.blackvein.quests.Quests"), + STATS("Stats", StatsHook.class, "Lolmewn"), + QUESTS_ALTERNATIVE("Quests", QuestsAlternative.class, "LMBishop", "com.leonardobishop.quests.Quests"), + SAVAGE_FACTIONS("Factions", "SavageFactions", SavageFactionsHook.class, "ProSavage", "com.massivecraft.factions" + ".SavageFactions"), - PLAYERPOINTS("PlayerPoints", new PlayerPointsHook(), "Blackixx"), - NUVOTIFIER("Votifier", "NuVotifier", new NuVotifierHook(), "Ichbinjoe", "com.vexsoftware.votifier" + + PLAYERPOINTS("PlayerPoints", PlayerPointsHook.class, "Blackixx"), + NUVOTIFIER("Votifier", "NuVotifier", NuVotifierHook.class, "Ichbinjoe", "com.vexsoftware.votifier" + ".NuVotifierBukkit"), - CMI("CMI", new CMIHook(), "Zrips"), - UHCSTATS("UhcStats", new UHCStatsHook(), "Mezy"), - TOWNY_ADVANCED("Towny", new TownyAdvancedHook(), "Shade"), - MCRPG("McRPG", new McRPGHook(), "Eunoians"); + CMI("CMI", CMIHook.class, "Zrips"), + UHCSTATS("UhcStats", UHCStatsHook.class, "Mezy"), + TOWNY_ADVANCED("Towny", TownyAdvancedHook.class, "Shade"), + MCRPG("McRPG", McRPGHook.class, "Eunoians"); private final String internalPluginName; private final String authorName; - private final LibraryHook hook; + private final Class extends LibraryHook> libraryClass; + private LibraryHook hook; private String humanPluginName; private String mainClass; - Library(String pluginName, String humanPluginName, LibraryHook hook, String authorName) { + Library(String pluginName, String humanPluginName, Class extends LibraryHook> libraryClass, String authorName) { this.internalPluginName = pluginName; this.humanPluginName = humanPluginName; - this.hook = hook; + this.libraryClass = libraryClass; this.authorName = authorName; } - Library(String pluginName, LibraryHook hook, String authorName) { + Library(String pluginName, Class extends LibraryHook> libraryClass, String authorName) { this.internalPluginName = pluginName; - this.hook = hook; + this.libraryClass = libraryClass; this.authorName = authorName; } - Library(String pluginName, LibraryHook hook, String authorName, String mainClass) { + Library(String pluginName, Class extends LibraryHook> libraryClass, String authorName, String mainClass) { this.internalPluginName = pluginName; - this.hook = hook; + this.libraryClass = libraryClass; this.authorName = authorName; this.mainClass = mainClass; } - Library(String pluginName, String humanPluginName, LibraryHook hook, String authorName, String mainClass) { + Library(String pluginName, String humanPluginName, Class extends LibraryHook> libraryClass, String authorName, + String mainClass) { this.internalPluginName = pluginName; this.humanPluginName = humanPluginName; - this.hook = hook; + this.libraryClass = libraryClass; this.authorName = authorName; this.mainClass = mainClass; } @@ -100,6 +103,16 @@ public String getInternalPluginName() { } public LibraryHook getHook() { + + // Check if hook is not initialized yet. + if (hook == null) { + try { + hook = libraryClass.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + } + return hook; } @@ -132,4 +145,14 @@ public boolean hasMainClass() { public void setMainClass(String mainClass) { this.mainClass = mainClass; } + + /** + * Check if this plugin is installed on the server. + * + * @return true if the plugin is enabled, false otherwise. + */ + public boolean isPluginInstalled() { + return Bukkit.getPluginManager().isPluginEnabled(Library.MCRPG.getInternalPluginName()); + } + } diff --git a/src/me/staartvin/utils/pluginlibrary/PluginLibrary.java b/src/me/staartvin/utils/pluginlibrary/PluginLibrary.java index f89703a..cf4d668 100644 --- a/src/me/staartvin/utils/pluginlibrary/PluginLibrary.java +++ b/src/me/staartvin/utils/pluginlibrary/PluginLibrary.java @@ -122,10 +122,9 @@ public int loadLibraries() { int count = 0; for (me.staartvin.utils.pluginlibrary.Library l : me.staartvin.utils.pluginlibrary.Library.values()) { - LibraryHook libraryHook = l.getHook(); - - if (LibraryHook.isPluginAvailable(l) && libraryHook.isAvailable()) { + if (LibraryHook.isPluginAvailable(l)) { try { + LibraryHook libraryHook = l.getHook(); if (libraryHook.hook()) { loadedLibraries.add(l); count++; diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/AFKTerminatorHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/AFKTerminatorHook.java index 2fec7eb..bb1a274 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/AFKTerminatorHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/AFKTerminatorHook.java @@ -18,19 +18,9 @@ */ public class AFKTerminatorHook extends LibraryHook implements AFKManager { - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.AFKTERMINATOR.getInternalPluginName()); - } - @Override public boolean isHooked() { - return isAvailable(); + return isPluginAvailable(Library.AFKTERMINATOR); } /* @@ -40,10 +30,10 @@ public boolean isHooked() { */ @Override public boolean hook() { - // All api calls are done static, so there is no need to get the plugin - // class. + // All api calls are done static, so there is no need to get the plugin + // class. // We only check if the plugin is available. - return isAvailable(); + return isPluginAvailable(Library.AFKTERMINATOR); } /** diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/ASkyBlockHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/ASkyBlockHook.java index 71534bf..1b0bf22 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/ASkyBlockHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/ASkyBlockHook.java @@ -18,15 +18,6 @@ public class ASkyBlockHook extends LibraryHook { private ASkyBlock aSkyBlock; - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.ASKYBLOCK.getInternalPluginName()); - } @Override public boolean isHooked() { @@ -41,7 +32,7 @@ public boolean isHooked() { @Override public boolean hook() { - if (!isAvailable()) + if (!isPluginAvailable(Library.ASKYBLOCK)) return false; aSkyBlock = (ASkyBlock) this.getServer().getPluginManager() diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/AcidIslandHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/AcidIslandHook.java index 28e5407..1504c15 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/AcidIslandHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/AcidIslandHook.java @@ -18,17 +18,6 @@ public class AcidIslandHook extends LibraryHook { private ASkyBlock acidIsland; - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.ACIDISLAND - .getInternalPluginName()); - } - @Override public boolean isHooked() { return acidIsland != null; @@ -42,7 +31,7 @@ public boolean isHooked() { @Override public boolean hook() { - if (!isAvailable()) + if (!isPluginAvailable(Library.ACIDISLAND)) return false; acidIsland = (ASkyBlock) this.getServer().getPluginManager() diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/AdvancedAchievementsHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/AdvancedAchievementsHook.java index 0a51b34..421ca40 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/AdvancedAchievementsHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/AdvancedAchievementsHook.java @@ -17,17 +17,6 @@ public class AdvancedAchievementsHook extends LibraryHook { private AdvancedAchievements advancedAchievements; - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.ADVANCEDACHIEVEMENTS - .getInternalPluginName()); - } - @Override public boolean isHooked() { return advancedAchievements != null; @@ -41,7 +30,7 @@ public boolean isHooked() { @Override public boolean hook() { - if (!isAvailable()) + if (!isPluginAvailable(Library.ADVANCEDACHIEVEMENTS)) return false; advancedAchievements = (AdvancedAchievements) this.getServer().getPluginManager() diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/AutorankHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/AutorankHook.java index 8852d83..fcb9642 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/AutorankHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/AutorankHook.java @@ -23,15 +23,6 @@ public class AutorankHook extends LibraryHook { private Autorank autorank; - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return true; - } @Override public boolean isHooked() { @@ -45,7 +36,7 @@ public boolean isHooked() { */ @Override public boolean hook() { - if (!isAvailable()) + if (!isPluginAvailable(Library.AUTORANK)) return false; autorank = (Autorank) this.getServer().getPluginManager() diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/BattleLevelsHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/BattleLevelsHook.java index dfdb3fc..79bb6aa 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/BattleLevelsHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/BattleLevelsHook.java @@ -15,19 +15,10 @@ */ public class BattleLevelsHook extends LibraryHook { - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.BATTLELEVELS.getInternalPluginName()); - } @Override public boolean isHooked() { - return isAvailable(); + return isPluginAvailable(Library.BATTLELEVELS); } /* @@ -37,7 +28,7 @@ public boolean isHooked() { */ @Override public boolean hook() { - return isAvailable(); + return isPluginAvailable(Library.BATTLELEVELS); } /** diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/CMIHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/CMIHook.java index 90a8c6a..bdd4751 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/CMIHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/CMIHook.java @@ -16,19 +16,10 @@ */ public class CMIHook extends me.staartvin.utils.pluginlibrary.hooks.LibraryHook implements AFKManager { - /* - * (non-Javadoc) - * - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.CMI.getInternalPluginName()); - } @Override public boolean isHooked() { - return isAvailable(); + return isPluginAvailable(Library.CMI); } /* @@ -38,10 +29,10 @@ public boolean isHooked() { */ @Override public boolean hook() { - // All api calls are done static, so there is no need to get the plugin - // class. + // All api calls are done static, so there is no need to get the plugin + // class. // We only check if the plugin is available. - return isAvailable(); + return isPluginAvailable(Library.CMI); } /** diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/EssentialsXHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/EssentialsXHook.java index 0f9e591..80a1a38 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/EssentialsXHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/EssentialsXHook.java @@ -19,15 +19,6 @@ public class EssentialsXHook extends LibraryHook implements AFKManager { private Essentials essentials; - /* - * (non-Javadoc) - * - * @see me.staartvin.plugins.pluginlibrary.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.ESSENTIALSX.getInternalPluginName()); - } @Override public boolean isHooked() { @@ -41,7 +32,7 @@ public boolean isHooked() { */ @Override public boolean hook() { - if (!isAvailable()) + if (!isPluginAvailable(Library.ESSENTIALSX)) return false; essentials = (Essentials) this.getServer().getPluginManager() diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/FactionsHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/FactionsHook.java index 327d030..34c49d5 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/FactionsHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/FactionsHook.java @@ -27,16 +27,6 @@ public class FactionsHook extends LibraryHook { private Factions factions; - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.FACTIONS.getInternalPluginName()); - } - @Override public boolean isHooked() { return factions != null; @@ -49,8 +39,8 @@ public boolean isHooked() { */ @Override public boolean hook() { - if (!isAvailable()) - return false; + if (!isPluginAvailable(Library.FACTIONS)) + return false; Plugin plugin = this.getServer().getPluginManager() .getPlugin(Library.FACTIONS.getInternalPluginName()); diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/GriefPreventionHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/GriefPreventionHook.java index efc9d33..b4bbd12 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/GriefPreventionHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/GriefPreventionHook.java @@ -20,17 +20,6 @@ public class GriefPreventionHook extends LibraryHook { private GriefPrevention griefPrevention; - /* - * (non-Javadoc) - * - * @see me.staartvin.utils.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.GRIEFPREVENTION - .getInternalPluginName()); - } - @Override public boolean isHooked() { return griefPrevention != null; @@ -44,7 +33,7 @@ public boolean isHooked() { @Override public boolean hook() { - if (!isAvailable()) + if (!isPluginAvailable(Library.GRIEFPREVENTION)) return false; griefPrevention = (GriefPrevention) this.getServer().getPluginManager() diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/JobsHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/JobsHook.java index f52ca96..ce33dd3 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/JobsHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/JobsHook.java @@ -21,19 +21,9 @@ */ public class JobsHook extends LibraryHook { - /* - * (non-Javadoc) - * - * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable() - */ - @Override - public boolean isAvailable() { - return this.getServer().getPluginManager().isPluginEnabled(Library.JOBS.getInternalPluginName()); - } - @Override public boolean isHooked() { - return isAvailable(); + return isPluginAvailable(Library.JOBS); } /* @@ -43,7 +33,7 @@ public boolean isHooked() { */ @Override public boolean hook() { - return isAvailable(); + return isPluginAvailable(Library.JOBS); } diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/LibraryHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/LibraryHook.java index e4a2700..0470719 100644 --- a/src/me/staartvin/utils/pluginlibrary/hooks/LibraryHook.java +++ b/src/me/staartvin/utils/pluginlibrary/hooks/LibraryHook.java @@ -12,10 +12,27 @@ * Date created: 14:13:45 12 aug. 2015 * * @author Staartvin - * */ public abstract class LibraryHook { + /** + * Check if the given library is available. This means that it exists in the plugins folder and is enabled. + * + * @param library Library to check + * @return true if it exists and is started, false otherwise. + */ + public static boolean isPluginAvailable(Library library) { + Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(library.getInternalPluginName()); + + if (plugin == null) return false; + + // Check if plugin has a main class defined. + // If so, check if the main class is equal to that of the enabled plugin to make sure we have the correct one. + // Some plugins have the same name, but are of different authors. Checking the main class path makes sure we + // have the correct one. + return !library.hasMainClass() || plugin.getDescription().getMain().equalsIgnoreCase(library.getMainClass()); + } + protected PluginLibrary getPlugin() { return Bukkit.getServer().getServicesManager().load(PluginLibrary.class); } @@ -29,19 +46,8 @@ protected Server getServer() { } /** - * Whether or not the plugin is available. Checking whether a plugin is available may require some additional - * checks. This method can be used in conjunction with the {@link #isPluginAvailable(Library)} method to check for - * availability of a plugin. - * - * @return true when plugin is available to use; false otherwise. - * @deprecated Use {@link #isPluginAvailable instead}. - */ - @Deprecated - public abstract boolean isAvailable(); - - /** - * Check whether PluginLibrary is hooked into this plugin. Note that {@link #isAvailable()} only checks whether - * the plugin is available, but not whether it is hooked. + * Check whether PluginLibrary is hooked into this plugin. Note that {@link #isPluginAvailable(Library)} only checks + * whether the plugin is available, but not whether it is hooked. *
* If the plugin is not hooked, it cannot be used properly and should first be hooked by calling {@link #hook()}.
*
@@ -50,42 +56,9 @@ protected Server getServer() {
public abstract boolean isHooked();
/**
- * Check if the given library is available. This means that it exists in the plugins folder and is enabled.
+ * Hook the plugin to make sure data can be retrieved.
*
- * @param library Library to check
- * @return true if it exists and is started, false otherwise.
+ * @return true if PluginLibrary could successfully hook; false otherwise.
*/
- public static boolean isPluginAvailable(Library library) {
- Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(library.getInternalPluginName());
-
-// System.out.println("Library " + library.getHumanPluginName() + " plugin: " + plugin);
-//
-// if (plugin != null) {
-// System.out.println("Plugin enabled: " + plugin.isEnabled());
-// } else {
-// System.out.println("Plugin enabled: false");
-// }
-
- if (plugin == null) return false;
-
-// System.out.println("Library has main class: " + library.hasMainClass());
-//
-// if (library.hasMainClass()) {
-// System.out.println("(Should be) Library main class: " + library.getMainClass());
-// System.out.println("(Is) Library main class: " + plugin.getDescription().getMain());
-// }
-
- // Check if plugin has a main class defined.
- // If so, check if the main class is equal to that of the enabled plugin to make sure we have the correct one.
- // Some plugins have the same name, but are of different authors. Checking the main class path makes sure we
- // have the correct one.
- return !library.hasMainClass() || plugin.getDescription().getMain().equalsIgnoreCase(library.getMainClass());
- }
-
- /**
- * Hook the plugin to make sure data can be retrieved.
- *
- * @return true if PluginLibrary could successfully hook; false otherwise.
- */
- public abstract boolean hook();
+ public abstract boolean hook();
}
diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/McMMOHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/McMMOHook.java
index 7371588..6f89888 100644
--- a/src/me/staartvin/utils/pluginlibrary/hooks/McMMOHook.java
+++ b/src/me/staartvin/utils/pluginlibrary/hooks/McMMOHook.java
@@ -27,15 +27,6 @@ public class McMMOHook extends LibraryHook {
private mcMMO api;
- /*
- * (non-Javadoc)
- *
- * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable()
- */
- @Override
- public boolean isAvailable() {
- return this.getServer().getPluginManager().isPluginEnabled(Library.MCMMO.getInternalPluginName());
- }
@Override
public boolean isHooked() {
@@ -49,7 +40,7 @@ public boolean isHooked() {
*/
@Override
public boolean hook() {
- if (!isAvailable())
+ if (!isPluginAvailable(Library.MCMMO))
return false;
api = (mcMMO) this.getServer().getPluginManager().getPlugin(Library.MCMMO.getInternalPluginName());
diff --git a/src/me/staartvin/utils/pluginlibrary/hooks/McRPGHook.java b/src/me/staartvin/utils/pluginlibrary/hooks/McRPGHook.java
index db73bd7..14dc792 100644
--- a/src/me/staartvin/utils/pluginlibrary/hooks/McRPGHook.java
+++ b/src/me/staartvin/utils/pluginlibrary/hooks/McRPGHook.java
@@ -18,80 +18,70 @@
*/
public class McRPGHook extends LibraryHook {
- /*
- * (non-Javadoc)
- *
- * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#isAvailable()
- */
- @Override
- public boolean isAvailable() {
- return this.getServer().getPluginManager().isPluginEnabled(Library.MCRPG.getInternalPluginName());
- }
-
- @Override
- public boolean isHooked() {
- return isAvailable();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see me.staartvin.plugins.pluginlibrary.hooks.LibraryHook#hook()
- */
- @Override
- public boolean hook() {
- // All api calls are done static, so there is no need to get the plugin
- // class.
- // We only check if the plugin is available.
-
- return isAvailable();
- }
-
- /**
- * Get the {@link McRPGPlayer} object matching the given uuid.
- *
- * @param uuid UUID of the player.
- * @return Matched object or none if it doesn't exist.
- */
- public Optional