Better error messages
This commit is contained in:
@@ -128,11 +128,11 @@ public class ContentParser{
|
|||||||
block = Vars.content.getByName(ContentType.block, name);
|
block = Vars.content.getByName(ContentType.block, name);
|
||||||
|
|
||||||
if(value.has("type")){
|
if(value.has("type")){
|
||||||
throw new IllegalArgumentException("When overwriting an existing block, you must not re-declared its type. The original type will be used. Block: " + name);
|
throw new IllegalArgumentException("When overwriting an existing block, you must not re-declare its type. The original type will be used. Block: " + name);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//TODO generate dynamically instead of doing.. this
|
//TODO generate dynamically instead of doing.. this
|
||||||
Class<? extends Block> type = resolve(value.getString("type"),
|
Class<? extends Block> type = resolve(getType(value),
|
||||||
"io.anuke.mindustry.world",
|
"io.anuke.mindustry.world",
|
||||||
"io.anuke.mindustry.world.blocks",
|
"io.anuke.mindustry.world.blocks",
|
||||||
"io.anuke.mindustry.world.blocks.defense",
|
"io.anuke.mindustry.world.blocks.defense",
|
||||||
@@ -209,7 +209,7 @@ public class ContentParser{
|
|||||||
ContentType.unit, (TypeParser<UnitType>)(mod, name, value) -> {
|
ContentType.unit, (TypeParser<UnitType>)(mod, name, value) -> {
|
||||||
readBundle(ContentType.unit, name, value);
|
readBundle(ContentType.unit, name, value);
|
||||||
|
|
||||||
Class<BaseUnit> type = resolve(value.getString("type"), "io.anuke.mindustry.entities.type.base");
|
Class<BaseUnit> type = resolve(getType(value), "io.anuke.mindustry.entities.type.base");
|
||||||
UnitType unit = new UnitType(mod + "-" + name, supply(type));
|
UnitType unit = new UnitType(mod + "-" + name, supply(type));
|
||||||
currentContent = unit;
|
currentContent = unit;
|
||||||
read(() -> readFields(unit, value, true));
|
read(() -> readFields(unit, value, true));
|
||||||
@@ -222,6 +222,18 @@ public class ContentParser{
|
|||||||
ContentType.zone, parser(ContentType.zone, Zone::new)
|
ContentType.zone, parser(ContentType.zone, Zone::new)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private String getString(JsonValue value, String key){
|
||||||
|
if(value.has(key)){
|
||||||
|
return value.getString(key);
|
||||||
|
}else{
|
||||||
|
throw new IllegalArgumentException((currentContent == null ? "" : currentContent.sourceFile + ": ") + "You are missing a \"" + key + "\". It must be added before the file can be parsed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getType(JsonValue value){
|
||||||
|
return getString(value, "type");
|
||||||
|
}
|
||||||
|
|
||||||
private <T extends Content> T find(ContentType type, String name){
|
private <T extends Content> T find(ContentType type, String name){
|
||||||
Content c = Vars.content.getByName(type, name);
|
Content c = Vars.content.getByName(type, name);
|
||||||
if(c == null) c = Vars.content.getByName(type, currentMod.name + "-" + name);
|
if(c == null) c = Vars.content.getByName(type, currentMod.name + "-" + name);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=411d2784f538dfc10db2962a62833938029dafdd
|
archash=6ca636f2f51352022b2c770deafc3b549eb0421c
|
||||||
|
|||||||
Reference in New Issue
Block a user