Add MVRespawnEvent

This commit is contained in:
Eric Stokes 2011-06-30 20:42:32 -06:00
parent 60d456900d
commit 81315ba7a4
3 changed files with 42 additions and 20 deletions

View File

@ -7,12 +7,9 @@ import org.bukkit.entity.Animals;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Ghast; import org.bukkit.entity.Ghast;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
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.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener; 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;
@ -26,22 +23,6 @@ public class MVEntityListener extends EntityListener {
public MVEntityListener(MultiverseCore plugin) { public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
// Need to find a way to stop the Ghast Fireballs damaging
// surroundings but still doing damage to players.
@Override
public void onEntityExplode(EntityExplodeEvent event) {
}
@Override
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
p.sendMessage("You died!");
}
super.onEntityDeath(event);
}
@Override @Override
public void onEntityRegainHealth(EntityRegainHealthEvent event) { public void onEntityRegainHealth(EntityRegainHealthEvent event) {

View File

@ -11,6 +11,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
public class MVPlayerListener extends PlayerListener { public class MVPlayerListener extends PlayerListener {
MultiverseCore plugin; MultiverseCore plugin;
@ -82,7 +84,10 @@ public class MVPlayerListener extends PlayerListener {
// TODO: Handle Alternate Respawn from config // TODO: Handle Alternate Respawn from config
MVPlayerSession ps = this.plugin.getPlayerSession(event.getPlayer()); MVPlayerSession ps = this.plugin.getPlayerSession(event.getPlayer());
event.setRespawnLocation(ps.getRespawnWorld().getSpawnLocation()); Location newrespawn = ps.getRespawnWorld().getSpawnLocation();
MVRespawnEvent mvevent = new MVRespawnEvent(newrespawn, event.getPlayer(), this.plugin.configMV.getString("notchrespawnstyle", "none"));
this.plugin.getServer().getPluginManager().callEvent(mvevent);
event.setRespawnLocation(mvevent.getPlayersRespawnLocation());
} }
@Override @Override

View File

@ -0,0 +1,36 @@
package com.onarandombox.MultiverseCore.event;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
public class MVRespawnEvent extends Event{
private static final long serialVersionUID = -2991894063331856687L;
private Player player;
private Location location;
private String respawnMethod;
public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) {
super("MVRespawn");
this.player = p;
this.location = spawningAt;
this.respawnMethod = respawnMethod;
}
public Player getPlayer() {
return this.player;
}
public String getRespawnMethod() {
return this.respawnMethod;
}
public Location getPlayersRespawnLocation() {
return this.location;
}
public void setRespawnLocation(Location l) {
this.location = l;
}
}