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 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 and yaw) for a named player. If the "player" is in fact a
[org.bukkit.command.BlockCommandSender][bkbcs] then the attached [BlockCommand][bkbcs] then the attached Block's location is returned.
Block's location is returned.
#### Parameters #### Parameters

View file

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