mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-10 04:31:06 +00:00
Added configurable value "allow-decimals-in-price"
When disabled, "auto-calculate-item-amount" will be disabled too, even if it's set to true in the config. This closes #20
This commit is contained in:
parent
6205dfbd65
commit
7c27fc0d54
@ -264,7 +264,14 @@ class ShopCommand extends BukkitCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(p.getName() + " has entered the numbers correctly");
|
||||
plugin.debug(p.getName() + " has entered numbers as prices and amount");
|
||||
|
||||
if (!plugin.getShopChestConfig().allow_decimals_in_price && (buyPrice != (int) buyPrice || sellPrice != (int) sellPrice)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.PRICES_CONTAIN_DECIMALS));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug(p.getName() + " has entered the numbers correctly (according to allow-decimals configuration)");
|
||||
|
||||
boolean buyEnabled = !(buyPrice <= 0), sellEnabled = !(sellPrice <= 0);
|
||||
|
||||
|
@ -70,6 +70,9 @@ public class Config {
|
||||
**/
|
||||
public List<String> blacklist;
|
||||
|
||||
/** Whether prices may contain decimals **/
|
||||
public boolean allow_decimals_in_price;
|
||||
|
||||
/** Whether the buy price of a shop must be greater than or equal the sell price **/
|
||||
public boolean buy_greater_or_equal_sell;
|
||||
|
||||
@ -281,8 +284,9 @@ public class Config {
|
||||
database_mysql_password = plugin.getConfig().getString("database.mysql.password");
|
||||
database_type = Database.DatabaseType.valueOf(plugin.getConfig().getString("database.type"));
|
||||
minimum_prices = (plugin.getConfig().getConfigurationSection("minimum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("minimum-prices").getKeys(true);
|
||||
allow_decimals_in_price = plugin.getConfig().getBoolean("allow-decimals-in-price");
|
||||
allow_broken_items = plugin.getConfig().getBoolean("allow-broken-items");
|
||||
auto_calculate_item_amount = plugin.getConfig().getBoolean("auto-calculate-item-amount");
|
||||
auto_calculate_item_amount = (allow_decimals_in_price && plugin.getConfig().getBoolean("auto-calculate-item-amount"));
|
||||
shopLimits_group = (plugin.getConfig().getConfigurationSection("shop-limits.group") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.group").getKeys(true);
|
||||
shopLimits_player = (plugin.getConfig().getConfigurationSection("shop-limits.player") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("shop-limits.player").getKeys(true);
|
||||
blacklist = (plugin.getConfig().getStringList("blacklist") == null) ? new ArrayList<String>() : plugin.getConfig().getStringList("blacklist");
|
||||
|
@ -879,6 +879,7 @@ public class LanguageUtils {
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.OUT_OF_STOCK, langConfig.getString("message.out-of-stock", "&cShop out of stock.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.ERROR_OCCURRED, langConfig.getString("message.error-occurred", "&cAn error occurred: %ERROR%"), Regex.ERROR));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.AMOUNT_PRICE_NOT_NUMBER, langConfig.getString("message.amount-and-price-not-number", "&cAmount and price must be a number.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.PRICES_CONTAIN_DECIMALS, langConfig.getString("message.prices-contain-decimals", "&cPrices must not contain decimals.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.NO_ITEM_IN_HAND, langConfig.getString("message.no-item-in-hand", "&cNo item in hand")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.CLICK_CHEST_CREATE, langConfig.getString("message.click-chest-to-create-shop", "&aClick a chest to create a shop.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.CLICK_CHEST_REMOVE, langConfig.getString("message.click-chest-to-remove-shop", "&aClick a shop-chest to remove the shop.")));
|
||||
|
@ -76,6 +76,7 @@ public class LocalizedMessage {
|
||||
OUT_OF_STOCK,
|
||||
ERROR_OCCURRED,
|
||||
AMOUNT_PRICE_NOT_NUMBER,
|
||||
PRICES_CONTAIN_DECIMALS,
|
||||
NO_ITEM_IN_HAND,
|
||||
CLICK_CHEST_CREATE,
|
||||
CLICK_CHEST_REMOVE,
|
||||
|
@ -41,6 +41,9 @@ two-line-hologram-lift: 0.25
|
||||
# The price will be calculated correspondingly. (If it's not clear enough, please let me know)
|
||||
auto-calculate-item-amount: false
|
||||
|
||||
# Set whether prices may contain decimals (prices of existing shops will stay)
|
||||
allow-decimals-in-price: true
|
||||
|
||||
# Set whether players should be allowed to sell/buy broken items
|
||||
allow-broken-items: false
|
||||
|
||||
|
@ -31,7 +31,8 @@ message.not-enough-items=&cNicht genug Items.
|
||||
message.vendor-not-enough-money=&cVerkäufer hat nicht genug Geld.
|
||||
message.out-of-stock=&cShop ausverkauft.
|
||||
message.error-occurred=&cEin Fehler ist aufgetreten: %ERROR%
|
||||
message.amount-and-price-not-number=&cAnzahl und Preis müssen Zahlen sein.
|
||||
message.amount-and-price-not-number=&cAnzahl und Preise müssen Zahlen sein.
|
||||
message.prices-contain-decimals=&cPreise dürfen keine Dezimalen enthalten.
|
||||
message.no-item-in-hand=&cKein Item in der Hand.
|
||||
message.click-chest-to-create-shop=&aKlicke auf eine Truhe, um einen Shop zu erstellen.
|
||||
message.click-chest-to-remove-shop=&aKlicke auf einen Shop, um ihn zu entfernen.
|
||||
|
@ -115,8 +115,12 @@ message.out-of-stock=&cShop out of stock.
|
||||
# Usable regex: %ERROR%
|
||||
message.error-occurred=&cAn error occurred: %ERROR%
|
||||
|
||||
# Set the message when the arguments <AMOUNT> and <PRICE> of '/shop create' are not a number.
|
||||
message.amount-and-price-not-number=&cAmount and price must be a number.
|
||||
# Set the message when the arguments <AMOUNT>, <BUY-PRICE> and/or <SELL-PRICE> of '/shop create' are not a number.
|
||||
message.amount-and-price-not-number=&cAmount and prices must be numbers.
|
||||
|
||||
# Set the message when the config value "allow-decimals-in-prices" is set to false
|
||||
# and a player enters a price with decimals
|
||||
message.prices-contain-decimals=&cPrices must not contain decimals.
|
||||
|
||||
# Set the message when the player doesn't hold an item in the hand.
|
||||
message.no-item-in-hand=&cNo item in hand
|
||||
|
Loading…
Reference in New Issue
Block a user