Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/AcShop/src/main/java/com/mcatk/acshop/ShopGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ private void addPriceLore(ItemStack icon, String id, int price) {
private ItemStack getQuitIcon() {
ItemStack icon = new ItemStack(Material.GOLD_NUGGET);
ItemMeta meta = icon.getItemMeta();
meta.setDisplayName("返回");
meta.setDisplayName("\u00a7e返回");
ArrayList<String> lore = new ArrayList<>();
lore.add("\u00a77点击返回主菜单");
meta.setLore(lore);
icon.setItemMeta(meta);
return icon;
}
Expand Down
22 changes: 13 additions & 9 deletions modules/AcShop/src/main/java/com/mcatk/acshop/ShopListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ public void onInventoryClick(InventoryClickEvent event) {
if (event.getWhoClicked() instanceof Player) {
ItemStack icon = event.getCurrentItem();
event.setCancelled(true);
if (icon != null) {
if (icon != null && icon.hasItemMeta()) {
if (icon.getItemMeta().hasDisplayName() &&
icon.getItemMeta().getDisplayName().endsWith("返回")) {
((Player) event.getWhoClicked()).chat("/menu_shop");
Comment on lines +20 to +22
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match return button by exact label

Using endsWith("返回") to detect the back button means any clicked item whose display name ends with that suffix will execute /menu_shop and bypass the purchase path. In this GUI, display names are data-driven from shop items, so a legitimate item name that ends with 返回 is misclassified as navigation; this should be an exact normalized match (or a slot/material check) to avoid blocking purchases.

Useful? React with 👍 / 👎.

return;
}

List<String> list = icon.getItemMeta().getLore();
if (list != null) {
if (list != null && !list.isEmpty()) {
String shopId = event.getInventory().getTitle().split("-")[1];
String itemId = list.get(0).split(":")[1];
Item item = AcShop.getShops().getItem(shopId, itemId);
new Operation().buy((Player) event.getWhoClicked(), item);
}
if (icon.getItemMeta().getDisplayName() != null) {
if (icon.getItemMeta().getDisplayName().equals("返回")) {
((Player) event.getWhoClicked()).chat("/menu_shop");
String[] loreParts = list.get(0).split(":");
if (loreParts.length > 1) {
String itemId = loreParts[1];
Item item = AcShop.getShops().getItem(shopId, itemId);
new Operation().buy((Player) event.getWhoClicked(), item);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public MedalsGui(String playerID) {
// back button
back = new ItemStack(Material.GOLD_NUGGET);
ItemMeta meta = back.getItemMeta();
meta.setDisplayName("返回");
meta.setDisplayName("\u00a7e返回");
ArrayList<String> lore = new ArrayList<>();
lore.add("\u00a77点击返回主菜单");
meta.setLore(lore);
back.setItemMeta(meta);
gui.setItem(53, back);
}
Expand All @@ -63,13 +66,19 @@ public void onInventoryClick(InventoryClickEvent e) {
e.setCancelled(true);
ItemStack clickedItem = e.getCurrentItem();
if (clickedItem == null || clickedItem.getType() == Material.AIR) return;
if (clickedItem.equals(back)) {

if (clickedItem.hasItemMeta() &&
clickedItem.getItemMeta().hasDisplayName() &&
clickedItem.getItemMeta().getDisplayName().endsWith("返回")) {
((Player) e.getWhoClicked()).chat("/menu");
Comment on lines +70 to 73
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect medal back action without suffix matching

The back-button check now triggers on any display name that endsWith("返回"), so medals whose configured names end with that text are treated as “return” clicks and never reach setMainMedal. Because medal names come from data, this creates a real behavior regression for valid medal entries; use an exact back-button identity (or fixed slot/material) instead of suffix matching.

Useful? React with 👍 / 👎.

return;
}

Medal medal = iconMap.get(clickedItem);
SQLManager.getInstance().setMainMedal(e.getWhoClicked().getName(), medal.getId());
e.getWhoClicked().sendMessage("§e已将勋章 " + medal.getName() + " §e设为主勋章");
if (medal != null) {
SQLManager.getInstance().setMainMedal(e.getWhoClicked().getName(), medal.getId());
e.getWhoClicked().sendMessage("§e已将勋章 " + medal.getName() + " §e设为主勋章");
}
}


Expand Down