mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-30 14:33:30 +01:00
added createPlayerAccount method.
This commit is contained in:
parent
887f2eef0a
commit
06ed5fa3c6
@ -154,4 +154,10 @@ public interface Economy {
|
||||
* @return the List of Banks
|
||||
*/
|
||||
public List<String> getBanks();
|
||||
|
||||
/**
|
||||
* Attempts to create a player account for the given player
|
||||
* @return if the account creation was successful
|
||||
*/
|
||||
public boolean createPlayerAccount(String playerName);
|
||||
}
|
@ -29,6 +29,8 @@ import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
@ -241,4 +243,14 @@ public class Economy_3co implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return economy.hasAccount(plugin.getServer().getPlayer(playerName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p == null) {
|
||||
return false;
|
||||
}
|
||||
economy.createAccount(p, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -290,4 +290,12 @@ public class Economy_BOSE6 implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return economy.playerRegistered(playerName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (economy.playerRegistered(playerName, false)) {
|
||||
return false;
|
||||
}
|
||||
return economy.registerPlayer(playerName);
|
||||
}
|
||||
}
|
||||
|
@ -291,4 +291,12 @@ public class Economy_BOSE7 implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return economy.playerRegistered(playerName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (economy.playerRegistered(playerName, false)) {
|
||||
return false;
|
||||
}
|
||||
return economy.registerPlayer(playerName);
|
||||
}
|
||||
}
|
||||
|
@ -206,4 +206,13 @@ public class Economy_CurrencyCore implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return this.currency.getAccountManager().getAccount(playerName) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (this.currency.getAccountManager().getAccount(playerName) != null) {
|
||||
return false;
|
||||
}
|
||||
this.currency.getAccountManager().createAccount(playerName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -206,4 +206,9 @@ public class Economy_EconXP implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return econ.getPlayer(playerName) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,8 @@ public class Economy_Essentials implements Economy {
|
||||
return balance;
|
||||
}
|
||||
|
||||
private boolean createPlayerAccount(String playerName) {
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
try {
|
||||
com.earth2me.essentials.api.Economy.add(playerName, 0);
|
||||
return true;
|
||||
|
@ -175,4 +175,13 @@ public class Economy_MineConomy implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return Accounting.containsKey(playerName, MineConomy.accounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
Accounting.setBalance(playerName, 0, MineConomy.accounts);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -246,4 +246,9 @@ public class Economy_MultiCurrency implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -182,4 +182,13 @@ public class Economy_eWallet implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return econ.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
econ.createAccount(playerName, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -252,4 +252,13 @@ public class Economy_iConomy4 implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return iConomy.getBank().hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
iConomy.getBank().addAccount(playerName);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -215,4 +215,13 @@ public class Economy_iConomy5 implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return iConomy.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
iConomy.getAccount(playerName);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -208,4 +208,12 @@ public class Economy_iConomy6 implements Economy {
|
||||
public boolean hasAccount(String playerName) {
|
||||
return accounts.exists(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return accounts.create(playerName);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user