52 lines
2.5 KiB
Java
52 lines
2.5 KiB
Java
package net.t2code.t2codelib.SPIGOT.system;
|
|
|
|
import net.milkbowl.vault.economy.Economy;
|
|
import net.milkbowl.vault.permission.Permission;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
|
import net.t2code.t2codelib.util.T2C_Util;
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
|
|
import java.util.Objects;
|
|
|
|
public class Vault {
|
|
|
|
public static Boolean vaultEnable;
|
|
public static Boolean connected;
|
|
|
|
public static void loadVault() throws InterruptedException {
|
|
long long_ = System.currentTimeMillis();
|
|
if (T2C_Main.getPlugin().getServer().getPluginManager().getPlugin("Vault") != null && Objects.requireNonNull(T2C_Main.getPlugin().getServer().getPluginManager().getPlugin("Vault")).isEnabled()) {
|
|
vaultEnable = true;
|
|
RegisteredServiceProvider<Economy> eco = T2C_Main.getPlugin().getServer().getServicesManager().getRegistration(Economy.class);
|
|
if (eco != null) {
|
|
T2C_Main.setEco(eco.getProvider());
|
|
if (T2C_Main.getEco() != null) {
|
|
connected = true;
|
|
|
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
|
} else {
|
|
connected = false;
|
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §4Economy could not be connected / found! [1]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
|
}
|
|
} else {
|
|
connected = false;
|
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix(), " §4Economy could not be connected / found! [2]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
|
}
|
|
RegisteredServiceProvider<Permission> perm = T2C_Main.getPlugin().getServer().getServicesManager().getRegistration(Permission.class);
|
|
if (perm != null) {
|
|
T2C_Main.setPerm(perm.getProvider());
|
|
}
|
|
} else {
|
|
vaultEnable = false;
|
|
connected = false;
|
|
T2C_Send.sendStartTextCenter(T2C_Util.getPrefix()," §4Vault could not be connected! [3]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms", false);
|
|
}
|
|
}
|
|
|
|
public static void vaultDisable() {
|
|
if (!connected) return;
|
|
connected = false;
|
|
T2C_Send.console(T2C_Util.getPrefix()+ " §4Vault / Economy successfully deactivated.");
|
|
}
|
|
}
|