Fixes issue #179
This commit is contained in:
parent
ed863e460c
commit
bba65fdfca
5 changed files with 21 additions and 12 deletions
|
@ -1042,7 +1042,7 @@ The ScriptCraft console methods work like the [Web API implementation][webcons].
|
||||||
console.log('Hello %s', 'world');
|
console.log('Hello %s', 'world');
|
||||||
|
|
||||||
Basic variable substitution is supported (ScriptCraft's implementation
|
Basic variable substitution is supported (ScriptCraft's implementation
|
||||||
of console uses the Bukkit Plugin [Logger][lgr] under the hood and
|
of console uses the Bukkit Plugin [Logger][lgr] or Canary Plugin [Logman][cmlgr] under the hood and
|
||||||
uses [java.lang.String.format()][strfmt] for variable
|
uses [java.lang.String.format()][strfmt] for variable
|
||||||
substitution. All output will be sent to the server console (not
|
substitution. All output will be sent to the server console (not
|
||||||
in-game).
|
in-game).
|
||||||
|
@ -1057,6 +1057,7 @@ ScriptCraft uses Java's [String.format()][strfmt] so any string substitution ide
|
||||||
}
|
}
|
||||||
|
|
||||||
[lgr]: http://jd.bukkit.org/beta/apidocs/org/bukkit/plugin/PluginLogger.html
|
[lgr]: http://jd.bukkit.org/beta/apidocs/org/bukkit/plugin/PluginLogger.html
|
||||||
|
[cmlgr]: https://ci.visualillusionsent.net/job/CanaryLib/javadoc/net/canarymod/logger/Logman.html
|
||||||
[strfmt]: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String, java.lang.Object...)
|
[strfmt]: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String, java.lang.Object...)
|
||||||
[webcons]: https://developer.mozilla.org/en-US/docs/Web/API/console
|
[webcons]: https://developer.mozilla.org/en-US/docs/Web/API/console
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ The ScriptCraft console methods work like the [Web API implementation][webcons].
|
||||||
console.log('Hello %s', 'world');
|
console.log('Hello %s', 'world');
|
||||||
|
|
||||||
Basic variable substitution is supported (ScriptCraft's implementation
|
Basic variable substitution is supported (ScriptCraft's implementation
|
||||||
of console uses the Bukkit Plugin [Logger][lgr] under the hood and
|
of console uses the Bukkit Plugin [Logger][lgr] or Canary Plugin [Logman][cmlgr] under the hood and
|
||||||
uses [java.lang.String.format()][strfmt] for variable
|
uses [java.lang.String.format()][strfmt] for variable
|
||||||
substitution. All output will be sent to the server console (not
|
substitution. All output will be sent to the server console (not
|
||||||
in-game).
|
in-game).
|
||||||
|
@ -31,6 +31,7 @@ ScriptCraft uses Java's [String.format()][strfmt] so any string substitution ide
|
||||||
}
|
}
|
||||||
|
|
||||||
[lgr]: http://jd.bukkit.org/beta/apidocs/org/bukkit/plugin/PluginLogger.html
|
[lgr]: http://jd.bukkit.org/beta/apidocs/org/bukkit/plugin/PluginLogger.html
|
||||||
|
[cmlgr]: https://ci.visualillusionsent.net/job/CanaryLib/javadoc/net/canarymod/logger/Logman.html
|
||||||
[strfmt]: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String, java.lang.Object...)
|
[strfmt]: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String, java.lang.Object...)
|
||||||
[webcons]: https://developer.mozilla.org/en-US/docs/Web/API/console
|
[webcons]: https://developer.mozilla.org/en-US/docs/Web/API/console
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
/*global persist,exports,config,__plugin,require*/
|
||||||
var File = java.io.File,
|
var File = java.io.File,
|
||||||
FileWriter = java.io.FileWriter,
|
FileWriter = java.io.FileWriter,
|
||||||
PrintWriter = java.io.PrintWriter;
|
PrintWriter = java.io.PrintWriter;
|
||||||
|
@ -84,7 +84,8 @@ exports.autoload = function( context, pluginDir, logger, options ) {
|
||||||
}
|
}
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
if ( typeof logger != 'undefined' ) {
|
if ( typeof logger != 'undefined' ) {
|
||||||
logger.error( 'Plugin ' + pluginPath + ' ' + e );
|
var msg = 'Plugin ' + pluginPath + ' ' + e ;
|
||||||
|
__plugin.canary ? logger.error( msg ) : logger.severe( msg );
|
||||||
} else {
|
} else {
|
||||||
java.lang.System.out.println( 'Error: Plugin ' + pluginPath + ' ' + e );
|
java.lang.System.out.println( 'Error: Plugin ' + pluginPath + ' ' + e );
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,7 +454,7 @@ function __onEnable ( __engine, __plugin, __script ) {
|
||||||
}
|
}
|
||||||
result = JSON.parse(contents);
|
result = JSON.parse(contents);
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
logger.error( 'Error evaluating ' + canonizedFilename + ', ' + e );
|
logError('Error evaluating ' + canonizedFilename + ', ' + e );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
|
@ -497,7 +497,7 @@ function __onEnable ( __engine, __plugin, __script ) {
|
||||||
result = __engine.eval( wrappedCode );
|
result = __engine.eval( wrappedCode );
|
||||||
// issue #103 avoid side-effects of || operator on Mac Rhino
|
// issue #103 avoid side-effects of || operator on Mac Rhino
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
logger.error( 'Error evaluating ' + canonizedFilename + ', ' + e );
|
logError('Error evaluating ' + canonizedFilename + ', ' + e );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
|
@ -508,7 +508,7 @@ function __onEnable ( __engine, __plugin, __script ) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( warnOnFileNotFound ) {
|
if ( warnOnFileNotFound ) {
|
||||||
logger.warning( canonizedFilename + ' not found' );
|
logWarn(canonizedFilename + ' not found' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -612,12 +612,12 @@ function __onEnable ( __engine, __plugin, __script ) {
|
||||||
echo(sender, JSON.stringify( jsResult, replacer, 2) );
|
echo(sender, JSON.stringify( jsResult, replacer, 2) );
|
||||||
}
|
}
|
||||||
} catch ( displayError ) {
|
} catch ( displayError ) {
|
||||||
logger.error( 'Error while trying to display result: ' + jsResult + ', Error: '+ displayError );
|
logError('Error while trying to display result: ' + jsResult + ', Error: '+ displayError) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
logger.error( 'Error while trying to evaluate javascript: ' + fnBody + ', Error: '+ e );
|
logError( 'Error while trying to evaluate javascript: ' + fnBody + ', Error: '+ e );
|
||||||
echo( sender, 'Error while trying to evaluate javascript: ' + fnBody + ', Error: '+ e );
|
echo( sender, 'Error while trying to evaluate javascript: ' + fnBody + ', Error: '+ e );
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -650,7 +650,12 @@ function __onEnable ( __engine, __plugin, __script ) {
|
||||||
server = Bukkit.server;
|
server = Bukkit.server;
|
||||||
logger = __plugin.logger;
|
logger = __plugin.logger;
|
||||||
}
|
}
|
||||||
|
function logError(msg){
|
||||||
|
__plugin.canary ? logger.error( msg ) : logger.severe( msg );
|
||||||
|
}
|
||||||
|
function logWarn(msg){
|
||||||
|
__plugin.canary ? logger.warn( msg ) : logger.warning( msg );
|
||||||
|
}
|
||||||
var File = java.io.File,
|
var File = java.io.File,
|
||||||
FileReader = java.io.FileReader,
|
FileReader = java.io.FileReader,
|
||||||
BufferedReader = java.io.BufferedReader,
|
BufferedReader = java.io.BufferedReader,
|
||||||
|
|
|
@ -59,7 +59,7 @@ var __scboot = null;
|
||||||
*/
|
*/
|
||||||
__scboot = function ( plugin, engine, classLoader )
|
__scboot = function ( plugin, engine, classLoader )
|
||||||
{
|
{
|
||||||
var logger = plugin.logman,
|
var logger = plugin.canary ? plugin.logman : plugin.logger,
|
||||||
initScriptFile = new File(jsPlugins,initScript),
|
initScriptFile = new File(jsPlugins,initScript),
|
||||||
zips = ['lib','plugins','modules'],
|
zips = ['lib','plugins','modules'],
|
||||||
i = 0,
|
i = 0,
|
||||||
|
@ -90,7 +90,8 @@ var __scboot = null;
|
||||||
engine.eval(new FileReader(initScriptFile));
|
engine.eval(new FileReader(initScriptFile));
|
||||||
__onEnable(engine, plugin, initScriptFile);
|
__onEnable(engine, plugin, initScriptFile);
|
||||||
}catch ( e ){
|
}catch ( e ){
|
||||||
logger.error('Error evaluating ' + initScriptFile + ': ' + e);
|
var msg = 'Error evaluating ' + initScriptFile + ': ' + e;
|
||||||
|
plugin.canary ? logger.error(msg) : logger.severe(msg);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue