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

@ -27,7 +27,7 @@ public class MVTeleport {
/**
* This method will be specific to beds, and check on top of the bed then around it.
*
*
* @return
*/
public Location getSafeBedDestination(Location bedLocation) {
@ -103,7 +103,7 @@ public class MVTeleport {
/**
* For my crappy algorithm, radius MUST be odd
*
*
* @param l
* @param radius
* @return
@ -186,7 +186,7 @@ public class MVTeleport {
/**
* Deprectated. use safelyTeleport(Entity e, Destination d)
*
*
* @param e
* @param l
* @return
@ -202,7 +202,7 @@ public class MVTeleport {
}
/**
*
*
* @param e
* @param l
* @return
@ -250,7 +250,7 @@ public class MVTeleport {
}
/**
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if it's not, will adjust the final destination accordingly.
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if it's not, will adjust the final destination accordingly.
* @param e Entity to teleport
* @param d Destination to teleport them to
* @return true for success, false for failure
@ -260,25 +260,26 @@ public class MVTeleport {
this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination");
return false;
}
Location safeLoc = d.getLocation(e);
if(d.useSafeTeleporter()) {
safeLoc = this.getSafeLocation(e, d);
}
if (safeLoc != null) {
e.teleport(safeLoc);
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
e.setVelocity(d.getVelocity());
}
if(e.teleport(safeLoc)) {
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
e.setVelocity(d.getVelocity());
}
return true;
}
}
return false;
}
/**
* Returns a safe location for the entity to spawn at.
*
*
* @param e The entity to spawn
* @param d The MVDestination to take the entity to.
* @return A new location to spawn the entity at.

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() {
@ -192,7 +189,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
log.info(tag + " This plugin needs AllPay v" + allpayversion + " or higher!");
return false;
}
private boolean validateCH() {
try {
this.commandHandler = new CommandHandler(this, null);
@ -366,7 +363,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* Grab the players session if one exists, otherwise create a session then return it.
*
*
* @param player
* @return
*/
@ -381,7 +378,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* Grab and return the Teleport class.
*
*
* @return
*/
public MVTeleport getTeleporter() {
@ -416,7 +413,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* Print messages to the server Log as well as to our DebugLog. 'debugLog' is used to seperate Heroes information from the Servers Log Output.
*
*
* @param level
* @param msg
*/
@ -442,7 +439,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the standard Server Console.
*
*
* @param level
* @param msg
*/
@ -453,7 +450,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
*
* @return
*/
private String getAuthors() {
@ -484,7 +481,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* This code should get moved somewhere more appropriate, but for now, it's here.
*
*
* @param env
* @return
*/
@ -535,7 +532,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* Returns the number of plugins that have specifically hooked into core.
*
*
* @return
*/
public int getPluginCount() {
@ -570,7 +567,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
/**
* This is a convenience method to allow the QueuedCommand system to call it. You should NEVER call this directly.
*
*
* @param p Player
* @param l The potentially unsafe location.
*/

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());
}
}