diff --git a/MineTweaker3-API/src/main/java/minetweaker/MineTweakerImplementationAPI.java b/MineTweaker3-API/src/main/java/minetweaker/MineTweakerImplementationAPI.java index 8a67e3a6..f091d92e 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/MineTweakerImplementationAPI.java +++ b/MineTweaker3-API/src/main/java/minetweaker/MineTweakerImplementationAPI.java @@ -219,7 +219,7 @@ public void execute(String[] arguments, IPlayer player) IItemStack out = shapeless.getOutput(); MineTweakerAPI.logError("Could not dump recipe for " + out, ex); } else { - MineTweakerAPI.logError("Could not dump recipe", ex) + MineTweakerAPI.logError("Could not dump recipe", ex); } } } diff --git a/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandAnyArray.java b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandAnyArray.java index 14c2242c..abe89415 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandAnyArray.java +++ b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandAnyArray.java @@ -1,10 +1,9 @@ package minetweaker.expand; +import minetweaker.api.data.*; +import stanhebben.zenscript.annotations.*; + import java.util.Arrays; -import minetweaker.api.data.DataList; -import minetweaker.api.data.IData; -import stanhebben.zenscript.annotations.ZenCaster; -import stanhebben.zenscript.annotations.ZenExpansion; /** * Makes arrays convertable to IData. diff --git a/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandByteArray.java b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandByteArray.java new file mode 100644 index 00000000..293c0527 --- /dev/null +++ b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandByteArray.java @@ -0,0 +1,18 @@ +package minetweaker.expand; + +import minetweaker.api.data.*; +import stanhebben.zenscript.annotations.*; + +/** + * Makes byte arrays convertable to IData. + * + * @author Jared + */ +@ZenExpansion("byte[]") +public class ExpandByteArray { + + @ZenCaster + public static IData asData(byte[] values) { + return new DataByteArray(values, true); + } +} \ No newline at end of file diff --git a/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandIntArray.java b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandIntArray.java new file mode 100644 index 00000000..ae331275 --- /dev/null +++ b/MineTweaker3-API/src/main/java/minetweaker/expand/ExpandIntArray.java @@ -0,0 +1,19 @@ + +package minetweaker.expand; + +import minetweaker.api.data.*; +import stanhebben.zenscript.annotations.*; + +/** + * Makes int arrays convertable to IData. + * + * @author Jared + */ +@ZenExpansion("int[]") +public class ExpandIntArray { + + @ZenCaster + public static IData asData(int[] values) { + return new DataIntArray(values, true); + } +} \ No newline at end of file diff --git a/MineTweaker3-API/src/main/java/minetweaker/runtime/providers/ScriptProviderDirectory.java b/MineTweaker3-API/src/main/java/minetweaker/runtime/providers/ScriptProviderDirectory.java index be1c5c5b..d3c69251 100644 --- a/MineTweaker3-API/src/main/java/minetweaker/runtime/providers/ScriptProviderDirectory.java +++ b/MineTweaker3-API/src/main/java/minetweaker/runtime/providers/ScriptProviderDirectory.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import minetweaker.MineTweakerAPI; @@ -20,6 +21,7 @@ * @author Stan */ public class ScriptProviderDirectory implements IScriptProvider { + public final static String SORTING_FLAG = ".sorting"; private final File directory; public ScriptProviderDirectory(File directory) { @@ -29,11 +31,40 @@ public ScriptProviderDirectory(File directory) { this.directory = directory; } + protected File[] getFiles() + { + if( directory.exists() ) + { + //Build path to flag file + StringBuilder sortFlag = new StringBuilder(); + sortFlag.append(directory.getAbsolutePath()); + sortFlag.append("/"); + sortFlag.append(SORTING_FLAG); + + File file = new File( sortFlag.toString() ); + File files[] = directory.listFiles(); + + //Sorting flag file exists + if( file.exists() ) + { + Arrays.sort(files); + } + return files; + } + else + { + return null; + } + } + @Override public Iterator getScripts() { List scripts = new ArrayList(); - if (directory.exists()) { - for (File file : directory.listFiles()) { + File files[] = this.getFiles(); + + if( files != null ) + { + for (File file : files) { if (file.isDirectory()) { scripts.add(new ScriptIteratorDirectory(file)); } else if (file.getName().endsWith(".zs")) { @@ -46,7 +77,7 @@ public Iterator getScripts() { } } } - } + } return scripts.iterator(); } }