From c78813a405af6e4eede6fc6052d201249bff999c Mon Sep 17 00:00:00 2001 From: SenpaiDipper Date: Sun, 19 Dec 2021 15:05:48 +0000 Subject: [PATCH] Fixed Possible NPE's with System.getProperty --- src/main/java/com/eu/habbo/Emulator.java | 4 ++-- .../habbohotel/wired/highscores/WiredHighscoreManager.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java index 97fe313a..f10c5404 100644 --- a/src/main/java/com/eu/habbo/Emulator.java +++ b/src/main/java/com/eu/habbo/Emulator.java @@ -32,8 +32,8 @@ import java.util.regex.Pattern; public final class Emulator { private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class); - private static final String OS_NAME = System.getProperty("os.name"); - private static final String CLASS_PATH = System.getProperty("java.class.path"); + private static final String OS_NAME = (System.getProperty("os.name") != null ? System.getProperty("os.name") : "Unknown"); + private static final String CLASS_PATH = (System.getProperty("java.class.path") != null ? System.getProperty("java.class.path") : "Unknown"); public final static int MAJOR = 3; public final static int MINOR = 0; diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java index 31431699..e7cf9cef 100644 --- a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java @@ -22,8 +22,11 @@ public class WiredHighscoreManager { private static final Logger LOGGER = LoggerFactory.getLogger(WiredHighscoreManager.class); private final HashMap> data = new HashMap<>(); + + private final static String locale = (System.getProperty("user.language") != null ? System.getProperty("user.language") : "en"); + private final static String country = (System.getProperty("user.country") != null ? System.getProperty("user.country") : "US"); - private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(System.getProperty("user.language"), System.getProperty("user.country"))).getFirstDayOfWeek(); + private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(locale, country)).getFirstDayOfWeek(); private final static DayOfWeek lastDayOfWeek = DayOfWeek.of(((firstDayOfWeek.getValue() + 5) % DayOfWeek.values().length) + 1); private final static ZoneId zoneId = ZoneId.systemDefault();