Making bukkit objects easier to identify by name (bk prefix)
This commit is contained in:
parent
d976563adf
commit
96b1a54896
14 changed files with 116 additions and 96 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
# 2014 02 19
|
||||||
|
|
||||||
|
## Version 2.0.5
|
||||||
|
|
||||||
|
Asynchronous building. Drone now builds asynchronously.
|
||||||
|
|
||||||
# 2014 02 11
|
# 2014 02 11
|
||||||
|
|
||||||
## Version 2.0.4
|
## Version 2.0.4
|
||||||
|
|
|
@ -82,9 +82,10 @@ events.on( org.bukkit.event.block.BlockBreakEvent, function( listener, evt ) {
|
||||||
|
|
||||||
***/
|
***/
|
||||||
|
|
||||||
var bkEvent = org.bukkit.event,
|
var bkEventPriority = org.bukkit.event.EventPriority,
|
||||||
bkEvtExecutor = org.bukkit.plugin.EventExecutor,
|
bkEventExecutor = org.bukkit.plugin.EventExecutor,
|
||||||
bkRegListener = org.bukkit.plugin.RegisteredListener;
|
bkRegisteredListener = org.bukkit.plugin.RegisteredListener,
|
||||||
|
bkEventPackage = 'org.bukkit.event.';
|
||||||
|
|
||||||
exports.on = function(
|
exports.on = function(
|
||||||
/* String or java Class */
|
/* String or java Class */
|
||||||
|
@ -98,9 +99,9 @@ exports.on = function(
|
||||||
eventExecutor;
|
eventExecutor;
|
||||||
|
|
||||||
if ( typeof priority == 'undefined' ) {
|
if ( typeof priority == 'undefined' ) {
|
||||||
priority = bkEvent.EventPriority.HIGHEST;
|
priority = bkEventPriority.HIGHEST;
|
||||||
} else {
|
} else {
|
||||||
priority = bkEvent.EventPriority[priority];
|
priority = bkEventPriority[priority.toUpperCase()];
|
||||||
}
|
}
|
||||||
if ( typeof eventType == 'string' ) {
|
if ( typeof eventType == 'string' ) {
|
||||||
/*
|
/*
|
||||||
|
@ -111,13 +112,13 @@ exports.on = function(
|
||||||
*/
|
*/
|
||||||
if ( typeof Java != 'undefined' ) {
|
if ( typeof Java != 'undefined' ) {
|
||||||
// nashorn environment
|
// nashorn environment
|
||||||
eventType = Java.type( 'org.bukkit.event.' + eventType );
|
eventType = Java.type( bkEventPackage + eventType );
|
||||||
} else {
|
} else {
|
||||||
eventType = eval( 'org.bukkit.event.' + eventType );
|
eventType = eval( bkEventPackage + eventType );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handlerList = eventType.getHandlerList( );
|
handlerList = eventType.getHandlerList( );
|
||||||
eventExecutor = new bkEvtExecutor( ) {
|
eventExecutor = new bkEventExecutor( ) {
|
||||||
execute: function( l, e ) {
|
execute: function( l, e ) {
|
||||||
handler( listener.reg, e );
|
handler( listener.reg, e );
|
||||||
}
|
}
|
||||||
|
@ -130,7 +131,7 @@ exports.on = function(
|
||||||
The workaround is to make the ScriptCraftPlugin java class a Listener.
|
The workaround is to make the ScriptCraftPlugin java class a Listener.
|
||||||
Should only unregister() registered plugins in ScriptCraft js code.
|
Should only unregister() registered plugins in ScriptCraft js code.
|
||||||
*/
|
*/
|
||||||
listener.reg = new bkRegListener( __plugin, eventExecutor, priority, __plugin, true );
|
listener.reg = new bkRegisteredListener( __plugin, eventExecutor, priority, __plugin, true );
|
||||||
handlerList.register( listener.reg );
|
handlerList.register( listener.reg );
|
||||||
return listener.reg;
|
return listener.reg;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,35 +37,37 @@ location. For example...
|
||||||
create a firework at the given location
|
create a firework at the given location
|
||||||
*/
|
*/
|
||||||
var firework = function( location ) {
|
var firework = function( location ) {
|
||||||
var Color = org.bukkit.Color;
|
var bkColor = org.bukkit.Color;
|
||||||
var FireworkEffect = org.bukkit.FireworkEffect;
|
var bkFireworkEffect = org.bukkit.FireworkEffect;
|
||||||
var EntityType = org.bukkit.entity.EntityType;
|
var bkEntityType = org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
var randInt = function( n ) {
|
var randInt = function( n ) {
|
||||||
return Math.floor( Math.random() * n );
|
return Math.floor( Math.random() * n );
|
||||||
};
|
};
|
||||||
var getColor = function( i ) {
|
var getColor = function( i ) {
|
||||||
var colors = [
|
var colors = [
|
||||||
Color.AQUA, Color.BLACK, Color.BLUE, Color.FUCHSIA, Color.GRAY,
|
bkColor.AQUA, bkColor.BLACK, bkColor.BLUE, bkColor.FUCHSIA, bkColor.GRAY,
|
||||||
Color.GREEN, Color.LIME, Color.MAROON, Color.NAVY, Color.OLIVE,
|
bkColor.GREEN, bkColor.LIME, bkColor.MAROON, bkColor.NAVY, bkColor.OLIVE,
|
||||||
Color.ORANGE, Color.PURPLE, Color.RED, Color.SILVER, Color.TEAL,
|
bkColor.ORANGE, bkColor.PURPLE, bkColor.RED, bkColor.SILVER, bkColor.TEAL,
|
||||||
Color.WHITE, Color.YELLOW];
|
bkColor.WHITE, bkColor.YELLOW];
|
||||||
return colors[i];
|
return colors[i];
|
||||||
};
|
};
|
||||||
var fw = location.world.spawnEntity(location, EntityType.FIREWORK);
|
var fw = location.world.spawnEntity(location, bkEntityType.FIREWORK);
|
||||||
var fwm = fw.getFireworkMeta();
|
var fwm = fw.getFireworkMeta();
|
||||||
var fwTypes = [FireworkEffect.Type.BALL,
|
var fwTypes = [
|
||||||
FireworkEffect.Type.BALL_LARGE,
|
bkFireworkEffect.Type.BALL,
|
||||||
FireworkEffect.Type.BURST,
|
bkFireworkEffect.Type.BALL_LARGE,
|
||||||
FireworkEffect.Type.CREEPER,
|
bkFireworkEffect.Type.BURST,
|
||||||
FireworkEffect.Type.STAR];
|
bkFireworkEffect.Type.CREEPER,
|
||||||
|
bkFireworkEffect.Type.STAR
|
||||||
|
];
|
||||||
var type = fwTypes[ randInt( 5 ) ];
|
var type = fwTypes[ randInt( 5 ) ];
|
||||||
|
|
||||||
var r1i = randInt( 17 );
|
var r1i = randInt( 17 );
|
||||||
var r2i = randInt( 17 );
|
var r2i = randInt( 17 );
|
||||||
var c1 = getColor( r1i );
|
var c1 = getColor( r1i );
|
||||||
var c2 = getColor( r2i );
|
var c2 = getColor( r2i );
|
||||||
var effectBuilder = FireworkEffect.builder()
|
var effectBuilder = bkFireworkEffect.builder()
|
||||||
.flicker( Math.round( Math.random() ) == 0 )
|
.flicker( Math.round( Math.random() ) == 0 )
|
||||||
.withColor( c1 )
|
.withColor( c1 )
|
||||||
.withFade( c2 )
|
.withFade( c2 )
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
var bkDisplaySlot = org.bukkit.scoreboard.DisplaySlot;
|
||||||
/*
|
/*
|
||||||
The scoreboard is a simple wrapper around the Bukkit Scoreboard API.
|
The scoreboard is a simple wrapper around the Bukkit Scoreboard API.
|
||||||
It's only concerned with display of scores, not maintaining them - that's the game's job.
|
It's only concerned with display of scores, not maintaining them - that's the game's job.
|
||||||
|
@ -5,7 +6,6 @@
|
||||||
module.exports = function( options ) {
|
module.exports = function( options ) {
|
||||||
var temp = {};
|
var temp = {};
|
||||||
var ccScoreboard;
|
var ccScoreboard;
|
||||||
var DisplaySlot = org.bukkit.scoreboard.DisplaySlot;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start: function( ) {
|
start: function( ) {
|
||||||
|
@ -16,7 +16,7 @@ module.exports = function( options ) {
|
||||||
for ( objective in options ) {
|
for ( objective in options ) {
|
||||||
ccObj = ccScoreboard.registerNewObjective( objective, 'dummy' );
|
ccObj = ccScoreboard.registerNewObjective( objective, 'dummy' );
|
||||||
for ( slot in options[ objective ] ) {
|
for ( slot in options[ objective ] ) {
|
||||||
ccObj.displaySlot = DisplaySlot[ slot ];
|
ccObj.displaySlot = bkDisplaySlot[ slot ];
|
||||||
ccObj.displayName = options[ objective ][ slot ];
|
ccObj.displayName = options[ objective ][ slot ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ module.exports = function( options ) {
|
||||||
for ( objective in options ) {
|
for ( objective in options ) {
|
||||||
ccScoreboard.getObjective(objective).unregister();
|
ccScoreboard.getObjective(objective).unregister();
|
||||||
for ( slot in options[ objective ] ) {
|
for ( slot in options[ objective ] ) {
|
||||||
ccScoreboard.clearSlot( DisplaySlot[ slot ] );
|
ccScoreboard.clearSlot( bkDisplaySlot[ slot ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
var utils = require('utils');
|
var utils = require('utils'),
|
||||||
var stringExt = require('utils/string-exts');
|
stringExt = require('utils/string-exts'),
|
||||||
var _store = {};
|
_store = {},
|
||||||
|
bkBukkit = org.bukkit.Bukkit,
|
||||||
|
bkSign = org.bukkit.block.Sign;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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 the
|
(that is - a menu sign will still be a menu after the
|
||||||
|
@ -158,12 +161,12 @@ signs.menu = function( /* String */ label, /* Array */ options, /* Function */ c
|
||||||
var len = signsOfSameLabel.length;
|
var len = signsOfSameLabel.length;
|
||||||
for ( i = 0; i < len; i++ ) {
|
for ( i = 0; i < len; i++ ) {
|
||||||
var loc = signsOfSameLabel[i];
|
var loc = signsOfSameLabel[i];
|
||||||
var world = org.bukkit.Bukkit.getWorld(loc.world);
|
var world = bkBukkit.getWorld(loc.world);
|
||||||
if ( !world ) {
|
if ( !world ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var block = world.getBlockAt( loc.x, loc.y, loc.z );
|
var block = world.getBlockAt( loc.x, loc.y, loc.z );
|
||||||
if ( block.state instanceof org.bukkit.block.Sign ) {
|
if ( block.state instanceof bkSign ) {
|
||||||
convertToMenuSign( block.state, false );
|
convertToMenuSign( block.state, false );
|
||||||
defragged.push( loc );
|
defragged.push( loc );
|
||||||
}
|
}
|
||||||
|
@ -187,7 +190,7 @@ events.on( 'player.PlayerInteractEvent', function( listener, event ) {
|
||||||
a sign, then update it.
|
a sign, then update it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! event.clickedBlock.state instanceof org.bukkit.block.Sign ) {
|
if ( ! event.clickedBlock.state instanceof bkSign ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var evtLocStr = utils.locationToString(event.clickedBlock.location);
|
var evtLocStr = utils.locationToString(event.clickedBlock.location);
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
var File = java.io.File;
|
var File = java.io.File,
|
||||||
|
bkBukkit = org.bukkit.Bukkit,
|
||||||
|
bkLocation = org.bukkit.Location,
|
||||||
|
bkBlockCommandSender = org.bukkit.command.BlockCommandSender;
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
## Utilities Module
|
## Utilities Module
|
||||||
|
|
||||||
|
@ -47,7 +50,7 @@ var _player = function ( playerName ) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( typeof playerName == 'string' )
|
if ( typeof playerName == 'string' )
|
||||||
return org.bukkit.Bukkit.getPlayer( playerName );
|
return bkBukkit.getPlayer( playerName );
|
||||||
else
|
else
|
||||||
return playerName; // assumes it's a player object
|
return playerName; // assumes it's a player object
|
||||||
}
|
}
|
||||||
|
@ -126,11 +129,11 @@ exports.locationFromJSON = function( json ) {
|
||||||
var world;
|
var world;
|
||||||
if ( json.constuctor == Array ) {
|
if ( json.constuctor == Array ) {
|
||||||
// for support of legacy format
|
// for support of legacy format
|
||||||
world = org.bukkit.Bukkit.getWorld( json[0] );
|
world = bkBukkit.getWorld( json[0] );
|
||||||
return new org.bukkit.Location( world, json[1], json[2] , json[3] );
|
return new bkLocation( world, json[1], json[2] , json[3] );
|
||||||
} else {
|
} else {
|
||||||
world = org.bukkit.Bukkit.getWorld( json.world );
|
world = bkBukkit.getWorld( json.world );
|
||||||
return new org.bukkit.Location( world, json.x, json.y , json.z, json.yaw, json.pitch );
|
return new bkLocation( world, json.x, json.y , json.z, json.yaw, json.pitch );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -162,7 +165,7 @@ An [org.bukkit.Location][bkloc] object.
|
||||||
exports.getPlayerPos = function( player ) {
|
exports.getPlayerPos = function( player ) {
|
||||||
player = _player( player );
|
player = _player( player );
|
||||||
if ( player ) {
|
if ( player ) {
|
||||||
if ( player instanceof org.bukkit.command.BlockCommandSender )
|
if ( player instanceof bkBlockCommandSender )
|
||||||
return player.block.location;
|
return player.block.location;
|
||||||
else
|
else
|
||||||
return player.location;
|
return player.location;
|
||||||
|
|
|
@ -28,6 +28,10 @@ player23's arrows explosive.
|
||||||
var signs = require('signs'),
|
var signs = require('signs'),
|
||||||
fireworks = require('fireworks'),
|
fireworks = require('fireworks'),
|
||||||
utils = require('utils'),
|
utils = require('utils'),
|
||||||
|
bkTeleportCause = org.bukkit.event.player.PlayerTeleportEvent.TeleportCause,
|
||||||
|
bkArrow = org.bukkit.entity.Arrow,
|
||||||
|
bkPlayer = org.bukkit.entity.Player,
|
||||||
|
bkTreeType = org.bukkit.TreeType,
|
||||||
EXPLOSIVE_YIELD = 2.5,
|
EXPLOSIVE_YIELD = 2.5,
|
||||||
_store = { players: { } },
|
_store = { players: { } },
|
||||||
arrows = plugin( 'arrows', { store: _store }, true ),
|
arrows = plugin( 'arrows', { store: _store }, true ),
|
||||||
|
@ -81,7 +85,6 @@ var _onArrowHit = function( listener, event ) {
|
||||||
shooter = projectile.shooter,
|
shooter = projectile.shooter,
|
||||||
fireworkCount = 5,
|
fireworkCount = 5,
|
||||||
arrowType,
|
arrowType,
|
||||||
TeleportCause = org.bukkit.event.player.PlayerTeleportEvent.TeleportCause,
|
|
||||||
launch = function( ) {
|
launch = function( ) {
|
||||||
fireworks.firework( projectile.location );
|
fireworks.firework( projectile.location );
|
||||||
if ( --fireworkCount ) {
|
if ( --fireworkCount ) {
|
||||||
|
@ -89,8 +92,8 @@ var _onArrowHit = function( listener, event ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (projectile instanceof org.bukkit.entity.Arrow
|
if (projectile instanceof bkArrow
|
||||||
&& shooter instanceof org.bukkit.entity.Player) {
|
&& shooter instanceof bkPlayer) {
|
||||||
|
|
||||||
arrowType = arrows.store.players[ shooter.name ];
|
arrowType = arrows.store.players[ shooter.name ];
|
||||||
|
|
||||||
|
@ -101,11 +104,11 @@ var _onArrowHit = function( listener, event ) {
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
projectile.remove();
|
projectile.remove();
|
||||||
shooter.teleport( projectile.location, TeleportCause.PLUGIN );
|
shooter.teleport( projectile.location, bkTeleportCause.PLUGIN );
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
projectile.remove();
|
projectile.remove();
|
||||||
world.generateTree( projectile.location, org.bukkit.TreeType.BIG_TREE );
|
world.generateTree( projectile.location, bkTreeType.BIG_TREE );
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
projectile.remove();
|
projectile.remove();
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
var Drone = require('../drone').Drone;
|
var Drone = require('../drone').Drone;
|
||||||
var Material = org.bukkit.Material;
|
var bkMaterial = org.bukkit.Material;
|
||||||
|
|
||||||
function canHang( material ) {
|
function canHang( material ) {
|
||||||
if (material.equals(Material.AIR) ||
|
|
||||||
material.equals(Material.VINE) ) {
|
if ( material.equals(bkMaterial.AIR) ||
|
||||||
|
material.equals(bkMaterial.VINE) ) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
var utils = require('utils'),
|
var utils = require('utils'),
|
||||||
blocks = require('blocks'),
|
blocks = require('blocks'),
|
||||||
Location = org.bukkit.Location,
|
bkLocation = org.bukkit.Location,
|
||||||
Player = org.bukkit.entity.Player,
|
bkPlayer = org.bukkit.entity.Player,
|
||||||
Sign = org.bukkit.block.Sign,
|
bkSign = org.bukkit.block.Sign,
|
||||||
TreeType = org.bukkit.TreeType,
|
bkTreeType = org.bukkit.TreeType,
|
||||||
Material = org.bukkit.Material;
|
bkMaterial = org.bukkit.Material;
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
## Drone Plugin
|
## Drone Plugin
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ var putSign = function( texts, x, y, z, blockId, meta, world ) {
|
||||||
putBlock( x, y, z, blockId, meta, world );
|
putBlock( x, y, z, blockId, meta, world );
|
||||||
block = world.getBlockAt( x, y, z );
|
block = world.getBlockAt( x, y, z );
|
||||||
state = block.state;
|
state = block.state;
|
||||||
if ( state instanceof Sign ) {
|
if ( state instanceof bkSign ) {
|
||||||
for ( i = 0; i < texts.length; i++ ) {
|
for ( i = 0; i < texts.length; i++ ) {
|
||||||
state.setLine( i % 4, texts[ i ] );
|
state.setLine( i % 4, texts[ i ] );
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ var Drone = function( x, y, z, dir, world ) {
|
||||||
this.record = false;
|
this.record = false;
|
||||||
var usePlayerCoords = false;
|
var usePlayerCoords = false;
|
||||||
var player = self;
|
var player = self;
|
||||||
if ( x instanceof Player ) {
|
if ( x instanceof bkPlayer ) {
|
||||||
player = x;
|
player = x;
|
||||||
}
|
}
|
||||||
var playerPos = utils.getPlayerPos( player );
|
var playerPos = utils.getPlayerPos( player );
|
||||||
|
@ -694,7 +694,7 @@ var Drone = function( x, y, z, dir, world ) {
|
||||||
that.world = loc.world;
|
that.world = loc.world;
|
||||||
};
|
};
|
||||||
var mp = utils.getMousePos( player );
|
var mp = utils.getMousePos( player );
|
||||||
if ( typeof x == 'undefined' || x instanceof Player ) {
|
if ( typeof x == 'undefined' || x instanceof bkPlayer ) {
|
||||||
if ( mp ) {
|
if ( mp ) {
|
||||||
populateFromLocation( mp );
|
populateFromLocation( mp );
|
||||||
if ( playerPos ) {
|
if ( playerPos ) {
|
||||||
|
@ -713,7 +713,7 @@ var Drone = function( x, y, z, dir, world ) {
|
||||||
populateFromLocation( playerPos );
|
populateFromLocation( playerPos );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( arguments[0] instanceof Location ) {
|
if ( arguments[0] instanceof bkLocation ) {
|
||||||
populateFromLocation( arguments[ 0 ] );
|
populateFromLocation( arguments[ 0 ] );
|
||||||
} else {
|
} else {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
@ -898,7 +898,7 @@ Drone.extend( 'chkpt', function( name ) {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
Drone.extend( 'move', function( ) {
|
Drone.extend( 'move', function( ) {
|
||||||
if ( arguments[0] instanceof Location ) {
|
if ( arguments[0] instanceof bkLocation ) {
|
||||||
this.x = arguments[0].x;
|
this.x = arguments[0].x;
|
||||||
this.y = arguments[0].y;
|
this.y = arguments[0].y;
|
||||||
this.z = arguments[0].z;
|
this.z = arguments[0].z;
|
||||||
|
@ -980,7 +980,7 @@ Drone.extend( 'down', function( n ) {
|
||||||
// position
|
// position
|
||||||
//
|
//
|
||||||
Drone.prototype.getLocation = function( ) {
|
Drone.prototype.getLocation = function( ) {
|
||||||
return new Location( this.world, this.x, this.y, this.z );
|
return new bkLocation( this.world, this.x, this.y, this.z );
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
// building
|
// building
|
||||||
|
@ -1040,7 +1040,7 @@ Drone.prototype.cuboida = function(/* Array */ blocks, w, h, d, overwrite ) {
|
||||||
_traverse[dir].width( that, w, function( ) {
|
_traverse[dir].width( that, w, function( ) {
|
||||||
var block = that.world.getBlockAt( that.x, that.y, that.z );
|
var block = that.world.getBlockAt( that.x, that.y, that.z );
|
||||||
var properBlock = properBlocks[ bi % len ];
|
var properBlock = properBlocks[ bi % len ];
|
||||||
if (overwrite || block.type.equals(Material.AIR) ) {
|
if (overwrite || block.type.equals(bkMaterial.AIR) ) {
|
||||||
block.setTypeIdAndData( properBlock[0], properBlock[1], false );
|
block.setTypeIdAndData( properBlock[0], properBlock[1], false );
|
||||||
}
|
}
|
||||||
bi++;
|
bi++;
|
||||||
|
@ -1805,10 +1805,10 @@ Drone.extend( 'rand', function( dist, width, height, depth, overwrite ) {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
var _trees = {
|
var _trees = {
|
||||||
oak: TreeType.BIG_TREE ,
|
oak: bkTreeType.BIG_TREE ,
|
||||||
birch: TreeType.BIRCH ,
|
birch: bkTreeType.BIRCH ,
|
||||||
jungle: TreeType.JUNGLE,
|
jungle: bkTreeType.JUNGLE,
|
||||||
spruce: TreeType.REDWOOD
|
spruce: bkTreeType.REDWOOD
|
||||||
};
|
};
|
||||||
for ( var p in _trees ) {
|
for ( var p in _trees ) {
|
||||||
Drone.extend(p, function( v ) {
|
Drone.extend(p, function( v ) {
|
||||||
|
@ -1817,7 +1817,7 @@ for ( var p in _trees ) {
|
||||||
if ( block.typeId == 2 ) {
|
if ( block.typeId == 2 ) {
|
||||||
this.up( );
|
this.up( );
|
||||||
}
|
}
|
||||||
var treeLoc = new Location(this.world,this.x,this.y,this.z );
|
var treeLoc = new bkLocation(this.world,this.x,this.y,this.z );
|
||||||
var successful = treeLoc.world.generateTree(treeLoc,v );
|
var successful = treeLoc.world.generateTree(treeLoc,v );
|
||||||
if ( block.typeId == 2 ) {
|
if ( block.typeId == 2 ) {
|
||||||
this.down( );
|
this.down( );
|
||||||
|
|
|
@ -60,7 +60,8 @@ The following administration options can only be used by server operators...
|
||||||
|
|
||||||
***/
|
***/
|
||||||
var utils = require('utils'),
|
var utils = require('utils'),
|
||||||
TeleportCause = org.bukkit.event.player.PlayerTeleportEvent.TeleportCause,
|
bkTeleportCause = org.bukkit.event.player.PlayerTeleportEvent.TeleportCause,
|
||||||
|
bkBukkit = org.bukkit.Bukkit,
|
||||||
_store = {
|
_store = {
|
||||||
houses: { },
|
houses: { },
|
||||||
openHouses: { },
|
openHouses: { },
|
||||||
|
@ -113,7 +114,7 @@ var homes = plugin( 'homes', {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
homeLoc = utils.locationFromJSON( loc );
|
homeLoc = utils.locationFromJSON( loc );
|
||||||
guest.teleport(homeLoc, TeleportCause.PLUGIN);
|
guest.teleport(homeLoc, bkTeleportCause.PLUGIN);
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
determine whether a guest is allow visit a host's home
|
determine whether a guest is allow visit a host's home
|
||||||
|
@ -185,7 +186,7 @@ var homes = plugin( 'homes', {
|
||||||
player = utils.player( player );
|
player = utils.player( player );
|
||||||
// if home is public - all players
|
// if home is public - all players
|
||||||
if ( _store.openHouses[player.name] ) {
|
if ( _store.openHouses[player.name] ) {
|
||||||
onlinePlayers = org.bukkit.Bukkit.getOnlinePlayers();
|
onlinePlayers = bkBukkit.getOnlinePlayers();
|
||||||
for ( i = 0; i < onlinePlayers.length; i++ ) {
|
for ( i = 0; i < onlinePlayers.length; i++ ) {
|
||||||
if ( onlinePlayers[i].name != player.name) {
|
if ( onlinePlayers[i].name != player.name) {
|
||||||
result.push( onlinePlayers[i].name );
|
result.push( onlinePlayers[i].name );
|
||||||
|
|
|
@ -15,12 +15,13 @@ Once the game begins, guess a number by typing the `/` character
|
||||||
followed by a number between 1 and 10.
|
followed by a number between 1 and 10.
|
||||||
|
|
||||||
***/
|
***/
|
||||||
var Prompt = org.bukkit.conversations.Prompt,
|
var bkPrompt = org.bukkit.conversations.Prompt,
|
||||||
ConversationFactory = org.bukkit.conversations.ConversationFactory,
|
bkConversationFactory = org.bukkit.conversations.ConversationFactory,
|
||||||
ConversationPrefix = org.bukkit.conversations.ConversationPrefix;
|
bkConversationPrefix = org.bukkit.conversations.ConversationPrefix,
|
||||||
|
bkBukkit = org.bukkit.Bukkit;
|
||||||
|
|
||||||
var sb = function( cmd ) {
|
var sb = function( cmd ) {
|
||||||
org.bukkit.Bukkit.dispatchCommand( server.consoleSender, 'scoreboard ' + cmd ) ;
|
bkBukkit.dispatchCommand( server.consoleSender, 'scoreboard ' + cmd ) ;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Game_NumberGuess = {
|
exports.Game_NumberGuess = {
|
||||||
|
@ -34,7 +35,7 @@ exports.Game_NumberGuess = {
|
||||||
|
|
||||||
var number = Math.ceil( Math.random() * 10 );
|
var number = Math.ceil( Math.random() * 10 );
|
||||||
|
|
||||||
var prompt = new Prompt( ) {
|
var prompt = new bkPrompt( ) {
|
||||||
|
|
||||||
getPromptText: function( ctx ) {
|
getPromptText: function( ctx ) {
|
||||||
var hint = '';
|
var hint = '';
|
||||||
|
@ -72,12 +73,12 @@ exports.Game_NumberGuess = {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var convPrefix = new ConversationPrefix( ) {
|
var convPrefix = new bkConversationPrefix( ) {
|
||||||
getPrefix: function( ctx ) {
|
getPrefix: function( ctx ) {
|
||||||
return '[1-10] ';
|
return '[1-10] ';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new ConversationFactory( __plugin )
|
new bkConversationFactory( __plugin )
|
||||||
.withModality( true )
|
.withModality( true )
|
||||||
.withFirstPrompt( prompt )
|
.withFirstPrompt( prompt )
|
||||||
.withPrefix( convPrefix )
|
.withPrefix( convPrefix )
|
||||||
|
|
|
@ -42,11 +42,11 @@ cover to make the game more fun.
|
||||||
|
|
||||||
***/
|
***/
|
||||||
|
|
||||||
var GameMode = org.bukkit.GameMode,
|
var bkGameMode = org.bukkit.GameMode,
|
||||||
EntityDamageByEntityEvent = org.bukkit.event.entity.EntityDamageByEntityEvent,
|
bkEntityDamageByEntityEvent = org.bukkit.event.entity.EntityDamageByEntityEvent,
|
||||||
ItemStack = org.bukkit.inventory.ItemStack,
|
bkItemStack = org.bukkit.inventory.ItemStack,
|
||||||
Material = org.bukkit.Material,
|
bkMaterial = org.bukkit.Material,
|
||||||
Snowball = org.bukkit.entity.Snowball;
|
bkSnowball = org.bukkit.entity.Snowball;
|
||||||
|
|
||||||
var _startGame = function( gameState ) {
|
var _startGame = function( gameState ) {
|
||||||
var i,
|
var i,
|
||||||
|
@ -73,7 +73,7 @@ var _startGame = function( gameState ) {
|
||||||
for ( i = 0; i < team.length; i++ ) {
|
for ( i = 0; i < team.length; i++ ) {
|
||||||
player = server.getPlayer( team[i] );
|
player = server.getPlayer( team[i] );
|
||||||
gameState.savedModes[ player.name ] = player.gameMode;
|
gameState.savedModes[ player.name ] = player.gameMode;
|
||||||
player.gameMode = GameMode.SURVIVAL;
|
player.gameMode = bkGameMode.SURVIVAL;
|
||||||
player.inventory.addItem( gameState.ammo );
|
player.inventory.addItem( gameState.ammo );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ var _endGame = function( gameState ) {
|
||||||
player.sendMessage( scores );
|
player.sendMessage( scores );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handlerList = EntityDamageByEntityEvent.getHandlerList();
|
handlerList = bkEntityDamageByEntityEvent.getHandlerList();
|
||||||
handlerList.unregister( gameState.listener );
|
handlerList.unregister( gameState.listener );
|
||||||
gameState.inProgress = false;
|
gameState.inProgress = false;
|
||||||
};
|
};
|
||||||
|
@ -197,7 +197,7 @@ var createGame = function( duration, teams ) {
|
||||||
return {
|
return {
|
||||||
start: function( ) {
|
start: function( ) {
|
||||||
_startGame( _gameState );
|
_startGame( _gameState );
|
||||||
_gameState.listener = events.on('entity.EntityDamageByEntityEvent',_onSnowballHit);
|
_gameState.listener = events.on(bkEntityDamageByEntityEvent,_onSnowballHit);
|
||||||
new java.lang.Thread( function( ) {
|
new java.lang.Thread( function( ) {
|
||||||
while ( _gameState.duration-- ) {
|
while ( _gameState.duration-- ) {
|
||||||
java.lang.Thread.sleep( 1000 ); // sleep 1,000 millisecs (1 second)
|
java.lang.Thread.sleep( 1000 ); // sleep 1,000 millisecs (1 second)
|
||||||
|
|
|
@ -42,10 +42,10 @@ your own mini-game...
|
||||||
***/
|
***/
|
||||||
|
|
||||||
var store = {},
|
var store = {},
|
||||||
Bukkit = org.bukkit.Bukkit,
|
bkBukkit = org.bukkit.Bukkit,
|
||||||
Cow = org.bukkit.entity.Cow,
|
bkCow = org.bukkit.entity.Cow,
|
||||||
Sound = org.bukkit.Sound,
|
bkSound = org.bukkit.Sound,
|
||||||
OfflinePlayer = org.bukkit.OfflinePlayer,
|
bkOfflinePlayer = org.bukkit.OfflinePlayer,
|
||||||
scoreboardConfig = {
|
scoreboardConfig = {
|
||||||
cowclicker: {
|
cowclicker: {
|
||||||
SIDEBAR: 'Cows Clicked'
|
SIDEBAR: 'Cows Clicked'
|
||||||
|
@ -66,14 +66,14 @@ var _onPlayerInteract = function( listener, event ) {
|
||||||
loc.world.playSound( loc, snd, vol, pitch );
|
loc.world.playSound( loc, snd, vol, pitch );
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( clickedEntity instanceof Cow) {
|
if ( clickedEntity instanceof bkCow) {
|
||||||
store[ player.name ].score++;
|
store[ player.name ].score++;
|
||||||
scoreboard.update( 'cowclicker', player, store[ player.name ].score );
|
scoreboard.update( 'cowclicker', player, store[ player.name ].score );
|
||||||
|
|
||||||
Bukkit.dispatchCommand( player, 'me clicked a cow!' );
|
bkBukkit.dispatchCommand( player, 'me clicked a cow!' );
|
||||||
sound( Sound.CLICK, 1, 1 );
|
sound( bkSound.CLICK, 1, 1 );
|
||||||
setTimeout( function( ) {
|
setTimeout( function( ) {
|
||||||
sound( Sound.COW_HURT, 10, 0.85 ) ;
|
sound( bkSound.COW_HURT, 10, 0.85 ) ;
|
||||||
}, 200 );
|
}, 200 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -128,7 +128,7 @@ var _addPlayer = function( player, score ) {
|
||||||
|
|
||||||
var _removePlayer = function( player, notify ) {
|
var _removePlayer = function( player, notify ) {
|
||||||
|
|
||||||
if ( player instanceof OfflinePlayer && player.player ) {
|
if ( player instanceof bkOfflinePlayer && player.player ) {
|
||||||
player = player.player;
|
player = player.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,9 @@ for a list of possible entities (creatures) which can be spawned.
|
||||||
|
|
||||||
***/
|
***/
|
||||||
var entities = [],
|
var entities = [],
|
||||||
EntityType = org.bukkit.entity.EntityType;
|
bkEntityType = org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
var MaterialEnum = Packages.MaterialEnum;
|
var entitytypes = bkEntityType.values();
|
||||||
|
|
||||||
var entitytypes = EntityType.values();
|
|
||||||
for ( var t in entitytypes ) {
|
for ( var t in entitytypes ) {
|
||||||
if ( entitytypes[t] && entitytypes[t].ordinal ) {
|
if ( entitytypes[t] && entitytypes[t].ordinal ) {
|
||||||
entities.push(entitytypes[t].name());
|
entities.push(entitytypes[t].name());
|
||||||
|
|
Reference in a new issue