adding check for Plugin
This commit is contained in:
parent
d4df3c0845
commit
714a3ca0fb
1 changed files with 11 additions and 4 deletions
|
@ -25,7 +25,10 @@ public final class SRCore {
|
|||
* @return The instance of the SRCore
|
||||
*/
|
||||
public static @NotNull SRCore getInstance() {
|
||||
return instance == null ? new SRCore() : instance;
|
||||
if (instance == null) {
|
||||
instance = new SRCore();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +42,7 @@ public final class SRCore {
|
|||
|
||||
if (plugin == null)
|
||||
throw new IllegalStateException(
|
||||
"Plugin is not set. Set it using SRCore.setPlugin(Plugin plugin)");
|
||||
"Plugin is not set. Set it using SRCore.getInstance().setPlugin(Plugin plugin)");
|
||||
}
|
||||
|
||||
return plugin;
|
||||
|
@ -53,7 +56,10 @@ public final class SRCore {
|
|||
public void setPlugin(@Nullable Plugin plugin) {
|
||||
if (this.plugin != null) throw new IllegalStateException("Plugin is already set");
|
||||
|
||||
if (plugin == null) return;
|
||||
if (plugin == null) {
|
||||
error("Plugin passed was null");
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -65,7 +71,8 @@ public final class SRCore {
|
|||
if (PLUGIN_CLASS_LOADER_CLASS.isInstance(loader)) {
|
||||
return ReflectionUtils.getFieldValue(PLUGIN_CLASS_LOADER_PLUGIN_FIELD, loader);
|
||||
} else if (PAPER_PLUGIN_CLASS_LOADER_CLASS != null
|
||||
&& PAPER_PLUGIN_CLASS_LOADER_CLASS.isInstance(loader)) {
|
||||
&& PAPER_PLUGIN_CLASS_LOADER_CLASS.isInstance(loader)
|
||||
&& PAPER_PLUGIN_CLASS_LOADER_GET_LOADED_JAVA_PLUGIN_METHOD != null) {
|
||||
return ReflectionUtils.invokeMethod(
|
||||
PAPER_PLUGIN_CLASS_LOADER_GET_LOADED_JAVA_PLUGIN_METHOD, loader);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue