mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Add ShopProduct#getLocalizedName for easier access
This commit is contained in:
parent
6d57267492
commit
0896a52556
@ -337,7 +337,7 @@ public class ShopInteractListener implements Listener {
|
||||
if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
|
||||
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.VENDOR_OUT_OF_STOCK,
|
||||
new Replacement(Placeholder.AMOUNT, String.valueOf(shop.getProduct().getAmount())),
|
||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(itemStack))));
|
||||
new Replacement(Placeholder.ITEM_NAME, shop.getProduct().getLocalizedName())));
|
||||
}
|
||||
plugin.debug("Shop is out of stock");
|
||||
}
|
||||
@ -639,7 +639,7 @@ public class ShopInteractListener implements Listener {
|
||||
new Replacement(Placeholder.AMOUNT, String.valueOf(product.getAmount()))) + " ";
|
||||
|
||||
String[] parts = productString.split(Placeholder.ITEM_NAME.toString());
|
||||
String productName = LanguageUtils.getItemName(product.getItemStack());
|
||||
String productName = product.getLocalizedName();
|
||||
String jsonItem = "";
|
||||
JsonBuilder jb = new JsonBuilder(plugin);
|
||||
JsonBuilder.PartArray rootArray = new JsonBuilder.PartArray();
|
||||
@ -806,14 +806,14 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.BUY_SUCCESS, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
|
||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.VENDOR, vendorName)));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
|
||||
|
||||
if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
|
||||
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.SOMEONE_BOUGHT, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
|
||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.PLAYER, executor.getName())));
|
||||
}
|
||||
|
||||
@ -848,7 +848,7 @@ public class ShopInteractListener implements Listener {
|
||||
}.runTaskLater(plugin, 1L);
|
||||
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.BUY_SUCCESS_ADMIN, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
|
||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice))));
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.BUY_PRICE, String.valueOf(newPrice))));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully bought (#" + shop.getID() + ")");
|
||||
}
|
||||
@ -969,14 +969,14 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
String vendorName = (shop.getVendor().getName() == null ? shop.getVendor().getUniqueId().toString() : shop.getVendor().getName());
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.SELL_SUCCESS, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
|
||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.VENDOR, vendorName)));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
|
||||
|
||||
if (shop.getVendor().isOnline() && Config.enableVendorMessages) {
|
||||
shop.getVendor().getPlayer().sendMessage(LanguageUtils.getMessage(Message.SOMEONE_SOLD, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
|
||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice)),
|
||||
new Replacement(Placeholder.PLAYER, executor.getName())));
|
||||
}
|
||||
|
||||
@ -1012,7 +1012,7 @@ public class ShopInteractListener implements Listener {
|
||||
}.runTaskLater(plugin, 1L);
|
||||
|
||||
executor.sendMessage(LanguageUtils.getMessage(Message.SELL_SUCCESS_ADMIN, new Replacement(Placeholder.AMOUNT, String.valueOf(newAmount)),
|
||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(product)), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice))));
|
||||
new Replacement(Placeholder.ITEM_NAME, newProduct.getLocalizedName()), new Replacement(Placeholder.SELL_PRICE, String.valueOf(newPrice))));
|
||||
|
||||
plugin.debug(executor.getName() + " successfully sold (#" + shop.getID() + ")");
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public class Shop {
|
||||
Map<Placeholder, Object> placeholders = new EnumMap<>(Placeholder.class);
|
||||
placeholders.put(Placeholder.VENDOR, getVendor().getName());
|
||||
placeholders.put(Placeholder.AMOUNT, getProduct().getAmount());
|
||||
placeholders.put(Placeholder.ITEM_NAME, LanguageUtils.getItemName(itemStack));
|
||||
placeholders.put(Placeholder.ITEM_NAME, getProduct().getLocalizedName());
|
||||
placeholders.put(Placeholder.ENCHANTMENT, LanguageUtils.getEnchantmentString(ItemUtils.getEnchantments(itemStack)));
|
||||
placeholders.put(Placeholder.BUY_PRICE, getBuyPrice());
|
||||
placeholders.put(Placeholder.SELL_PRICE, getSellPrice());
|
||||
|
@ -2,6 +2,8 @@ package de.epiceric.shopchest.shop;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import de.epiceric.shopchest.language.LanguageUtils;
|
||||
|
||||
public class ShopProduct {
|
||||
|
||||
private final ItemStack itemStack;
|
||||
@ -17,6 +19,13 @@ public class ShopProduct {
|
||||
this(itemStack, itemStack.getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The localized name of the product's {@link ItemStack} in the selected language file.
|
||||
*/
|
||||
public String getLocalizedName() {
|
||||
return LanguageUtils.getItemName(getItemStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link ItemStack} with an amount of {@code 1}.
|
||||
*/
|
||||
|
@ -5,7 +5,6 @@ import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.event.ShopBuySellEvent;
|
||||
import de.epiceric.shopchest.event.ShopBuySellEvent.Type;
|
||||
import de.epiceric.shopchest.exceptions.WorldNotFoundException;
|
||||
import de.epiceric.shopchest.language.LanguageUtils;
|
||||
import de.epiceric.shopchest.shop.Shop;
|
||||
import de.epiceric.shopchest.shop.ShopProduct;
|
||||
import de.epiceric.shopchest.shop.Shop.ShopType;
|
||||
@ -526,7 +525,7 @@ public abstract class Database {
|
||||
ps.setLong(3, millis);
|
||||
ps.setString(4, executor.getName());
|
||||
ps.setString(5, executor.getUniqueId().toString());
|
||||
ps.setString(6, LanguageUtils.getItemName(product.getItemStack()));
|
||||
ps.setString(6, product.getLocalizedName());
|
||||
ps.setString(7, Utils.encode(product.getItemStack()));
|
||||
ps.setInt(8, product.getAmount());
|
||||
ps.setString(9, shop.getVendor().getName());
|
||||
|
Loading…
Reference in New Issue
Block a user