From d2a6398b4dc2ac33807c873bb528d0cbeaacff50 Mon Sep 17 00:00:00 2001 From: tastybento Date: Wed, 7 Aug 2024 21:29:26 -0700 Subject: [PATCH 1/2] Add a try around the new API for glow and fallback to old way #2459 --- .../bentobox/bentobox/api/panels/PanelItem.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java index 24c76e1c9..aaa108f41 100644 --- a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java +++ b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java @@ -132,7 +132,19 @@ public class PanelItem { return; } if (meta != null) { - meta.setEnchantmentGlintOverride(glow); + try { + meta.setEnchantmentGlintOverride(glow); + } catch (Exception e) { + // Try the old way + if (meta != null) { + if (glow) { + meta.addEnchant(Enchantment.LURE, 0, glow); + } else { + meta.removeEnchant(Enchantment.LURE); + } + icon.setItemMeta(meta); + } + } icon.setItemMeta(meta); } From 21efeb813bc5eadbff9f81cb557be4d061c7256f Mon Sep 17 00:00:00 2001 From: tastybento Date: Wed, 7 Aug 2024 21:46:31 -0700 Subject: [PATCH 2/2] Make the catch specific to the potential error --- src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java index aaa108f41..9bfd67aa9 100644 --- a/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java +++ b/src/main/java/world/bentobox/bentobox/api/panels/PanelItem.java @@ -134,7 +134,7 @@ public class PanelItem { if (meta != null) { try { meta.setEnchantmentGlintOverride(glow); - } catch (Exception e) { + } catch (NoSuchMethodError e) { // Try the old way if (meta != null) { if (glow) {