From 86b98368bc3ff396fd5b203471455404f5ca0095 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 May 2019 01:58:27 -0700 Subject: [PATCH] Move API checks into their own class --- src/main/java/com/gmail/nossr50/mcMMO.java | 17 +-------------- .../nossr50/util/CompatibilityCheck.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 064f59ccd..e7d55600b 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -119,7 +119,7 @@ public class mcMMO extends JavaPlugin { databaseManager = DatabaseManagerFactory.getDatabaseManager(); //Check for the newer API and tell them what to do if its missing - checkForOutdatedAPI(); + CompatibilityCheck.checkForOutdatedAPI(serverAPIOutdated, getServerSoftwareStr()); if (serverAPIOutdated) { Bukkit @@ -247,21 +247,6 @@ public class mcMMO extends JavaPlugin { return playerLevelUtils; } - /** - * Uses reflection to check for incompatible server software - */ - private void checkForOutdatedAPI() { - try { - Class checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent"); - Method newerAPIMethod = checkForClass.getMethod("getItems"); - Class checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent"); - } catch (ClassNotFoundException | NoSuchMethodException e) { - serverAPIOutdated = true; - String software = getServerSoftwareStr(); - getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!"); - } - } - /** * Returns a ServerSoftwareType based on version strings * Custom software is returned as CRAFTBUKKIT diff --git a/src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java b/src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java new file mode 100644 index 000000000..fd06c2728 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java @@ -0,0 +1,21 @@ +package com.gmail.nossr50.util; + +import com.gmail.nossr50.mcMMO; + +import java.lang.reflect.Method; + +public class CompatibilityCheck { + /** + * Uses reflection to check for incompatible server software + */ + public static void checkForOutdatedAPI(boolean serverAPIOutdated, String software) { + try { + Class checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent"); + Method newerAPIMethod = checkForClass.getMethod("getItems"); + Class checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent"); + } catch (ClassNotFoundException | NoSuchMethodException e) { + serverAPIOutdated = true; + mcMMO.p.getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!"); + } + } +}