Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<classpathentry kind="src" path="src/docs/java"/>
<classpathentry kind="src" path="src/main/java/bukkit"/>
<classpathentry kind="src" path="src/main/java/canary"/>
<classpathentry kind="src" path="src/main/java/webserver"/>
<classpathentry kind="src" path="src/main/java/common"/>
<classpathentry kind="lib" path="lib/bukkit-1.7.10-R0.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/canarymod.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ ScriptCraft plugin &hellip;
[ic]: http://canarymod.net/releases
[cmapi]: https://ci.visualillusionsent.net/job/CanaryLib/javadoc/

# BlocklyCraft visual editor

ScriptCraft now includes a graphical editor. This allows even younger aspiring programmers
to create Minecraft Mods without (initially) having to learn how to type even a single line of JavaScript,
making it (also) a visual programming environment, and not only a text-based code one. This visual editor
is web-based, and based on Google's Blockly (which was influenced by MIT's Scratch, which was inspired by
Logo, the original "turtle graphics" educational programming language designed in 1967 equally at MIT.)

[http://localhost:7070/blocklycraft/](http://localhost:7070/blocklycraft/index.html) opens this intuitive editor, and [this first video introduces](https://www.youtube.com/watch?v=cat5f-Hy16k) how to use it, [this video in Italian](https://www.youtube.com/watch?v=83I8DzWjnNQ) is from Devoxx4kids Ticino 2015, where [BlocklyMinecraft was born during a Hackergarten](https://www.flickr.com/photos/132694685@N07/16616720023/in/set-72157649797804723).


# Contributing

If you would like to contribute source code and/or documentation changes please [read contributing.md][contrib]
Expand Down
36 changes: 36 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## ToDo

[ ] BlocklyCraft: Translate Italian-only blocks to French & German
[ ] Create HTML version of MinecraftModdingIdeas_20150416.docx, link it as Help?
[ ] Video/s more, Blog, Tweet..
[ ] announce it on https://groups.google.com/forum/#!forum/blockly
[ ] get linked on https://blockly-games.appspot.com/about?lang=en
[ ] Save using https://blockly-demo.appspot.com/static/demos/storage/index.html & https://developers.google.com/blockly/installation/cloud-storage
[ ] How-to refresh() without restarting the web server? If figured out, then re-enable the commented out httpServer.openURL(); in *BOTH* ScriptCraftPlugin classes
[ ] https://github.com/maxogden/javascript-editor
[ ] support Java (Xtend?) instead of JavaScript coding (use Hotea)


## Done

# 2015.05.30
[X] Michael integrated Lauro's clean-up and English instead of Italian only Translations; submitted pull request to Walter!

# 2015.04.26
[X] Web Server handles POST to update JS files, under fixed folder, to later support Save from Blockly (using POST instead of GET)
[X] Bundled complete BlocklyCraft, as received in Lauro's ZIP - but complete separate 3rd-party from our code
[X] Introduced it in README.md incl. link to https://www.youtube.com/watch?v=cat5f-Hy16k

# 2015.04.22
[X] Integrated js/plugins/blocklycraft (without Blockly in www/, yet)
[X] copy 2-3 files, works! now showing in Git.
[X] remove hard-coded path.. avoid error on start-up
[X] cleaned up files much, formatting, header, etc.

# 2015.04.19
[X] Given hugely successful Devoxx4Kids workshop in Lugano, Ticino, Switzerland using this ScriptCraft + BlocklyCraft ;)
[X] Integrated Web Server
* Can serve static files
* HTTP host and port configured via -Dorg.scriptcraftjs.webserver.WebServer.port and *.host
* HTTP Request/Response details logging intentionally disabled
* Automatically opens web browser
31 changes: 24 additions & 7 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Glowstone (which is bukkit-compatible)
* Spigot (which is bukkit-compatible)
-->
<property name="src.common" location="src/main/java/common"/>
<property name="src.canary" location="src/main/java/canary"/>
<property name="src.bukkit" location="src/main/java/bukkit"/>

