Fixes issue #204 (getPlayerPos() throws error)

This commit is contained in:
walterhiggins 2015-01-18 21:16:38 +00:00
parent 60e3e547bd
commit 1fabb59eb5
2 changed files with 17 additions and 10 deletions

View file

@ -4981,8 +4981,7 @@ Location object.
This function returns the player's [Location][cmloc] (x, y, z, pitch
and yaw) for a named player. If the "player" is in fact a
[org.bukkit.command.BlockCommandSender][bkbcs] then the attached
Block's location is returned.
[BlockCommand][bkbcs] then the attached Block's location is returned.
#### Parameters

View file

@ -205,8 +205,7 @@ exports.getPlayerObject = function( player ) {
This function returns the player's [Location][cmloc] (x, y, z, pitch
and yaw) for a named player. If the "player" is in fact a
[org.bukkit.command.BlockCommandSender][bkbcs] then the attached
Block's location is returned.
[BlockCommand][bkbcs] then the attached Block's location is returned.
#### Parameters
@ -219,16 +218,25 @@ A [Location][cmloc] object.
[bkbcs]: http://jd.bukkit.org/dev/apidocs/org/bukkit/command/BlockCommandSender.html
[bksndr]: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/command/CommandSender.html
***/
exports.getPlayerPos = function( player ) {
function getPlayerPos( player ){
player = _player( player );
if ( player ) {
if (__plugin.bukkit){
if ( player instanceof bkBlockCommandSender )
return player.block.location;
else
return player.location;
}
if (__plugin.canary){
if ( player instanceof Packages.net.canarymod.api.world.blocks.CommandBlock)
return player.block.location;
else
return player.location;
}
}
return null;
};
}
exports.getPlayerPos = getPlayerPos;
/************************************************************************
### utils.getMousePos() function