From 5ab25c8033ce7c0eea8d6bd7e122a7c373df4312 Mon Sep 17 00:00:00 2001 From: TheFaser Date: Mon, 13 Nov 2023 22:41:59 +0500 Subject: [PATCH] CommandFlectonechat: fix NumberFormatException and other exceptions --- .../module/commands/CommandFlectonechat.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java b/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java index e0c9e56..65b471d 100644 --- a/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java +++ b/src/main/java/net/flectone/chat/module/commands/CommandFlectonechat.java @@ -77,12 +77,16 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command } else object = string; } - if (StringUtils.isNumeric(args[3])) { - object = Integer.parseInt(args[3]); - } else if (NumberUtils.isNumber(args[3])) { - object = Double.parseDouble(args[3]); - } else if (args[3].equalsIgnoreCase("true") || args[3].equalsIgnoreCase("false")) { - object = Boolean.parseBoolean(args[3]); + try { + if (StringUtils.isNumeric(args[3])) { + object = Integer.parseInt(args[3]); + } else if (NumberUtils.isNumber(args[3])) { + object = Double.parseDouble(args[3]); + } else if (args[3].equalsIgnoreCase("true") || args[3].equalsIgnoreCase("false")) { + object = Boolean.parseBoolean(args[3]); + } + } catch (Exception e) { + object = args[3]; } FConfiguration file = fileType.get().getFile();