From 9ec53145a02246332431dfc570cd2fbf4ac7fcf0 Mon Sep 17 00:00:00 2001 From: TheJeterLP Date: Sat, 31 Dec 2022 00:16:36 +0100 Subject: [PATCH] [FIX] Fix ClassNotFoundException when using a different server software than Spigot --- pom.xml | 2 +- src/main/java/de/jeter/chatex/PlayerListener.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index d2355e5..dcc585a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ChatEx 2022 - 2.9.6 + 2.9.7 ChatManagement plugin for Bukkit https://www.spigotmc.org/resources/chatex-continued.71041/ diff --git a/src/main/java/de/jeter/chatex/PlayerListener.java b/src/main/java/de/jeter/chatex/PlayerListener.java index 57378a0..132687d 100644 --- a/src/main/java/de/jeter/chatex/PlayerListener.java +++ b/src/main/java/de/jeter/chatex/PlayerListener.java @@ -24,7 +24,6 @@ import de.jeter.updatechecker.Result; import de.jeter.updatechecker.UpdateChecker; import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.hover.content.Text; @@ -54,10 +53,15 @@ public void onJoin(PlayerJoinEvent e) { if (Config.CHECK_UPDATE.getBoolean() && e.getPlayer().hasPermission("chatex.notifyupdate") && checker != null) { if (checker.getResult() == Result.UPDATE_FOUND) { - TextComponent msg = new TextComponent(Locales.UPDATE_FOUND.getString(null).replaceAll("%oldversion", ChatEx.getInstance().getDescription().getVersion()).replaceAll("%newversion", ChatEx.getInstance().getUpdateChecker().getLatestRemoteVersion())); - msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§aClick to download"))); - msg.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, checker.getDownloadLink())); - e.getPlayer().spigot().sendMessage(msg); + try { + Class.forName("net.md_5.bungee.api.chat.TextComponent"); + TextComponent msg = new TextComponent(Locales.UPDATE_FOUND.getString(null).replaceAll("%oldversion", ChatEx.getInstance().getDescription().getVersion()).replaceAll("%newversion", ChatEx.getInstance().getUpdateChecker().getLatestRemoteVersion())); + msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§aClick to download"))); + msg.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, checker.getDownloadLink())); + e.getPlayer().spigot().sendMessage(msg); + } catch (ClassNotFoundException ex) { + e.getPlayer().sendMessage(Locales.UPDATE_FOUND.getString(null).replaceAll("%oldversion", ChatEx.getInstance().getDescription().getVersion()).replaceAll("%newversion", ChatEx.getInstance().getUpdateChecker().getLatestRemoteVersion())); + } } } }