Less hacky support for atrocious json
This commit is contained in:
@@ -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 + "'");
|
||||
}
|
||||
|
||||
@@ -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(" ", "-");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user