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(){
|
||||
return [
|
||||
"/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){
|
||||
var aliases = this.store.players;
|
||||
var aliases = _store.players;
|
||||
var name = player.name;
|
||||
if (typeof aliases[name] == "undefined")
|
||||
aliases[name] = {};
|
||||
aliases[name][alias] = commands;
|
||||
},
|
||||
remove: function(player, alias){
|
||||
var aliases = this.store.players;
|
||||
var aliases = _store.players;
|
||||
if (aliases[player.name])
|
||||
delete aliases[player.name][alias];
|
||||
},
|
||||
list: function(player){
|
||||
var result = [];
|
||||
var aliases = this.store.players[player.name];
|
||||
var aliases = _store.players[player.name];
|
||||
for (var a in aliases)
|
||||
result.push(a + " = " + aliases[a].join(";"));
|
||||
return result;
|
||||
}
|
||||
},
|
||||
store: _store
|
||||
},true);
|
||||
|
||||
if (typeof alias.store.players == "undefined")
|
||||
alias.store.players = {};
|
||||
exports.alias = alias;
|
||||
|
||||
command("alias",function(params){
|
||||
command("alias", function ( params ) {
|
||||
/*
|
||||
this function also intercepts command options for /jsp
|
||||
*/
|
||||
|
@ -59,7 +62,7 @@ command("alias",function(params){
|
|||
if (params.length == 0)
|
||||
return self.sendMessage(alias.help());
|
||||
|
||||
var playerHasAliases = alias.store.players[self.name];
|
||||
var playerHasAliases = _store.players[self.name];
|
||||
if (!playerHasAliases)
|
||||
return false;
|
||||
// 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 arrows.normal() sets arrow type to normal.
|
||||
/js arrows.explosive() - makes arrows explode.
|
||||
/js arrows.teleport() - makes player teleport to where arrow has landed.
|
||||
/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.
|
||||
/js var arrows = require('./arrows/arrows')
|
||||
|
||||
* `/js arrows.sign()` turns a targeted sign into a Arrows menu
|
||||
* `/js arrows.normal()` sets arrow type to normal.
|
||||
* `/js arrows.explosive()` - makes arrows explode.
|
||||
* `/js arrows.teleport()` - makes player teleport to where arrow has landed.
|
||||
* `/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
|
||||
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
|
||||
*/
|
||||
|
@ -48,24 +56,20 @@ var arrows = arrows || plugin("arrows",{
|
|||
/*
|
||||
launch a firework where the arrow lands
|
||||
*/
|
||||
explosiveYield: 2.5
|
||||
explosiveYield: 2.5,
|
||||
|
||||
store: _store
|
||||
|
||||
},true);
|
||||
/*
|
||||
initialize data
|
||||
*/
|
||||
arrows.store.players = arrows.store.players || {};
|
||||
|
||||
/*
|
||||
private implementation of normal, explosive, teleport, flourish and lightning functions
|
||||
*/
|
||||
(function(){
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
exports.arrows = arrows;
|
||||
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
arrows[type] = (function(n){
|
||||
return function(player){
|
||||
if (typeof player == "undefined")
|
||||
|
@ -78,36 +82,32 @@ arrows.store.players = arrows.store.players || {};
|
|||
arrows.store.players[playerName] = n;
|
||||
};
|
||||
})(_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
|
||||
*/
|
||||
var _onMenuChoice = function(event){
|
||||
*/
|
||||
var _onMenuChoice = function(event){
|
||||
arrows.store.players[event.player.name] = event.number;
|
||||
};
|
||||
arrows.sign = signs.menu("Arrow",
|
||||
};
|
||||
arrows.sign = signs.menu("Arrow",
|
||||
["Normal","Explosive","Teleport","Flourish","Lightning","Firework"],
|
||||
_onMenuChoice );
|
||||
|
||||
/*
|
||||
/*
|
||||
event handler called when a projectile hits something
|
||||
*/
|
||||
var _onArrowHit = function(listener,event)
|
||||
{
|
||||
*/
|
||||
var _onArrowHit = function(listener,event)
|
||||
{
|
||||
var projectile = event.entity;
|
||||
var world = projectile.world;
|
||||
var shooter = projectile.shooter;
|
||||
var fireworkCount = 5;
|
||||
if (projectile instanceof org.bukkit.entity.Arrow &&
|
||||
shooter instanceof org.bukkit.entity.Player)
|
||||
{
|
||||
var arrowType = arrows.store.players[shooter.name];
|
||||
|
||||
switch (arrowType){
|
||||
case 1:
|
||||
projectile.remove();
|
||||
|
@ -129,10 +129,15 @@ ready(function()
|
|||
break;
|
||||
case 5:
|
||||
projectile.remove();
|
||||
var launch = function(){
|
||||
fireworks.firework(projectile.location);
|
||||
if (--fireworkCount)
|
||||
setTimeout(launch,2000);
|
||||
};
|
||||
launch();
|
||||
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
|
||||
*/
|
||||
var chat = chat || plugin("chat", {
|
||||
exports.chat = plugin("chat", {
|
||||
/*
|
||||
set the color of text for a given player
|
||||
*/
|
||||
setColor: function(player, color){
|
||||
this.store.players[player.name] = color;
|
||||
}
|
||||
},true);
|
||||
/*
|
||||
initialize the store
|
||||
*/
|
||||
chat.store.players = chat.store.players || {};
|
||||
},
|
||||
|
||||
ready(function()
|
||||
{
|
||||
var colors = [
|
||||
store: _store
|
||||
|
||||
},true);
|
||||
|
||||
var colors = [
|
||||
"black", "blue", "darkgreen", "darkaqua", "darkred",
|
||||
"purple", "gold", "gray", "darkgray", "indigo",
|
||||
"brightgreen", "aqua", "red", "pink", "yellow", "white"
|
||||
];
|
||||
var colorCodes = {};
|
||||
for (var i =0;i < colors.length;i++) {
|
||||
];
|
||||
var colorCodes = {};
|
||||
for (var i =0;i < colors.length;i++) {
|
||||
var hexCode = i.toString(16);
|
||||
colorCodes[colors[i]] = hexCode;
|
||||
}
|
||||
}
|
||||
|
||||
events.on("player.AsyncPlayerChatEvent",function(l,e){
|
||||
events.on("player.AsyncPlayerChatEvent",function(l,e){
|
||||
var player = e.player;
|
||||
var playerChatColor = chat.store.players[player.name];
|
||||
if (playerChatColor){
|
||||
e.message = "§" + colorCodes[playerChatColor] + e.message;
|
||||
}
|
||||
});
|
||||
var listColors = function(params){
|
||||
});
|
||||
var listColors = function(params){
|
||||
var colorNamesInColor = [];
|
||||
for (var i = 0;i < colors.length;i++)
|
||||
colorNamesInColor[i] = "§"+colorCodes[colors[i]] + colors[i];
|
||||
self.sendMessage("valid chat colors are " + colorNamesInColor.join(", "));
|
||||
};
|
||||
command("list_colors", listColors);
|
||||
command("chat_color",function(params){
|
||||
};
|
||||
command("list_colors", listColors);
|
||||
command("chat_color",function(params){
|
||||
var color = params[0];
|
||||
if (colorCodes[color]){
|
||||
chat.setColor(self,color);
|
||||
|
@ -49,5 +52,5 @@ ready(function()
|
|||
self.sendMessage(color + " is not a valid color");
|
||||
listColors();
|
||||
}
|
||||
},colors);
|
||||
});
|
||||
},colors);
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
var utils = require('utils');
|
||||
var events = require('events');
|
||||
|
||||
/************************************************************************
|
||||
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.
|
||||
|
||||
***/
|
||||
var classroom = {
|
||||
allowScripting: function(/* boolean: true or false */ canScript){}
|
||||
};
|
||||
var _canScript = false;
|
||||
|
||||
ready(function(){
|
||||
classroom.allowScripting = function(canScript)
|
||||
{
|
||||
exports.classroom = {
|
||||
allowScripting: function (/* boolean: true or false */ canScript) {
|
||||
/*
|
||||
only operators should be allowed run this function
|
||||
*/
|
||||
|
@ -67,12 +67,13 @@ ready(function(){
|
|||
});
|
||||
});
|
||||
}
|
||||
classroom.canScript = canScript;
|
||||
};
|
||||
events.on("player.PlayerLoginEvent", function(listener, event) {
|
||||
_canScript = canScript;
|
||||
}
|
||||
};
|
||||
events.on('player.PlayerLoginEvent', function(listener, event) {
|
||||
var player = event.player;
|
||||
if (classroom.canScript){
|
||||
player.addAttachment(__plugin, "scriptcraft.*", true);
|
||||
}
|
||||
}, "HIGHEST");
|
||||
});
|
||||
}, "HIGHEST");
|
||||
|
||||
|
|
|
@ -272,4 +272,4 @@ blocks.rainbow = [blocks.wool.red,
|
|||
blocks.wool.purple];
|
||||
|
||||
|
||||
module.exports = blocks;
|
||||
exports.blocks = blocks;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var Drone = require('./drone');
|
||||
var blocks = require('./blocks');
|
||||
var Drone = require('./drone').Drone;
|
||||
var blocks = require('./blocks').blocks;
|
||||
|
||||
module.exports = Drone;
|
||||
/************************************************************************
|
||||
Drone.blocktype() method
|
||||
========================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
|
||||
//
|
||||
// a castle is just a big wide fort with 4 taller forts at each corner
|
||||
//
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var Drone = require('../drone');
|
||||
var blocks = require('../blocks');
|
||||
var Drone = require('../drone').Drone;
|
||||
var blocks = require('../blocks').blocks;
|
||||
|
||||
module.exports = Drone;
|
||||
/**
|
||||
* Creates a tile pattern of given block types and size
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
|
||||
//
|
||||
// usage:
|
||||
// [1] to build a cottage at the player's current location or the cross-hairs location...
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
|
||||
//
|
||||
// Create a floor of colored tiles some of which emit light.
|
||||
// The tiles change color every second creating a strobe-lit dance-floor.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
|
||||
//
|
||||
// constructs a medieval fort
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
|
||||
//
|
||||
// Constructs the JS logo
|
||||
// https://raw.github.com/voodootikigod/logo.js/master/js.png
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var Drone = require('../drone');
|
||||
var blocks = require('../blocks');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
var blocks = require('../blocks').blocks;
|
||||
|
||||
/************************************************************************
|
||||
Drone.rainbow() method
|
||||
======================
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var Drone = require('../drone');
|
||||
var blocks = require('../blocks');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
var blocks = require('../blocks').blocks;
|
||||
|
||||
//
|
||||
// usage:
|
||||
// [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 blocks = require('../blocks');
|
||||
var Drone = require('../drone').Drone;
|
||||
var blocks = require('../blocks').blocks;
|
||||
|
||||
module.exports = Drone;
|
||||
Drone.extend('skyscraper',function(floors){
|
||||
|
||||
if (typeof floors == "undefined")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var Drone = require('../drone');
|
||||
var blocks = require('../blocks');
|
||||
var Drone = require('../drone').Drone;
|
||||
var blocks = require('../blocks').blocks;
|
||||
|
||||
module.exports = Drone;
|
||||
/************************************************************************
|
||||
Drone.spiral_stairs() method
|
||||
============================
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
/**
|
||||
* Creates a stream of blocks in a given direction until it hits something other than air
|
||||
*
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
var Drone = require('../drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('../drone').Drone;
|
||||
//
|
||||
// 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 blocks = require('./blocks');
|
||||
var _utils = require('utils');
|
||||
var blocks = require('./blocks').blocks;
|
||||
|
||||
/*********************************************************************
|
||||
Drone Module
|
||||
|
@ -732,7 +732,7 @@ Drone = function(x,y,z,dir,world)
|
|||
return this;
|
||||
};
|
||||
|
||||
module.exports = Drone;
|
||||
exports.Drone = Drone;
|
||||
|
||||
//
|
||||
// add custom methods to the Drone object using this function
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
var Drone = require('./drone');
|
||||
module.exports = Drone;
|
||||
var Drone = require('./drone').Drone;
|
||||
|
||||
/************************************************************************
|
||||
Drone.sphere() method
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var Drone = require('./drone');
|
||||
var Drone = require('./drone').Drone;
|
||||
|
||||
Drone.prototype.testHorizontalStrokeWidth = function(){
|
||||
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
|
||||
other players to their home and also visit other player's homes.
|
||||
*/
|
||||
plugin("homes", {
|
||||
var homes = plugin("homes", {
|
||||
help: function(){
|
||||
return [
|
||||
/* basic functions */
|
||||
|
@ -33,7 +39,7 @@ plugin("homes", {
|
|||
host = guest;
|
||||
guest = utils.getPlayerObject(guest);
|
||||
host = utils.getPlayerObject(host);
|
||||
var loc = this.store.houses[host.name];
|
||||
var loc = _store.houses[host.name];
|
||||
if (!loc){
|
||||
guest.sendMessage(host.name + " has no home");
|
||||
return;
|
||||
|
@ -53,9 +59,9 @@ plugin("homes", {
|
|||
_canVisit: function(guest, host){
|
||||
if (guest == host)
|
||||
return true;
|
||||
if (this.store.openHouses[host.name])
|
||||
if (_store.openHouses[host.name])
|
||||
return true;
|
||||
var invitations = this.store.invites[host.name];
|
||||
var invitations = _store.invites[host.name];
|
||||
if (invitations)
|
||||
for (var i = 0;i < invitations.length;i++)
|
||||
if (invitations[i] == guest.name)
|
||||
|
@ -65,7 +71,7 @@ plugin("homes", {
|
|||
set: function(player){
|
||||
player = utils.getPlayerObject(player);
|
||||
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.y)
|
||||
,Math.floor(loc.z)
|
||||
|
@ -74,7 +80,7 @@ plugin("homes", {
|
|||
},
|
||||
remove: function(player){
|
||||
player = utils.getPlayerObject(player);
|
||||
delete this.store.houses[player.name];
|
||||
delete _store.houses[player.name];
|
||||
},
|
||||
/* ========================================================================
|
||||
social functions
|
||||
|
@ -85,11 +91,11 @@ plugin("homes", {
|
|||
*/
|
||||
list: function(player){
|
||||
var result = [];
|
||||
for (var ohp in this.store.openHouses)
|
||||
for (var ohp in _store.openHouses)
|
||||
result.push(ohp);
|
||||
player = utils.getPlayerObject(player);
|
||||
for (var host in this.store.invites){
|
||||
var guests = this.store.invites[host];
|
||||
for (var host in _store.invites){
|
||||
var guests = _store.invites[host];
|
||||
for (var i = 0;i < guests.length; i++)
|
||||
if (guests[i] == player.name)
|
||||
result.push(host);
|
||||
|
@ -103,14 +109,14 @@ plugin("homes", {
|
|||
player = utils.getPlayerObject(player);
|
||||
var result = [];
|
||||
// if home is public - all players
|
||||
if (this.store.openHouses[player.name]){
|
||||
if (_store.openHouses[player.name]){
|
||||
var online = org.bukkit.Bukkit.getOnlinePlayers();
|
||||
for (var i = 0;i < online.length; i++)
|
||||
if (online[i].name != player.name)
|
||||
result.push(online[i].name);
|
||||
}else{
|
||||
if (this.store.invites[player.name])
|
||||
result = this.store.invites[player.name];
|
||||
if (_store.invites[player.name])
|
||||
result = _store.invites[player.name];
|
||||
else
|
||||
result = [];
|
||||
}
|
||||
|
@ -123,10 +129,10 @@ plugin("homes", {
|
|||
host = utils.getPlayerObject(host);
|
||||
guest = utils.getPlayerObject(guest);
|
||||
var invitations = [];
|
||||
if (this.store.invites[host.name])
|
||||
invitations = this.store.invites[host.name];
|
||||
if (_store.invites[host.name])
|
||||
invitations = _store.invites[host.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("type '/jsp home " + host.name + "' to accept");
|
||||
},
|
||||
|
@ -136,21 +142,21 @@ plugin("homes", {
|
|||
uninvite: function(host, guest){
|
||||
host = utils.getPlayerObject(host);
|
||||
guest = utils.getPlayerObject(guest);
|
||||
var invitations = this.store.invites[host.name];
|
||||
var invitations = _store.invites[host.name];
|
||||
if (!invitations)
|
||||
return;
|
||||
var revisedInvites = [];
|
||||
for (var i =0;i < invitations.length; i++)
|
||||
if (invitations[i] != guest.name)
|
||||
revisedInvites.push(invitations[i]);
|
||||
this.store.invites[host.name] = revisedInvites;
|
||||
_store.invites[host.name] = revisedInvites;
|
||||
},
|
||||
/*
|
||||
make the player's house public
|
||||
*/
|
||||
open: function(player, optionalMsg){
|
||||
player = utils.getPlayerObject(player);
|
||||
this.store.openHouses[player.name] = true;
|
||||
_store.openHouses[player.name] = true;
|
||||
if (typeof optionalMsg != "undefined")
|
||||
__plugin.server.broadcastMessage(optionalMsg);
|
||||
},
|
||||
|
@ -159,32 +165,31 @@ plugin("homes", {
|
|||
*/
|
||||
close: function(player){
|
||||
player = utils.getPlayerObject(player);
|
||||
delete this.store.openHouses[player.name];
|
||||
delete _store.openHouses[player.name];
|
||||
},
|
||||
/* ========================================================================
|
||||
admin functions
|
||||
======================================================================== */
|
||||
listall: function(){
|
||||
var result = [];
|
||||
for (var home in this.store.houses)
|
||||
for (var home in _store.houses)
|
||||
result.push(home);
|
||||
return result;
|
||||
},
|
||||
clear: function(player){
|
||||
player = utils.getPlayerObject(player);
|
||||
delete this.store.houses[player.name];
|
||||
delete this.store.openHouses[player.name];
|
||||
}
|
||||
|
||||
delete _store.houses[player.name];
|
||||
delete _store.openHouses[player.name];
|
||||
},
|
||||
store: _store
|
||||
}, true);
|
||||
|
||||
exports.homes = homes;
|
||||
|
||||
/*
|
||||
private implementation
|
||||
*/
|
||||
(function(){
|
||||
/*
|
||||
define a set of command options that can be used by players
|
||||
*/
|
||||
var options = {
|
||||
*/
|
||||
var options = {
|
||||
'set': function(){homes.set();},
|
||||
'delete': function(){ homes.remove();},
|
||||
'help': function(){ self.sendMessage(homes.help());},
|
||||
|
@ -253,14 +258,14 @@ plugin("homes", {
|
|||
else
|
||||
homes.clear(params[1]);
|
||||
}
|
||||
};
|
||||
var optionList = [];
|
||||
for (var o in options)
|
||||
};
|
||||
var optionList = [];
|
||||
for (var o in options)
|
||||
optionList.push(o);
|
||||
/*
|
||||
/*
|
||||
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){
|
||||
homes.go();
|
||||
return;
|
||||
|
@ -275,16 +280,7 @@ plugin("homes", {
|
|||
else
|
||||
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.
|
||||
*/
|
||||
ready(function(){
|
||||
/*************************************************************************
|
||||
## Minigame: Guess the number
|
||||
|
||||
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);
|
||||
|
||||
var number = Math.ceil(Math.random() * 10);
|
||||
|
@ -44,5 +50,5 @@ ready(function(){
|
|||
.withPrefix(new ConversationPrefix(){ getPrefix: function(ctx){ return "[1-10] ";} })
|
||||
.buildConversation(self);
|
||||
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.
|
||||
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 blueTeam = ['<player3>','<player4>,...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...
|
||||
|
||||
|
@ -29,15 +30,10 @@ load(__folder + "../events/events.js");
|
|||
|
||||
*/
|
||||
|
||||
var SnowBallFight = function(teams, duration){};
|
||||
SnowBallFight.prototype.start = function(){};
|
||||
|
||||
(function(){
|
||||
|
||||
/*
|
||||
/*
|
||||
setup game
|
||||
*/
|
||||
var _startGame = function(gameState){
|
||||
*/
|
||||
var _startGame = function(gameState){
|
||||
// don't let game start if already in progress (wait for game to finish)
|
||||
if (gameState.inProgress){
|
||||
return;
|
||||
|
@ -61,11 +57,11 @@ SnowBallFight.prototype.start = function(){};
|
|||
player.inventory.addItem(gameState.ammo);
|
||||
}
|
||||
}
|
||||
};
|
||||
/*
|
||||
};
|
||||
/*
|
||||
end the game
|
||||
*/
|
||||
var _endGame = function(gameState){
|
||||
*/
|
||||
var _endGame = function(gameState){
|
||||
var scores = [];
|
||||
|
||||
var leaderBoard = [];
|
||||
|
@ -92,11 +88,11 @@ SnowBallFight.prototype.start = function(){};
|
|||
var handlerList = org.bukkit.event.entity.EntityDamageByEntityEvent.getHandlerList();
|
||||
handlerList.unregister(gameState.listener);
|
||||
gameState.inProgress = false;
|
||||
};
|
||||
/*
|
||||
};
|
||||
/*
|
||||
get the team the player belongs to
|
||||
*/
|
||||
var _getTeam = function(player,pteams) {
|
||||
*/
|
||||
var _getTeam = function(player,pteams) {
|
||||
for (var teamName in pteams) {
|
||||
var team = pteams[teamName];
|
||||
for (var i = 0;i < team.length; i++)
|
||||
|
@ -104,11 +100,11 @@ SnowBallFight.prototype.start = function(){};
|
|||
return teamName;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/*
|
||||
};
|
||||
/*
|
||||
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);
|
||||
|
||||
|
@ -172,9 +168,9 @@ SnowBallFight.prototype.start = function(){};
|
|||
}).start();
|
||||
}
|
||||
};
|
||||
};
|
||||
SnowBallFight = _constructor;
|
||||
};
|
||||
var SnowBallFight = _constructor;
|
||||
|
||||
}());
|
||||
exports.Game_SnowBallFight = SnowBallFight;
|
||||
|
||||
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
var signs = require('./menu');
|
||||
var signs = require('signs');
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// In game, create a sign , target it and type ...
|
||||
//
|
||||
// /js var signExamples = require('./signs/examples');
|
||||
// /js signExamples.testMenu()
|
||||
// /js signs.menu_food();
|
||||
//
|
||||
exports.testMenu = signs
|
||||
.menu("Dinner",
|
||||
// ... or ...
|
||||
//
|
||||
// /js signs.menu_time()
|
||||
//
|
||||
exports.signs = {
|
||||
menu_food: signs.menu("Dinner",
|
||||
["Lamb","Pork","Chicken","Duck","Beef"],
|
||||
function(event){
|
||||
event.player.sendMessage("You chose " + event.text);
|
||||
});
|
||||
}),
|
||||
//
|
||||
// This is an example sign that displays a menu of times of day
|
||||
// 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 signExamples.timeOfDay()
|
||||
//
|
||||
exports.timeOfDay = signs
|
||||
.menu("Time",
|
||||
menu_time: signs.menu("Time",
|
||||
["Dawn","Midday","Dusk","Midnight"],
|
||||
function(event){
|
||||
event.player.location.world.setTime( event.number * 6000 );
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue