mirror of
https://github.com/JamesPeters98/ChestsPlusPlus.git
synced 2024-11-14 22:56:27 +01:00
Fix API NPE
NMSProvider was giving a NPE
This commit is contained in:
parent
9ad0e41c6b
commit
5bc7fbcd37
@ -10,16 +10,17 @@ public class Api {
|
||||
private static Plugin plugin;
|
||||
private static NMSProvider nmsProvider;
|
||||
|
||||
public static void register(Plugin plugin) {
|
||||
public static void init(Plugin plugin) {
|
||||
Api.plugin = plugin;
|
||||
Values.init(plugin);
|
||||
nmsProvider = setupNMSProvider();
|
||||
}
|
||||
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static NMSProvider setupNMSProvider() {
|
||||
private static NMSProvider setupNMSProvider() {
|
||||
String packageName = NMSProvider.class.getPackage().getName();
|
||||
String nmsVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
String nmsProvider = packageName + "." + nmsVersion + ".NMSProviderImpl";
|
||||
@ -33,7 +34,7 @@ public class Api {
|
||||
}
|
||||
}
|
||||
|
||||
protected static NMSProvider getNmsProvider() {
|
||||
public static NMSProvider getNmsProvider() {
|
||||
return nmsProvider;
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +94,7 @@ public class ChestsPlusPlus extends JavaPlugin {
|
||||
Stats.addCharts(metrics);
|
||||
|
||||
//API initialisation
|
||||
Api.register(this);
|
||||
ApiSpecific.init();
|
||||
ApiSpecific.init(this);
|
||||
|
||||
//Register commands
|
||||
new ChestLinkCommand().register(this);
|
||||
|
@ -5,6 +5,7 @@ import com.jamesdpeters.minecraft.chests.ChestOpener;
|
||||
import com.jamesdpeters.minecraft.chests.MaterialChecker;
|
||||
import com.jamesdpeters.minecraft.chests.NMSProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class ApiSpecific {
|
||||
@ -13,8 +14,9 @@ public class ApiSpecific {
|
||||
private static ChestOpener chestOpener;
|
||||
private static NMSProvider nmsProvider;
|
||||
|
||||
public static void init() {
|
||||
nmsProvider = Api.setupNMSProvider();
|
||||
public static void init(Plugin plugin) {
|
||||
Api.init(plugin);
|
||||
nmsProvider = Api.getNmsProvider();
|
||||
if (nmsProvider == null) nmsProvider = new NMSProviderDefault();
|
||||
materialChecker = nmsProvider.getMaterialChecker();
|
||||
chestOpener = nmsProvider.getChestOpener();
|
||||
|
Loading…
Reference in New Issue
Block a user