Skip to content

Commit

Permalink
feat: Add variable %name% to the market gui item lore
Browse files Browse the repository at this point in the history
  • Loading branch information
blank038 committed Oct 21, 2023
1 parent e910f96 commit 931f2b3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/com/blank038/servermarket/gui/impl/MarketGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ private String getCurrentTypeDisplayName() {
private ItemStack getShowItem(MarketData marketData, SaleCache saleItem, FileConfiguration data) {
ItemStack itemStack = saleItem.getSaleItem().clone();
ItemMeta itemMeta = itemStack.getItemMeta();
String displayName = itemMeta.hasDisplayName() ? itemMeta.getDisplayName() : itemStack.getType().name();
if (data.contains("sale-name")) {
String displayName = itemMeta.hasDisplayName() ? itemMeta.getDisplayName() : itemStack.getType().name(),
finalName = data.getString("sale-name").replace("%name%", displayName);
String finalName = data.getString("sale-name").replace("%name%", displayName);
itemMeta.setDisplayName(TextUtil.formatHexColor(finalName));
}
if (marketData.isShowSaleInfo()) {
Expand All @@ -233,8 +233,11 @@ private ItemStack getShowItem(MarketData marketData, SaleCache saleItem, FileCon
SimpleDateFormat sdf = new SimpleDateFormat(marketData.getDateFormat());
// 设置额外信息
for (String i : data.getStringList("sale-info")) {
lore.add(TextUtil.formatHexColor(i).replace("%seller%", saleItem.getOwnerName())
.replace("%price%", String.valueOf(saleItem.getPrice())).replace("%time%", sdf.format(date)));
lore.add(TextUtil.formatHexColor(i)
.replace("%seller%", saleItem.getOwnerName())
.replace("%price%", String.valueOf(saleItem.getPrice()))
.replace("%time%", sdf.format(date))
.replace("%name%", displayName));
}
itemMeta.setLore(lore);
}
Expand Down

0 comments on commit 931f2b3

Please sign in to comment.