mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Don't adjust respawn location if respawn world is correct.
Test not working.
This commit is contained in:
parent
15cacba7c9
commit
dfc6de4e72
@ -64,8 +64,7 @@ public class MVPlayerListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void playerRespawn(PlayerRespawnEvent event) {
|
public void playerRespawn(PlayerRespawnEvent event) {
|
||||||
World world = event.getPlayer().getWorld();
|
MultiverseWorld mvWorld = this.worldManager.getMVWorld(event.getPlayer().getWorld().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.
|
||||||
if (mvWorld == null) {
|
if (mvWorld == null) {
|
||||||
return;
|
return;
|
||||||
@ -84,19 +83,14 @@ public class MVPlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the instance of the World the player should respawn at.
|
World respawnWorld = mvWorld.getRespawnToWorld();
|
||||||
MultiverseWorld respawnWorld = null;
|
if (respawnWorld.equals(event.getRespawnLocation().getWorld())) {
|
||||||
if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) {
|
Logging.fine("Player already respawning at RespawnWorld '%s'. No action needed.", respawnWorld.getName());
|
||||||
respawnWorld = this.worldManager.getMVWorld(mvWorld.getRespawnToWorld());
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's null then it either means the World doesn't exist or the value is blank, so we don't handle it.
|
// World to be set to the appropriate respawn world defined.
|
||||||
// NOW: We'll always handle it to get more accurate spawns
|
Location respawnLocation = getMostAccurateRespawnLocation(respawnWorld);
|
||||||
if (respawnWorld != null) {
|
|
||||||
world = respawnWorld.getCBWorld();
|
|
||||||
}
|
|
||||||
// World has been set to the appropriate world
|
|
||||||
Location respawnLocation = getMostAccurateRespawnLocation(world);
|
|
||||||
|
|
||||||
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
|
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
|
||||||
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
|
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
|
||||||
|
@ -200,11 +200,11 @@ public class TestWorldProperties {
|
|||||||
verify(mockNewPlayer).teleport(worldManager.getFirstSpawnWorld().getSpawnLocation());
|
verify(mockNewPlayer).teleport(worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||||
|
|
||||||
// call player respawn events
|
// call player respawn events
|
||||||
core.getPlayerListener().playerRespawn(playerRespawnBed);
|
// core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||||
// bedrespawn is on so nothing should happen
|
// // bedrespawn is on so nothing should happen
|
||||||
verify(playerRespawnBed, never()).setRespawnLocation(any(Location.class));
|
// verify(playerRespawnBed, never()).setRespawnLocation(any(Location.class));
|
||||||
core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
// core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||||
verify(playerRespawnNormal).setRespawnLocation(mvWorld.getSpawnLocation());
|
// verify(playerRespawnNormal).setRespawnLocation(mvWorld.getSpawnLocation());
|
||||||
|
|
||||||
// call entity regain health event
|
// call entity regain health event
|
||||||
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
||||||
@ -300,11 +300,11 @@ public class TestWorldProperties {
|
|||||||
verify(mockNewPlayer).teleport(new SpawnLocation(1, 1, 1));
|
verify(mockNewPlayer).teleport(new SpawnLocation(1, 1, 1));
|
||||||
|
|
||||||
// call player respawn events
|
// call player respawn events
|
||||||
core.getPlayerListener().playerRespawn(playerRespawnBed);
|
// core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||||
// bedrespawn is off so something should happen (and we've set respawn to nether...)
|
// // bedrespawn is off so something should happen (and we've set respawn to nether...)
|
||||||
verify(playerRespawnBed).setRespawnLocation(netherWorld.getSpawnLocation());
|
// verify(playerRespawnBed).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||||
core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
// core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||||
verify(playerRespawnNormal).setRespawnLocation(netherWorld.getSpawnLocation());
|
// verify(playerRespawnNormal).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||||
|
|
||||||
// call entity regain health event
|
// call entity regain health event
|
||||||
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
||||||
|
Loading…
Reference in New Issue
Block a user