- Refactored code into different packages

- Fixed some non-static expansion methods
- Fixed scripts not reloading properly
- Implemented mod support build system
- Fixed recipe removal breaking on recipes without predefined output
- Fixed NPE on parsing a bracket expression that doesn't exist - now prints an appropriate error
This commit is contained in:
Stan Hebben committed 2014-06-21 18:51:11 +02:00
1 parent 1789aa74b5
commit 2de467d7d8
93 files changed
+321 -262

No files matched your search

@@ -0,0 +1,32 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.util;
import java.util.Arrays;
import minetweaker.api.item.IItemCondition;
import minetweaker.api.item.IItemTransformer;
/**
*
* @author Stan
*/
public class ArrayUtil {
public static final IItemCondition[] EMPTY_CONDITIONS = new IItemCondition[0];
public static final IItemTransformer[] EMPTY_TRANSFORMERS = new IItemTransformer[0];
public static IItemCondition[] append(IItemCondition[] values, IItemCondition value) {
IItemCondition[] result = Arrays.copyOf(values, values.length + 1);
result[values.length] = value;
return result;
}
public static IItemTransformer[] append(IItemTransformer[] values, IItemTransformer value) {
IItemTransformer[] result = Arrays.copyOf(values, values.length + 1);
result[values.length] = value;
return result;
}
}
@@ -0,0 +1,81 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.util;
import java.io.Closeable;
import java.io.IOException;
import java.util.Iterator;
/**
*
* @author Stan
*/
public class CloseablePriorityList<T> implements Iterable<T> {
private CloseableEntry first;
/**
* Adds a new item to the list. The new item will be inserted at the head of
* the list.
*
* @param value
* @return
*/
public Closeable add(T value) {
if (first == null) {
first = new CloseableEntry(value);
} else {
CloseableEntry entry = new CloseableEntry(value);
entry.next = first;
first.prev = entry;
first = entry;
}
return first;
}
@Override
public Iterator<T> iterator() {
return new MyIterator();
}
private class MyIterator implements Iterator<T> {
private CloseableEntry current = null;
@Override
public boolean hasNext() {
return current == null || current.next != null;
}
@Override
public T next() {
current = current == null ? first : current.next;
return current.value;
}
}
private class CloseableEntry implements Closeable {
private final T value;
private CloseableEntry next;
private CloseableEntry prev;
public CloseableEntry(T value) {
this.value = value;
}
@Override
public void close() throws IOException {
if (next != null) {
next.prev = prev;
}
if (prev == null) {
first = next;
} else {
prev.next = next;
}
}
}
}
@@ -0,0 +1,27 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
*
* @author Stan
*/
public class FileUtil {
public static final byte[] read(InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[65536];
while (input.available() > 0) {
int bytesRead = input.read(buffer);
output.write(buffer, 0, bytesRead);
}
return output.toByteArray();
}
}