Omit abstract event classes from events-helper.
Improved tab completion for jre8
This commit is contained in:
parent
d8cfcb4572
commit
2ba3335a16
17 changed files with 55 additions and 159 deletions
|
@ -1,2 +1,2 @@
|
|||
bukkit-version=1.7.2
|
||||
scriptcraft-version=2.0.6
|
||||
bukkit-version=1.7.9
|
||||
scriptcraft-version=2.0.8
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
<java classname="jscript" failonerror="true" fork="true" output="${dist}/js/lib/events-helper.js">
|
||||
<classpath>
|
||||
<pathelement path="src/docs/java"/>
|
||||
<pathelement path="${minecraft.dir}/craftbukkit.jar"/>
|
||||
</classpath>
|
||||
<arg value="src/generateEventsHelper.js"/>
|
||||
</java>
|
||||
|
|
|
@ -48,9 +48,6 @@ Walter Higgins
|
|||
* [Using string substitutions](#using-string-substitutions)
|
||||
* [Events Helper Module](#events-helper-module)
|
||||
* [Usage](#usage)
|
||||
* [events.hanging()](#eventshanging)
|
||||
* [events.world()](#eventsworld)
|
||||
* [events.chunk()](#eventschunk)
|
||||
* [events.worldUnload()](#eventsworldunload)
|
||||
* [events.worldLoad()](#eventsworldload)
|
||||
* [events.chunkLoad()](#eventschunkload)
|
||||
|
@ -59,7 +56,6 @@ Walter Higgins
|
|||
* [events.spawnChange()](#eventsspawnchange)
|
||||
* [events.chunkUnload()](#eventschunkunload)
|
||||
* [events.worldInit()](#eventsworldinit)
|
||||
* [events.entity()](#eventsentity)
|
||||
* [events.horseJump()](#eventshorsejump)
|
||||
* [events.entityCombust()](#eventsentitycombust)
|
||||
* [events.entityRegainHealth()](#eventsentityregainhealth)
|
||||
|
@ -92,30 +88,22 @@ Walter Higgins
|
|||
* [events.itemSpawn()](#eventsitemspawn)
|
||||
* [events.sheepDyeWool()](#eventssheepdyewool)
|
||||
* [events.entityTeleport()](#eventsentityteleport)
|
||||
* [events.block()](#eventsblock)
|
||||
* [events.blockFade()](#eventsblockfade)
|
||||
* [events.blockDamage()](#eventsblockdamage)
|
||||
* [events.blockPiston()](#eventsblockpiston)
|
||||
* [events.blockPistonExtend()](#eventsblockpistonextend)
|
||||
* [events.blockExp()](#eventsblockexp)
|
||||
* [events.blockGrow()](#eventsblockgrow)
|
||||
* [events.blockPistonRetract()](#eventsblockpistonretract)
|
||||
* [events.blockDispense()](#eventsblockdispense)
|
||||
* [events.blockBreak()](#eventsblockbreak)
|
||||
* [events.painting()](#eventspainting)
|
||||
* [events.paintingPlace()](#eventspaintingplace)
|
||||
* [events.weather()](#eventsweather)
|
||||
* [events.lightningStrike()](#eventslightningstrike)
|
||||
* [events.vehicle()](#eventsvehicle)
|
||||
* [events.vehicleEnter()](#eventsvehicleenter)
|
||||
* [events.vehicleMove()](#eventsvehiclemove)
|
||||
* [events.vehicleCollision()](#eventsvehiclecollision)
|
||||
* [events.vehicleCreate()](#eventsvehiclecreate)
|
||||
* [events.asyncPlayerPreLogin()](#eventsasyncplayerprelogin)
|
||||
* [events.playerUnleashEntity()](#eventsplayerunleashentity)
|
||||
* [events.playerPreLogin()](#eventsplayerprelogin)
|
||||
* [events.player()](#eventsplayer)
|
||||
* [events.server()](#eventsserver)
|
||||
* [events.inventoryPickupItem()](#eventsinventorypickupitem)
|
||||
* [events.inventoryMoveItem()](#eventsinventorymoveitem)
|
||||
* [events.furnaceBurn()](#eventsfurnaceburn)
|
||||
|
@ -194,7 +182,6 @@ Walter Higgins
|
|||
* [events.playerToggleFlight()](#eventsplayertoggleflight)
|
||||
* [events.playerAnimation()](#eventsplayeranimation)
|
||||
* [events.asyncPlayerChat()](#eventsasyncplayerchat)
|
||||
* [events.playerBucket()](#eventsplayerbucket)
|
||||
* [events.playerRegisterChannel()](#eventsplayerregisterchannel)
|
||||
* [events.playerMove()](#eventsplayermove)
|
||||
* [events.playerTeleport()](#eventsplayerteleport)
|
||||
|
@ -206,8 +193,6 @@ Walter Higgins
|
|||
* [events.serverCommand()](#eventsservercommand)
|
||||
* [events.remoteServerCommand()](#eventsremoteservercommand)
|
||||
* [events.mapInitialize()](#eventsmapinitialize)
|
||||
* [events.service()](#eventsservice)
|
||||
* [events.plugin()](#eventsplugin)
|
||||
* [events.serviceRegister()](#eventsserviceregister)
|
||||
* [events.serverListPing()](#eventsserverlistping)
|
||||
* [events.serviceUnregister()](#eventsserviceunregister)
|
||||
|
@ -963,30 +948,6 @@ The crucial difference is that the events module will have functions for each
|
|||
of the built-in events so tab-completion will help
|
||||
beginning programmers to explore the events at the server console window.
|
||||
|
||||
### events.hanging()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the hanging.HangingEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.world()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the world.WorldEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.chunk()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the world.ChunkEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.worldUnload()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1051,14 +1012,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.entity()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the entity.EntityEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.horseJump()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1315,14 +1268,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.block()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the block.BlockEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.blockFade()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1339,14 +1284,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.blockPiston()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the block.BlockPistonEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.blockPistonExtend()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1395,14 +1332,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.painting()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the painting.PaintingEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.paintingPlace()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1411,14 +1340,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.weather()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the weather.WeatherEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.lightningStrike()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1427,14 +1348,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.vehicle()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the vehicle.VehicleEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.vehicleEnter()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1451,14 +1364,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.vehicleCollision()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the vehicle.VehicleCollisionEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.vehicleCreate()
|
||||
|
||||
#### Parameters
|
||||
|
@ -1491,22 +1396,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.player()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the player.PlayerEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.server()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the server.ServerEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.inventoryPickupItem()
|
||||
|
||||
#### Parameters
|
||||
|
@ -2131,14 +2020,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.playerBucket()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the player.PlayerBucketEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.playerRegisterChannel()
|
||||
|
||||
#### Parameters
|
||||
|
@ -2227,22 +2108,6 @@ see events.on() for more information.
|
|||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.service()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the server.ServiceEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.plugin()
|
||||
|
||||
#### Parameters
|
||||
|
||||
* callback - A function which is called whenever the server.PluginEvent event is fired
|
||||
|
||||
see events.on() for more information.
|
||||
|
||||
### events.serviceRegister()
|
||||
|
||||
#### Parameters
|
||||
|
@ -3138,7 +3003,7 @@ Drones can be created in any of the following ways...
|
|||
block is broken at the block's location you would do so like
|
||||
this...
|
||||
|
||||
events.on('block.BlockBreakEvent',function( event) {
|
||||
events.blockBreak( function( event) {
|
||||
var location = event.block.location;
|
||||
var drone = new Drone(location);
|
||||
// do more stuff with the drone here...
|
||||
|
@ -4046,7 +3911,6 @@ Source Code ...
|
|||
|
||||
A simple event-driven minecraft plugin. How to handle Events.
|
||||
|
||||
|
||||
This example demonstrates event-driven programming. The code below
|
||||
will display the version of ScriptCraft every time an operator joins
|
||||
the game. This module is notable from previous modules for the
|
||||
|
@ -4128,6 +3992,14 @@ cleaner and more readable. Similarly where you see a method like
|
|||
}
|
||||
});
|
||||
|
||||
Update: Since version 2.0.8 the above code can be replaced by the more succinct:
|
||||
|
||||
events.playerJoin( function( event ) {
|
||||
if ( event.player.op ) {
|
||||
event.player.sendMessage('Welcome to ' + __plugin);
|
||||
}
|
||||
});
|
||||
|
||||
## Arrows Plugin
|
||||
|
||||
The arrows mod adds fancy arrows to the game. Arrows which...
|
||||
|
|
|
@ -36,6 +36,13 @@ while ( ( entry = zis.nextEntry) != null) {
|
|||
var name = '' + entry.name;
|
||||
if (name.match(/org\/bukkit\/event\/.+Event\.class$/)){
|
||||
name = name.replace(/\//g,'.').replace('.class','');
|
||||
|
||||
// abstract events don't have a static getHandlerList method so
|
||||
// shouldn't be added to this module
|
||||
var hasHandlerList = eval(name + '.getHandlerList');
|
||||
if ( !hasHandlerList ) {
|
||||
continue;
|
||||
}
|
||||
var parts = name.split('.');
|
||||
var shortName = name.replace('org.bukkit.event.','');
|
||||
var fname = parts.reverse().shift().replace(/^(.)/,function(a){ return a.toLowerCase()}).replace(/Event$/,'');
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
exports.isJavaObject = function( o ) {
|
||||
if (o === global){
|
||||
return false;
|
||||
}
|
||||
return o instanceof java.lang.Object;
|
||||
};
|
||||
|
|
|
@ -619,15 +619,16 @@ function __onEnable ( __engine, __plugin, __script )
|
|||
global.plugin = plugins.plugin;
|
||||
|
||||
var events = require('events');
|
||||
events.on( 'server.PluginDisableEvent', function( evt ) {
|
||||
// wph 20131226 - make events global as it is used by many plugins/modules
|
||||
global.events = events;
|
||||
|
||||
events.pluginDisable(function( evt ) {
|
||||
// save config
|
||||
_save( global.config, new File( jsPluginsRootDir, 'data/global-config.json' ) );
|
||||
|
||||
_runUnloadHandlers();
|
||||
org.bukkit.event.HandlerList['unregisterAll(org.bukkit.plugin.Plugin)'](__plugin);
|
||||
});
|
||||
// wph 20131226 - make events global as it is used by many plugins/modules
|
||||
global.events = events;
|
||||
|
||||
|
||||
global.__onCommand = function( sender, cmd, label, args) {
|
||||
|
|
|
@ -24,6 +24,7 @@ var _getProperties = function( o ) {
|
|||
i,
|
||||
j,
|
||||
isObjectMethod,
|
||||
propValue,
|
||||
typeofProperty;
|
||||
|
||||
if ( isJavaObject( o ) ) {
|
||||
|
@ -49,12 +50,14 @@ var _getProperties = function( o ) {
|
|||
}
|
||||
typeofProperty = null;
|
||||
try {
|
||||
typeofProperty = typeof o[i];
|
||||
propValue = o[i];
|
||||
typeofProperty = typeof propValue;
|
||||
} catch( e ) {
|
||||
if ( e.message == 'java.lang.IllegalStateException: Entity not leashed' ) {
|
||||
// wph 20131020 fail silently for Entity leashing in craftbukkit
|
||||
} else {
|
||||
throw e;
|
||||
// don't throw an error during tab completion just make a best effort to
|
||||
// do the job.
|
||||
}
|
||||
}
|
||||
if ( typeofProperty == 'function' ) {
|
||||
|
@ -119,6 +122,9 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
|
|||
if ( statement.length == 0 ) {
|
||||
propsOfLastArg = _globalSymbols;
|
||||
} else {
|
||||
if (statement.match(/\)$/)){
|
||||
return;
|
||||
}
|
||||
statementSyms = statement.split(/[^\$a-zA-Z0-9_\.]/);
|
||||
|
||||
lastSymbol = statementSyms[statementSyms.length-1];
|
||||
|
|
|
@ -184,7 +184,7 @@ signs.menu = function( /* String */ label, /* Array */ options, /* Function */ c
|
|||
//
|
||||
// update it every time player interacts with it.
|
||||
//
|
||||
events.on( 'player.PlayerInteractEvent', function( event ) {
|
||||
events.playerInteract( function( event ) {
|
||||
/*
|
||||
look up our list of menu signs. If there's a matching location and there's
|
||||
a sign, then update it.
|
||||
|
|
|
@ -223,7 +223,7 @@ var _intercept = function( msg, invoker, exec ) {
|
|||
Intercept all command processing and replace with aliased commands if the
|
||||
command about to be issued matches an alias.
|
||||
*/
|
||||
events.on( 'player.PlayerCommandPreprocessEvent', function( evt ) {
|
||||
events.playerCommandPreprocess( function( evt ) {
|
||||
var invoker = evt.player;
|
||||
var exec = function( cmd ) {
|
||||
invoker.performCommand(cmd);
|
||||
|
@ -237,7 +237,7 @@ events.on( 'player.PlayerCommandPreprocessEvent', function( evt ) {
|
|||
command('void',function( ) {
|
||||
} );
|
||||
|
||||
events.on( 'server.ServerCommandEvent', function( evt ) {
|
||||
events.serverCommand( function( evt ) {
|
||||
var invoker = evt.sender;
|
||||
var exec = function( cmd ) {
|
||||
invoker.server.dispatchCommand( invoker, cmd);
|
||||
|
|
|
@ -121,5 +121,5 @@ var _onArrowHit = function( event ) {
|
|||
}
|
||||
}
|
||||
};
|
||||
events.on( 'entity.ProjectileHitEvent', _onArrowHit );
|
||||
events.projectileHit( _onArrowHit );
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ foreach( colors, function ( color, i ) {
|
|||
colorCodes[color] = i.toString( 16 );
|
||||
} );
|
||||
|
||||
events.on( 'player.AsyncPlayerChatEvent', function( event ) {
|
||||
events.asyncPlayerChat( function( event ) {
|
||||
var player = event.player;
|
||||
var playerChatColor = _store.players[ player.name ];
|
||||
if ( playerChatColor ) {
|
||||
|
|
|
@ -158,7 +158,7 @@ var classroom = plugin('classroom', {
|
|||
|
||||
exports.classroom = classroom;
|
||||
|
||||
events.on( 'player.PlayerJoinEvent', function( event ) {
|
||||
events.playerJoin( function( event ) {
|
||||
if ( _store.enableScripting ) {
|
||||
grantScripting(event.player);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ exports.commando = function( name, func, options, intercepts ) {
|
|||
return result;
|
||||
};
|
||||
|
||||
events.on( 'player.PlayerCommandPreprocessEvent', function( evt ) {
|
||||
events.playerCommandPreprocess( function( evt ) {
|
||||
var msg = '' + evt.message;
|
||||
var parts = msg.match( /^\/([^\s]+)/ );
|
||||
if ( !parts ) {
|
||||
|
@ -98,7 +98,7 @@ events.on( 'player.PlayerCommandPreprocessEvent', function( evt ) {
|
|||
evt.message = '/jsp ' + msg.replace( /^\//, '' );
|
||||
}
|
||||
} );
|
||||
events.on( 'server.ServerCommandEvent', function( evt ) {
|
||||
events.serverCommand( function( evt ) {
|
||||
var msg = '' + evt.command;
|
||||
var parts = msg.match( /^\/*([^\s]+)/ );
|
||||
if ( !parts ) {
|
||||
|
|
|
@ -118,7 +118,7 @@ Drones can be created in any of the following ways...
|
|||
block is broken at the block's location you would do so like
|
||||
this...
|
||||
|
||||
events.on('block.BlockBreakEvent',function( event) {
|
||||
events.blockBreak( function( event) {
|
||||
var location = event.block.location;
|
||||
var drone = new Drone(location);
|
||||
// do more stuff with the drone here...
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
A simple event-driven minecraft plugin. How to handle Events.
|
||||
|
||||
|
||||
This example demonstrates event-driven programming. The code below
|
||||
will display the version of ScriptCraft every time an operator joins
|
||||
the game. This module is notable from previous modules for the
|
||||
|
@ -85,6 +84,14 @@ cleaner and more readable. Similarly where you see a method like
|
|||
}
|
||||
});
|
||||
|
||||
Update: Since version 2.0.8 the above code can be replaced by the more succinct:
|
||||
|
||||
events.playerJoin( function( event ) {
|
||||
if ( event.player.op ) {
|
||||
event.player.sendMessage('Welcome to ' + __plugin);
|
||||
}
|
||||
});
|
||||
|
||||
***/
|
||||
events.on( 'player.PlayerJoinEvent', function( event ) {
|
||||
if ( event.player.op ) {
|
||||
|
|
|
@ -43,7 +43,6 @@ cover to make the game more fun.
|
|||
***/
|
||||
|
||||
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;
|
||||
|
@ -196,7 +195,7 @@ var createGame = function( duration, teams ) {
|
|||
return {
|
||||
start: function( ) {
|
||||
_startGame( _gameState );
|
||||
_gameState.listener = events.on(bkEntityDamageByEntityEvent,_onSnowballHit);
|
||||
_gameState.listener = events.entityDamageByEntity( _onSnowballHit );
|
||||
new java.lang.Thread( function( ) {
|
||||
while ( _gameState.duration-- ) {
|
||||
java.lang.Thread.sleep( 1000 ); // sleep 1,000 millisecs (1 second)
|
||||
|
|
|
@ -94,9 +94,9 @@ var _startGame = function( ) {
|
|||
console.log('Staring game: Cow Clicker');
|
||||
}
|
||||
|
||||
events.on( 'player.PlayerQuitEvent', _onPlayerQuit );
|
||||
events.on( 'player.PlayerJoinEvent', _onPlayerJoin );
|
||||
events.on( 'player.PlayerInteractEntityEvent', _onPlayerInteract );
|
||||
events.playerQuit( _onPlayerQuit );
|
||||
events.playerJoin( _onPlayerJoin );
|
||||
events.playerInteractEntity( _onPlayerInteract );
|
||||
|
||||
scoreboard.start();
|
||||
|
||||
|
|
Reference in a new issue