Migrate to the new event system

This commit is contained in:
Eric Stokes 2012-01-22 21:44:43 -07:00
parent bf76b77cf6
commit ecb97fd5c1
9 changed files with 148 additions and 161 deletions

View File

@ -25,7 +25,6 @@ import com.onarandombox.MultiverseCore.event.MVVersionEvent;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener; import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener; import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPluginListener; import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVPortalAdjustListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager; import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.DebugLog; import com.onarandombox.MultiverseCore.utils.DebugLog;
@ -44,8 +43,6 @@ import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -156,7 +153,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup the block/player/entity listener. // Setup the block/player/entity listener.
private MVPlayerListener playerListener = new MVPlayerListener(this); private MVPlayerListener playerListener = new MVPlayerListener(this);
private MVPortalAdjustListener portalAdjustListener = new MVPortalAdjustListener(this);
private MVEntityListener entityListener = new MVEntityListener(this); private MVEntityListener entityListener = new MVEntityListener(this);
private MVPluginListener pluginListener = new MVPluginListener(this); private MVPluginListener pluginListener = new MVPluginListener(this);
@ -319,28 +315,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/ */
private void registerEvents() { private void registerEvents() {
PluginManager pm = getServer().getPluginManager(); PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_TELEPORT, this.playerListener, Priority.Highest, this); // Cancel Teleports if needed. pm.registerEvents(this.playerListener, this);
pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Priority.Normal, this); // To create the Player Session pm.registerEvents(this.entityListener, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Priority.Normal, this); // To remove Player Sessions pm.registerEvents(this.pluginListener, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight. pm.registerEvents(this.weatherListener, this);
pm.registerEvent(Event.Type.PLAYER_LOGIN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this); // To prepend the world name
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.High, this);
// We want this high to have it go last, so it can cancel if needbe.
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.portalAdjustListener, Priority.Lowest, this); // To handle portal correction
pm.registerEvent(Event.Type.PLAYER_CHANGED_WORLD, this.playerListener, Priority.Monitor, this); // To switch gamemode
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow fake PVP
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.
pm.registerEvent(Event.Type.FOOD_LEVEL_CHANGE, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this.pluginListener, Priority.Monitor, this);
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this.pluginListener, Priority.Monitor, this);
pm.registerEvent(Event.Type.WEATHER_CHANGE, this.weatherListener, Priority.Normal, this);
pm.registerEvent(Event.Type.THUNDER_CHANGE, this.weatherListener, Priority.Normal, this);
} }
/** /**

View File

@ -5,8 +5,6 @@
* with this project. * * with this project. *
******************************************************************************/ ******************************************************************************/
// TODO maybe remove this comment...?
// This file is no longer licensed under that silly CC license. I have blanked it out and will start implementaiton of my own in a few days. For now there is no help.
package com.onarandombox.MultiverseCore.commands; package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;

View File

