mirror of https://github.com/MilkBowl/VaultAPI.git
Added IdentityEconomyWrapper
This commit is contained in:
parent
243509cbc6
commit
49c17e261f
2
pom.xml
2
pom.xml
|
@ -25,7 +25,7 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
|
||||
<scm>
|
||||
<url>https://github.com/anjoismysign/VaultAPI2</url>
|
||||
<connection>scm:git:git://github.com:MilkBanjoismysign/VaultAPI2.git</connection>
|
||||
<connection>scm:git:git://github.com:anjoismysign/VaultAPI2.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:anjoismysign/VaultAPI2.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package net.milkbowl.vault.economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
|
||||
public class EconomyWrapper {
|
||||
private final Economy economy;
|
||||
public EconomyWrapper(Economy economy){
|
||||
|
@ -15,4 +19,22 @@ public class EconomyWrapper {
|
|||
public LegacyEconomy legacy(){
|
||||
return new LegacyEconomy(economy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will register both IdentityEconomy and legacy Economy to Vault
|
||||
* @return true registered successfully, false already registered
|
||||
*/
|
||||
public boolean registerProviders(){
|
||||
ServicesManager manager = Bukkit.getServicesManager();
|
||||
if (manager.isProvidedFor(IdentityEconomy.class))
|
||||
return false;
|
||||
if (manager.isProvidedFor(Economy.class))
|
||||
return false;
|
||||
LegacyEconomy legacy = legacy();
|
||||
manager.register(IdentityEconomy.class, legacy,
|
||||
Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
|
||||
manager.register(Economy.class, economy,
|
||||
Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,11 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The main economy API
|
||||
* Its provider needs to be registered before Economy.class
|
||||
* This is because Vault2 will attempt to do it automatically
|
||||
* <p>
|
||||
* If not understood, register using either {@link IdentityEconomyWrapper#registerProviders()}
|
||||
* or {@link EconomyWrapper#registerProviders()}
|
||||
*/
|
||||
public interface IdentityEconomy extends Economy{
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package net.milkbowl.vault.economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
|
||||
public class IdentityEconomyWrapper {
|
||||
private final IdentityEconomy economy;
|
||||
|
||||
public IdentityEconomyWrapper(IdentityEconomy economy){
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will register both IdentityEconomy and legacy Economy to Vault
|
||||
* @return true registered successfully, false already registered
|
||||
*/
|
||||
public boolean registerProviders(){
|
||||
ServicesManager manager = Bukkit.getServicesManager();
|
||||
if (manager.isProvidedFor(IdentityEconomy.class))
|
||||
return false;
|
||||
if (manager.isProvidedFor(Economy.class))
|
||||
return false;
|
||||
manager.register(IdentityEconomy.class, economy,
|
||||
Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
|
||||
manager.register(Economy.class, economy,
|
||||
Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package net.milkbowl.vault.economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
Loading…
Reference in New Issue