From d30f0d578dc8e59ea64fa722b15ff0b97a797e90 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Fri, 13 Dec 2019 17:07:42 +0100 Subject: [PATCH] Fixed issue when used a dev-build of papi --- Changelog.txt | 1 + src/main/java/com/gamingmesh/jobs/Jobs.java | 28 ++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 83ca9472..202ddb94 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,5 @@ # 4.15.0 +- Fixed issue when used a dev-build of papi # 4.15.0 (Dev) - Fixed issue when the quest description only showed one lines of list. diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 1197db70..2634cba5 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -206,19 +206,27 @@ public class Jobs extends JavaPlugin { return Placeholder; } - private boolean setupPlaceHolderAPI() { + @SuppressWarnings("deprecation") + private boolean setupPlaceHolderAPI() { if (!getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) return false; - if (Integer.parseInt(getServer().getPluginManager().getPlugin("PlaceholderAPI") - .getDescription().getVersion().replace(".", "")) >= Integer.parseInt("2100")) { - if (new NewPlaceholderAPIHook(this).register()) + try { + if (Integer.parseInt(getServer().getPluginManager().getPlugin("PlaceholderAPI") + .getDescription().getVersion().replace(".", "")) >= Integer.parseInt("2100")) { + if (new NewPlaceholderAPIHook(this).register()) + consoleMsg("&e[Jobs] PlaceholderAPI hooked."); + } else { + if (new PlaceholderAPIHook(this).hook()) + consoleMsg("&e[Jobs] PlaceholderAPI hooked. This is a deprecated version of PlaceholderAPI. Please update " + + "to the latest version."); + } + } catch (NumberFormatException e) { // when using a dev build + if (new NewPlaceholderAPIHook(this).register()) { consoleMsg("&e[Jobs] PlaceholderAPI hooked."); - } else { - if (new PlaceholderAPIHook(this).hook()) - consoleMsg("&e[Jobs] PlaceholderAPI hooked. This is a deprecated version of PlaceholderAPI. Please update " - + "to the latest version."); + } } + return true; } @@ -1427,7 +1435,9 @@ public class Jobs extends JavaPlugin { } public static void consoleMsg(String msg) { - Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg)); + if (msg != null) { + Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', msg)); + } } public static SelectionManager getSelectionManager() {