renamed __self to self
This commit is contained in:
parent
6bcebe35e6
commit
888ee6c208
5 changed files with 47 additions and 41 deletions
|
@ -20,18 +20,18 @@ var global = this;
|
|||
}
|
||||
|
||||
var _getPlayerPos = function(){
|
||||
if (typeof __self == "undefined")
|
||||
if (typeof self == "undefined")
|
||||
return;
|
||||
return __self.location;
|
||||
return self.location;
|
||||
};
|
||||
|
||||
var _getMousePos = function(){
|
||||
if (typeof __self == "undefined")
|
||||
if (typeof self == "undefined")
|
||||
return;
|
||||
// __self might be CONSOLE or a CommandBlock
|
||||
if (!__self.getTargetBlock)
|
||||
// self might be CONSOLE or a CommandBlock
|
||||
if (!self.getTargetBlock)
|
||||
return;
|
||||
var targetedBlock = __self.getTargetBlock(null,5);
|
||||
var targetedBlock = self.getTargetBlock(null,5);
|
||||
if (targetedBlock == null || targetedBlock.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ var global = this;
|
|||
metadata = 0;
|
||||
var pl = org.bukkit.entity.Player;
|
||||
var cs = org.bukkit.command.BlockCommandSender;
|
||||
var world = (__self instanceof pl)?__self.location.world:(__self instanceof cs)?__self.block.location.world:null;
|
||||
var world = (self instanceof pl)?self.location.world:(self instanceof cs)?self.block.location.world:null;
|
||||
var block = world.getBlockAt(x,y,z);
|
||||
if (block.typeId != blockId || block.data != metadata)
|
||||
block.setTypeIdAndData(blockId,metadata,false);
|
||||
|
@ -75,12 +75,12 @@ var global = this;
|
|||
};
|
||||
|
||||
var _getWorld = function(){
|
||||
if (__self instanceof org.bukkit.entity.Player)
|
||||
return __self.location.world;
|
||||
if (typeof __self == "undefined")
|
||||
if (self instanceof org.bukkit.entity.Player)
|
||||
return self.location.world;
|
||||
if (typeof self == "undefined")
|
||||
return;
|
||||
if (__self instanceof org.bukkit.command.BlockCommandSender)
|
||||
return __self.block.location.world;
|
||||
if (self instanceof org.bukkit.command.BlockCommandSender)
|
||||
return self.block.location.world;
|
||||
};
|
||||
|
||||
var _notifyAdministrators = function(msg){
|
||||
|
@ -93,11 +93,11 @@ var global = this;
|
|||
};
|
||||
var _echo = function(msg){
|
||||
__plugin.logger.info(msg);
|
||||
if (typeof __self == "undefined"){
|
||||
if (typeof self == "undefined"){
|
||||
java.lang.System.out.println(msg);
|
||||
return;
|
||||
}
|
||||
__self.sendMessage(msg);
|
||||
self.sendMessage(msg);
|
||||
};
|
||||
|
||||
global.getPlayerPos = _getPlayerPos;
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
*/
|
||||
var global = this;
|
||||
var verbose = verbose || false;
|
||||
/*
|
||||
wph 20130124 - make self, plugin and bukkit public - these are far more useful now that tab-complete works.
|
||||
*/
|
||||
var bukkit = org.bukkit.Bukkit;
|
||||
var __plugin = plugin;
|
||||
//
|
||||
// private implementation
|
||||
//
|
||||
|
@ -186,7 +191,7 @@ var verbose = verbose || false;
|
|||
intercepted = true;
|
||||
}
|
||||
if (!intercepted)
|
||||
__self.sendMessage("Command '" + name + "' is not recognised");
|
||||
self.sendMessage("Command '" + name + "' is not recognised");
|
||||
}else{
|
||||
func = cmd.callback;
|
||||
var params = [];
|
||||
|
@ -357,7 +362,7 @@ var verbose = verbose || false;
|
|||
|
||||
var _getPlayerObject = function(player){
|
||||
if (typeof player == "undefined")
|
||||
return __self;
|
||||
return self;
|
||||
if (typeof player == "string")
|
||||
return org.bukkit.Bukkit.getPlayer(player);
|
||||
return player;
|
||||
|
|
|
@ -292,7 +292,7 @@ var Drone = Drone || {
|
|||
this.dir = dir%4;
|
||||
}
|
||||
// for debugging
|
||||
//__self.sendMessage("New Drone " + this.toString());
|
||||
//self.sendMessage("New Drone " + this.toString());
|
||||
if (usePlayerCoords){
|
||||
this.fwd(3);
|
||||
}
|
||||
|
@ -772,7 +772,7 @@ var Drone = Drone || {
|
|||
{
|
||||
Drone.prototype[p] = function(v){
|
||||
return function(){
|
||||
var treeLoc = new org.bukkit.Location(__self.world,this.x,this.y,this.z);
|
||||
var treeLoc = new org.bukkit.Location(self.world,this.x,this.y,this.z);
|
||||
treeLoc.world.generateTree(treeLoc,v);
|
||||
return this;
|
||||
};
|
||||
|
|
|
@ -182,14 +182,14 @@ plugin("homes", {
|
|||
var options = {
|
||||
set: function(){homes.set();},
|
||||
'delete': function(){ homes.remove();},
|
||||
help: function(){ __self.sendMessage(homes.help());},
|
||||
help: function(){ self.sendMessage(homes.help());},
|
||||
list: function(){
|
||||
var visitable = homes.list();
|
||||
if (visitable.length == 0){
|
||||
__self.sendMessage("There are no homes to visit");
|
||||
self.sendMessage("There are no homes to visit");
|
||||
return;
|
||||
}else{
|
||||
__self.sendMessage([
|
||||
self.sendMessage([
|
||||
"You can visit any of these " + visitable.length + " homes"
|
||||
,visitable.join(", ")
|
||||
]);
|
||||
|
@ -198,53 +198,53 @@ plugin("homes", {
|
|||
ilist: function(){
|
||||
var potentialVisitors = homes.ilist();
|
||||
if (potentialVisitors.length == 0)
|
||||
__self.sendMessage("No one can visit your home");
|
||||
self.sendMessage("No one can visit your home");
|
||||
else
|
||||
__self.sendMessage([
|
||||
self.sendMessage([
|
||||
"These " + potentialVisitors.length + "players can visit your home",
|
||||
potentialVisitors.join(", ")]);
|
||||
},
|
||||
invite: function(params){
|
||||
if (params.length == 1){
|
||||
__self.sendMessage("You must provide a player's name");
|
||||
self.sendMessage("You must provide a player's name");
|
||||
return;
|
||||
}
|
||||
var playerName = params[1];
|
||||
var guest = getPlayerObject(playerName);
|
||||
if (!guest)
|
||||
__self.sendMessage(playerName + " is not here");
|
||||
self.sendMessage(playerName + " is not here");
|
||||
else
|
||||
homes.invite(__self,guest);
|
||||
homes.invite(self,guest);
|
||||
},
|
||||
uninvite: function(params){
|
||||
if (params.length == 1){
|
||||
__self.sendMessage("You must provide a player's name");
|
||||
self.sendMessage("You must provide a player's name");
|
||||
return;
|
||||
}
|
||||
var playerName = params[1];
|
||||
var guest = getPlayerObject(playerName);
|
||||
if (!guest)
|
||||
__self.sendMessage(playerName + " is not here");
|
||||
self.sendMessage(playerName + " is not here");
|
||||
else
|
||||
homes.uninvite(__self,guest);
|
||||
homes.uninvite(self,guest);
|
||||
},
|
||||
'public': function(params){
|
||||
homes.open(__self,params.slice(1).join(' '));
|
||||
__self.sendMessage("Your home is open to the public");
|
||||
homes.open(self,params.slice(1).join(' '));
|
||||
self.sendMessage("Your home is open to the public");
|
||||
},
|
||||
'private': function(){
|
||||
homes.close();
|
||||
__self.sendMessage("Your home is closed to the public");
|
||||
self.sendMessage("Your home is closed to the public");
|
||||
},
|
||||
listall: function(){
|
||||
if (!__self.isOp())
|
||||
__self.sendMessage("Only operators can do this");
|
||||
if (!self.isOp())
|
||||
self.sendMessage("Only operators can do this");
|
||||
else
|
||||
__self.sendMessage(homes.listall().join(", "));
|
||||
self.sendMessage(homes.listall().join(", "));
|
||||
},
|
||||
clear: function(params){
|
||||
if (!__self.isOp())
|
||||
__self.sendMessage("Only operators can do this");
|
||||
if (!self.isOp())
|
||||
self.sendMessage("Only operators can do this");
|
||||
else
|
||||
homes.clear(params[1]);
|
||||
}
|
||||
|
@ -266,9 +266,9 @@ plugin("homes", {
|
|||
else{
|
||||
var host = getPlayerObject(params[0]);
|
||||
if (!host)
|
||||
__self.sendMessage(params[0] + " is not here");
|
||||
self.sendMessage(params[0] + " is not here");
|
||||
else
|
||||
homes.go(__self,host);
|
||||
homes.go(self,host);
|
||||
}
|
||||
},optionList);
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
load(__folder + "../utils/text.js");
|
||||
/*
|
||||
Define the signs module - signs are persistent
|
||||
(that is - a menu sign will still be a menu after th
|
||||
|
@ -33,7 +34,7 @@ var signs = signs || plugin("signs", {
|
|||
if (offset+i < optLen)
|
||||
text = p_displayOptions[offset+i];
|
||||
if (offset+i == p_selectedIndex)
|
||||
text = ("" + text).replace(/^ /,">");
|
||||
text = ("" + text).replace(/^ /,">".white());
|
||||
p_sign.setLine(i+1,text);
|
||||
}
|
||||
p_sign.update(true);
|
||||
|
@ -92,7 +93,7 @@ var signs = signs || plugin("signs", {
|
|||
// per-sign variables go here
|
||||
//
|
||||
var cSelectedIndex = selectedIndex;
|
||||
sign.setLine(0,paddedLabel);
|
||||
sign.setLine(0,paddedLabel.bold());
|
||||
var _updateSign = function(p_player,p_sign) {
|
||||
cSelectedIndex = (cSelectedIndex+1) % optLen;
|
||||
_redrawMenuSign(p_sign,cSelectedIndex,displayOptions);
|
||||
|
|
Reference in a new issue