mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00: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;
|
||||||
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
|
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
|
||||||
import de.epiceric.shopchest.utils.Utils;
|
import de.epiceric.shopchest.utils.Utils;
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
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;
|
double creationPrice = (shopType == ShopType.NORMAL) ? Config.shop_creation_price_normal : Config.shop_creation_price_admin;
|
||||||
if (creationPrice > 0) {
|
if (creationPrice > 0) {
|
||||||
if (plugin.getEconomy().getBalance(p) >= creationPrice) {
|
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 {
|
|
||||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new LocalizedMessage.ReplacedRegex(Regex.CREATION_PRICE, String.valueOf(creationPrice))));
|
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_CREATE_NOT_ENOUGH_MONEY, new LocalizedMessage.ReplacedRegex(Regex.CREATION_PRICE, String.valueOf(creationPrice))));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,13 @@ public class ShopInteractListener implements Listener {
|
|||||||
return;
|
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);
|
Shop shop = new Shop(id, plugin, executor, product, location, buyPrice, sellPrice, shopType);
|
||||||
|
|
||||||
ShopUtils.addShop(shop, true);
|
ShopUtils.addShop(shop, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user