Skip to content

Commit 505a0a4

Browse files
authored
fix Double is null (#1192)
1 parent 716d7fd commit 505a0a4

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/main/java/fr/openmc/core/features/city/sub/notation/menu/NotationDialog.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ public static DialogBody lineCityNotation(City city, String weekStr) {
104104
Component base = Component.empty();
105105

106106
if (notation != null) {
107-
String activity = String.format("%.2f/" + NotationNote.NOTE_ACTIVITY.getMaxNote(), Math.round(notation.getNoteActivity() * 100.0) / 100.0);
108-
String eco = String.format("%.2f/" + NotationNote.NOTE_PIB.getMaxNote(), Math.round(notation.getNoteEconomy() * 100.0) / 100.0);
109-
String military = String.format("%.2f/" + NotationNote.NOTE_MILITARY.getMaxNote(), Math.round(notation.getNoteMilitary() * 100.0) / 100.0);
107+
double noteActivity = notation.getNoteActivity() != null ? notation.getNoteActivity() : 0;
108+
double noteEconomy = notation.getNoteEconomy() != null ? notation.getNoteEconomy() : 0;
109+
double noteMilitary = notation.getNoteMilitary() != null ? notation.getNoteMilitary() : 0;
110+
111+
String activity = String.format("%.2f/" + NotationNote.NOTE_ACTIVITY.getMaxNote(), Math.round(noteActivity * 100.0) / 100.0);
112+
String eco = String.format("%.2f/" + NotationNote.NOTE_PIB.getMaxNote(), Math.round(noteEconomy * 100.0) / 100.0);
113+
String military = String.format("%.2f/" + NotationNote.NOTE_MILITARY.getMaxNote(), Math.round(noteMilitary * 100.0) / 100.0);
110114
String arch = String.format("%.2f/" + NotationNote.NOTE_ARCHITECTURAL.getMaxNote(), Math.round(notation.getNoteArchitectural() * 100.0) / 100.0);
111115
String coh = String.format("%.2f/" + NotationNote.NOTE_COHERENCE.getMaxNote(), Math.round(notation.getNoteCoherence() * 100.0) / 100.0);
112116
String total = String.format("%.2f/%.0f", Math.round(notation.getTotalNote() * 100.0) / 100.0, NotationNote.getMaxTotalNote());
@@ -150,13 +154,18 @@ public static Component getHoverTotal(CityNotation notation) {
150154
return Component.text("Aucun total pour vous");
151155
}
152156

157+
158+
double noteActivity = notation.getNoteActivity() != null ? notation.getNoteActivity() : 0;
159+
double noteEconomy = notation.getNoteEconomy() != null ? notation.getNoteEconomy() : 0;
160+
double noteMilitary = notation.getNoteMilitary() != null ? notation.getNoteMilitary() : 0;
161+
153162
return Component.text("§6§lDétails")
154163
.appendNewline()
155-
.append(Component.text("§8Activité " + notation.getNoteActivity()))
164+
.append(Component.text("§8Activité " + noteActivity))
156165
.appendNewline()
157-
.append(Component.text("§8Économie " + notation.getNoteEconomy()))
166+
.append(Component.text("§8Économie " + noteEconomy))
158167
.appendNewline()
159-
.append(Component.text("§8Militaire " + notation.getNoteMilitary()))
168+
.append(Component.text("§8Militaire " + noteMilitary))
160169
.appendNewline()
161170
.append(Component.text("§8Architecture " + notation.getNoteArchitectural()))
162171
.appendNewline()

0 commit comments

Comments
 (0)