Java Code Examples for org.bukkit.event.HandlerList#getRegisteredListeners()

The following examples show how to use org.bukkit.event.HandlerList#getRegisteredListeners() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubCommand_Debug.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
public void printHandlerList(@NotNull CommandSender sender, String event) {
    try {
        final Class<?> clazz = Class.forName(event);
        final Method method = clazz.getMethod("getHandlerList");
        final Object[] obj = new Object[0];
        final HandlerList list = (HandlerList) method.invoke(null, obj);

        for (RegisteredListener listener1 : list.getRegisteredListeners()) {
            MsgUtil.sendMessage(sender,
                    ChatColor.AQUA
                            + listener1.getPlugin().getName()
                            + ChatColor.YELLOW
                            + " # "
                            + ChatColor.GREEN
                            + listener1.getListener().getClass().getCanonicalName());
        }
    } catch (Throwable th) {
        MsgUtil.sendMessage(sender, "ERR " + th.getMessage());
        th.printStackTrace();
    }
}
 
Example 2
Source File: ItemMenuListener.java    From AnnihilationPro with MIT License 6 votes vote down vote up
/**
 * Checks if the {@link ninja.amp.ampmenus.MenuListener} is registered to a
 * plugin.
 *
 * @param plugin
 *            The plugin.
 * @return True if the {@link ninja.amp.ampmenus.MenuListener} is registered
 *         to the plugin, else false.
 */
public boolean isRegistered(JavaPlugin plugin)
{
	if (plugin.equals(this.plugin))
	{
		for (RegisteredListener listener : HandlerList
				.getRegisteredListeners(plugin))
		{
			if (listener.getListener().equals(INSTANCE))
			{
				return true;
			}
		}
	}
	return false;
}
 
Example 3
Source File: MenuListener.java    From AmpMenus with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Checks if the {@link ninja.amp.ampmenus.MenuListener} is registered to a plugin.
 *
 * @param plugin The plugin.
 * @return True if the {@link ninja.amp.ampmenus.MenuListener} is registered to the plugin, else false.
 */
public boolean isRegistered(JavaPlugin plugin) {
    if (plugin.equals(this.plugin)) {
        for (RegisteredListener listener : HandlerList.getRegisteredListeners(plugin)) {
            if (listener.getListener().equals(INSTANCE)) {
                return true;
            }
        }
    }
    return false;
}