add assertPluginPresent to AbstractHook

This commit is contained in:
asofold 2012-07-23 16:10:32 +02:00
parent 40f7057744
commit 53e8b24740

View File

@ -1,5 +1,6 @@
package me.asofold.bukkit.cncp.hooks; package me.asofold.bukkit.cncp.hooks;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
/** /**
@ -23,4 +24,12 @@ public abstract class AbstractHook implements Hook{
return null; return null;
} }
/**
* Throw a runtime exception if the plugin is not present.
* @param pluginName
*/
protected void assertPluginPresent(String pluginName){
if (Bukkit.getPluginManager().getPlugin(pluginName) == null) throw new RuntimeException("Assertion, " + getHookName() + ": Plugin " + pluginName + " is not present.");
}
} }