reorg
This commit is contained in:
parent
d0da034fb7
commit
b2761d29e3
27 changed files with 516 additions and 536 deletions
|
@ -1,4 +1,7 @@
|
||||||
plugin("alias", {
|
|
||||||
|
var _store = {players: {}};
|
||||||
|
|
||||||
|
var alias = plugin("alias", {
|
||||||
help: function(){
|
help: function(){
|
||||||
return [
|
return [
|
||||||
"/jsp alias set <alias> <commands> : Set a shortcut/alias for one or more commands (separated by ';')\n" +
|
"/jsp alias set <alias> <commands> : Set a shortcut/alias for one or more commands (separated by ';')\n" +
|
||||||
|
@ -10,30 +13,30 @@ plugin("alias", {
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
set: function(player, alias, commands){
|
set: function(player, alias, commands){
|
||||||
var aliases = this.store.players;
|
var aliases = _store.players;
|
||||||
var name = player.name;
|
var name = player.name;
|
||||||
if (typeof aliases[name] == "undefined")
|
if (typeof aliases[name] == "undefined")
|
||||||
aliases[name] = {};
|
aliases[name] = {};
|
||||||
aliases[name][alias] = commands;
|
aliases[name][alias] = commands;
|
||||||
},
|
},
|
||||||
remove: function(player, alias){
|
remove: function(player, alias){
|
||||||
var aliases = this.store.players;
|
var aliases = _store.players;
|
||||||
if (aliases[player.name])
|
if (aliases[player.name])
|
||||||
delete aliases[player.name][alias];
|
delete aliases[player.name][alias];
|
||||||
},
|
},
|
||||||
list: function(player){
|
list: function(player){
|
||||||
var result = [];
|
var result = [];
|
||||||
var aliases = this.store.players[player.name];
|
var aliases = _store.players[player.name];
|
||||||
for (var a in aliases)
|
for (var a in aliases)
|
||||||
result.push(a + " = " + aliases[a].join(";"));
|
result.push(a + " = " + aliases[a].join(";"));
|
||||||
return result;
|
return result;
|
||||||
}
|
},
|
||||||
|
store: _store
|
||||||
},true);
|
},true);
|
||||||
|
|
||||||
if (typeof alias.store.players == "undefined")
|
exports.alias = alias;
|
||||||
alias.store.players = {};
|
|
||||||
|
|
||||||
command("alias",function(params){
|
command("alias", function ( params ) {
|
||||||
/*
|
/*
|
||||||
this function also intercepts command options for /jsp
|
this function also intercepts command options for /jsp
|
||||||
*/
|
*/
|
||||||
|
@ -59,7 +62,7 @@ command("alias",function(params){
|
||||||
if (params.length == 0)
|
if (params.length == 0)
|
||||||
return self.sendMessage(alias.help());
|
return self.sendMessage(alias.help());
|
||||||
|
|
||||||
var playerHasAliases = alias.store.players[self.name];
|
var playerHasAliases = _store.players[self.name];
|
||||||
if (!playerHasAliases)
|
if (!playerHasAliases)
|
||||||
return false;
|
return false;
|
||||||
// is it an alias?
|
// is it an alias?
|
||||||
|
|
|
@ -1,25 +1,33 @@
|
||||||
/*
|
/*************************************************************************
|
||||||
|
|
||||||
The arrows mod adds fancy arrows to the game.
|
## The arrows mod adds fancy arrows to the game.
|
||||||
|
|
||||||
Usage:
|
### Usage:
|
||||||
|
|
||||||
/js arrows.sign() turns a targeted sign into a Arrows menu
|
/js var arrows = require('./arrows/arrows')
|
||||||
/js arrows.normal() sets arrow type to normal.
|
|
||||||
/js arrows.explosive() - makes arrows explode.
|
* `/js arrows.sign()` turns a targeted sign into a Arrows menu
|
||||||
/js arrows.teleport() - makes player teleport to where arrow has landed.
|
* `/js arrows.normal()` sets arrow type to normal.
|
||||||
/js arrows.flourish() - makes a tree grow where the arrow lands.
|
* `/js arrows.explosive()` - makes arrows explode.
|
||||||
/js arrows.lightning() - lightning strikes where the arrow lands.
|
* `/js arrows.teleport()` - makes player teleport to where arrow has landed.
|
||||||
/js arrows.firework() - A firework launches where the the arrow lands.
|
* `/js arrows.flourish()` - makes a tree grow where the arrow lands.
|
||||||
|
* `/js arrows.lightning()` - lightning strikes where the arrow lands.
|
||||||
|
* `/js arrows.firework()` - A firework launches where the the arrow lands.
|
||||||
|
|
||||||
All of the above functions can take an optional player object or name as
|
All of the above functions can take an optional player object or name as
|
||||||
a parameter. E.g.
|
a parameter. E.g.
|
||||||
|
|
||||||
/js arrows.explosive('player23') makes player23's arrows explosive.
|
`/js arrows.explosive('player23')` makes player23's arrows explosive.
|
||||||
|
|
||||||
*/
|
***/
|
||||||
|
|
||||||
var arrows = arrows || plugin("arrows",{
|
var signs = require('signs');
|
||||||
|
var events = require('events');
|
||||||
|
var fireworks = require('fireworks');
|
||||||
|
|
||||||
|
var _store = {players: {}};
|
||||||
|
|
||||||
|
var arrows = plugin("arrows",{
|
||||||
/*
|
/*
|
||||||
turn a sign into a menu of arrow choices
|
turn a sign into a menu of arrow choices
|
||||||
*/
|
*/
|
||||||
|
@ -48,24 +56,20 @@ var arrows = arrows || plugin("arrows",{
|
||||||
/*
|
/*
|
||||||
launch a firework where the arrow lands
|
launch a firework where the arrow lands
|
||||||
*/
|
*/
|
||||||
explosiveYield: 2.5
|
explosiveYield: 2.5,
|
||||||
|
|
||||||
|
store: _store
|
||||||
|
|
||||||
},true);
|
},true);
|
||||||
/*
|
|
||||||
initialize data
|
|
||||||
*/
|
|
||||||
arrows.store.players = arrows.store.players || {};
|
|
||||||
|
|
||||||
/*
|
exports.arrows = arrows;
|
||||||
private implementation of normal, explosive, teleport, flourish and lightning functions
|
|
||||||
*/
|
//
|
||||||
(function(){
|
// setup functions for the arrow types
|
||||||
//
|
//
|
||||||
// setup functions for the arrow types
|
var _types = {normal: 0, explosive: 1, teleport: 2, flourish: 3, lightning: 4, firework: 5};
|
||||||
//
|
for (var type in _types)
|
||||||
var _types = {normal: 0, explosive: 1, teleport: 2, flourish: 3, lightning: 4, firework: 5};
|
{
|
||||||
for (var type in _types)
|
|
||||||
{
|
|
||||||
arrows[type] = (function(n){
|
arrows[type] = (function(n){
|
||||||
return function(player){
|
return function(player){
|
||||||
if (typeof player == "undefined")
|
if (typeof player == "undefined")
|
||||||
|
@ -78,36 +82,32 @@ arrows.store.players = arrows.store.players || {};
|
||||||
arrows.store.players[playerName] = n;
|
arrows.store.players[playerName] = n;
|
||||||
};
|
};
|
||||||
})(_types[type]);
|
})(_types[type]);
|
||||||
}
|
}
|
||||||
}());
|
|
||||||
/*
|
/*
|
||||||
Arrows depends on 2 other modules: 'signs' and 'events' so the following code
|
|
||||||
can't execute until all modules have loaded (ready).
|
|
||||||
*/
|
|
||||||
ready(function()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
called when the player chooses an arrow option from a menu sign
|
called when the player chooses an arrow option from a menu sign
|
||||||
*/
|
*/
|
||||||
var _onMenuChoice = function(event){
|
var _onMenuChoice = function(event){
|
||||||
arrows.store.players[event.player.name] = event.number;
|
arrows.store.players[event.player.name] = event.number;
|
||||||
};
|
};
|
||||||
arrows.sign = signs.menu("Arrow",
|
arrows.sign = signs.menu("Arrow",
|
||||||
["Normal","Explosive","Teleport","Flourish","Lightning","Firework"],
|
["Normal","Explosive","Teleport","Flourish","Lightning","Firework"],
|
||||||
_onMenuChoice );
|
_onMenuChoice );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
event handler called when a projectile hits something
|
event handler called when a projectile hits something
|
||||||
*/
|
*/
|
||||||
var _onArrowHit = function(listener,event)
|
var _onArrowHit = function(listener,event)
|
||||||
{
|
{
|
||||||
var projectile = event.entity;
|
var projectile = event.entity;
|
||||||
var world = projectile.world;
|
var world = projectile.world;
|
||||||
var shooter = projectile.shooter;
|
var shooter = projectile.shooter;
|
||||||
|
var fireworkCount = 5;
|
||||||
if (projectile instanceof org.bukkit.entity.Arrow &&
|
if (projectile instanceof org.bukkit.entity.Arrow &&
|
||||||
shooter instanceof org.bukkit.entity.Player)
|
shooter instanceof org.bukkit.entity.Player)
|
||||||
{
|
{
|
||||||
var arrowType = arrows.store.players[shooter.name];
|
var arrowType = arrows.store.players[shooter.name];
|
||||||
|
|
||||||
switch (arrowType){
|
switch (arrowType){
|
||||||
case 1:
|
case 1:
|
||||||
projectile.remove();
|
projectile.remove();
|
||||||
|
@ -129,10 +129,15 @@ ready(function()
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
projectile.remove();
|
projectile.remove();
|
||||||
|
var launch = function(){
|
||||||
fireworks.firework(projectile.location);
|
fireworks.firework(projectile.location);
|
||||||
|
if (--fireworkCount)
|
||||||
|
setTimeout(launch,2000);
|
||||||
|
};
|
||||||
|
launch();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
events.on("entity.ProjectileHitEvent",_onArrowHit);
|
events.on('entity.ProjectileHitEvent',_onArrowHit);
|
||||||
});
|
|
||||||
|
|
|
@ -1,47 +1,50 @@
|
||||||
|
/*
|
||||||
|
TODO: Document this module
|
||||||
|
*/
|
||||||
|
var events = require('events');
|
||||||
|
|
||||||
|
var _store = {players: {}};
|
||||||
/*
|
/*
|
||||||
declare a new javascript plugin for changing chat text color
|
declare a new javascript plugin for changing chat text color
|
||||||
*/
|
*/
|
||||||
var chat = chat || plugin("chat", {
|
exports.chat = plugin("chat", {
|
||||||
/*
|
/*
|
||||||
set the color of text for a given player
|
set the color of text for a given player
|
||||||
*/
|
*/
|
||||||
setColor: function(player, color){
|
setColor: function(player, color){
|
||||||
this.store.players[player.name] = color;
|
this.store.players[player.name] = color;
|
||||||
}
|
},
|
||||||
},true);
|
|
||||||
/*
|
|
||||||
initialize the store
|
|
||||||
*/
|
|
||||||
chat.store.players = chat.store.players || {};
|
|
||||||
|
|
||||||
ready(function()
|
store: _store
|
||||||
{
|
|
||||||
var colors = [
|
},true);
|
||||||
|
|
||||||
|
var colors = [
|
||||||
"black", "blue", "darkgreen", "darkaqua", "darkred",
|
"black", "blue", "darkgreen", "darkaqua", "darkred",
|
||||||
"purple", "gold", "gray", "darkgray", "indigo",
|
"purple", "gold", "gray", "darkgray", "indigo",
|
||||||
"brightgreen", "aqua", "red", "pink", "yellow", "white"
|
"brightgreen", "aqua", "red", "pink", "yellow", "white"
|
||||||
];
|
];
|
||||||
var colorCodes = {};
|
var colorCodes = {};
|
||||||
for (var i =0;i < colors.length;i++) {
|
for (var i =0;i < colors.length;i++) {
|
||||||
var hexCode = i.toString(16);
|
var hexCode = i.toString(16);
|
||||||
colorCodes[colors[i]] = hexCode;
|
colorCodes[colors[i]] = hexCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
events.on("player.AsyncPlayerChatEvent",function(l,e){
|
events.on("player.AsyncPlayerChatEvent",function(l,e){
|
||||||
var player = e.player;
|
var player = e.player;
|
||||||
var playerChatColor = chat.store.players[player.name];
|
var playerChatColor = chat.store.players[player.name];
|
||||||
if (playerChatColor){
|
if (playerChatColor){
|
||||||
e.message = "§" + colorCodes[playerChatColor] + e.message;
|
e.message = "§" + colorCodes[playerChatColor] + e.message;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var listColors = function(params){
|
var listColors = function(params){
|
||||||
var colorNamesInColor = [];
|
var colorNamesInColor = [];
|
||||||
for (var i = 0;i < colors.length;i++)
|
for (var i = 0;i < colors.length;i++)
|
||||||
colorNamesInColor[i] = "§"+colorCodes[colors[i]] + colors[i];
|
colorNamesInColor[i] = "§"+colorCodes[colors[i]] + colors[i];
|
||||||
self.sendMessage("valid chat colors are " + colorNamesInColor.join(", "));
|
self.sendMessage("valid chat colors are " + colorNamesInColor.join(", "));
|
||||||
};
|
};
|
||||||
command("list_colors", listColors);
|
command("list_colors", listColors);
|
||||||
command("chat_color",function(params){
|
command("chat_color",function(params){
|
||||||
var color = params[0];
|
var color = params[0];
|
||||||
if (colorCodes[color]){
|
if (colorCodes[color]){
|
||||||
chat.setColor(self,color);
|
chat.setColor(self,color);
|
||||||
|
@ -49,5 +52,5 @@ ready(function()
|
||||||
self.sendMessage(color + " is not a valid color");
|
self.sendMessage(color + " is not a valid color");
|
||||||
listColors();
|
listColors();
|
||||||
}
|
}
|
||||||
},colors);
|
},colors);
|
||||||
});
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
var utils = require('utils');
|
||||||
|
var events = require('events');
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Classroom Module
|
Classroom Module
|
||||||
================
|
================
|
||||||
|
@ -41,13 +44,10 @@ Only ops users can run the classroom.allowScripting() function - this is so that
|
||||||
don't try to bar themselves and each other from scripting.
|
don't try to bar themselves and each other from scripting.
|
||||||
|
|
||||||
***/
|
***/
|
||||||
var classroom = {
|
var _canScript = false;
|
||||||
allowScripting: function(/* boolean: true or false */ canScript){}
|
|
||||||
};
|
|
||||||
|
|
||||||
ready(function(){
|
exports.classroom = {
|
||||||
classroom.allowScripting = function(canScript)
|
allowScripting: function (/* boolean: true or false */ canScript) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
only operators should be allowed run this function
|
only operators should be allowed run this function
|
||||||
*/
|
*/
|
||||||
|
@ -67,12 +67,13 @@ ready(function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
classroom.canScript = canScript;
|
_canScript = canScript;
|
||||||
};
|
}
|
||||||
events.on("player.PlayerLoginEvent", function(listener, event) {
|
};
|
||||||
|
events.on('player.PlayerLoginEvent', function(listener, event) {
|
||||||
var player = event.player;
|
var player = event.player;
|
||||||
if (classroom.canScript){
|
if (classroom.canScript){
|
||||||
player.addAttachment(__plugin, "scriptcraft.*", true);
|
player.addAttachment(__plugin, "scriptcraft.*", true);
|
||||||
}
|
}
|
||||||
}, "HIGHEST");
|
}, "HIGHEST");
|
||||||
});
|
|
||||||
|
|
|
@ -272,4 +272,4 @@ blocks.rainbow = [blocks.wool.red,
|
||||||
blocks.wool.purple];
|
blocks.wool.purple];
|
||||||
|
|
||||||
|
|
||||||
module.exports = blocks;
|
exports.blocks = blocks;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
var Drone = require('./drone');
|
var Drone = require('./drone').Drone;
|
||||||
var blocks = require('./blocks');
|
var blocks = require('./blocks').blocks;
|
||||||
|
|
||||||
module.exports = Drone;
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Drone.blocktype() method
|
Drone.blocktype() method
|
||||||
========================
|
========================
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
//
|
//
|
||||||
// a castle is just a big wide fort with 4 taller forts at each corner
|
// a castle is just a big wide fort with 4 taller forts at each corner
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
var blocks = require('../blocks');
|
var blocks = require('../blocks').blocks;
|
||||||
|
|
||||||
module.exports = Drone;
|
|
||||||
/**
|
/**
|
||||||
* Creates a tile pattern of given block types and size
|
* Creates a tile pattern of given block types and size
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
//
|
//
|
||||||
// usage:
|
// usage:
|
||||||
// [1] to build a cottage at the player's current location or the cross-hairs location...
|
// [1] to build a cottage at the player's current location or the cross-hairs location...
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
//
|
//
|
||||||
// Create a floor of colored tiles some of which emit light.
|
// Create a floor of colored tiles some of which emit light.
|
||||||
// The tiles change color every second creating a strobe-lit dance-floor.
|
// The tiles change color every second creating a strobe-lit dance-floor.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
//
|
//
|
||||||
// constructs a medieval fort
|
// constructs a medieval fort
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
//
|
//
|
||||||
// Constructs the JS logo
|
// Constructs the JS logo
|
||||||
// https://raw.github.com/voodootikigod/logo.js/master/js.png
|
// https://raw.github.com/voodootikigod/logo.js/master/js.png
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
var blocks = require('../blocks');
|
var blocks = require('../blocks').blocks;
|
||||||
module.exports = Drone;
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Drone.rainbow() method
|
Drone.rainbow() method
|
||||||
======================
|
======================
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
/**
|
/**
|
||||||
* Iterates over each cube in a cubic region. For each cube has a chance to callback your
|
* Iterates over each cube in a cubic region. For each cube has a chance to callback your
|
||||||
* function and provide a new drone to it.
|
* function and provide a new drone to it.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
var blocks = require('../blocks');
|
var blocks = require('../blocks').blocks;
|
||||||
module.exports = Drone;
|
|
||||||
//
|
//
|
||||||
// usage:
|
// usage:
|
||||||
// [1] to place a new block with redstone wire on it (block on bottom, redstone on top)
|
// [1] to place a new block with redstone wire on it (block on bottom, redstone on top)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
var blocks = require('../blocks');
|
var blocks = require('../blocks').blocks;
|
||||||
|
|
||||||
module.exports = Drone;
|
|
||||||
Drone.extend('skyscraper',function(floors){
|
Drone.extend('skyscraper',function(floors){
|
||||||
|
|
||||||
if (typeof floors == "undefined")
|
if (typeof floors == "undefined")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
var blocks = require('../blocks');
|
var blocks = require('../blocks').blocks;
|
||||||
|
|
||||||
module.exports = Drone;
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Drone.spiral_stairs() method
|
Drone.spiral_stairs() method
|
||||||
============================
|
============================
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
/**
|
/**
|
||||||
* Creates a stream of blocks in a given direction until it hits something other than air
|
* Creates a stream of blocks in a given direction until it hits something other than air
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
var Drone = require('../drone');
|
var Drone = require('../drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
//
|
//
|
||||||
// constructs a mayan temple
|
// constructs a mayan temple
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
var Drone = require('./drone');
|
|
||||||
var utils = require('../utils/utils');
|
|
||||||
|
|
||||||
var files = [];
|
|
||||||
|
|
||||||
var filter = function(file,name){
|
|
||||||
name = "" + name;
|
|
||||||
if (name.match(/drone\.js$/))
|
|
||||||
return false;
|
|
||||||
if (name.match(/drone\-exts\.js$/))
|
|
||||||
return false;
|
|
||||||
if (name.match(/\.js$/))
|
|
||||||
return true;
|
|
||||||
if (file.isDirectory())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
var files = utils.find(__dirname, filter);
|
|
||||||
|
|
||||||
utils.foreach(files, function (file){
|
|
||||||
require(file);
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = Drone;
|
|
|
@ -1,5 +1,5 @@
|
||||||
var _utils = require('../utils/utils');
|
var _utils = require('utils');
|
||||||
var blocks = require('./blocks');
|
var blocks = require('./blocks').blocks;
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
Drone Module
|
Drone Module
|
||||||
|
@ -732,7 +732,7 @@ Drone = function(x,y,z,dir,world)
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Drone;
|
exports.Drone = Drone;
|
||||||
|
|
||||||
//
|
//
|
||||||
// add custom methods to the Drone object using this function
|
// add custom methods to the Drone object using this function
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
var Drone = require('./drone');
|
var Drone = require('./drone').Drone;
|
||||||
module.exports = Drone;
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
Drone.sphere() method
|
Drone.sphere() method
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var Drone = require('./drone');
|
var Drone = require('./drone').Drone;
|
||||||
|
|
||||||
Drone.prototype.testHorizontalStrokeWidth = function(){
|
Drone.prototype.testHorizontalStrokeWidth = function(){
|
||||||
this.arc({
|
this.arc({
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
|
var utils = require('utils');
|
||||||
|
var _store = {
|
||||||
|
houses: {},
|
||||||
|
openHouses: {},
|
||||||
|
invites: {}
|
||||||
|
};
|
||||||
/*
|
/*
|
||||||
The homes plugin lets players set a location as home and return to the location, invite
|
The homes plugin lets players set a location as home and return to the location, invite
|
||||||
other players to their home and also visit other player's homes.
|
other players to their home and also visit other player's homes.
|
||||||
*/
|
*/
|
||||||
plugin("homes", {
|
var homes = plugin("homes", {
|
||||||
help: function(){
|
help: function(){
|
||||||
return [
|
return [
|
||||||
/* basic functions */
|
/* basic functions */
|
||||||
|
@ -33,7 +39,7 @@ plugin("homes", {
|
||||||
host = guest;
|
host = guest;
|
||||||
guest = utils.getPlayerObject(guest);
|
guest = utils.getPlayerObject(guest);
|
||||||
host = utils.getPlayerObject(host);
|
host = utils.getPlayerObject(host);
|
||||||
var loc = this.store.houses[host.name];
|
var loc = _store.houses[host.name];
|
||||||
if (!loc){
|
if (!loc){
|
||||||
guest.sendMessage(host.name + " has no home");
|
guest.sendMessage(host.name + " has no home");
|
||||||
return;
|
return;
|
||||||
|
@ -53,9 +59,9 @@ plugin("homes", {
|
||||||
_canVisit: function(guest, host){
|
_canVisit: function(guest, host){
|
||||||
if (guest == host)
|
if (guest == host)
|
||||||
return true;
|
return true;
|
||||||
if (this.store.openHouses[host.name])
|
if (_store.openHouses[host.name])
|
||||||
return true;
|
return true;
|
||||||
var invitations = this.store.invites[host.name];
|
var invitations = _store.invites[host.name];
|
||||||
if (invitations)
|
if (invitations)
|
||||||
for (var i = 0;i < invitations.length;i++)
|
for (var i = 0;i < invitations.length;i++)
|
||||||
if (invitations[i] == guest.name)
|
if (invitations[i] == guest.name)
|
||||||
|
@ -65,7 +71,7 @@ plugin("homes", {
|
||||||
set: function(player){
|
set: function(player){
|
||||||
player = utils.getPlayerObject(player);
|
player = utils.getPlayerObject(player);
|
||||||
var loc = player.location;
|
var loc = player.location;
|
||||||
this.store.houses[player.name] = [""+loc.world.name
|
_store.houses[player.name] = [""+loc.world.name
|
||||||
,Math.floor(loc.x)
|
,Math.floor(loc.x)
|
||||||
,Math.floor(loc.y)
|
,Math.floor(loc.y)
|
||||||
,Math.floor(loc.z)
|
,Math.floor(loc.z)
|
||||||
|
@ -74,7 +80,7 @@ plugin("homes", {
|
||||||
},
|
},
|
||||||
remove: function(player){
|
remove: function(player){
|
||||||
player = utils.getPlayerObject(player);
|
player = utils.getPlayerObject(player);
|
||||||
delete this.store.houses[player.name];
|
delete _store.houses[player.name];
|
||||||
},
|
},
|
||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
social functions
|
social functions
|
||||||
|
@ -85,11 +91,11 @@ plugin("homes", {
|
||||||
*/
|
*/
|
||||||
list: function(player){
|
list: function(player){
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var ohp in this.store.openHouses)
|
for (var ohp in _store.openHouses)
|
||||||
result.push(ohp);
|
result.push(ohp);
|
||||||
player = utils.getPlayerObject(player);
|
player = utils.getPlayerObject(player);
|
||||||
for (var host in this.store.invites){
|
for (var host in _store.invites){
|
||||||
var guests = this.store.invites[host];
|
var guests = _store.invites[host];
|
||||||
for (var i = 0;i < guests.length; i++)
|
for (var i = 0;i < guests.length; i++)
|
||||||
if (guests[i] == player.name)
|
if (guests[i] == player.name)
|
||||||
result.push(host);
|
result.push(host);
|
||||||
|
@ -103,14 +109,14 @@ plugin("homes", {
|
||||||
player = utils.getPlayerObject(player);
|
player = utils.getPlayerObject(player);
|
||||||
var result = [];
|
var result = [];
|
||||||
// if home is public - all players
|
// if home is public - all players
|
||||||
if (this.store.openHouses[player.name]){
|
if (_store.openHouses[player.name]){
|
||||||
var online = org.bukkit.Bukkit.getOnlinePlayers();
|
var online = org.bukkit.Bukkit.getOnlinePlayers();
|
||||||
for (var i = 0;i < online.length; i++)
|
for (var i = 0;i < online.length; i++)
|
||||||
if (online[i].name != player.name)
|
if (online[i].name != player.name)
|
||||||
result.push(online[i].name);
|
result.push(online[i].name);
|
||||||
}else{
|
}else{
|
||||||
if (this.store.invites[player.name])
|
if (_store.invites[player.name])
|
||||||
result = this.store.invites[player.name];
|
result = _store.invites[player.name];
|
||||||
else
|
else
|
||||||
result = [];
|
result = [];
|
||||||
}
|
}
|
||||||
|
@ -123,10 +129,10 @@ plugin("homes", {
|
||||||
host = utils.getPlayerObject(host);
|
host = utils.getPlayerObject(host);
|
||||||
guest = utils.getPlayerObject(guest);
|
guest = utils.getPlayerObject(guest);
|
||||||
var invitations = [];
|
var invitations = [];
|
||||||
if (this.store.invites[host.name])
|
if (_store.invites[host.name])
|
||||||
invitations = this.store.invites[host.name];
|
invitations = _store.invites[host.name];
|
||||||
invitations.push(guest.name);
|
invitations.push(guest.name);
|
||||||
this.store.invites[host.name] = invitations;
|
_store.invites[host.name] = invitations;
|
||||||
guest.sendMessage(host.name + " has invited you to their home.");
|
guest.sendMessage(host.name + " has invited you to their home.");
|
||||||
guest.sendMessage("type '/jsp home " + host.name + "' to accept");
|
guest.sendMessage("type '/jsp home " + host.name + "' to accept");
|
||||||
},
|
},
|
||||||
|
@ -136,21 +142,21 @@ plugin("homes", {
|
||||||
uninvite: function(host, guest){
|
uninvite: function(host, guest){
|
||||||
host = utils.getPlayerObject(host);
|
host = utils.getPlayerObject(host);
|
||||||
guest = utils.getPlayerObject(guest);
|
guest = utils.getPlayerObject(guest);
|
||||||
var invitations = this.store.invites[host.name];
|
var invitations = _store.invites[host.name];
|
||||||
if (!invitations)
|
if (!invitations)
|
||||||
return;
|
return;
|
||||||
var revisedInvites = [];
|
var revisedInvites = [];
|
||||||
for (var i =0;i < invitations.length; i++)
|
for (var i =0;i < invitations.length; i++)
|
||||||
if (invitations[i] != guest.name)
|
if (invitations[i] != guest.name)
|
||||||
revisedInvites.push(invitations[i]);
|
revisedInvites.push(invitations[i]);
|
||||||
this.store.invites[host.name] = revisedInvites;
|
_store.invites[host.name] = revisedInvites;
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
make the player's house public
|
make the player's house public
|
||||||
*/
|
*/
|
||||||
open: function(player, optionalMsg){
|
open: function(player, optionalMsg){
|
||||||
player = utils.getPlayerObject(player);
|
player = utils.getPlayerObject(player);
|
||||||
this.store.openHouses[player.name] = true;
|
_store.openHouses[player.name] = true;
|
||||||
if (typeof optionalMsg != "undefined")
|
if (typeof optionalMsg != "undefined")
|
||||||
__plugin.server.broadcastMessage(optionalMsg);
|
__plugin.server.broadcastMessage(optionalMsg);
|
||||||
},
|
},
|
||||||
|
@ -159,32 +165,31 @@ plugin("homes", {
|
||||||
*/
|
*/
|
||||||
close: function(player){
|
close: function(player){
|
||||||
player = utils.getPlayerObject(player);
|
player = utils.getPlayerObject(player);
|
||||||
delete this.store.openHouses[player.name];
|
delete _store.openHouses[player.name];
|
||||||
},
|
},
|
||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
admin functions
|
admin functions
|
||||||
======================================================================== */
|
======================================================================== */
|
||||||
listall: function(){
|
listall: function(){
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var home in this.store.houses)
|
for (var home in _store.houses)
|
||||||
result.push(home);
|
result.push(home);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
clear: function(player){
|
clear: function(player){
|
||||||
player = utils.getPlayerObject(player);
|
player = utils.getPlayerObject(player);
|
||||||
delete this.store.houses[player.name];
|
delete _store.houses[player.name];
|
||||||
delete this.store.openHouses[player.name];
|
delete _store.openHouses[player.name];
|
||||||
}
|
},
|
||||||
|
store: _store
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
exports.homes = homes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private implementation
|
|
||||||
*/
|
|
||||||
(function(){
|
|
||||||
/*
|
|
||||||
define a set of command options that can be used by players
|
define a set of command options that can be used by players
|
||||||
*/
|
*/
|
||||||
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());},
|
||||||
|
@ -253,14 +258,14 @@ plugin("homes", {
|
||||||
else
|
else
|
||||||
homes.clear(params[1]);
|
homes.clear(params[1]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var optionList = [];
|
var optionList = [];
|
||||||
for (var o in options)
|
for (var o in options)
|
||||||
optionList.push(o);
|
optionList.push(o);
|
||||||
/*
|
/*
|
||||||
Expose a set of commands that players can use at the in-game command prompt
|
Expose a set of commands that players can use at the in-game command prompt
|
||||||
*/
|
*/
|
||||||
command("home", function(params){
|
command("home", function ( params ) {
|
||||||
if (params.length == 0){
|
if (params.length == 0){
|
||||||
homes.go();
|
homes.go();
|
||||||
return;
|
return;
|
||||||
|
@ -275,16 +280,7 @@ plugin("homes", {
|
||||||
else
|
else
|
||||||
homes.go(self,host);
|
homes.go(self,host);
|
||||||
}
|
}
|
||||||
},optionList);
|
},optionList);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
initialize the store
|
|
||||||
*/
|
|
||||||
if (typeof homes.store.houses == "undefined")
|
|
||||||
homes.store.houses = {};
|
|
||||||
if (typeof homes.store.openHouses == "undefined")
|
|
||||||
homes.store.openHouses = {};
|
|
||||||
if (typeof homes.store.invites == "undefined")
|
|
||||||
homes.store.invites = {};
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
/*
|
/*************************************************************************
|
||||||
A basic number-guessing game that uses the Bukkit Conversation API.
|
## Minigame: Guess the number
|
||||||
*/
|
|
||||||
ready(function(){
|
|
||||||
|
|
||||||
global.GuessTheNumber = function()
|
### Example
|
||||||
{
|
|
||||||
|
/js Game_NumberGuess.start()
|
||||||
|
|
||||||
|
... Begins a number-guessing game where you must guess the number (between 1 and 10) chosen by the computer.
|
||||||
|
|
||||||
|
A basic number-guessing game that uses the Bukkit Conversation API.
|
||||||
|
***/
|
||||||
|
exports.Game_NumberGuess = {
|
||||||
|
start: function() {
|
||||||
importPackage(org.bukkit.conversations);
|
importPackage(org.bukkit.conversations);
|
||||||
|
|
||||||
var number = Math.ceil(Math.random() * 10);
|
var number = Math.ceil(Math.random() * 10);
|
||||||
|
@ -44,5 +50,5 @@ ready(function(){
|
||||||
.withPrefix(new ConversationPrefix(){ getPrefix: function(ctx){ return "[1-10] ";} })
|
.withPrefix(new ConversationPrefix(){ getPrefix: function(ctx){ return "[1-10] ";} })
|
||||||
.buildConversation(self);
|
.buildConversation(self);
|
||||||
conv.begin();
|
conv.begin();
|
||||||
};
|
}
|
||||||
});
|
};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
load(__folder + "../events/events.js");
|
var events = require('events');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OK - this is a rough and ready prototype of a simple multi-player shoot-em-up.
|
OK - this is a rough and ready prototype of a simple multi-player shoot-em-up.
|
||||||
Get a bunch of players in close proximity and issue the following commands...
|
Get a bunch of players in close proximity and issue the following commands...
|
||||||
|
@ -6,7 +7,7 @@ load(__folder + "../events/events.js");
|
||||||
/js var redTeam = ['<player1>','<player2>',...etc]
|
/js var redTeam = ['<player1>','<player2>',...etc]
|
||||||
/js var blueTeam = ['<player3>','<player4>,...etc]
|
/js var blueTeam = ['<player3>','<player4>,...etc]
|
||||||
/js var greenTeam = ['<player5>','<player6>,...etc]
|
/js var greenTeam = ['<player5>','<player6>,...etc]
|
||||||
/js new SnowBallFight({red: redTeam,blue: blueTeam,green: greenTeam},60).start();
|
/js new Game_SnowBallFight({red: redTeam,blue: blueTeam,green: greenTeam},60).start();
|
||||||
|
|
||||||
Alternatively you can just have all players play against each other...
|
Alternatively you can just have all players play against each other...
|
||||||
|
|
||||||
|
@ -29,15 +30,10 @@ load(__folder + "../events/events.js");
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var SnowBallFight = function(teams, duration){};
|
/*
|
||||||
SnowBallFight.prototype.start = function(){};
|
|
||||||
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*
|
|
||||||
setup game
|
setup game
|
||||||
*/
|
*/
|
||||||
var _startGame = function(gameState){
|
var _startGame = function(gameState){
|
||||||
// don't let game start if already in progress (wait for game to finish)
|
// don't let game start if already in progress (wait for game to finish)
|
||||||
if (gameState.inProgress){
|
if (gameState.inProgress){
|
||||||
return;
|
return;
|
||||||
|
@ -61,11 +57,11 @@ SnowBallFight.prototype.start = function(){};
|
||||||
player.inventory.addItem(gameState.ammo);
|
player.inventory.addItem(gameState.ammo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
end the game
|
end the game
|
||||||
*/
|
*/
|
||||||
var _endGame = function(gameState){
|
var _endGame = function(gameState){
|
||||||
var scores = [];
|
var scores = [];
|
||||||
|
|
||||||
var leaderBoard = [];
|
var leaderBoard = [];
|
||||||
|
@ -92,11 +88,11 @@ SnowBallFight.prototype.start = function(){};
|
||||||
var handlerList = org.bukkit.event.entity.EntityDamageByEntityEvent.getHandlerList();
|
var handlerList = org.bukkit.event.entity.EntityDamageByEntityEvent.getHandlerList();
|
||||||
handlerList.unregister(gameState.listener);
|
handlerList.unregister(gameState.listener);
|
||||||
gameState.inProgress = false;
|
gameState.inProgress = false;
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
get the team the player belongs to
|
get the team the player belongs to
|
||||||
*/
|
*/
|
||||||
var _getTeam = function(player,pteams) {
|
var _getTeam = function(player,pteams) {
|
||||||
for (var teamName in pteams) {
|
for (var teamName in pteams) {
|
||||||
var team = pteams[teamName];
|
var team = pteams[teamName];
|
||||||
for (var i = 0;i < team.length; i++)
|
for (var i = 0;i < team.length; i++)
|
||||||
|
@ -104,11 +100,11 @@ SnowBallFight.prototype.start = function(){};
|
||||||
return teamName;
|
return teamName;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
construct a new game
|
construct a new game
|
||||||
*/
|
*/
|
||||||
var _constructor = function(duration, teams) {
|
var _constructor = function(duration, teams) {
|
||||||
|
|
||||||
var _snowBalls = new org.bukkit.inventory.ItemStack(org.bukkit.Material.SNOW_BALL, 64);
|
var _snowBalls = new org.bukkit.inventory.ItemStack(org.bukkit.Material.SNOW_BALL, 64);
|
||||||
|
|
||||||
|
@ -172,9 +168,9 @@ SnowBallFight.prototype.start = function(){};
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
SnowBallFight = _constructor;
|
var SnowBallFight = _constructor;
|
||||||
|
|
||||||
}());
|
exports.Game_SnowBallFight = SnowBallFight;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
var signs = require('./menu');
|
var signs = require('signs');
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// In game, create a sign , target it and type ...
|
// In game, create a sign , target it and type ...
|
||||||
//
|
//
|
||||||
// /js var signExamples = require('./signs/examples');
|
// /js signs.menu_food();
|
||||||
// /js signExamples.testMenu()
|
|
||||||
//
|
//
|
||||||
exports.testMenu = signs
|
// ... or ...
|
||||||
.menu("Dinner",
|
//
|
||||||
|
// /js signs.menu_time()
|
||||||
|
//
|
||||||
|
exports.signs = {
|
||||||
|
menu_food: signs.menu("Dinner",
|
||||||
["Lamb","Pork","Chicken","Duck","Beef"],
|
["Lamb","Pork","Chicken","Duck","Beef"],
|
||||||
function(event){
|
function(event){
|
||||||
event.player.sendMessage("You chose " + event.text);
|
event.player.sendMessage("You chose " + event.text);
|
||||||
});
|
}),
|
||||||
//
|
//
|
||||||
// This is an example sign that displays a menu of times of day
|
// This is an example sign that displays a menu of times of day
|
||||||
// interacting with the sign will change the time of day accordingly.
|
// interacting with the sign will change the time of day accordingly.
|
||||||
|
@ -22,11 +25,10 @@ exports.testMenu = signs
|
||||||
// /js var signExamples = require('./signs/examples');
|
// /js var signExamples = require('./signs/examples');
|
||||||
// /js signExamples.timeOfDay()
|
// /js signExamples.timeOfDay()
|
||||||
//
|
//
|
||||||
exports.timeOfDay = signs
|
menu_time: signs.menu("Time",
|
||||||
.menu("Time",
|
|
||||||
["Dawn","Midday","Dusk","Midnight"],
|
["Dawn","Midday","Dusk","Midnight"],
|
||||||
function(event){
|
function(event){
|
||||||
event.player.location.world.setTime( event.number * 6000 );
|
event.player.location.world.setTime( event.number * 6000 );
|
||||||
});
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue