mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-02 16:59:56 +01:00
Add MVRespawnEvent
This commit is contained in:
parent
60d456900d
commit
81315ba7a4
@ -7,12 +7,9 @@ import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
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.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
@ -27,22 +24,6 @@ public class MVEntityListener extends EntityListener {
|
||||
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
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
if(event.isCancelled()) {
|
||||
|
@ -11,6 +11,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
|
||||
public class MVPlayerListener extends PlayerListener {
|
||||
MultiverseCore plugin;
|
||||
|
||||
@ -82,7 +84,10 @@ public class MVPlayerListener extends PlayerListener {
|
||||
// TODO: Handle Alternate Respawn from config
|
||||
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user