Fixed teleport issue

This commit is contained in:
Grafe 2013-11-13 22:57:23 +01:00
parent a6b5adf1dc
commit e1e94f5bfe
4 changed files with 23 additions and 9 deletions

View File

@ -25,6 +25,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.dre.dungeonsxl.game.GameWorld; import com.dre.dungeonsxl.game.GameWorld;
import com.dre.dungeonsxl.trigger.DistanceTrigger; import com.dre.dungeonsxl.trigger.DistanceTrigger;
import com.dre.dungeonsxl.util.DUtility;
public class DPlayer { public class DPlayer {
public static P p = P.p; public static P p = P.p;
@ -100,7 +101,7 @@ public class DPlayer {
} }
} }
this.player.teleport(teleport); DUtility.secureTeleport(this.player, teleport);
} }
public void escape() { public void escape() {
@ -214,9 +215,9 @@ public class DPlayer {
public void respawn() { public void respawn() {
DGroup dgroup = DGroup.get(this.player); DGroup dgroup = DGroup.get(this.player);
if (this.checkpoint == null) { if (this.checkpoint == null) {
this.player.teleport(dgroup.getGworld().locStart); DUtility.secureTeleport(this.player, dgroup.getGworld().locStart);
} else { } else {
this.player.teleport(this.checkpoint); DUtility.secureTeleport(this.player, this.checkpoint);
} }
if (this.wolf != null) { if (this.wolf != null) {
this.wolf.teleport(this.player); this.wolf.teleport(this.player);
@ -434,9 +435,9 @@ public class DPlayer {
EditWorld eworld = EditWorld.get(dplayer.world); EditWorld eworld = EditWorld.get(dplayer.world);
if (eworld != null) { if (eworld != null) {
if (eworld.lobby == null) { if (eworld.lobby == null) {
dplayer.player.teleport(eworld.world.getSpawnLocation()); DUtility.secureTeleport(dplayer.player, eworld.world.getSpawnLocation());
} else { } else {
dplayer.player.teleport(eworld.lobby); DUtility.secureTeleport(dplayer.player, eworld.lobby);
} }
} }
} else { } else {
@ -444,12 +445,12 @@ public class DPlayer {
if (gworld != null) { if (gworld != null) {
DGroup dgroup = DGroup.get(dplayer.player); DGroup dgroup = DGroup.get(dplayer.player);
if (dplayer.checkpoint == null) { if (dplayer.checkpoint == null) {
dplayer.player.teleport(dgroup.getGworld().locStart); DUtility.secureTeleport(dplayer.player, dgroup.getGworld().locStart);
if (dplayer.wolf != null) { if (dplayer.wolf != null) {
dplayer.wolf.teleport(dgroup.getGworld().locStart); dplayer.wolf.teleport(dgroup.getGworld().locStart);
} }
} else { } else {
dplayer.player.teleport(dplayer.checkpoint); DUtility.secureTeleport(dplayer.player, dplayer.checkpoint);
if (dplayer.wolf != null) { if (dplayer.wolf != null) {
dplayer.wolf.teleport(dplayer.checkpoint); dplayer.wolf.teleport(dplayer.checkpoint);
} }

View File

@ -15,6 +15,8 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.dre.dungeonsxl.util.DUtility;
public class DSavePlayer { public class DSavePlayer {
private static P p = P.p; private static P p = P.p;
@ -71,7 +73,7 @@ public class DSavePlayer {
} }
onlinePlayer.addPotionEffects(this.oldPotionEffects); onlinePlayer.addPotionEffects(this.oldPotionEffects);
onlinePlayer.teleport(this.oldLocation); DUtility.secureTeleport(onlinePlayer, this.oldLocation);
} else { } else {
/* Player is offline */ /* Player is offline */
Player offlinePlayer = p.getOfflinePlayer(this.playerName, this.oldLocation); Player offlinePlayer = p.getOfflinePlayer(this.playerName, this.oldLocation);

View File

@ -37,6 +37,7 @@ import com.dre.dungeonsxl.game.GameChest;
import com.dre.dungeonsxl.game.GameWorld; import com.dre.dungeonsxl.game.GameWorld;
import com.dre.dungeonsxl.trigger.InteractTrigger; import com.dre.dungeonsxl.trigger.InteractTrigger;
import com.dre.dungeonsxl.trigger.UseItemTrigger; import com.dre.dungeonsxl.trigger.UseItemTrigger;
import com.dre.dungeonsxl.util.DUtility;
public class PlayerListener implements Listener { public class PlayerListener implements Listener {
public P p = P.p; public P p = P.p;
@ -465,7 +466,7 @@ public class PlayerListener implements Listener {
@Override @Override
public void run() { public void run() {
if (this.player.getLocation().distance(this.location) > 2) { if (this.player.getLocation().distance(this.location) > 2) {
this.player.teleport(this.location); DUtility.secureTeleport(this.player, this.location);
} }
DPlayer dplayer = DPlayer.get(this.player); DPlayer dplayer = DPlayer.get(this.player);

View File

@ -6,10 +6,12 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import com.dre.dungeonsxl.P; import com.dre.dungeonsxl.P;
@ -81,4 +83,12 @@ public class DUtility {
} }
} }
} }
public static void secureTeleport(Player player, Location location){
if(player.isInsideVehicle()){
player.leaveVehicle();
}
player.teleport(location);
}
} }