本文整理汇总了Java中org.bukkit.plugin.IllegalPluginAccessException类的典型用法代码示例。如果您正苦于以下问题:Java IllegalPluginAccessException类的具体用法?Java IllegalPluginAccessException怎么用?Java IllegalPluginAccessException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IllegalPluginAccessException类属于org.bukkit.plugin包,在下文中一共展示了IllegalPluginAccessException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerEvent
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
@Override
public void registerEvent(Class<? extends Event> event, Listener listener, EventPriority priority, EventExecutor executor, Plugin plugin, boolean ignoreCancelled) {
Validate.notNull(listener, "Listener cannot be null");
Validate.notNull(priority, "Priority cannot be null");
Validate.notNull(executor, "Executor cannot be null");
Validate.notNull(plugin, "Plugin cannot be null");
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled");
}
if (useTimings) {
getEventListeners(event).register(new TimedRegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
} else {
getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
}
}
示例2: getRegistrationClass
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
try {
clazz.getDeclaredMethod("getHandlerList");
return clazz;
} catch (NoSuchMethodException e) {
if ((clazz.getSuperclass() != null)
&& (!clazz.getSuperclass().equals(Event.class))
&& (Event.class.isAssignableFrom(clazz.getSuperclass()))) {
return getRegistrationClass(clazz.getSuperclass().asSubclass(
Event.class));
}
}
throw new IllegalPluginAccessException(
"Unable to find handler list for event " + clazz.getName());
}
示例3: validate
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private static void validate(final Plugin plugin, final Object task) {
Validate.notNull(plugin, "Plugin cannot be null");
Validate.notNull(task, "Task cannot be null");
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
}
}
示例4: getEventListeners
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private HandlerList getEventListeners(Class<? extends Event> type) {
try {
Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList");
method.setAccessible(true);
return (HandlerList) method.invoke(null);
} catch (Exception e) {
throw new IllegalPluginAccessException(e.toString());
}
}
示例5: getRegistrationClass
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
try {
clazz.getDeclaredMethod("getHandlerList");
return clazz;
} catch (NoSuchMethodException e) {
if (clazz.getSuperclass() != null
&& !clazz.getSuperclass().equals(Event.class)
&& Event.class.isAssignableFrom(clazz.getSuperclass())) {
return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
} else {
throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName() + ". Static getHandlerList method required!");
}
}
}
示例6: getEventListeners
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private HandlerList getEventListeners(Class<? extends Event> type) {
try {
Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList");
method.setAccessible(true);
return (HandlerList) method.invoke(null);
} catch (Exception e) {
throw new IllegalPluginAccessException(e.toString());
}
}
示例7: getRegistrationClass
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
try {
clazz.getDeclaredMethod("getHandlerList");
return clazz;
} catch (NoSuchMethodException e) {
if (clazz.getSuperclass() != null && !clazz.getSuperclass().equals(Event.class)
&& Event.class.isAssignableFrom(clazz.getSuperclass())) {
return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
} else {
throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName()
+ ". Static getHandlerList method required!");
}
}
}
示例8: registerEvents
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
public void registerEvents(Listener listener, Plugin plugin) {
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled");
}
for (Map.Entry<Class<? extends Event>, Set<RegisteredListener>> entry : plugin.getPluginLoader()
.createRegisteredListeners(listener, plugin).entrySet()) {
getEventListeners(getRegistrationClass(entry.getKey())).registerAll(entry.getValue());
}
}
示例9: getEventListeners
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
/**
* Gets event listeners
*
* @param type event type
* @return handler list
*/
private HandlerList getEventListeners(Class<? extends Event> type) {
try {
Method method = Reflections.getMethod(type, "getHandlerList");
method.setAccessible(true);
return (HandlerList) method.invoke(null);
}
catch(Exception e) {
throw new IllegalPluginAccessException(e.toString());
}
}
示例10: getRegistrationClass
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
/**
* Gets registration class
*
* @param clazz event class
* @return the class
*/
private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
try {
clazz.getDeclaredMethod("getHandlerList");
return clazz;
}
catch(NoSuchMethodException e) {
if((clazz.getSuperclass() != null) && (!clazz.getSuperclass().equals(Event.class)) && (Event.class.isAssignableFrom(clazz.getSuperclass()))) {
return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
}
}
throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName());
}
示例11: getPlugin
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
/**
* Gets a Bukkit plugin.
*
* @param plugin The name of the plugin to get.
* @return A Bukkit plugin.
*/
public static Plugin getPlugin(final String plugin) {
if (!Bukkit.getPluginManager().isPluginEnabled(plugin)) {
throw new IllegalPluginAccessException(String.format("The plugin [%s] is not enabled!", plugin));
}
return Bukkit.getPluginManager().getPlugin(plugin);
}
示例12: testGetPluginNotFound
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
@Test(expected = IllegalPluginAccessException.class)
public void testGetPluginNotFound() {
final String pluginName = "Test plugin";
final PluginManager pluginManager = mock(PluginManager.class);
when(pluginManager.isPluginEnabled(pluginName)).thenReturn(false);
mockStatic(Bukkit.class);
when(Bukkit.getPluginManager()).thenReturn(pluginManager);
try {
BukkitUtil.getPlugin(pluginName);
} finally {
verify(pluginManager).isPluginEnabled(pluginName);
verifyStatic();
}
}
示例13: getRegistrationClass
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private static Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
try {
clazz.getDeclaredMethod("getHandlerList");
return clazz;
} catch (NoSuchMethodException e) {
if (clazz.getSuperclass() != null
&& !clazz.getSuperclass().equals(Event.class)
&& Event.class.isAssignableFrom(clazz.getSuperclass())) {
return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
} else {
throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName());
}
}
}
示例14: getHandlerList
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private static HandlerList getHandlerList(Class<? extends Event> type) {
try {
Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList");
method.setAccessible(true);
return (HandlerList) method.invoke(null);
} catch (Exception e) {
throw new IllegalPluginAccessException(e.toString());
}
}
示例15: validate
import org.bukkit.plugin.IllegalPluginAccessException; //导入依赖的package包/类
private static void validate(Plugin plugin, Object task) {
Preconditions.checkState(plugin != null, "Plugin is null");
Preconditions.checkNotNull(task, "task");
//noinspection ConstantConditions
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register task while disabled");
}
}