mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 00:30:07 +01:00
Move API checks into their own class
This commit is contained in:
parent
b5eb942682
commit
86b98368bc
@ -119,7 +119,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
||||||
|
|
||||||
//Check for the newer API and tell them what to do if its missing
|
//Check for the newer API and tell them what to do if its missing
|
||||||
checkForOutdatedAPI();
|
CompatibilityCheck.checkForOutdatedAPI(serverAPIOutdated, getServerSoftwareStr());
|
||||||
|
|
||||||
if (serverAPIOutdated) {
|
if (serverAPIOutdated) {
|
||||||
Bukkit
|
Bukkit
|
||||||
@ -247,21 +247,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return playerLevelUtils;
|
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
|
* Returns a ServerSoftwareType based on version strings
|
||||||
* Custom software is returned as CRAFTBUKKIT
|
* Custom software is returned as CRAFTBUKKIT
|
||||||
|
21
src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java
Normal file
21
src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java
Normal file
@ -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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user