From c6821260395b68fe0eb82574a89551463e113e7c Mon Sep 17 00:00:00 2001 From: litwak913 Date: Tue, 1 Oct 2024 09:09:20 +0800 Subject: [PATCH] refactor: background color check --- core/src/cn/harryh/arkpets/ArkConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/cn/harryh/arkpets/ArkConfig.java b/core/src/cn/harryh/arkpets/ArkConfig.java index 38ccc975..28bbbe2a 100644 --- a/core/src/cn/harryh/arkpets/ArkConfig.java +++ b/core/src/cn/harryh/arkpets/ArkConfig.java @@ -119,9 +119,9 @@ public boolean isNewcomer() { @JSONField(serialize = false) public Color getBackgroundColor() { Color backgroundColor; - try { + if (background_color.matches("^#[0-9a-fA-F]{8}$")) { backgroundColor = Color.valueOf(background_color); - } catch (NumberFormatException | StringIndexOutOfBoundsException e) { + } else { Logger.warn("System", "Invalid background color,using transparent"); backgroundColor = Color.CLEAR; }