fix(init): try to properly disable the plugin
This commit is contained in:
parent
f31bcfc6d5
commit
93c7e6cb60
55 changed files with 41 additions and 150 deletions
|
@ -27,52 +27,55 @@ public class NickoBukkit extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
mojangAPI = new MojangAPI();
|
||||
nickoConfiguration = new NickoConfiguration(this);
|
||||
dataStore = new PlayerDataStore(this);
|
||||
|
||||
getLogger().info("Loading internals...");
|
||||
if (getInternals() == null) {
|
||||
getLogger().log(Level.SEVERE, "Nicko could not find a valid implementation for this server version. Is your server supported?");
|
||||
dataStore.getStorage().setError(true);
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
}
|
||||
|
||||
final PluginCommand command = getCommand("nicko");
|
||||
if (command != null) {
|
||||
command.setExecutor(new NickoCommand());
|
||||
command.setTabCompleter(new NickoTabCompleter());
|
||||
}
|
||||
|
||||
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerQuitListener(), this);
|
||||
|
||||
mojangAPI = new MojangAPI();
|
||||
nickoConfiguration = new NickoConfiguration(this);
|
||||
|
||||
getLogger().info("Loading configuration...");
|
||||
saveDefaultConfig();
|
||||
|
||||
getLogger().info("Loading persistence...");
|
||||
dataStore = new PlayerDataStore(this);
|
||||
if (!dataStore.getStorage().getProvider().init()) {
|
||||
dataStore.getStorage().setError(true);
|
||||
getLogger().warning("Failed to open persistence, data will NOT be saved!");
|
||||
}
|
||||
|
||||
if (nickoConfiguration.isBungeecordEnabled()) {
|
||||
getLogger().info("Enabling Bungeecord support...");
|
||||
if (ServerUtils.checkBungeeCordHook()) {
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE, new UpdateMessageHandler());
|
||||
if (getServer().getPluginManager().isPluginEnabled(this)) {
|
||||
final PluginCommand command = getCommand("nicko");
|
||||
if (command != null) {
|
||||
command.setExecutor(new NickoCommand());
|
||||
command.setTabCompleter(new NickoTabCompleter());
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().info("Nicko (Bukkit) has been enabled.");
|
||||
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerQuitListener(), this);
|
||||
|
||||
getLogger().info("Loading configuration...");
|
||||
saveDefaultConfig();
|
||||
|
||||
getLogger().info("Loading persistence...");
|
||||
|
||||
if (!dataStore.getStorage().getProvider().init()) {
|
||||
dataStore.getStorage().setError(true);
|
||||
getLogger().warning("Failed to open persistence, data will NOT be saved!");
|
||||
}
|
||||
|
||||
if (nickoConfiguration.isBungeecordEnabled()) {
|
||||
getLogger().info("Enabling Bungeecord support...");
|
||||
if (ServerUtils.checkBungeeCordHook()) {
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, NickoBungee.NICKO_PLUGIN_CHANNEL_UPDATE, new UpdateMessageHandler());
|
||||
}
|
||||
}
|
||||
|
||||
getLogger().info("Nicko (Bukkit) has been enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Closing persistence...");
|
||||
if (!dataStore.getStorage().getProvider().close()) {
|
||||
getLogger().warning("Failed to close persistence!");
|
||||
}
|
||||
if (dataStore.getStorage().isError()) {
|
||||
if (!dataStore.getStorage().isError()) {
|
||||
getLogger().info("Closing persistence...");
|
||||
if (!dataStore.getStorage().getProvider().close()) {
|
||||
getLogger().warning("Failed to close persistence!");
|
||||
}
|
||||
dataStore.getStorage().setError(false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue