diff --git a/src/main/javascript/utils/utils.js b/src/main/javascript/utils/utils.js new file mode 100644 index 0000000..0a260da --- /dev/null +++ b/src/main/javascript/utils/utils.js @@ -0,0 +1,24 @@ +/************************************************************************ +Utilities Module +================ +Miscellaneous utility functions and classes to help with programming. + + * locationToString(Location) - returns a bukkit Location object in string form. + + * getPlayerObject(playerName) - returns the Player object for a named + player or `self` if no name is provided. + +***/ +var utils = utils || { + locationToString: function(location){ + return JSON.stringify([""+location.world.name,location.x, location.y, location.z]); + }, + + getPlayerObject: function(playerName){ + if (typeof playerName == "undefined") + return self; + if (typeof playerName == "string") + return org.bukkit.Bukkit.getPlayer(playerName); + return player; + } +};