fix for issue #69

This commit is contained in:
walterhiggins 2013-03-09 16:50:12 +00:00
parent 6e113a2eca
commit 66abbfc142
3 changed files with 61 additions and 29 deletions

View file

@ -219,6 +219,19 @@ There are a couple of special javascript variables available in ScriptCraft...
* server - The Minecraft Server object. * server - The Minecraft Server object.
* self - the current player. (Note - this value should not be used in multi-threaded scripts - it's not thread-safe) * self - the current player. (Note - this value should not be used in multi-threaded scripts - it's not thread-safe)
refresh() function
------------------
The refresh() function will ...
1. Disable the ScriptCraft plugin.
2. Unload all event listeners associated with the ScriptCraft plugin.
3. Enable the ScriptCraft plugin.
... refresh() can be used during development to reload only scriptcraft javascript files.
See [issue #69][issue69] for more information.
[issue69]: https://github.com/walterhiggins/ScriptCraft/issues/69
Drone.spiral_stairs() method Drone.spiral_stairs() method
============================ ============================
Constructs a spiral staircase with slabs at each corner. Constructs a spiral staircase with slabs at each corner.

View file

@ -89,8 +89,6 @@ public class ScriptCraftPlugin extends JavaPlugin implements Listener
public void onEnable() public void onEnable()
{ {
unzipJS(); unzipJS();
if (this.engine == null){
FileReader reader = null; FileReader reader = null;
try{ try{
ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngineManager factory = new ScriptEngineManager();
@ -113,7 +111,6 @@ public class ScriptCraftPlugin extends JavaPlugin implements Listener
} }
} }
} }
}
public List<String> onTabComplete(CommandSender sender, Command cmd, public List<String> onTabComplete(CommandSender sender, Command cmd,
String alias, String alias,
String[] args) String[] args)

View file

@ -645,12 +645,33 @@ var server = org.bukkit.Bukkit.server;
var unloadHandlers = []; var unloadHandlers = [];
var _addUnloadHandler = function(f) { var _addUnloadHandler = function(f) {
unloadHandlers.push(f); unloadHandlers.push(f);
} };
var _runUnloadHandlers = function() { var _runUnloadHandlers = function() {
for (var i = 0; i < unloadHandlers.length; i++) { for (var i = 0; i < unloadHandlers.length; i++) {
unloadHandlers[i](); unloadHandlers[i]();
} }
} };
/*************************************************************************
refresh() function
------------------
The refresh() function will ...
1. Disable the ScriptCraft plugin.
2. Unload all event listeners associated with the ScriptCraft plugin.
3. Enable the ScriptCraft plugin.
... refresh() can be used during development to reload only scriptcraft javascript files.
See [issue #69][issue69] for more information.
[issue69]: https://github.com/walterhiggins/ScriptCraft/issues/69
***/
global.refresh = function(){
__plugin.pluginLoader.disablePlugin(__plugin);
forg.bukkit.event.HandlerList["unregisterAll(org.bukkit.plugin.Plugin)"](__plugin);
__plugin.pluginLoader.enablePlugin(__plugin);
};
global.load = _load; global.load = _load;
global.save = _save; global.save = _save;
@ -685,6 +706,7 @@ var server = org.bukkit.Bukkit.server;
_runUnloadHandlers(); _runUnloadHandlers();
}); });
}()); }());