diff --git a/core/src/io/anuke/mindustry/game/Objectives.java b/core/src/io/anuke/mindustry/game/Objectives.java index c901fe4f68..340346bc13 100644 --- a/core/src/io/anuke/mindustry/game/Objectives.java +++ b/core/src/io/anuke/mindustry/game/Objectives.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.game; import io.anuke.arc.*; import io.anuke.arc.util.ArcAnnotate.*; import io.anuke.mindustry.type.*; +import io.anuke.mindustry.world.*; /** Holds objective classes. */ public class Objectives{ @@ -30,22 +31,22 @@ public class Objectives{ } public static class Unlock implements Objective{ - public @NonNull UnlockableContent content; + public @NonNull Block block; - public Unlock(UnlockableContent content){ - this.content = content; + public Unlock(Block block){ + this.block = block; } protected Unlock(){} @Override public boolean complete(){ - return content.unlocked(); + return block.unlocked(); } @Override public String display(){ - return Core.bundle.format("requirement.unlock", content.localizedName); + return Core.bundle.format("requirement.unlock", block.localizedName); } } diff --git a/core/src/io/anuke/mindustry/mod/ContentParser.java b/core/src/io/anuke/mindustry/mod/ContentParser.java index 06c06f96e5..d83ce429ac 100644 --- a/core/src/io/anuke/mindustry/mod/ContentParser.java +++ b/core/src/io/anuke/mindustry/mod/ContentParser.java @@ -40,7 +40,7 @@ public class ContentParser{ put(BulletType.class, (type, data) -> { Class bc = data.has("type") ? resolve(data.getString("type"), "io.anuke.mindustry.entities.bullets") : BasicBulletType.class; data.remove("type"); - BulletType result = bc.getDeclaredConstructor().newInstance(); + BulletType result = make(bc); readFields(result, data); return result; }); @@ -62,9 +62,9 @@ public class ContentParser{ return Core.assets.get(path); }); put(Objective.class, (type, data) -> { - Class oc = data.has("type") ? resolve(data.getString("type"), "io.anuke.mindustry.game.objectives") : ZoneWave.class; + Class oc = data.has("type") ? resolve(data.getString("type"), "io.anuke.mindustry.game.Objectives") : ZoneWave.class; data.remove("type"); - Objective obj = oc.getDeclaredConstructor().newInstance(); + Objective obj = make(oc); readFields(obj, data); return obj; }); @@ -123,6 +123,7 @@ public class ContentParser{ ); Block block = type.getDeclaredConstructor(String.class).newInstance(mod + "-" + name); + currentContent = block; read(() -> { if(value.has("consumes")){ for(JsonValue child : value.get("consumes")){ @@ -167,6 +168,7 @@ public class ContentParser{ Class type = resolve(value.getString("type"), "io.anuke.mindustry.entities.type.base"); UnitType unit = new UnitType(mod + "-" + name, supply(type)); + currentContent = unit; read(() -> readFields(unit, value, true)); return unit; @@ -187,6 +189,7 @@ public class ContentParser{ item = constructor.get(mod + "-" + name); } + currentContent = item; read(() -> readFields(item, value)); return item; }; @@ -233,7 +236,11 @@ public class ContentParser{ } public void finishParsing(){ - reads.each(Runnable::run); + try{ + reads.each(Runnable::run); + }catch(Exception e){ + throw new RuntimeException("Error occurred parsing content: " + currentContent, e); + } reads.clear(); } @@ -261,6 +268,16 @@ public class ContentParser{ return c; } + private T make(Class type){ + try{ + java.lang.reflect.Constructor cons = type.getDeclaredConstructor(); + cons.setAccessible(true); + return cons.newInstance(); + }catch(Exception e){ + throw new RuntimeException(e); + } + } + private Supplier supply(Class type){ try{ java.lang.reflect.Constructor cons = type.getDeclaredConstructor(); @@ -374,9 +391,13 @@ public class ContentParser{ try{ return (Class)Class.forName(type + '.' + base); }catch(Exception ignored){ + try{ + return (Class)Class.forName(type + '$' + base); + }catch(Exception ignored2){ + } } } - throw new IllegalArgumentException("Type not found: " + potentials[0]); + throw new IllegalArgumentException("Types not found: " + base + "." + potentials[0]); } private interface FieldParser{ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java index cf65340627..7a7d716294 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ZoneInfoDialog.java @@ -84,9 +84,9 @@ public class ZoneInfoDialog extends FloatingDialog{ r.add("$research.list").colspan(2).left(); r.row(); for(Unlock blocko : blocks){ - r.addImage(blocko.content.icon(Cicon.small)).size(8 * 3).padRight(5); - r.add(blocko.content.localizedName).color(Color.lightGray).left(); - r.addImage(blocko.content.unlocked() ? Icon.checkSmall : Icon.cancelSmall, blocko.content.unlocked() ? Color.lightGray : Color.scarlet).padLeft(3); + r.addImage(blocko.block.icon(Cicon.small)).size(8 * 3).padRight(5); + r.add(blocko.block.localizedName).color(Color.lightGray).left(); + r.addImage(blocko.block.unlocked() ? Icon.checkSmall : Icon.cancelSmall, blocko.block.unlocked() ? Color.lightGray : Color.scarlet).padLeft(3); r.row(); } diff --git a/gradle.properties b/gradle.properties index 6ccbc668ef..dcfbb32c6f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=feb8c35e143c0a048488341ae916c7732ea7a84e +archash=59cff366c4d46577b659e153183eb824eaafd7f7