org.bukkit.plugin.IllegalPluginAccessException Java Examples

The following examples show how to use org.bukkit.plugin.IllegalPluginAccessException. 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: DatabaseManager.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Queued database manager. Use queue to solve run SQL make server lagg issue.
 *
 * @param plugin plugin main class
 * @param db     database
 */
public DatabaseManager(@NotNull QuickShop plugin, @NotNull Database db) {
    this.plugin = plugin;
    this.warningSender = new WarningSender(plugin, 600000);
    this.database = db;
    this.useQueue = plugin.getConfig().getBoolean("database.queue");

    if (!useQueue) {
        return;
    }
    try {
        task =
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        plugin.getDatabaseManager().runTask();
                    }
                }.runTaskTimerAsynchronously(plugin, 1, plugin.getConfig().getLong("database.queue-commit-interval") * 20);
    } catch (IllegalPluginAccessException e) {
        Util.debugLog("Plugin is disabled but trying create database task, move to Main Thread...");
        plugin.getDatabaseManager().runTask();
    }
}
 
Example #2
Source File: LoggedPluginManager.java    From VoxelGamesLibv2 with MIT License 6 votes vote down vote up
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());
}
 
Example #3
Source File: Events.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
static 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());
  }
}
 
Example #4
Source File: Events.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
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());
    }
  }
}
 
Example #5
Source File: CraftScheduler.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example #6
Source File: HelperMergedEventListener.java    From helper with MIT License 5 votes vote down vote up
private static Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) {
    try {
        clazz.getDeclaredMethod("getHandlerList");
        return clazz;
    } catch (NoSuchMethodException var2) {
        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() + ".");
        }
    }
}
 
Example #7
Source File: LoggedPluginManager.java    From VoxelGamesLibv2 with MIT License 5 votes vote down vote up
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());
    }
}
 
Example #8
Source File: CraftScheduler.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example #9
Source File: LoggedPluginManager.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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());
	}
}
 
Example #10
Source File: LoggedPluginManager.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #11
Source File: Conversation.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Instead of ending the conversation it saves it to the database, from
 * where it will be resumed after the player logs in again.
 */
public void suspend() {
    if (inOut == null) {
        LogUtils.getLogger().log(Level.WARNING, "Conversation IO is not loaded, conversation will end for player "
                + PlayerConverter.getName(playerID));
        list.remove(playerID);
        HandlerList.unregisterAll(this);
        return;
    }
    inOut.end();

    // save the conversation to the database
    String loc = location.getX() + ";" + location.getY() + ";" + location.getZ() + ";"
            + location.getWorld().getName();
    plugin.getSaver().add(new Record(UpdateType.UPDATE_CONVERSATION,
            new String[]{convID + " " + option + " " + loc, playerID}));

    // End interceptor
    if (interceptor != null) {
        interceptor.end();
    }

    // delete conversation
    list.remove(playerID);
    HandlerList.unregisterAll(this);

    try {
        new BukkitRunnable() {

            @Override
            public void run() {
                Bukkit.getServer().getPluginManager().callEvent(new PlayerConversationEndEvent(player, Conversation.this));
            }
        }.runTask(BetonQuest.getInstance());
    } catch (IllegalPluginAccessException e) {
        LogUtils.logThrowableIgnore(e);
    }

}