feat: load storage and disable if not sql
This commit is contained in:
parent
eda5b33370
commit
b09a09438e
2 changed files with 43 additions and 8 deletions
|
@ -14,6 +14,7 @@ public class Nicko {
|
||||||
private ConfigurationManager configManager;
|
private ConfigurationManager configManager;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
|
private boolean bungeecord;
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
|
|
||||||
private PlayerDataStore dataStore;
|
private PlayerDataStore dataStore;
|
||||||
|
@ -66,4 +67,12 @@ public class Nicko {
|
||||||
public void setConfig(Configuration config) {
|
public void setConfig(Configuration config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBungeecord() {
|
||||||
|
return bungeecord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBungeecord(boolean bungeecord) {
|
||||||
|
this.bungeecord = bungeecord;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package net.artelnatif.nicko.bungee;
|
package net.artelnatif.nicko.bungee;
|
||||||
|
|
||||||
|
import net.artelnatif.nicko.Nicko;
|
||||||
import net.artelnatif.nicko.bungee.event.UpdateMessageListener;
|
import net.artelnatif.nicko.bungee.event.UpdateMessageListener;
|
||||||
|
import net.artelnatif.nicko.storage.sql.SQLStorageProvider;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
||||||
public class NickoBungee extends Plugin {
|
public class NickoBungee extends Plugin {
|
||||||
|
@ -9,11 +11,32 @@ public class NickoBungee extends Plugin {
|
||||||
public static final String PROXY_FETCH = NICKO_PLUGIN_CHANNEL_BASE + "fetch";
|
public static final String PROXY_FETCH = NICKO_PLUGIN_CHANNEL_BASE + "fetch";
|
||||||
public static final String SERVER_DATA = NICKO_PLUGIN_CHANNEL_BASE + "data";
|
public static final String SERVER_DATA = NICKO_PLUGIN_CHANNEL_BASE + "data";
|
||||||
|
|
||||||
|
private final Nicko nicko = new Nicko();
|
||||||
|
|
||||||
private static NickoBungee plugin;
|
private static NickoBungee plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
nicko.initBungeecord(this);
|
||||||
|
|
||||||
|
getLogger().info("Loading persistence...");
|
||||||
|
if (!(nicko.getDataStore().getStorage().getProvider() instanceof SQLStorageProvider)) {
|
||||||
|
getLogger().severe("Nicko does not support local storage in combination with Bungeecord.");
|
||||||
|
getLogger().severe("The plugin will not continue.");
|
||||||
|
nicko.getDataStore().getStorage().setError(true);
|
||||||
|
nicko.setBungeecord(false);
|
||||||
|
onDisable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nicko.getDataStore().getStorage().isError()) {
|
||||||
|
if (!nicko.getDataStore().getStorage().getProvider().init()) {
|
||||||
|
getLogger().severe("Failed to open persistence!");
|
||||||
|
getLogger().severe("Player data transfer is disabled.");
|
||||||
|
nicko.setBungeecord(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
getLogger().info("Registering channel...");
|
getLogger().info("Registering channel...");
|
||||||
getProxy().registerChannel(SERVER_DATA);
|
getProxy().registerChannel(SERVER_DATA);
|
||||||
|
@ -23,14 +46,17 @@ public class NickoBungee extends Plugin {
|
||||||
|
|
||||||
getLogger().info("Nicko (Bungee) has been enabled.");
|
getLogger().info("Nicko (Bungee) has been enabled.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
if (!nicko.getDataStore().getStorage().isError()) {
|
||||||
getLogger().info("Unregistering channels...");
|
getLogger().info("Unregistering channels...");
|
||||||
getProxy().unregisterChannel(PROXY_UPDATE);
|
getProxy().unregisterChannel(PROXY_UPDATE);
|
||||||
|
|
||||||
getLogger().info("Nicko (Bungee) has been disabled.");
|
getLogger().info("Nicko (Bungee) has been disabled.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static NickoBungee getInstance() {
|
public static NickoBungee getInstance() {
|
||||||
return plugin;
|
return plugin;
|
||||||
|
|
Loading…
Reference in a new issue