mirror of
https://github.com/EpicEricEE/ShopChest.git
synced 2024-11-08 20:01:25 +01:00
Creation price should only be withdrawn if the shop is created successfully
This commit is contained in:
parent
8f75f9f90d
commit
57c6955d6a
@ -13,7 +13,6 @@ import de.epiceric.shopchest.utils.ShopUtils;
|
||||
import de.epiceric.shopchest.utils.UpdateChecker;
|
||||
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
|
||||
import de.epiceric.shopchest.utils.Utils;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -316,13 +315,7 @@ public class Commands extends BukkitCommand {
|
||||
|
||||
double creationPrice = (shopType == ShopType.NORMAL) ? Config.shop_creation_price_normal : Config.shop_creation_price_admin;
|
||||
if (creationPrice > 0) {
|
||||
if (plugin.getEconomy().getBalance(p) >= creationPrice) {
|
||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(p, creationPrice);
|
||||
if (!r.transactionSuccess()) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedRegex(Regex.ERROR, r.errorMessage)));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (plugin.getEconomy().getBalance(p) < creationPrice) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new LocalizedMessage.ReplacedRegex(Regex.CREATION_PRICE, String.valueOf(creationPrice))));
|
||||
return;
|
||||
}
|
||||
|
@ -242,6 +242,13 @@ public class ShopInteractListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
double creationPrice = (shopType == ShopType.NORMAL) ? Config.shop_creation_price_normal : Config.shop_creation_price_admin;
|
||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(executor, creationPrice);
|
||||
if (!r.transactionSuccess()) {
|
||||
executor.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.ERROR_OCCURRED, new LocalizedMessage.ReplacedRegex(Regex.ERROR, r.errorMessage)));
|
||||
return;
|
||||
}
|
||||
|
||||
Shop shop = new Shop(id, plugin, executor, product, location, buyPrice, sellPrice, shopType);
|
||||
|
||||
ShopUtils.addShop(shop, true);
|
||||
|
Loading…
Reference in New Issue
Block a user