Expand Down Expand Up @@ -60,7 +61,8 @@
<get src="https://ci.visualillusionsent.net/job/CanaryMod/lastStableBuild/artifact/*zip*/archive.zip"
maxtime="60"
dest="target/canarymod.zip"
verbose="true"/>
verbose="true"
skipexisting="true" />
<unzip src="target/canarymod.zip"
dest="target/lib">
<mapper type="glob" from="*.jar" to="canarymod.jar"/>
Expand All @@ -73,6 +75,7 @@
target="1.6"
destdir="${build}"
debug="true">
<src path="${src.common}"/>
<src path="${src.canary}"/>
<src path="${src.bukkit}"/>
<classpath>
Expand Down Expand Up @@ -189,7 +192,7 @@ Walter Higgins
</concat>
</target>

<target name="zip_js" depends="zip_lib, zip_modules, zip_plugins">
<target name="zip_js" depends="zip_lib, zip_modules, zip_plugins, zip_www">
</target>

<target name="copy-js" depends="gen-events-helper-canary,gen-events-helper-bukkit,init">
Expand All @@ -202,34 +205,44 @@ Walter Higgins
<delete file="${build}/lib.zip"/>
<zip destfile="${build}/lib.zip"
basedir="${dist}/js"
excludes="modules/**, plugins/**,">
excludes="modules/**, plugins/**, www/**">
</zip>
</target>

<target name="get_underscore" depends="copy-js" unless="underscore.present">
<!-- download underscore -->
<get src="http://underscorejs.org/underscore.js"
verbose="true"
dest="${dist}/js/modules/underscore.js"/>
dest="${dist}/js/modules/underscore.js"
skipexisting="true"/>
</target>

<target name="zip_modules" depends="copy-js, get_underscore">
<delete file="${build}/modules.zip"/>
<zip destfile="${build}/modules.zip"
basedir="${dist}/js"
excludes="lib/**, plugins/**,">
excludes="lib/**, plugins/**, www/**">
</zip>
</target>

<target name="zip_plugins" depends="copy-js">
<delete file="${build}/plugins.zip"/>
<zip destfile="${build}/plugins.zip"
basedir="${dist}/js"
excludes="lib/**, modules/**">
excludes="lib/**, modules/**, www/**">
</zip>
</target>

<target name="package" depends="gendocs,zip_js,compile-plugins" description="generate the distribution" >
<target name="zip_www" depends="copy-js">
<delete file="${build}/www.zip"/>
<zip destfile="${build}/www.zip"
basedir="${dist}/js"
excludes="lib/**, modules/**, plugins/**, www/blocklycraft/3rd-party/google-blockly-master.zip"
level="9">
</zip>
</target>

<target name="package" depends="blockly,gendocs,zip_js,compile-plugins" description="generate the distribution" >
<!-- ensure plugin.yml is always copied -->
<delete file="${build}/plugin.yml" />
<delete file="${build}/Canary.inf" />
Expand Down Expand Up @@ -262,4 +275,8 @@ Walter Higgins
<mkdir dir="${minecraft.dir}/plugins" />
<copy file="${dist}/${DSTAMP}/scriptcraft.jar" todir="${minecraft.dir}/plugins"/>
</target>

<target name="blockly">
<ant dir="src/main/js/www/blocklycraft/" />
</target>
</project>
4 changes: 4 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
RELEASE NOTES
=============

TBD Release (2015 ? ?)
--------------------------
Added BlocklyMinecraft visual editor contributed by Lauro Canonica and Michael Vorburger.ch

3.1.4 Release (2015 05 09)
--------------------------
Various bug fixes and new 'inventory' module.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.scriptcraftjs.bukkit;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.scriptcraftjs.webserver.ScriptCraftWebServer;

public class ScriptCraftPlugin extends JavaPlugin implements Listener
{
Expand All @@ -22,6 +24,8 @@ public class ScriptCraftPlugin extends JavaPlugin implements Listener
private String NO_JAVASCRIPT_MESSAGE = "No JavaScript Engine available. ScriptCraft will not work without Javascript.";
protected ScriptEngine engine = null;

protected ScriptCraftWebServer httpServer = new ScriptCraftWebServer();

@Override public void onEnable()
{
Thread currentThread = Thread.currentThread();
Expand All @@ -37,6 +41,11 @@ public class ScriptCraftPlugin extends JavaPlugin implements Listener
this.engine.eval(new InputStreamReader(this.getResource("boot.js")));
inv.invokeFunction("__scboot", this, engine);
}

httpServer.start();
this.getLogger().info(httpServer.getStartedLogMessage());
// httpServer.openURL();

} catch (Exception e) {
e.printStackTrace();
this.getLogger().severe(e.getMessage());
Expand All @@ -45,6 +54,12 @@ public class ScriptCraftPlugin extends JavaPlugin implements Listener
}
}

