mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-12-23 01:21:47 +00:00
Added shop creation costs (configurable)
This commit is contained in:
parent
ce2c812b27
commit
e2e034bcc8
15
config.yml
15
config.yml
@ -41,6 +41,17 @@ main-command-name: "shop"
|
||||
# Value MUST be a number (e.g. 1, 1.5, 2.75, ...)
|
||||
maximal-distance: 1.75
|
||||
|
||||
# Set the price a player has to pay in order to create...
|
||||
# You can set this to 0 to disable costs.
|
||||
# Value MUST be a number (e.g. 1, 1.5, 2.75, ...)
|
||||
shop-creation-price:
|
||||
|
||||
# ...a normal shop
|
||||
normal: 5
|
||||
|
||||
# ...an admin shop
|
||||
admin: 0
|
||||
|
||||
# Set whether the shop's chest should be protected by hoppers
|
||||
hopper-protection: true
|
||||
|
||||
@ -135,6 +146,10 @@ messages:
|
||||
# Set the message when the clicked chest is not a shop.
|
||||
chest-no-shop: "&cChest is not a shop."
|
||||
|
||||
# Set the message when the player doesn't have enough money to create a shop
|
||||
# Usable Regex: %CREATION-PRICE%, %CURRENCY-SYMBOL%
|
||||
shop-create-not-enough-money: "&cNot enough money. You need &6%CREATION-PRICE%%CURRENCY-SYMBOL% &cto create a shop."
|
||||
|
||||
shop-info:
|
||||
|
||||
# Set the vendor message the player gets after entering '/shop info'.
|
||||
|
@ -10,6 +10,7 @@ import de.epiceric.shopchest.utils.ClickType.EnumClickType;
|
||||
import de.epiceric.shopchest.utils.ShopUtils;
|
||||
import de.epiceric.shopchest.utils.UpdateChecker;
|
||||
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -281,6 +282,20 @@ public class Commands extends BukkitCommand {
|
||||
}
|
||||
}
|
||||
|
||||
double creationPrice = (shopType == ShopType.NORMAL) ? Config.shop_creation_price_normal() : Config.shop_creation_price_admin();
|
||||
if (creationPrice > 0) {
|
||||
if (ShopChest.econ.getBalance(p) >= creationPrice) {
|
||||
EconomyResponse r = ShopChest.econ.withdrawPlayer(p, creationPrice);
|
||||
if (!r.transactionSuccess()) {
|
||||
p.sendMessage(Config.error_occurred(r.errorMessage));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(Config.shop_create_not_enough_money(creationPrice));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ClickType.addPlayerClickType(p, new ClickType(EnumClickType.CREATE, itemStack, buyPrice, sellPrice, shopType));
|
||||
p.sendMessage(Config.click_chest_to_create());
|
||||
|
||||
|
@ -72,6 +72,14 @@ public class Config {
|
||||
return plugin.getConfig().getDouble("maximal-distance");
|
||||
}
|
||||
|
||||
public static double shop_creation_price_normal() {
|
||||
return plugin.getConfig().getDouble("shop-creation-price.normal");
|
||||
}
|
||||
|
||||
public static double shop_creation_price_admin() {
|
||||
return plugin.getConfig().getDouble("shop-creation-price.admin");
|
||||
}
|
||||
|
||||
public static int default_limit() {
|
||||
return plugin.getConfig().getInt("shop-limits.default");
|
||||
}
|
||||
@ -264,6 +272,10 @@ public class Config {
|
||||
return plugin.getConfig().getString("messages.shop-info.none").replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
|
||||
}
|
||||
|
||||
public static String shop_create_not_enough_money(double creationPrice) {
|
||||
return plugin.getConfig().getString("messages.shop-create-not-enough-money").replace(Regex.creationPrice, String.valueOf(creationPrice)).replace(Regex.currencySymbol, currency_symbol()).replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
|
||||
}
|
||||
|
||||
public static String limit_reached(int limit) {
|
||||
return plugin.getConfig().getString("messages.shop-limit-reached").replace(Regex.limit, String.valueOf(limit)).replaceAll("(&([a-f0-9k-or]))", "\u00A7$2");
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ public class Regex {
|
||||
public static String vendor = "%VENDOR%";
|
||||
public static String amount = "%AMOUNT%";
|
||||
public static String itemName = "%ITEMNAME%";
|
||||
public static String price = "%PRICE%";
|
||||
public static String creationPrice = "%CREATION-PRICE%";
|
||||
public static String currencySymbol = "%CURRENCY-SYMBOL%";
|
||||
public static String error = "%ERROR%";
|
||||
public static String enchantment = "%ENCHANTMENT%";
|
||||
|
Loading…
Reference in New Issue
Block a user