mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
parent
bdf39503ab
commit
30ede5e01e
@ -301,7 +301,7 @@ class ShopCommand extends BukkitCommand {
|
||||
for (String key : plugin.getShopChestConfig().minimum_prices) {
|
||||
|
||||
ItemStack itemStack;
|
||||
double price = plugin.getConfig().getDouble("minimum-prices." + key);
|
||||
double minPrice = plugin.getConfig().getDouble("minimum-prices." + key);
|
||||
|
||||
if (key.contains(":")) {
|
||||
itemStack = new ItemStack(Material.getMaterial(key.split(":")[0]), 1, Short.parseShort(key.split(":")[1]));
|
||||
@ -311,15 +311,45 @@ class ShopCommand extends BukkitCommand {
|
||||
|
||||
if (itemStack.getType().equals(Utils.getPreferredItemInHand(p).getType()) && itemStack.getDurability() == Utils.getPreferredItemInHand(p).getDurability()) {
|
||||
if (buyEnabled) {
|
||||
if ((buyPrice <= amount * price) && (buyPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedRegex(Regex.MIN_PRICE, String.valueOf(amount * price))));
|
||||
if ((buyPrice < amount * minPrice) && (buyPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, new LocalizedMessage.ReplacedRegex(Regex.MIN_PRICE, String.valueOf(amount * minPrice))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sellEnabled) {
|
||||
if ((sellPrice <= amount * price) && (sellPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_LOW, new LocalizedMessage.ReplacedRegex(Regex.MIN_PRICE, String.valueOf(amount * price))));
|
||||
if ((sellPrice < amount * minPrice) && (sellPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_LOW, new LocalizedMessage.ReplacedRegex(Regex.MIN_PRICE, String.valueOf(amount * minPrice))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug(p.getName() + "'s prices are higher than the minimum");
|
||||
|
||||
for (String key : plugin.getShopChestConfig().maximum_prices) {
|
||||
|
||||
ItemStack itemStack;
|
||||
double maxPrice = plugin.getConfig().getDouble("maximum-prices." + key);
|
||||
|
||||
if (key.contains(":")) {
|
||||
itemStack = new ItemStack(Material.getMaterial(key.split(":")[0]), 1, Short.parseShort(key.split(":")[1]));
|
||||
} else {
|
||||
itemStack = new ItemStack(Material.getMaterial(key), 1);
|
||||
}
|
||||
|
||||
if (itemStack.getType().equals(Utils.getPreferredItemInHand(p).getType()) && itemStack.getDurability() == Utils.getPreferredItemInHand(p).getDurability()) {
|
||||
if (buyEnabled) {
|
||||
if ((buyPrice > amount * maxPrice) && (buyPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.BUY_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedRegex(Regex.MAX_PRICE, String.valueOf(amount * maxPrice))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sellEnabled) {
|
||||
if ((sellPrice > amount * maxPrice) && (sellPrice > 0)) {
|
||||
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SELL_PRICE_TOO_HIGH, new LocalizedMessage.ReplacedRegex(Regex.MAX_PRICE, String.valueOf(amount * maxPrice))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -57,10 +57,17 @@ public class Config {
|
||||
/**
|
||||
* <p>The minimum prices for certain items</p>
|
||||
* This returns a key set, which contains e.g "STONE", "STONE:1", of the <i>minimum-prices</i> section in ShopChest's config.
|
||||
* To actually retrieve the price for an item, you have to get the Double <i>minimum-prices.<b>key</b></i>.
|
||||
* To actually retrieve the minimum price for an item, you have to get the double {@code minimum-prices.<key>}.
|
||||
**/
|
||||
public Set<String> minimum_prices;
|
||||
|
||||
/**
|
||||
* <p>The maximum prices for certain items</p>
|
||||
* This returns a key set, which contains e.g "STONE", "STONE:1", of the {@code maximum-prices} section in ShopChest's config.
|
||||
* To actually retrieve the maximum price for an item, you have to get the double {@code maximum-prices.<key>}.
|
||||
**/
|
||||
public Set<String> maximum_prices;
|
||||
|
||||
/**
|
||||
* <p>List containing items, of which players can't create a shop</p>
|
||||
* If this list contains an item (e.g "STONE", "STONE:1"), it's in the blacklist.
|
||||
@ -315,6 +322,7 @@ 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);
|
||||
maximum_prices = (plugin.getConfig().getConfigurationSection("maximum-prices") == null) ? new HashSet<String>() : plugin.getConfig().getConfigurationSection("maximum-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 = (allow_decimals_in_price && plugin.getConfig().getBoolean("auto-calculate-item-amount"));
|
||||
|
@ -9,6 +9,7 @@ public enum Regex {
|
||||
ERROR("%ERROR%"),
|
||||
ENCHANTMENT("%ENCHANTMENT%"),
|
||||
MIN_PRICE("%MIN-PRICE%"),
|
||||
MAX_PRICE("%MAX-PRICE%"),
|
||||
VERSION("%VERSION%"),
|
||||
BUY_PRICE("%BUY-PRICE%"),
|
||||
SELL_PRICE("%SELL-PRICE%"),
|
||||
|
@ -953,6 +953,8 @@ public class LanguageUtils {
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.CANNOT_SELL_BROKEN_ITEM, langConfig.getString("message.cannot-sell-broken-item", "&cYou can't sell a broken item.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_PRICE_TOO_LOW, langConfig.getString("message.buy-price-too-low", "&cThe buy price must be higher than %MIN-PRICE%."), Regex.MIN_PRICE));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELL_PRICE_TOO_LOW, langConfig.getString("message.sell-price-too-low", "&cThe sell price must be higher than %MIN-PRICE%."), Regex.MIN_PRICE));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUY_PRICE_TOO_HIGH, langConfig.getString("message.buy-price-too-high", "&cThe buy price must be lower than %MAX-PRICE%."), Regex.MAX_PRICE));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELL_PRICE_TOO_HIGH, langConfig.getString("message.sell-price-too-high", "&cThe sell price must be lower than %MAX-PRICE%."), Regex.MAX_PRICE));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.BUYING_DISABLED, langConfig.getString("message.buying-disabled", "&cBuying is disabled at this shop.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.SELLING_DISABLED, langConfig.getString("message.selling-disabled", "&cSelling is disabled at this shop.")));
|
||||
messages.add(new LocalizedMessage(LocalizedMessage.Message.RELOADED_SHOPS, langConfig.getString("message.reloaded-shops", "&aSuccessfully reloaded %AMOUNT% shop/s."), Regex.AMOUNT));
|
||||
|
@ -88,6 +88,8 @@ public class LocalizedMessage {
|
||||
CANNOT_SELL_BROKEN_ITEM,
|
||||
BUY_PRICE_TOO_LOW,
|
||||
SELL_PRICE_TOO_LOW,
|
||||
BUY_PRICE_TOO_HIGH,
|
||||
SELL_PRICE_TOO_HIGH,
|
||||
BUYING_DISABLED,
|
||||
SELLING_DISABLED,
|
||||
RELOADED_SHOPS,
|
||||
|
@ -128,18 +128,26 @@ explosion-protection: true
|
||||
buy-greater-or-equal-sell: true
|
||||
|
||||
# Set the minimum prices for each individual Item. Not per Stack, per single Item!
|
||||
# To add an item DELETE THE '[]' after 'minimum-prices:' and follow the format below.
|
||||
# To add an item, follow the format below.
|
||||
# Important: You must have exactly 2 spaces between the text and the edge.
|
||||
# You can find the item names in the 'item_names.txt' file.
|
||||
minimum-prices: []
|
||||
minimum-prices:
|
||||
# "STONE:1": 0.5
|
||||
# "DIAMOND_SWORD": 100
|
||||
|
||||
# Set the maximum prices for each individual Item. Not per Stack, per single Item!
|
||||
# To add an item, follow the format below.
|
||||
# Important: You must have exactly 2 spaces between the text and the edge.
|
||||
# You can find the item names in the 'item_names.txt' file.
|
||||
maximum-prices:
|
||||
# "STONE:1": 19.9
|
||||
# "DIAMOND_SWORD": 1000
|
||||
|
||||
# Set the items of which a player can't create a shop.
|
||||
# To add an item DELETE THE '[]' after 'blacklist:' and follow format below.
|
||||
# To add an item, follow the format below.
|
||||
# Important: You must have exactly 2 spaces between the text and edge.
|
||||
# You can find the item names in the 'item_names.txt' file.
|
||||
blacklist: []
|
||||
blacklist:
|
||||
# - "STONE:1"
|
||||
# - "DIAMOND_BLOCK"
|
||||
|
||||
@ -188,7 +196,7 @@ database:
|
||||
|
||||
# Shop limits are handled with permissions.
|
||||
# A player with permission "shopchest.limit.X" has a limit of X shops,
|
||||
# a player with permission "shopchest.limit.*" doesn't have a shop limit.
|
||||
# a player with permission "shopchest.limit.*" does not have a shop limit.
|
||||
shop-limits:
|
||||
|
||||
# Set whether admin shops should be excluded of the shop limits.
|
||||
|
@ -44,6 +44,8 @@ message.cannot-break-shop=&cDu kannst einen Shop nicht zerstören.
|
||||
message.cannot-sell-broken-item=&cDu kannst kein kaputtes Artikel verkaufen.
|
||||
message.buy-price-too-low=&cDer Kaufpreis muss höher sein als %MIN-PRICE%.
|
||||
message.sell-price-too-low=&cDer Verkaufspreis muss höher sein als %MIN-PRICE%.
|
||||
message.buy-price-too-high=&cDer Kaufpreis muss geringer sein als %MAX-PRICE%.
|
||||
message.sell-price-too-high=&cDer Verkaufspreis muss geringer sein als %MAX-PRICE%.
|
||||
message.buying-disabled=&cKaufen ist an diesem Shop nicht möglich.
|
||||
message.selling-disabled=&cVerkaufen ist an diesem Shop nicht möglich.
|
||||
message.reloaded-shops=&a%AMOUNT% Shop/s wurden erfolgreich neu geladen.
|
||||
|
@ -159,6 +159,14 @@ message.buy-price-too-low=&cThe buy price must be higher than %MIN-PRICE%.
|
||||
# Usable regex: %MIN-PRICE%
|
||||
message.sell-price-too-low=&cThe sell price must be higher than %MIN-PRICE%.
|
||||
|
||||
# Set the message when the entered buy price is below the maximum price.
|
||||
# Usable regex: %MAX-PRICE%
|
||||
message.buy-price-too-high=&cThe buy price must be lower than %MAX-PRICE%.
|
||||
|
||||
# Set the message when the entered sell price is below the maximum price.
|
||||
# Usable regex: %MAX-PRICE%
|
||||
message.sell-price-too-high=&cThe sell price must be lower than %MAX-PRICE%.
|
||||
|
||||
# Set the message when buying is disabled at the shop.
|
||||
message.buying-disabled=&cBuying is disabled at this shop.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user