From 1fabb59eb5454128297bb4fd1423890992173d25 Mon Sep 17 00:00:00 2001 From: walterhiggins Date: Sun, 18 Jan 2015 21:16:38 +0000 Subject: [PATCH] Fixes issue #204 (getPlayerPos() throws error) --- docs/API-Reference.md | 3 +-- src/main/js/modules/utils/utils.js | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/API-Reference.md b/docs/API-Reference.md index 0decf23..309607a 100644 --- a/docs/API-Reference.md +++ b/docs/API-Reference.md @@ -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 diff --git a/src/main/js/modules/utils/utils.js b/src/main/js/modules/utils/utils.js index 068d9ca..57a8662 100644 --- a/src/main/js/modules/utils/utils.js +++ b/src/main/js/modules/utils/utils.js @@ -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 ( player instanceof bkBlockCommandSender ) - return player.block.location; - else - return player.location; + 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