This commit is contained in:
Daniel Saukel 2016-04-28 00:03:25 +02:00
parent 43e6a04da1
commit 1cdc78dda3
2 changed files with 56 additions and 36 deletions

View File

@ -22,12 +22,10 @@ import io.github.dre2n.dungeonsxl.config.MessageConfig;
import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages; import io.github.dre2n.dungeonsxl.config.MessageConfig.Messages;
import io.github.dre2n.dungeonsxl.config.WorldConfig; import io.github.dre2n.dungeonsxl.config.WorldConfig;
import io.github.dre2n.dungeonsxl.dungeon.DLootInventory; import io.github.dre2n.dungeonsxl.dungeon.DLootInventory;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent; import io.github.dre2n.dungeonsxl.event.dgroup.DGroupCreateEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent; import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerDeathEvent;
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent; import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerKickEvent;
import io.github.dre2n.dungeonsxl.game.GameChest; import io.github.dre2n.dungeonsxl.game.GameChest;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import io.github.dre2n.dungeonsxl.global.DPortal; import io.github.dre2n.dungeonsxl.global.DPortal;
import io.github.dre2n.dungeonsxl.global.GameSign; import io.github.dre2n.dungeonsxl.global.GameSign;
import io.github.dre2n.dungeonsxl.global.GlobalProtection; import io.github.dre2n.dungeonsxl.global.GlobalProtection;
@ -41,6 +39,8 @@ import io.github.dre2n.dungeonsxl.player.DSavePlayer;
import io.github.dre2n.dungeonsxl.task.RespawnTask; import io.github.dre2n.dungeonsxl.task.RespawnTask;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger; import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger; import io.github.dre2n.dungeonsxl.trigger.UseItemTrigger;
import io.github.dre2n.dungeonsxl.world.EditWorld;
import io.github.dre2n.dungeonsxl.world.GameWorld;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -376,29 +376,26 @@ public class PlayerListener implements Listener {
DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer()); DGroup dGroup = DGroup.getByPlayer(dPlayer.getPlayer());
if (dPlayer.getCheckpoint() == null) { Location respawn = dPlayer.getCheckpoint();
event.setRespawnLocation(dGroup.getGameWorld().getLocStart());
// Da einige Plugins einen anderen Respawn setzen wird if (respawn == null) {
// ein Scheduler gestartet der den Player nach einer respawn = dGroup.getGameWorld().getLocStart();
// Sekunde teleportiert.
new RespawnTask(player, dGroup.getGameWorld().getLocStart()).runTaskLater(plugin, 10L);
if (dPlayer.getWolf() != null) {
dPlayer.getWolf().teleport(dGroup.getGameWorld().getLocStart());
} }
} else { if (respawn == null) {
event.setRespawnLocation(dPlayer.getCheckpoint()); respawn = dGroup.getGameWorld().getLocLobby();
// Da einige Plugins einen anderen Respawn setzen wird
// ein Scheduler gestartet der den Player nach einer
// Sekunde teleportiert.
new RespawnTask(player, dPlayer.getCheckpoint()).runTaskLater(plugin, 10L);
if (dPlayer.getWolf() != null) {
dPlayer.getWolf().teleport(dPlayer.getCheckpoint());
} }
if (respawn == null) {
respawn = dGroup.getGameWorld().getWorld().getSpawnLocation();
}
// Because some plugins set another respawn point, DXL teleports a few ticks later.
new RespawnTask(player, respawn).runTaskLater(plugin, 10);
// Don't forget Doge!
if (dPlayer.getWolf() != null) {
dPlayer.getWolf().teleport(respawn);
} }
} }
} }

View File

@ -619,11 +619,24 @@ public class DPlayer extends DGlobalPlayer {
public void respawn() { public void respawn() {
DGroup dGroup = DGroup.getByPlayer(getPlayer()); DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (checkpoint == null) {
PlayerUtil.secureTeleport(getPlayer(), dGroup.getGameWorld().getLocStart()); Location respawn = checkpoint;
} else {
PlayerUtil.secureTeleport(getPlayer(), checkpoint); if (respawn == null) {
respawn = dGroup.getGameWorld().getLocStart();
} }
if (respawn == null) {
respawn = dGroup.getGameWorld().getLocLobby();
}
if (respawn == null) {
respawn = world.getSpawnLocation();
}
PlayerUtil.secureTeleport(getPlayer(), respawn);
// Don't forget Doge!
if (wolf != null) { if (wolf != null) {
wolf.teleport(getPlayer()); wolf.teleport(getPlayer());
} }
@ -833,7 +846,7 @@ public class DPlayer extends DGlobalPlayer {
public void update(boolean updateSecond) { public void update(boolean updateSecond) {
boolean locationValid = true; boolean locationValid = true;
Location teleportLocation = getPlayer().getLocation(); Location teleportLocation = player.getLocation();
boolean teleportWolf = false; boolean teleportWolf = false;
boolean respawnInventory = false; boolean respawnInventory = false;
boolean offline = false; boolean offline = false;
@ -855,19 +868,28 @@ public class DPlayer extends DGlobalPlayer {
teleportLocation = editWorld.getLobby(); teleportLocation = editWorld.getLobby();
} }
} }
} else if (gameWorld != null) { } else if (gameWorld != null) {
DGroup dGroup = DGroup.getByPlayer(getPlayer()); DGroup dGroup = DGroup.getByPlayer(getPlayer());
if (getCheckpoint() == null) {
teleportLocation = dGroup.getGameWorld().getLocStart();
if (getWolf() != null) {
getWolf().teleport(dGroup.getGameWorld().getLocStart());
}
} else {
teleportLocation = getCheckpoint(); teleportLocation = getCheckpoint();
if (teleportLocation == null) {
teleportLocation = dGroup.getGameWorld().getLocStart();
}
if (teleportLocation == null) {
teleportLocation = dGroup.getGameWorld().getLocLobby();
}
if (teleportLocation == null) {
teleportLocation = getWorld().getSpawnLocation();
}
// Don't forget Doge!
if (getWolf() != null) { if (getWolf() != null) {
teleportWolf = true; teleportWolf = true;
} }
}
// Respawn Items // Respawn Items
if (getRespawnInventory() != null || getRespawnArmor() != null) { if (getRespawnInventory() != null || getRespawnArmor() != null) {
@ -876,7 +898,8 @@ public class DPlayer extends DGlobalPlayer {
} }
} }
} else if (gameWorld != null) { } else if (gameWorld
!= null) {
// Update Wolf // Update Wolf
if (getWolf() != null) { if (getWolf() != null) {
if (getWolf().isDead()) { if (getWolf().isDead()) {
@ -913,7 +936,7 @@ public class DPlayer extends DGlobalPlayer {
} }
if (teleportWolf) { if (teleportWolf) {
getWolf().teleport(getCheckpoint()); getWolf().teleport(teleportLocation);
} }
if (respawnInventory) { if (respawnInventory) {