fixes issue #140

This commit is contained in:
walterhiggins 2014-06-14 15:36:56 +01:00
parent c01ce603c5
commit 521e35ffe8

View file

@ -4,6 +4,7 @@ var File = java.io.File,
out = java.lang.System.out, out = java.lang.System.out,
err = java.lang.System.err, err = java.lang.System.err,
Modifier = java.lang.reflect.Modifier, Modifier = java.lang.reflect.Modifier,
clz,
ZipInputStream = java.util.zip.ZipInputStream, ZipInputStream = java.util.zip.ZipInputStream,
zis = new ZipInputStream(new FileInputStream('./target/minecraft/craftbukkit.jar')), zis = new ZipInputStream(new FileInputStream('./target/minecraft/craftbukkit.jar')),
entry = null; entry = null;
@ -18,19 +19,17 @@ var content = [
'', '',
'### Usage', '### Usage',
'', '',
' events.blockBreak(function(evt){ ', ' events.blockBreak( function( event ) { ',
' evt.player.sendMessage("You broke a block!"); ', ' event.player.sendMessage(\'You broke a block!\'); ',
' });', ' });',
'', '',
'... which is just a shorter and less error-prone way of writing ...', '... which is just a shorter and less error-prone way of writing ...',
'', '',
' events.on("block.BlockBreakEvent",function(evt){ ', ' events.on(\'block.BlockBreakEvent\',function( event ) { ',
' evt.player.sendMessage("You broke a block!");', ' event.player.sendMessage(\'You broke a block!\');',
' });', ' });',
'', '',
'The crucial difference is that the events module now has functions for each ', 'The crucial difference is that the events module now has functions for each of the built-in events. The functions are accessible via TAB-completion so will help beginning programmers to explore the events at the server console window.',
'of the built-in events. The functions are accessible via tab-completion so will help ',
'beginning programmers to explore the events at the server console window.',
'', '',
'***/' '***/'
]; ];
@ -41,14 +40,18 @@ while ( ( entry = zis.nextEntry) != null) {
var name = '' + entry.name; var name = '' + entry.name;
if (name.match(/org\/bukkit\/event\/.+Event\.class$/)){ if (name.match(/org\/bukkit\/event\/.+Event\.class$/)){
name = name.replace(/\//g,'.').replace('.class',''); name = name.replace(/\//g,'.').replace('.class','');
var clz = java.lang.Class.forName(name); try {
clz = java.lang.Class.forName(name);
}catch ( e) {
clz = engine.eval(name);
}
var isAbstract = Modifier.isAbstract(clz.getModifiers()); var isAbstract = Modifier.isAbstract(clz.getModifiers());
if ( isAbstract ) { if ( isAbstract ) {
continue; continue;
} }
var parts = name.split('.'); var parts = name.split('.');
var shortName = name.replace('org.bukkit.event.',''); var shortName = name.replace('org.bukkit.event.','');
var fname = parts.reverse().shift().replace(/^(.)/,function(a){ return a.toLowerCase()}).replace(/Event$/,''); var fname = parts.reverse().shift().replace(/^(.)/,function(a){ return a.toLowerCase();}).replace(/Event$/,'');
var comment = [ var comment = [
'/*********************', '/*********************',