@ -18,9 +18,10 @@ import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.Squid; import org.bukkit.entity.Squid;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
@ -29,9 +30,9 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
* Multiverse's {@link EntityListener}. * Multiverse's Entity {@link Listener}.
*/ */
public class MVEntityListener extends EntityListener { public class MVEntityListener implements Listener {
private MultiverseCore plugin; private MultiverseCore plugin;
private MVWorldManager worldManager; private MVWorldManager worldManager;
@ -41,8 +42,12 @@ public class MVEntityListener extends EntityListener {
this.worldManager = plugin.getMVWorldManager(); this.worldManager = plugin.getMVWorldManager();
} }
@Override /**
public void onFoodLevelChange(FoodLevelChangeEvent event) { * This method is called when an entity's food level goes higher or lower.
* @param event The Event that was fired.
*/
@EventHandler
public void foodLevelChange(FoodLevelChangeEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
@ -58,9 +63,12 @@ public class MVEntityListener extends EntityListener {
} }
} }
/**
@Override * This method is called when an entity's health goes up or down.
public void onEntityRegainHealth(EntityRegainHealthEvent event) { * @param event The Event that was fired.
*/
@EventHandler
public void entityRegainHealth(EntityRegainHealthEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
@ -75,8 +83,8 @@ public class MVEntityListener extends EntityListener {
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit. * Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.
* @param event The event. * @param event The event.
*/ */
@Override @EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) { public void creatureSpawn(CreatureSpawnEvent event) {
// Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour. // Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour.
if (event.getSpawnReason() == SpawnReason.CUSTOM) { if (event.getSpawnReason() == SpawnReason.CUSTOM) {

View File

@ -12,14 +12,18 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent; import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
import com.onarandombox.MultiverseCore.utils.PermissionTools; import com.onarandombox.MultiverseCore.utils.PermissionTools;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
@ -28,9 +32,9 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
* Multiverse's {@link PlayerListener}. * Multiverse's {@link Listener} for players.
*/ */
public class MVPlayerListener extends PlayerListener { public class MVPlayerListener implements Listener {
private MultiverseCore plugin; private MultiverseCore plugin;
private MVWorldManager worldManager; private MVWorldManager worldManager;
private PermissionTools pt; private PermissionTools pt;
@ -41,9 +45,12 @@ public class MVPlayerListener extends PlayerListener {
worldManager = plugin.getMVWorldManager(); worldManager = plugin.getMVWorldManager();
pt = new PermissionTools(plugin); pt = new PermissionTools(plugin);
} }
/**
@Override * This method is called when a player wants to chat.
public void onPlayerChat(PlayerChatEvent event) { * @param event The Event that was fired.
*/
@EventHandler
public void playerChat(PlayerChatEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
@ -66,8 +73,12 @@ public class MVPlayerListener extends PlayerListener {
} }
} }
@Override /**
public void onPlayerRespawn(PlayerRespawnEvent event) { * This method is called when a player respawns.
* @param event The Event that was fired.
*/
@EventHandler(priority = EventPriority.LOW)
public void playerRespawn(PlayerRespawnEvent event) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName()); MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
// If it's not a World MV manages we stop. // If it's not a World MV manages we stop.
@ -108,8 +119,12 @@ public class MVPlayerListener extends PlayerListener {
return w.getSpawnLocation(); return w.getSpawnLocation();
} }
@Override /**
public void onPlayerJoin(PlayerJoinEvent event) { * This method is called when a player joins the server.
* @param event The Event that was fired.
*/
@EventHandler
public void playerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer(); Player p = event.getPlayer();
if (!p.hasPlayedBefore()) { if (!p.hasPlayedBefore()) {
this.plugin.log(Level.FINE, "Player joined first!"); this.plugin.log(Level.FINE, "Player joined first!");
@ -125,19 +140,31 @@ public class MVPlayerListener extends PlayerListener {
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld()); this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
} }
@Override /**
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) { * This method is called when a player changes worlds.
* @param event The Event that was fired.
*/
@EventHandler(priority = EventPriority.MONITOR)
public void playerChangedWorld(PlayerChangedWorldEvent event) {
// Permissions now determine whether or not to handle a gamemode. // Permissions now determine whether or not to handle a gamemode.
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld()); this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
} }
@Override /**
public void onPlayerQuit(PlayerQuitEvent event) { * This method is called when a player quits the game.
* @param event The Event that was fired.
*/
@EventHandler
public void playerQuit(PlayerQuitEvent event) {
this.plugin.removePlayerSession(event.getPlayer()); this.plugin.removePlayerSession(event.getPlayer());
} }
@Override /**
public void onPlayerTeleport(PlayerTeleportEvent event) { * This method is called when a player teleports anywhere.
* @param event The Event that was fired.
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void playerTeleport(PlayerTeleportEvent event) {
this.plugin.log(Level.FINEST, "Got teleport event for player '" + event.getPlayer().getName() + "' with cause '" + event.getCause() + "'"); this.plugin.log(Level.FINEST, "Got teleport event for player '" + event.getPlayer().getName() + "' with cause '" + event.getCause() + "'");
if (event.isCancelled()) { if (event.isCancelled()) {
@ -183,8 +210,39 @@ public class MVPlayerListener extends PlayerListener {
} }
} }
@Override /**
public void onPlayerPortal(PlayerPortalEvent event) { * This method is called to adjust the portal location to the actual portal location (and not
* right outside of it.
* @param event The Event that was fired.
*/
@EventHandler(priority = EventPriority.LOWEST)
public void playerPortalCheck(PlayerPortalEvent event) {
this.plugin.log(Level.FINE, "CALLING CORE-ADJUST!!!");
if (event.isCancelled() || event.getFrom() == null) {
return;
}
// REMEMBER! getTo MAY be NULL HERE!!!
// If the player was actually outside of the portal, adjust the from location
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.PORTAL) {
Location newloc = SafeTTeleporter.findPortalBlockNextTo(event.getFrom());
// TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
// TODO: we want to do here.
if (newloc != null) {
event.setFrom(newloc);
}
}
// Wait for the adjust, then return!
if (event.getTo() == null) {
return;
}
}
/**
* This method is called when a player actually portals via a vanilla style portal.
* @param event The Event that was fired.
*/
@EventHandler(priority = EventPriority.HIGH)
public void playerPortal(PlayerPortalEvent event) {
if (event.isCancelled() || (event.getFrom() == null)) { if (event.isCancelled() || (event.getFrom() == null)) {
return; return;
} }

View File

@ -9,17 +9,19 @@ package com.onarandombox.MultiverseCore.listeners;
import com.fernferret.allpay.AllPay; import com.fernferret.allpay.AllPay;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import java.util.Arrays; import java.util.Arrays;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
* Multiverse's {@link ServerListener}. * Multiverse's Plugin {@link Listener}.
*/ */
public class MVPluginListener extends ServerListener { public class MVPluginListener implements Listener {
private MultiverseCore plugin; private MultiverseCore plugin;
@ -31,8 +33,8 @@ public class MVPluginListener extends ServerListener {
* Keep an eye out for Plugins which we can utilize. * Keep an eye out for Plugins which we can utilize.
* @param event The event. * @param event The event.
*/ */
@Override @EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event) { public void pluginEnable(PluginEnableEvent event) {
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support // Let AllPay handle all econ plugin loadings, only go for econ plugins we support
if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) { if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) {
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin()); this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
@ -48,8 +50,8 @@ public class MVPluginListener extends ServerListener {
* We'll check if any of the plugins we rely on decide to Disable themselves. * We'll check if any of the plugins we rely on decide to Disable themselves.
* @param event The event. * @param event The event.
*/ */
@Override @EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event) { public void pluginDisable(PluginDisableEvent event) {
// TODO: Disable econ when it disables. // TODO: Disable econ when it disables.
} }

View File

@ -1,55 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerPortalEvent;
import java.util.logging.Level;
/**
* Multiverse's second {@link PlayerListener}.
* <p>
* Used to double-monitor {@link Type#PLAYER_PORTAL}.
*/
public class MVPortalAdjustListener extends PlayerListener {
private MultiverseCore plugin;
public MVPortalAdjustListener(MultiverseCore core) {
this.plugin = core;
}
@Override
public void onPlayerPortal(PlayerPortalEvent event) {
this.plugin.log(Level.FINE, "CALLING CORE-ADJUST!!!");
if (event.isCancelled() || event.getFrom() == null) {
return;
}
// REMEMBER! getTo MAY be NULL HERE!!!
// If the player was actually outside of the portal, adjust the from location
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.PORTAL) {
Location newloc = SafeTTeleporter.findPortalBlockNextTo(event.getFrom());
// TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
// TODO: we want to do here.
if (newloc != null) {
event.setFrom(newloc);
}
}
// Wait for the adjust, then return!
if (event.getTo() == null) {
return;
}
}
}

View File

@ -9,22 +9,30 @@ package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.weather.ThunderChangeEvent; import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.weather.WeatherListener;
/** /**
* Multiverse's {@link WeatherListener}. * Multiverse's Weather {@link Listener}.
*/ */
public class MVWeatherListener extends WeatherListener { public class MVWeatherListener implements Listener {
private MultiverseCore plugin; private MultiverseCore plugin;
public MVWeatherListener(MultiverseCore plugin) { public MVWeatherListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@Override /**
public void onWeatherChange(WeatherChangeEvent event) { * This method is called when the weather changes.
* @param event The Event that was fired.
*/
@EventHandler
public void weatherChange(WeatherChangeEvent event) {
if (event.isCancelled()) {
return;
}
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName()); MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
if (world != null) { if (world != null) {
// If it's going to start raining and we have weather disabled // If it's going to start raining and we have weather disabled
@ -32,8 +40,15 @@ public class MVWeatherListener extends WeatherListener {
} }
} }
@Override /**
public void onThunderChange(ThunderChangeEvent event) { * This method is called when a big storm is going to start.
* @param event The Event that was fired.
*/
@EventHandler
public void thunderChange(ThunderChangeEvent event) {
if (event.isCancelled()) {
return;
}
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName()); MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
if (world != null) { if (world != null) {
// If it's going to start raining and we have weather disabled // If it's going to start raining and we have weather disabled

View File

@ -7,9 +7,6 @@
package com.onarandombox.MultiverseCore.listeners; package com.onarandombox.MultiverseCore.listeners;
import org.bukkit.event.CustomEventListener;
import org.bukkit.event.Event;
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent; import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
import com.onarandombox.MultiverseCore.event.MVPlayerTouchedPortalEvent; import com.onarandombox.MultiverseCore.event.MVPlayerTouchedPortalEvent;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent; import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
@ -17,80 +14,66 @@ import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
import com.onarandombox.MultiverseCore.event.MVVersionEvent; import com.onarandombox.MultiverseCore.event.MVVersionEvent;
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent; import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent; import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/** /**
* Subclasses of this listener can be used to conveniently listen to MultiverseCore-events. * Subclasses of this listener can be used to conveniently listen to MultiverseCore-events.
*/ */
public abstract class MultiverseCoreListener extends CustomEventListener { public abstract class MultiverseCoreListener implements Listener {
/**
* {@inheritDoc}
*/
@Override
public final void onCustomEvent(Event event) {
if (event.getEventName().equals("MVConfigReload") && event instanceof MVConfigReloadEvent) {
onMVConfigReload((MVConfigReloadEvent) event);
} else if (event.getEventName().equals("MVPlayerTouchedPortalEvent") && event instanceof MVPlayerTouchedPortalEvent) {
onPlayerTouchedPortal((MVPlayerTouchedPortalEvent) event);
} else if (event.getEventName().equals("MVRespawn") && event instanceof MVRespawnEvent) {
onPlayerRespawn((MVRespawnEvent) event);
} else if (event.getEventName().equals("SafeTTeleporter") && event instanceof MVTeleportEvent) {
onPlayerTeleport((MVTeleportEvent) event);
} else if (event.getEventName().equals("MVVersionEvent") && event instanceof MVVersionEvent) {
onVersionRequest((MVVersionEvent) event);
} else if (event.getEventName().equals("MVWorldDeleteEvent") && event instanceof MVWorldDeleteEvent) {
onWorldDelete((MVWorldDeleteEvent) event);
} else if (event.getEventName().equals("MVWorldPropertyChange") && event instanceof MVWorldPropertyChangeEvent) {
onWorldPropertyChange((MVWorldPropertyChangeEvent) event);
}
}
/** /**
* Called when a {@link MVWorldPropertyChangeEvent} is fired. * Called when a {@link MVWorldPropertyChangeEvent} is fired.
* @param event The event. * @param event The event.
*/ */
public void onWorldPropertyChange(MVWorldPropertyChangeEvent event) { @EventHandler
public void worldPropertyChange(MVWorldPropertyChangeEvent event) {
} }
/** /**
* Called when a {@link MVWorldDeleteEvent} is fired. * Called when a {@link MVWorldDeleteEvent} is fired.
* @param event The event. * @param event The event.
*/ */
public void onWorldDelete(MVWorldDeleteEvent event) { @EventHandler
public void worldDelete(MVWorldDeleteEvent event) {
} }
/** /**
* Called when a {@link MVVersionEvent} is fired. * Called when a {@link MVVersionEvent} is fired.
* @param event The event. * @param event The event.
*/ */
public void onVersionRequest(MVVersionEvent event) { @EventHandler
public void versionRequest(MVVersionEvent event) {
} }
/** /**
* Called when a {@link MVTeleportEvent} is fired. * Called when a {@link MVTeleportEvent} is fired.
* @param event The event. * @param event The event.
*/ */
public void onPlayerTeleport(MVTeleportEvent event) { @EventHandler
public void playerTeleport(MVTeleportEvent event) {
} }
/** /**
* Called when a {@link MVRespawnEvent} is fired. * Called when a {@link MVRespawnEvent} is fired.
* @param event The event. * @param event The event.
*/ */
public void onPlayerRespawn(MVRespawnEvent event) { @EventHandler
public void playerRespawn(MVRespawnEvent event) {
} }
/** /**
* Called when a {@link MVPlayerTouchedPortalEvent} is fired. * Called when a {@link MVPlayerTouchedPortalEvent} is fired.
* @param event The event. * @param event The event.
*/ */
public void onPlayerTouchedPortal(MVPlayerTouchedPortalEvent event) { @EventHandler
public void playerTouchedPortal(MVPlayerTouchedPortalEvent event) {
} }
/** /**
* Called when a {@link MVConfigReloadEvent} is fired. * Called when a {@link MVConfigReloadEvent} is fired.
* @param event The event. * @param event The event.
*/ */
public void onMVConfigReload(MVConfigReloadEvent event) { @EventHandler
public void configReload(MVConfigReloadEvent event) {
} }
} }

View File

@ -128,7 +128,7 @@ public class PermissionTools {
// If the toWorld isn't controlled by MV, // If the toWorld isn't controlled by MV,
// We don't care. // We don't care.
if(toWorld == null) { if (toWorld == null) {
return true; return true;
} }
@ -148,7 +148,7 @@ public class PermissionTools {
if (!bank.hasEnough(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency(), errString)) { if (!bank.hasEnough(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency(), errString)) {
return false; return false;
} else if (pay) { } else if (pay) {
bank.pay(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency()); bank.give(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency());
} }
} }
return true; return true;