mirror of
https://github.com/MilkBowl/VaultAPI.git
synced 2024-09-27 14:53:01 +02:00
Added MultiEconomyWrapper
Moved economy wrappers to /economy/wrappers/ package Improved Economy documentation Improved IdentityEconomy documentation Improved MultiEconomy documentation
This commit is contained in:
parent
49c17e261f
commit
13b18ac7a1
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>vaultapi</artifactId>
|
||||
<version>2.2-SNAPSHOT</version>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
|
||||
<name>VaultAPI</name>
|
||||
<description>Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.
|
||||
|
@ -22,7 +22,6 @@ import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* The main economy API
|
||||
*
|
||||
*/
|
||||
public interface Economy {
|
||||
|
||||
|
@ -16,17 +16,20 @@
|
||||
|
||||
package net.milkbowl.vault.economy;
|
||||
|
||||
import net.milkbowl.vault.economy.wrappers.IdentityEconomyWrapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Its provider needs to be registered before Economy.class
|
||||
* This is because Vault2 will attempt to do it automatically
|
||||
* Adds UUID support to the Economy interface.
|
||||
* In case of {@link #isLegacy()} returning false, methods such as:
|
||||
* {@link #getAllRecords()} and {@link #getAllOnline()}
|
||||
* should be expected to work.
|
||||
* <p>
|
||||
* If not understood, register using either {@link IdentityEconomyWrapper#registerProviders()}
|
||||
* or {@link EconomyWrapper#registerProviders()}
|
||||
* In order to register/provide it, you should use {@link IdentityEconomyWrapper#registerProviders()}
|
||||
*/
|
||||
public interface IdentityEconomy extends Economy{
|
||||
/**
|
||||
|
@ -7,9 +7,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LegacyEconomy implements IdentityEconomy{
|
||||
public class LegacyEconomy implements IdentityEconomy {
|
||||
private final Economy economy;
|
||||
protected LegacyEconomy(Economy economy){
|
||||
public LegacyEconomy(Economy economy){
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.milkbowl.vault.economy;
|
||||
|
||||
import net.milkbowl.vault.economy.wrappers.MultiEconomyWrapper;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -8,6 +9,11 @@ import java.util.Collection;
|
||||
* This interface is used to provide multi-world, multi-currency support for the economy.
|
||||
* It allows disabling currencies/economies.
|
||||
* It forces currencies to support UUIDs.
|
||||
* <p>
|
||||
* In order to register/provide it, you should use {@link MultiEconomyWrapper#registerProviders()}
|
||||
* Inside this interface, we make use of the term "implementation" to refer to an actual currency.
|
||||
* You should expect that these currencies/implementations might
|
||||
* return true for {@link IdentityEconomy#isLegacy()} in case plugin's author preference!
|
||||
*/
|
||||
public interface MultiEconomy {
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package net.milkbowl.vault.economy;
|
||||
package net.milkbowl.vault.economy.wrappers;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.IdentityEconomy;
|
||||
import net.milkbowl.vault.economy.LegacyEconomy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
@ -21,8 +24,8 @@ public class EconomyWrapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Will register both IdentityEconomy and legacy Economy to Vault
|
||||
* @return true registered successfully, false already registered
|
||||
* Will register IdentityEconomy and legacy Economy to Vault
|
||||
* @return true if registered successfully, false if already registered
|
||||
*/
|
||||
public boolean registerProviders(){
|
||||
ServicesManager manager = Bukkit.getServicesManager();
|
@ -1,5 +1,7 @@
|
||||
package net.milkbowl.vault.economy;
|
||||
package net.milkbowl.vault.economy.wrappers;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.IdentityEconomy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
@ -12,8 +14,8 @@ public class IdentityEconomyWrapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Will register both IdentityEconomy and legacy Economy to Vault
|
||||
* @return true registered successfully, false already registered
|
||||
* Will register IdentityEconomy and legacy Economy to Vault
|
||||
* @return true if registered successfully, false if already registered
|
||||
*/
|
||||
public boolean registerProviders(){
|
||||
ServicesManager manager = Bukkit.getServicesManager();
|
@ -0,0 +1,37 @@
|
||||
package net.milkbowl.vault.economy.wrappers;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.IdentityEconomy;
|
||||
import net.milkbowl.vault.economy.MultiEconomy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
|
||||
public class MultiEconomyWrapper {
|
||||
private final MultiEconomy economy;
|
||||
|
||||
public MultiEconomyWrapper(MultiEconomy economy){
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will register MultiEconomy, IdentityEconomy and legacy Economy to Vault
|
||||
* @return true if registered successfully, false if already registered
|
||||
*/
|
||||
public boolean registerProviders(){
|
||||
ServicesManager manager = Bukkit.getServicesManager();
|
||||
if (manager.isProvidedFor(MultiEconomy.class))
|
||||
return false;
|
||||
if (manager.isProvidedFor(IdentityEconomy.class))
|
||||
return false;
|
||||
if (manager.isProvidedFor(Economy.class))
|
||||
return false;
|
||||
manager.register(MultiEconomy.class, economy,
|
||||
Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
|
||||
manager.register(IdentityEconomy.class, economy.getDefault(),
|
||||
Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
|
||||
manager.register(Economy.class, economy.getDefault(),
|
||||
Bukkit.getPluginManager().getPlugin("Vault"), ServicePriority.Normal);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user