+ Fixed issue with Vault not connecting to the plugin properly when using CMI instead of Essentials
+ Improved the message handling for start-up/shut-down
+ Added aspect to disable the plugin when it has issues loading
This commit is contained in:
Charles 2019-01-23 02:03:48 +08:00
parent 7ec14ec2a1
commit 2d56b90ce1
3 changed files with 21 additions and 41 deletions

View File

@ -67,7 +67,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
@Getter private HolographicDisplayHelper holographicDisplayHelper;
@Getter private VaultHelper vaultHelper;
@Getter private boolean debug = false;
@Getter private boolean debug = true;
@Override
public void onDisable() {
@ -76,10 +76,11 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
console.sendMessage(StringUtils.get().translateColor("&a============================="));
console.sendMessage(StringUtils.get().translateColor("&7EpicBosses " + getDescription().getVersion() + " by &5Songoda <3&7!"));
console.sendMessage(StringUtils.get().translateColor("&7Action: &aDisabling&7..."));
console.sendMessage(StringUtils.get().translateColor("&a============================="));
this.autoSpawnManager.stopIntervalSystems();
this.bossEntityManager.killAllHolders((World) null);
console.sendMessage(StringUtils.get().translateColor("&a============================="));
}
@Override
@ -89,7 +90,6 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
console.sendMessage(StringUtils.get().translateColor("&a============================="));
console.sendMessage(StringUtils.get().translateColor("&7EpicBosses " + getDescription().getVersion() + " by &5Songoda <3&7!"));
console.sendMessage(StringUtils.get().translateColor("&7Action: &aEnabling&7..."));
console.sendMessage(StringUtils.get().translateColor("&a============================="));
Debug.setPlugin(this);
@ -102,6 +102,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
if(!this.vaultHelper.isConnected()) {
Debug.FAILED_TO_CONNECT_TO_VAULT.debug();
Bukkit.getPluginManager().disablePlugin(this);
return;
}
@ -160,6 +161,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
this.autoSpawnManager.startIntervalSystems();
ServerUtils.get().logDebug("Loaded all fields and managers, saved messages and plugin is initialized and ready to go. (took " + (System.currentTimeMillis() - beginMs) + "ms).");
console.sendMessage(StringUtils.get().translateColor("&a============================="));
}
@Override

View File

@ -2,9 +2,7 @@ package com.songoda.epicbosses.utils.dependencies;
import com.songoda.epicbosses.utils.IHelper;
import lombok.Getter;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
@ -15,49 +13,29 @@ import org.bukkit.plugin.RegisteredServiceProvider;
*/
public class VaultHelper implements IHelper {
@Getter private Permission permission;
@Getter private Economy economy;
@Getter private Chat chat;
@Override
public boolean isConnected() {
return (setupChat() && setupPermission() && setupEconomy());
return setupEconomy();
}
private boolean setupChat() {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
public Economy getEconomy() {
if(this.economy == null) {
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return null;
}
this.economy = rsp.getProvider();
}
RegisteredServiceProvider<Chat> rsp = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
if (rsp == null) {
return false;
}
chat = rsp.getProvider();
return chat != null;
return this.economy;
}
private boolean setupEconomy() {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
this.economy = rsp.getProvider();
return this.economy != null;
}
private boolean setupPermission() {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Permission> rsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
if (rsp == null) {
return false;
}
this.permission = rsp.getProvider();
return this.permission != null;
return Bukkit.getServer().getPluginManager().getPlugin("Vault") != null;
}
}

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>1.0.0-U204</plugin.version>
<plugin.version>1.0.1</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>