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