|
9 | 9 |
|
10 | 10 | import com.google.gson.JsonArray; |
11 | 11 | import com.google.gson.JsonObject; |
| 12 | +import com.google.gson.JsonPrimitive; |
12 | 13 | import java.text.DecimalFormat; |
13 | 14 | import java.util.*; |
14 | 15 | import java.util.function.Predicate; |
@@ -918,30 +919,50 @@ private static String parseLayoutName(CrystalLayout layout) |
918 | 919 | if (layout instanceof ArchitectCrystalLayout) |
919 | 920 | { |
920 | 921 | StringBuilder builder = new StringBuilder(); |
921 | | - builder.append("Architect").append("\n"); |
| 922 | + builder.append("Architect"); |
922 | 923 |
|
923 | 924 | Optional<JsonObject> jsonObject = layout.writeJson(); |
924 | 925 |
|
925 | | - jsonObject.ifPresent(json -> { |
926 | | - JsonArray entries = json.getAsJsonArray("entries"); |
927 | | - |
928 | | - entries.forEach(entry -> { |
929 | | - ArchitectRoomEntry architectRoomEntry = ArchitectRoomEntry.fromJson((JsonObject) entry); |
930 | | - Component roomName = architectRoomEntry.getName(); |
| 926 | + jsonObject.ifPresent(json -> |
| 927 | + { |
| 928 | + if (json.has("completion")) |
| 929 | + { |
| 930 | + JsonPrimitive completionObject = json.getAsJsonPrimitive("completion"); |
931 | 931 |
|
932 | | - if (roomName != null) |
| 932 | + if (completionObject.isNumber()) |
933 | 933 | { |
934 | | - int count = architectRoomEntry.get(ArchitectRoomEntry.COUNT); |
935 | | - |
936 | | - builder.append("-Has "). |
937 | | - append(String.valueOf(count)). |
938 | | - append(" *"). |
939 | | - append(roomName.getString()). |
940 | | - append("* "). |
941 | | - append(count > 1 ? "Rooms" : "Room"). |
942 | | - append("\n"); |
| 934 | + float completion = json.getAsJsonPrimitive("completion").getAsFloat(); |
| 935 | + builder.append(" | "). |
| 936 | + append(Math.min(100.0F, Math.round(completion * 100.0F))). |
| 937 | + append("%"); |
943 | 938 | } |
944 | | - }); |
| 939 | + } |
| 940 | + |
| 941 | + builder.append("\n"); |
| 942 | + |
| 943 | + if (json.has("entries") && json.get("entries").isJsonArray()) |
| 944 | + { |
| 945 | + JsonArray entries = json.getAsJsonArray("entries"); |
| 946 | + |
| 947 | + entries.forEach(entry -> |
| 948 | + { |
| 949 | + ArchitectRoomEntry architectRoomEntry = ArchitectRoomEntry.fromJson((JsonObject) entry); |
| 950 | + Component roomName = architectRoomEntry.getName(); |
| 951 | + |
| 952 | + if (roomName != null) |
| 953 | + { |
| 954 | + int count = architectRoomEntry.get(ArchitectRoomEntry.COUNT); |
| 955 | + |
| 956 | + builder.append("-Has "). |
| 957 | + append(count). |
| 958 | + append(" *"). |
| 959 | + append(roomName.getString()). |
| 960 | + append("* "). |
| 961 | + append(count > 1 ? "Rooms" : "Room"). |
| 962 | + append("\n"); |
| 963 | + } |
| 964 | + }); |
| 965 | + } |
945 | 966 | }); |
946 | 967 |
|
947 | 968 | return builder.toString(); |
|
0 commit comments