Update economyoperation methods.
This commit is contained in:
@@ -17,7 +17,7 @@ public class EconomyOperations {
|
|||||||
private static String directory = "plugins" + File.separator + "PlayerVaults" + File.separator;
|
private static String directory = "plugins" + File.separator + "PlayerVaults" + File.separator;
|
||||||
private static File configFile = new File(directory + "config.yml");
|
private static File configFile = new File(directory + "config.yml");
|
||||||
private static YamlConfiguration bukkitConfig = new YamlConfiguration();
|
private static YamlConfiguration bukkitConfig = new YamlConfiguration();
|
||||||
|
|
||||||
public Main plugin;
|
public Main plugin;
|
||||||
public EconomyOperations(Main instance) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
public EconomyOperations(Main instance) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
@@ -30,33 +30,13 @@ public class EconomyOperations {
|
|||||||
* @return transaction success
|
* @return transaction success
|
||||||
*/
|
*/
|
||||||
public static boolean payToOpen(Player player) {
|
public static boolean payToOpen(Player player) {
|
||||||
if(bukkitConfig.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !Main.useVault)
|
if(!bukkitConfig.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !Main.useVault)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
double cost = bukkitConfig.getDouble("economy.cost-to-open");
|
double cost = bukkitConfig.getDouble("economy.cost-to-open");
|
||||||
EconomyResponse resp = Main.econ.withdrawPlayer(player.getName(), cost);
|
EconomyResponse resp = Main.econ.withdrawPlayer(player.getName(), cost);
|
||||||
if(resp.transactionSuccess()) {
|
if(resp.transactionSuccess()) {
|
||||||
player.sendMessage(Lang.TITLE.toString() + Lang.COST_TO_OPEN.toString());
|
player.sendMessage(Lang.TITLE.toString() + Lang.COST_TO_OPEN.toString().replaceAll("%price", "" + cost));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Have a player pay to make a vault.
|
|
||||||
* Returns true if successful. Otherwise false.
|
|
||||||
* @param player
|
|
||||||
* @return transaction success
|
|
||||||
*/
|
|
||||||
public static boolean payToMake(Player player) {
|
|
||||||
if(!bukkitConfig.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !Main.useVault)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
double cost = bukkitConfig.getDouble("economy.cost-to-create");
|
|
||||||
EconomyResponse resp = Main.econ.withdrawPlayer(player.getName(), cost);
|
|
||||||
if(resp.transactionSuccess()) {
|
|
||||||
player.sendMessage(Lang.TITLE.toString() + Lang.COST_TO_CREATE.toString());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +56,7 @@ public class EconomyOperations {
|
|||||||
double cost = bukkitConfig.getDouble("economy.refund-on-delete");
|
double cost = bukkitConfig.getDouble("economy.refund-on-delete");
|
||||||
EconomyResponse resp = Main.econ.depositPlayer(player.getName(), cost);
|
EconomyResponse resp = Main.econ.depositPlayer(player.getName(), cost);
|
||||||
if(resp.transactionSuccess()) {
|
if(resp.transactionSuccess()) {
|
||||||
player.sendMessage(Lang.TITLE.toString() + Lang.REFUND_AMOUNT.toString());
|
player.sendMessage(Lang.TITLE.toString() + Lang.REFUND_AMOUNT.toString().replaceAll("%price", "" + cost));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public enum Lang {
|
|||||||
NO_PERMS("no-permissions"),
|
NO_PERMS("no-permissions"),
|
||||||
INSUFFICIENT_FUNDS("insufficient-funds"),
|
INSUFFICIENT_FUNDS("insufficient-funds"),
|
||||||
REFUND_AMOUNT("refund-amount"),
|
REFUND_AMOUNT("refund-amount"),
|
||||||
COST_TO_CREATE("cost-to-create"),
|
|
||||||
COST_TO_OPEN("cost-to-open");
|
COST_TO_OPEN("cost-to-open");
|
||||||
|
|
||||||
private String path = "";
|
private String path = "";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# Will not download an update, that is your job :)
|
# Will not download an update, that is your job :)
|
||||||
check-update: true
|
check-update: true
|
||||||
|
|
||||||
# Settings here are for economy integration.
|
# Settings here are for economy integration. playervaults.free bypasses it.
|
||||||
economy:
|
economy:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user