Issue #26 - make plugin startup less verbose

This commit is contained in:
walterhiggins 2013-01-15 19:15:40 +00:00
parent 77de4a1134
commit 3b0395efb1
3 changed files with 27 additions and 16 deletions

View file

@ -5,6 +5,7 @@
<property name="src" location="${bukkit}/src"/> <property name="src" location="${bukkit}/src"/>
<property name="build" location="${bukkit}/build"/> <property name="build" location="${bukkit}/build"/>
<property name="dist" location="./" /> <property name="dist" location="./" />
<target name="init"> <target name="init">
<tstamp/> <tstamp/>
<mkdir dir="${build}"/> <mkdir dir="${build}"/>
@ -32,9 +33,11 @@
<delete dir="${build}"/> <delete dir="${build}"/>
</target> </target>
<target name="copy-js-cb-live"> <target name="update-live-cb" depends="bukkit-dist" description="Copy the built plugin to the live craftbukkit folder for testing.">
<copy todir="${craftbukkit}/js-plugins"> <delete dir="${craftbukkit}/js-plugins" />
<fileset dir="js-plugins"/> <delete>
</copy> <fileset dir="${craftbukkit}/plugins/" includes="scriptcraft.*"/>
</delete>
<copy file="${dist}/scriptcraft-${bukkit-version}-${DSTAMP}.jar" todir="${craftbukkit}/plugins"/>
</target> </target>
</project> </project>

View file

@ -36,8 +36,8 @@ public class ScriptCraftPlugin extends JavaPlugin
File jsPlugins = new File(JS_PLUGINS_DIR); File jsPlugins = new File(JS_PLUGINS_DIR);
if (!jsPlugins.exists()) if (!jsPlugins.exists())
{ {
getLogger().info("Directory " + JS_PLUGINS_DIR + " does not exist."); getLogger().finest("Directory " + JS_PLUGINS_DIR + " does not exist.");
getLogger().info("Initializing " + JS_PLUGINS_DIR + " directory with contents from plugin archive."); getLogger().finest("Initializing " + JS_PLUGINS_DIR + " directory with contents from plugin archive.");
jsPlugins.mkdir(); jsPlugins.mkdir();
@ -47,7 +47,7 @@ public class ScriptCraftPlugin extends JavaPlugin
while ( ( entry = zis.getNextEntry() ) != null) while ( ( entry = zis.getNextEntry() ) != null)
{ {
String filename = entry.getName(); String filename = entry.getName();
getLogger().info("Unzipping " + filename); getLogger().finest("Unzipping " + filename);
File newFile = new File(jsPlugins.getName() + File.separator + filename); File newFile = new File(jsPlugins.getName() + File.separator + filename);
//create all non exists folders //create all non exists folders

View file

@ -1,4 +1,5 @@
var global = this; var global = this;
var verbose = verbose || false;
var ScriptCraft = ScriptCraft || {}; var ScriptCraft = ScriptCraft || {};
ScriptCraft.core = ScriptCraft.core || {}; ScriptCraft.core = ScriptCraft.core || {};
// //
@ -18,31 +19,38 @@ ScriptCraft.core = ScriptCraft.core || {};
}; };
var _load = function(filename){ var _load = function(filename){
var file = new java.io.File(filename); var file = new java.io.File(filename);
print("loading " + _canonize(file));
var canonizedFilename = _canonize(file);
if (verbose)
print("loading " + canonizedFilename);
if (file.exists()){ if (file.exists()){
var parent = file.getParentFile(); var parent = file.getParentFile();
var reader = new java.io.FileReader(file); var reader = new java.io.FileReader(file);
__engine.put("__script",_canonize(file)); __engine.put("__script",canonizedFilename);
__engine.put("__folder",(parent?_canonize(parent):"")+"/"); __engine.put("__folder",(parent?_canonize(parent):"")+"/");
__engine.eval(reader); __engine.eval(reader);
}else{ }else{
print("Error: " + filename + " not found"); print("Error: " + canonizedFilename + " not found");
} }
}; };
var _listJsFiles = function(store,dir) var _listJsFiles = function(store,dir)
{ {
if (typeof dir == "undefined"){ if (typeof dir == "undefined"){
dir = new File(_originalScript).getParentFile().getParentFile(); dir = new java.io.File(_originalScript).getParentFile().getParentFile();
} }
var files = dir.listFiles(); var files = dir.listFiles();
for (var i = 0;i < files.length; i++){ for (var i = 0;i < files.length; i++){
if (files[i].isDirectory()){ var file = files[i];
_listJsFiles(store,files[i]); if (file.isDirectory()){
_listJsFiles(store,file);
}else{ }else{
if (files[i].getCanonicalPath().endsWith(".js") && if (file.getCanonicalPath().endsWith(".js") &&
!(files[i].getName().startsWith("_"))) !(file.getName().startsWith("_")) &&
file.exists())
{ {
store.push(files[i]); store.push(file);
} }
} }
} }