From 2eebbeacc191ad91775a41335a6dc0ea47da97ac Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Tue, 25 Feb 2020 18:13:16 +0800 Subject: [PATCH] 3.1.4.6 Former-commit-id: 5ab82e871cea20baaad65e7e0270cc2b7ebeffb2 --- pom.xml | 2 +- .../org/maxgamer/quickshop/Util/MsgUtil.java | 70 +++++++++++-------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/pom.xml b/pom.xml index 9d0e09573..a7b971cbc 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.maxgamer QuickShop - 3.1.4.5 + 3.1.4.6 diff --git a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java index e34c7dc2f..802338c91 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java +++ b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java @@ -201,33 +201,35 @@ public class MsgUtil { */ public static String getMessage( @NotNull String loc, @Nullable CommandSender player, @NotNull String... args) { - Optional raw = messagei18n.getString(loc); - if (!raw.isPresent()) { - Util.debugLog( - "ERR: MsgUtil cannot find the the phrase at " - + loc - + ", printing the all readed datas: " - + messagei18n); + try { + Optional raw = messagei18n.getString(loc); + if (!raw.isPresent()) { + Util.debugLog("ERR: MsgUtil cannot find the the phrase at " + loc + ", printing the all readed datas: " + messagei18n); - return invaildMsg + ": " + loc; - } - String filled = fillArgs(raw.get(), args); - if (player instanceof OfflinePlayer) { - if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled()) { - try { - filled = PlaceholderAPI.setPlaceholders((OfflinePlayer) player, filled); - Util.debugLog("Processed message " + filled + " by PlaceHolderAPI."); - } catch (Exception ignored) { - if (((OfflinePlayer) player).getPlayer() != null) { - try { - filled = PlaceholderAPI.setPlaceholders(((OfflinePlayer) player).getPlayer(), filled); - } catch (Exception ignore) { + return invaildMsg + ": " + loc; + } + String filled = fillArgs(raw.get(), args); + if (player instanceof OfflinePlayer) { + if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled()) { + try { + filled = PlaceholderAPI.setPlaceholders((OfflinePlayer) player, filled); + Util.debugLog("Processed message " + filled + " by PlaceHolderAPI."); + } catch (Exception ignored) { + if (((OfflinePlayer) player).getPlayer() != null) { + try { + filled = PlaceholderAPI.setPlaceholders(((OfflinePlayer) player).getPlayer(), filled); + } catch (Exception ignore) { + } } } } } + return filled; + } catch (Throwable th) { + plugin.getSentryErrorReporter().ignoreThrow(); + th.printStackTrace(); + return "Cannot load language key: " + loc + " because something not right, check the console for details."; } - return filled; } /** @@ -240,18 +242,24 @@ public class MsgUtil { */ public static String getMessageOfflinePlayer( @NotNull String loc, @Nullable OfflinePlayer player, @NotNull String... args) { - Optional raw = messagei18n.getString(loc); - if (!raw.isPresent()) { - return invaildMsg + ": " + loc; - } - String filled = fillArgs(raw.get(), args); - if (player != null) { - if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled()) { - filled = PlaceholderAPI.setPlaceholders(player, filled); - Util.debugLog("Processed message " + filled + " by PlaceHolderAPI."); + try { + Optional raw = messagei18n.getString(loc); + if (!raw.isPresent()) { + return invaildMsg + ": " + loc; } + String filled = fillArgs(raw.get(), args); + if (player != null) { + if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled()) { + filled = PlaceholderAPI.setPlaceholders(player, filled); + Util.debugLog("Processed message " + filled + " by PlaceHolderAPI."); + } + } + return filled; + } catch (Throwable th) { + plugin.getSentryErrorReporter().ignoreThrow(); + th.printStackTrace(); + return "Cannot load language key: " + loc + " because something not right, check the console for details."; } - return filled; } /**