aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/core/mod/parser
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
commit869c206c4fcc8001bd2e1d66f704290331813835 (patch)
tree96735ce8fe4665e2759c3374221d6f06f4527df2 /src/Java/binnie/core/mod/parser
parentec2c72827f01dd4bb2174137f1ab162f9ddaab62 (diff)
downloadGT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.gz
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.bz2
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.zip
Initial Commit
Diffstat (limited to 'src/Java/binnie/core/mod/parser')
-rw-r--r--src/Java/binnie/core/mod/parser/FieldParser.java55
-rw-r--r--src/Java/binnie/core/mod/parser/ItemParser.java24
2 files changed, 79 insertions, 0 deletions
diff --git a/src/Java/binnie/core/mod/parser/FieldParser.java b/src/Java/binnie/core/mod/parser/FieldParser.java
new file mode 100644
index 0000000000..c063d5aca9
--- /dev/null
+++ b/src/Java/binnie/core/mod/parser/FieldParser.java
@@ -0,0 +1,55 @@
+package binnie.core.mod.parser;
+
+import binnie.core.AbstractMod;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+
+public abstract class FieldParser
+{
+ public static Collection<FieldParser> parsers = new ArrayList();
+
+ public abstract boolean isHandled(Field paramField, AbstractMod paramAbstractMod);
+
+ public void preInit(Field field, AbstractMod mod)
+ throws IllegalArgumentException, IllegalAccessException
+ {}
+
+ public void init(Field field, AbstractMod mod)
+ throws IllegalArgumentException, IllegalAccessException
+ {}
+
+ public void postInit(Field field, AbstractMod mod)
+ throws IllegalArgumentException, IllegalAccessException
+ {}
+
+ public static void preInitParse(Field field, AbstractMod mod)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ for (FieldParser parser : parsers) {
+ if (parser.isHandled(field, mod)) {
+ parser.preInit(field, mod);
+ }
+ }
+ }
+
+ public static void initParse(Field field, AbstractMod mod)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ for (FieldParser parser : parsers) {
+ if (parser.isHandled(field, mod)) {
+ parser.init(field, mod);
+ }
+ }
+ }
+
+ public static void postInitParse(Field field, AbstractMod mod)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ for (FieldParser parser : parsers) {
+ if (parser.isHandled(field, mod)) {
+ parser.postInit(field, mod);
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/core/mod/parser/ItemParser.java b/src/Java/binnie/core/mod/parser/ItemParser.java
new file mode 100644
index 0000000000..8892a20aba
--- /dev/null
+++ b/src/Java/binnie/core/mod/parser/ItemParser.java
@@ -0,0 +1,24 @@
+package binnie.core.mod.parser;
+
+import binnie.core.AbstractMod;
+import cpw.mods.fml.common.registry.GameRegistry;
+import java.lang.reflect.Field;
+import net.minecraft.item.Item;
+
+public class ItemParser
+ extends FieldParser
+{
+ public boolean isHandled(Field field, AbstractMod mod)
+ {
+ return Item.class.isAssignableFrom(field.getType());
+ }
+
+ public void preInit(Field field, AbstractMod mod)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ Item item = (Item)field.get(null);
+ if (item != null) {
+ GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
+ }
+ }
+}