Less hacky support for atrocious json

This commit is contained in:
Anuken
2019-11-22 15:33:01 -05:00
parent 2c61fcdfa6
commit 6d6fac00d7
6 changed files with 14 additions and 27 deletions

View File

@@ -1084,7 +1084,7 @@ mech.alpha-mech.description = The standard control mech. Based on a Dagger unit,
mech.delta-mech.description = A fast, lightly-armored mech made for hit-and-run attacks. Does little damage against structures, but can kill large groups of enemy units very quickly with its arc lightning weapons.
mech.tau-mech.description = The support mech. Heals allied blocks by shooting at them. Can heal allies in a radius with its repair ability.
mech.omega-mech.description = A bulky and well-armored mech, made for front-line assaults. Its armor can block up to 90% of incoming damage.
mech.dart-ship.description = The standard control ship. Reasonably fast and light, but has little offensive capability and low mining speed.
mech.dart-ship.description = The standard control ship. Fast mining speed. Reasonably fast and light, but has little offensive capability.
mech.javelin-ship.description = A hit-and-run strike ship. While initially slow, it can accelerate to great speeds and fly by enemy outposts, dealing large amounts of damage with its lightning and missiles.
mech.trident-ship.description = A heavy bomber, built for construction and destroying enemy fortifications. Reasonably well armored.
mech.glaive-ship.description = A large, well-armored gunship. Equipped with an incendiary repeater. Highly maneuverable.

View File

@@ -365,22 +365,13 @@ public class ContentParser{
init();
}
JsonValue value;
try{
//try to read hjson, bail out if it doesn't work
value = parser.fromJson(null, Jval.read(json).toString(Jformat.plain));
}catch(Throwable t){
try{
value = parser.fromJson(null, json);
}catch(Throwable extra){
if(t instanceof RuntimeException){
throw t;
}else{
throw new RuntimeException(t);
}
}
//remove extra # characters to make it valid json... apparently some people have *unquoted* # characters in their json
if(file.extension().equals("json")){
json = json.replace("#", "\\#");
}
JsonValue value = parser.fromJson(null, Jval.read(json).toString(Jformat.plain));
if(!parsers.containsKey(type)){
throw new SerializationException("No parsers for content type '" + type + "'");
}

View File

@@ -493,16 +493,7 @@ public class Mods implements Loadable{
throw new IllegalArgumentException("No mod.json found.");
}
//try to read as hjson if possible
String readString = metaf.readString();
try{
readString = Jval.read(readString).toString(Jformat.plain);
}catch(Throwable e){
e.printStackTrace();
readString = metaf.readString();
}
ModMeta meta = json.fromJson(ModMeta.class, readString);
ModMeta meta = json.fromJson(ModMeta.class, Jval.read(metaf.readString()).toString(Jformat.plain));
String camelized = meta.name.replace(" ", "");
String mainClass = meta.main == null ? camelized.toLowerCase() + "." + camelized + "Mod" : meta.main;
String baseName = meta.name.toLowerCase().replace(" ", "-");

View File

@@ -345,7 +345,7 @@ public class HudFragment extends Fragment{
@Remote(targets = Loc.both, forward = true, called = Loc.both)
public static void setPlayerTeamEditor(Player player, Team team){
if(state.isEditor()){
if(state.isEditor() && player != null){
player.setTeam(team);
}
}

View File

@@ -0,0 +1,5 @@
- Added fallback mod loading for poorly formatted old mods
- Fixed infinite building range
- Fixed impact reactors being able to blow up core on servers
- Fixed liquid bridges passing backwards
- Updated various translations

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=92f150377ea71e7d132f88fc6e331dc49b21d5c5
archash=e678c42cdc539e794ad0a0079a45970181aa2fe3