mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2026-01-04 15:41:35 +00:00
add close icon
This commit is contained in:
@@ -68,12 +68,13 @@ public class BukkitMarketManager implements MarketManager, Listener {
|
|||||||
|
|
||||||
protected TextValue<Player> title;
|
protected TextValue<Player> title;
|
||||||
protected String[] layout;
|
protected String[] layout;
|
||||||
protected final HashMap<Character, CustomFishingItem> decorativeIcons;
|
protected final HashMap<Character, Pair<CustomFishingItem, Action<Player>[]>> decorativeIcons;
|
||||||
protected final ConcurrentHashMap<UUID, MarketGUI> marketGUICache;
|
protected final ConcurrentHashMap<UUID, MarketGUI> marketGUICache;
|
||||||
|
|
||||||
protected char itemSlot;
|
protected char itemSlot;
|
||||||
protected char sellSlot;
|
protected char sellSlot;
|
||||||
protected char sellAllSlot;
|
protected char sellAllSlot;
|
||||||
|
protected char closeSlot;
|
||||||
|
|
||||||
protected CustomFishingItem sellIconAllowItem;
|
protected CustomFishingItem sellIconAllowItem;
|
||||||
protected CustomFishingItem sellIconDenyItem;
|
protected CustomFishingItem sellIconDenyItem;
|
||||||
@@ -190,7 +191,10 @@ public class BukkitMarketManager implements MarketManager, Listener {
|
|||||||
for (Map.Entry<String, Object> entry : decorativeSection.getStringRouteMappedValues(false).entrySet()) {
|
for (Map.Entry<String, Object> entry : decorativeSection.getStringRouteMappedValues(false).entrySet()) {
|
||||||
if (entry.getValue() instanceof Section innerSection) {
|
if (entry.getValue() instanceof Section innerSection) {
|
||||||
char symbol = Objects.requireNonNull(innerSection.getString("symbol")).charAt(0);
|
char symbol = Objects.requireNonNull(innerSection.getString("symbol")).charAt(0);
|
||||||
decorativeIcons.put(symbol, new SingleItemParser("gui", innerSection, plugin.getConfigManager().getItemFormatFunctions()).getItem());
|
decorativeIcons.put(symbol, Pair.of(
|
||||||
|
new SingleItemParser("gui", innerSection, plugin.getConfigManager().getItemFormatFunctions()).getItem(),
|
||||||
|
plugin.getActionManager().parseActions(innerSection.getSection("action")))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,8 +217,8 @@ public class BukkitMarketManager implements MarketManager, Listener {
|
|||||||
gui.addElement(new MarketGUIElement(itemSlot, new ItemStack(Material.AIR)));
|
gui.addElement(new MarketGUIElement(itemSlot, new ItemStack(Material.AIR)));
|
||||||
gui.addElement(new MarketDynamicGUIElement(sellSlot, new ItemStack(Material.AIR)));
|
gui.addElement(new MarketDynamicGUIElement(sellSlot, new ItemStack(Material.AIR)));
|
||||||
gui.addElement(new MarketDynamicGUIElement(sellAllSlot, new ItemStack(Material.AIR)));
|
gui.addElement(new MarketDynamicGUIElement(sellAllSlot, new ItemStack(Material.AIR)));
|
||||||
for (Map.Entry<Character, CustomFishingItem> entry : decorativeIcons.entrySet()) {
|
for (Map.Entry<Character, Pair<CustomFishingItem, Action<Player>[]>> entry : decorativeIcons.entrySet()) {
|
||||||
gui.addElement(new MarketGUIElement(entry.getKey(), entry.getValue().build(context)));
|
gui.addElement(new MarketGUIElement(entry.getKey(), entry.getValue().left().build(context)));
|
||||||
}
|
}
|
||||||
gui.build().refresh().show();
|
gui.build().refresh().show();
|
||||||
marketGUICache.put(player.getUniqueId(), gui);
|
marketGUICache.put(player.getUniqueId(), gui);
|
||||||
@@ -336,6 +340,12 @@ public class BukkitMarketManager implements MarketManager, Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pair<CustomFishingItem, Action<Player>[]> decorativeIcon = this.decorativeIcons.get(element.getSymbol());
|
||||||
|
if (decorativeIcon != null) {
|
||||||
|
ActionManager.trigger(gui.context, decorativeIcon.right());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (element.getSymbol() == sellSlot) {
|
if (element.getSymbol() == sellSlot) {
|
||||||
|
|
||||||
Pair<Integer, Double> pair = getItemsToSell(gui.context, gui.getItemsInGUI());
|
Pair<Integer, Double> pair = getItemsToSell(gui.context, gui.getItemsInGUI());
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ mechanics:
|
|||||||
earnings-multiplier: 1
|
earnings-multiplier: 1
|
||||||
# Layout for the market menu
|
# Layout for the market menu
|
||||||
layout:
|
layout:
|
||||||
- 'AAAAAAAAA'
|
- 'AAAAAAAAC'
|
||||||
- 'AIIIIIIIA'
|
- 'AIIIIIIIA'
|
||||||
- 'AIIIIIIIA'
|
- 'AIIIIIIIA'
|
||||||
- 'AIIIIIIIA'
|
- 'AIIIIIIIA'
|
||||||
@@ -353,6 +353,17 @@ mechanics:
|
|||||||
name: ' '
|
name: ' '
|
||||||
components:
|
components:
|
||||||
minecraft:hide_tooltip: {}
|
minecraft:hide_tooltip: {}
|
||||||
|
close-icon:
|
||||||
|
symbol: 'C'
|
||||||
|
material: RED_STAINED_GLASS_PANE
|
||||||
|
display:
|
||||||
|
name: ' '
|
||||||
|
components:
|
||||||
|
minecraft:hide_tooltip: {}
|
||||||
|
# Add actions on click
|
||||||
|
action:
|
||||||
|
action_1:
|
||||||
|
type: close-inv
|
||||||
# This section is only effective if "override-vanilla" is set to true
|
# This section is only effective if "override-vanilla" is set to true
|
||||||
# Meaning vanilla mechanics, such as lure enchantment, will no longer apply
|
# Meaning vanilla mechanics, such as lure enchantment, will no longer apply
|
||||||
# You must configure their effects in CustomFishing instead
|
# You must configure their effects in CustomFishing instead
|
||||||
|
|||||||
Reference in New Issue
Block a user