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