@@ -13,34 +13,34 @@ object Hitboxes {
1313 private val file = File (Redaction .modDir, " hitboxes.json" )
1414
1515 fun initialize () {
16- if (! file.exists() || file.readText().isBlank()) {
17- file.createNewFile()
18- file.writeText(" { }" )
19- }
16+ try {
17+ if (! file.exists() || file.readText().isBlank()) {
18+ file.createNewFile()
19+ file.writeText(" { }" )
20+ }
2021
21- val readJson = PARSER .parse(file.readText()).asJsonObject
22- for (entity in Entity .map.values) {
23- val entityName = entity.name.lowercase(Locale .ENGLISH ).replace(" " , " _" )
24- if (! readJson.has(entityName)) {
25- readJson.add(entityName, PARSER .parse(GSON .toJson(entity)))
22+ val readJson = PARSER .parse(file.readText()).asJsonObject
23+ for (entity in Entity .map.values) {
24+ val entityName = entity.name.lowercase(Locale .ENGLISH ).replace(" " , " _" )
25+ if (! readJson.has(entityName)) {
26+ readJson.add(entityName, PARSER .parse(GSON .toJson(entity)))
27+ }
2628 }
27- }
28- if (! readJson.has(" general" )) {
29- readJson.add(" general" , PARSER .parse(GSON .toJson(GeneralConfig (hitboxWidth = 1 , forceHitbox = false , accurateHitbox = true ))))
30- }
31- if (readJson[" general" ].asJsonObject.has(" disable_for_self" )) {
32- readJson[" self" ].asJsonObject.addProperty(" hitbox_enabled" , false )
33- readJson[" self" ].asJsonObject.addProperty(" eyeline_enabled" , false )
34- readJson[" self" ].asJsonObject.addProperty(" line_enabled" , false )
35- readJson[" general" ].asJsonObject.remove(" disable_for_self" )
36- }
37- if (! readJson[" general" ].asJsonObject.has(" dashed_hitbox" )) {
38- readJson[" general" ].asJsonObject.addProperty(" dashed_hitbox" , false )
39- readJson[" general" ].asJsonObject.addProperty(" dashed_factor" , 6 )
40- }
41- file.writeText(GSON .toJson(readJson))
29+ if (! readJson.has(" general" )) {
30+ readJson.add(" general" , PARSER .parse(GSON .toJson(GeneralConfig (hitboxWidth = 1 , forceHitbox = false , accurateHitbox = true ))))
31+ }
32+ if (readJson[" general" ].asJsonObject.has(" disable_for_self" )) {
33+ readJson[" self" ].asJsonObject.addProperty(" hitbox_enabled" , false )
34+ readJson[" self" ].asJsonObject.addProperty(" eyeline_enabled" , false )
35+ readJson[" self" ].asJsonObject.addProperty(" line_enabled" , false )
36+ readJson[" general" ].asJsonObject.remove(" disable_for_self" )
37+ }
38+ if (! readJson[" general" ].asJsonObject.has(" dashed_hitbox" )) {
39+ readJson[" general" ].asJsonObject.addProperty(" dashed_hitbox" , false )
40+ readJson[" general" ].asJsonObject.addProperty(" dashed_factor" , 6 )
41+ }
42+ file.writeText(GSON .toJson(readJson))
4243
43- try {
4444 val json = PARSER .parse(file.readText()).asJsonObject
4545 for (entity in Entity .map) {
4646 val entityJson = json[entity.value.name.lowercase(Locale .ENGLISH ).replace(" " , " _" )].asJsonObject
0 commit comments