Switch Vault dependency to VaultAPI (#2430)

* Switch Vault dependency to VaultAPI
* Remove direct Vault class usage from VaultEco
This commit is contained in:
md678685 2019-02-20 11:28:20 +00:00 committed by GitHub
parent 189d6a23c6
commit aca83bd462
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -44,8 +44,8 @@
<dependencies>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.5.6</version>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -1,18 +1,17 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultEco implements Method {
private Vault vault;
private Plugin vault;
private Economy economy;
@Override
public Vault getPlugin() {
public Plugin getPlugin() {
return this.vault;
}
@ -108,7 +107,7 @@ public class VaultEco implements Method {
public boolean isCompatible(Plugin plugin) {
try {
RegisteredServiceProvider<Economy> ecoPlugin = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
return plugin instanceof Vault && ecoPlugin != null && !ecoPlugin.getProvider().getName().equals("Essentials Economy");
return plugin.getName().equals("Vault") && ecoPlugin != null && !ecoPlugin.getProvider().getName().equals("Essentials Economy");
} catch (LinkageError | Exception e) {
return false;
}
@ -116,7 +115,7 @@ public class VaultEco implements Method {
@Override
public void setPlugin(Plugin plugin) {
this.vault = (Vault) plugin;
this.vault = plugin;
RegisteredServiceProvider<Economy> economyProvider = this.vault.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
this.economy = economyProvider.getProvider();