@Override public void onDisable() {
super.onDisable();
httpServer.stop();
this.getLogger().info("HTTP web server stopped");
}

public List<String> onTabComplete(CommandSender sender, Command cmd,
String alias,
String[] args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
package org.scriptcraftjs.canarymod;

import java.io.InputStreamReader;
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;
import javax.script.Invocable;
import java.util.List;
import java.util.ArrayList;
import java.util.List;

import net.canarymod.plugin.Plugin;
import net.canarymod.plugin.PluginListener;
import net.canarymod.tasks.ServerTask;
import net.canarymod.tasks.TaskOwner;
import net.canarymod.commandsys.CommandListener;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

import net.canarymod.Canary;
import net.canarymod.chat.MessageReceiver;
import net.canarymod.commandsys.Command;
import net.canarymod.commandsys.CommandListener;
import net.canarymod.commandsys.TabComplete;
import net.canarymod.chat.MessageReceiver;
import net.canarymod.Canary;
// event help stuff
import net.canarymod.hook.Dispatcher;
import net.canarymod.hook.Hook;
import net.canarymod.plugin.Plugin;
import net.canarymod.plugin.PluginListener;
import net.canarymod.tasks.ServerTask;
import net.canarymod.tasks.TaskOwner;

import org.scriptcraftjs.webserver.ScriptCraftWebServer;

public class ScriptCraftPlugin extends Plugin implements PluginListener, CommandListener
{
Expand All @@ -28,8 +33,12 @@ public class ScriptCraftPlugin extends Plugin implements PluginListener, Command
"ScriptCraft will not work without Javascript.";
protected ScriptEngine engine = null;

protected ScriptCraftWebServer httpServer = new ScriptCraftWebServer();

@Override
public void disable(){
httpServer.stop();
this.getLogman().info("HTTP web server stopped");
try {
((Invocable)this.engine).invokeFunction("__onDisable", this.engine, this);
}catch ( Exception e) {
Expand All @@ -56,12 +65,16 @@ public boolean enable()
}

Canary.commands().registerCommands(this, this, false);

httpServer.start();
this.getLogman().info(httpServer.getStartedLogMessage());
// httpServer.openURL();

}catch(Exception e){
e.printStackTrace();
this.getLogman().error(e.getMessage());
}



return true;
}

Expand Down Expand Up @@ -151,12 +164,12 @@ private List<String> complete(MessageReceiver sender, String[] args, String cmd)
}
return result;
}

@TabComplete (commands = { "js" })
public List<String> jsComplete(MessageReceiver sender, String[] args){
return complete(sender, args, "js");
}

@TabComplete (commands = { "jsp" })
public List<String> jspComplete(MessageReceiver sender, String[] args){
return complete(sender, args, "jsp");
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/common/fi/iki/elonen/InternalRewrite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package fi.iki.elonen;

import java.util.Map;

import static fi.iki.elonen.NanoHTTPD.Response;

/**
* @author Paul S. Hawke (paul.hawke@gmail.com)
* On: 9/15/13 at 2:52 PM
*/
public class InternalRewrite extends Response {
private final String uri;
private final Map<String, String> headers;

public InternalRewrite(Map<String, String> headers, String uri) {
super(null);
this.headers = headers;
this.uri = uri;
}

public String getUri() {
return uri;
}

public Map<String, String> getHeaders() {
return headers;
}
}
12 changes: 12 additions & 0 deletions src/main/java/common/fi/iki/elonen/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (c) 2012-2013 by Paul S. Hawke, 2001,2005-2013 by Jarno Elonen, 2010 by Konstantinos Togias
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of the NanoHttpd organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading