Search in sources :

Example 6 with EventException

use of org.bukkit.event.EventException in project Essentials by EssentialsX.

the class EssentialsSpawn method onEnable.

@Override
public void onEnable() {
    final PluginManager pluginManager = getServer().getPluginManager();
    ess = (IEssentials) pluginManager.getPlugin("Essentials");
    if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
        LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
    }
    if (!ess.isEnabled()) {
        this.setEnabled(false);
        return;
    }
    spawns = new SpawnStorage(ess);
    ess.addReloadListener(spawns);
    final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
    EventPriority respawnPriority = ess.getSettings().getRespawnPriority();
    if (respawnPriority != null) {
        pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, new EventExecutor() {

            @Override
            public void execute(final Listener ll, final Event event) throws EventException {
                ((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
            }
        }, this);
    }
    EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority();
    if (joinPriority != null) {
        pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, new EventExecutor() {

            @Override
            public void execute(final Listener ll, final Event event) throws EventException {
                ((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
            }
        }, this);
    }
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) EventExecutor(org.bukkit.plugin.EventExecutor) Listener(org.bukkit.event.Listener) EventException(org.bukkit.event.EventException) PlayerRespawnEvent(org.bukkit.event.player.PlayerRespawnEvent) PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) Event(org.bukkit.event.Event) PlayerRespawnEvent(org.bukkit.event.player.PlayerRespawnEvent) EventPriority(org.bukkit.event.EventPriority)

Aggregations

Event (org.bukkit.event.Event)6 EventException (org.bukkit.event.EventException)6 Listener (org.bukkit.event.Listener)6 EventExecutor (org.bukkit.plugin.EventExecutor)6 EventPriority (org.bukkit.event.EventPriority)4 PluginManager (org.bukkit.plugin.PluginManager)4 Method (java.lang.reflect.Method)3 RegisteredListener (org.bukkit.plugin.RegisteredListener)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Set (java.util.Set)2 EventHandler (org.bukkit.event.EventHandler)2 HandlerList (org.bukkit.event.HandlerList)2 PlayerJoinEvent (org.bukkit.event.player.PlayerJoinEvent)2 PlayerRespawnEvent (org.bukkit.event.player.PlayerRespawnEvent)2 AuthorNagException (org.bukkit.plugin.AuthorNagException)2 TimedRegisteredListener (org.bukkit.plugin.TimedRegisteredListener)2 Lists (com.google.common.collect.Lists)1 ReflectionUtils (com.laytonsmith.PureUtilities.Common.ReflectionUtils)1 EventIdentifier (com.laytonsmith.annotations.EventIdentifier)1 File (java.io.File)1