Only set the velocity if a player did successfully teleport. Issue #72

This commit is contained in:
Eric Stokes 2011-09-17 11:12:02 -06:00
parent e3edcb88df
commit 1b42a25ccb
3 changed files with 24 additions and 28 deletions

View File

@ -267,12 +267,13 @@ public class MVTeleport {
}
if (safeLoc != null) {
e.teleport(safeLoc);
if(e.teleport(safeLoc)) {
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
e.setVelocity(d.getVelocity());
}
return true;
}
}
return false;
}

View File

@ -13,6 +13,7 @@ import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.onarandombox.MultiverseCore.listeners.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World.Environment;
@ -21,6 +22,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.config.Configuration;
@ -56,10 +58,6 @@ import com.onarandombox.MultiverseCore.commands.WhoCommand;
import com.onarandombox.MultiverseCore.configuration.DefaultConfig;
import com.onarandombox.MultiverseCore.configuration.MVConfigMigrator;
import com.onarandombox.MultiverseCore.configuration.MVCoreConfigMigrator;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.utils.CannonDestination;
import com.onarandombox.utils.DebugLog;
import com.onarandombox.utils.DestinationFactory;
@ -119,7 +117,6 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
getDataFolder().mkdirs();
// Setup our Debug Log
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
}
public Configuration getConfig() {

View File

@ -126,8 +126,6 @@ public class TeleportCommand extends MultiverseCommand {
}
String message = ChatColor.GREEN + "Multiverse" + ChatColor.WHITE + " did not teleport " + ChatColor.AQUA + player + ChatColor.WHITE + " to " + ChatColor.DARK_AQUA + d.getName() + ChatColor.WHITE + " because it was unsafe.";
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items, paramTypes, message, "Would you like to try anyway?", "", "", 15);
} else {
teleportee.setVelocity(d.getVelocity());
}
}