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

View file

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

View file

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