Further changes to achieve compat with Nashorn java 8

This commit is contained in:
walterhiggins 2014-01-13 23:01:17 +00:00
parent 93fb626276
commit 3a6cb1057d
7 changed files with 22 additions and 17 deletions

View file

@ -105,7 +105,7 @@ Walter Higgins
<pathelement path="src/docs/java"/>
</classpath>
<arg value="src/docs/javascript/generateTOC.js"/>
<arg value="src/docs/templates/ypgpm.mdt"/>
<arg value="src/docs/templates/ypgpm.md"/>
</java>
</target>
@ -113,10 +113,9 @@ Walter Higgins
<target name="construct-ypgpm" depends="gen-toc-ypgpm,init">
<concat destfile="docs/YoungPersonsGuideToProgrammingMinecraft.md">
<header filtering="no" trimleading="yes"># The Young Person's Guide to Programming in Minecraft
</header>
<fileset file="${dist}/toc-ypgpm.md" />
<fileset file="src/docs/templates/ypgpm.mdt" />
<fileset file="src/docs/templates/ypgpm.md" />
</concat>
</target>

View file

@ -1,5 +1,4 @@
# The Young Person's Guide to Programming in Minecraft
## Table of Contents
* [Introduction](#introduction)
* [Installation](#installation)

View file

@ -3,7 +3,12 @@
*/
var err = java.lang.System.err;
args = args.slice(1);
args = Array.prototype.slice.call(args,1);
if (typeof importPackage == 'undefined'){
// load compatibility script
load('nashorn:mozilla_compat.js');
}
var dir = args[0];
var foreach = function(array, func){
for (var i =0; i < array.length; i++){
@ -142,7 +147,7 @@ for (var i = 0;i < contents.length; i++){
writeComment = false;
}
if (writeComment){
println(contents[i]);
java.lang.System.out.println(contents[i]);
}
}

View file

@ -1,4 +1,4 @@
args = args.slice(1);
args = Array.prototype.slice.call(args,1);
// wph 20140105 trim not availabe in String on Mac OS.
if (typeof String.prototype.trim == 'undefined'){
@ -33,18 +33,18 @@ var createLink = function(text){
anchors[result] = 1;
return result;
};
println('## Table of Contents');
java.lang.System.out.println('## Table of Contents');
for (var i = 0; i < contents.length; i++){
line = contents[i];
if (line.match(/^##\s+/)){
var h2 = line.match(/^##\s+(.*)/)[1].trim();
var link = createLink(h2);
println (' * [' + h2 + '](#' + link + ')');
java.lang.System.out.println (' * [' + h2 + '](#' + link + ')');
}
if (line.match(/^###\s+/)){
var h3 = line.match(/^###\s+(.*)/)[1].trim();
var link = createLink(h3);
println (' * [' + h3 + '](#' + link + ')');
java.lang.System.out.println (' * [' + h3 + '](#' + link + ')');
}
}

View file

@ -22,10 +22,9 @@ var executeCmd = function(args, player){
if (!intercepted)
console.warn('Command %s is not recognised',name);
}else{
func = cmd.callback;
var result = null;
try {
result = func(args.slice(1),player);
result = cmd.callback(args.slice(1),player);
}catch (e){
console.error("Error while trying to execute command: " + JSON.stringify(args));
throw e;

View file

@ -37,9 +37,10 @@ location. For example...
create a firework at the given location
*/
var firework = function(location){
importPackage(org.bukkit.entity);
importPackage(org.bukkit);
var Color = org.bukkit.Color;
var FireworkEffect = org.bukkit.FireworkEffect;
var EntityType = org.bukkit.entity.EntityType;
var randInt = function(n){
return Math.floor(Math.random() * n);
};

View file

@ -29,8 +29,10 @@ exports.Game_NumberGuess = {
sb('players set ' + sender.name + ' NumberGuess ' + guesses);
sb('objectives setdisplay sidebar NumberGuess');
importPackage(org.bukkit.conversations);
var Prompt = org.bukkit.conversations.Prompt;
var ConversationFactory = org.bukkit.conversations.ConversationFactory;
var ConversationPrefix = org.bukkit.conversations.ConversationPrefix;
var number = Math.ceil(Math.random() * 10);
var prompt = new Prompt()