9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2025-01-17 23:50:11 +08:00
parent 9b18b7175e
commit 66ce7da7e2
8 changed files with 37 additions and 9 deletions

View File

@@ -24,7 +24,6 @@ import org.bukkit.Location;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
/** /**
* Represents keys for accessing context values with specific types. * Represents keys for accessing context values with specific types.

View File

@@ -17,7 +17,9 @@
package net.momirealms.customfishing.api.mechanic.totem; package net.momirealms.customfishing.api.mechanic.totem;
import java.util.*; import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class ActiveTotemList { public class ActiveTotemList {

View File

@@ -43,6 +43,6 @@ public class ListUtils {
} else if (obj instanceof List<?> list) { } else if (obj instanceof List<?> list) {
return (List<String>) list; return (List<String>) list;
} }
throw new IllegalArgumentException("Cannot convert " + obj + " to a list"); throw new IllegalArgumentException("Invalid value found. Cannot convert " + obj.getClass().getSimpleName() + " to a list");
} }
} }

View File

@@ -159,6 +159,7 @@ public class BukkitConfigManager extends ConfigManager {
.addIgnoredRoute(configVersion, "mechanics.market.sell-all-icons", '.') .addIgnoredRoute(configVersion, "mechanics.market.sell-all-icons", '.')
.addIgnoredRoute(configVersion, "mechanics.market.sell-icons", '.') .addIgnoredRoute(configVersion, "mechanics.market.sell-icons", '.')
.addIgnoredRoute(configVersion, "mechanics.market.decorative-icons", '.') .addIgnoredRoute(configVersion, "mechanics.market.decorative-icons", '.')
.addIgnoredRoute(configVersion, "mechanics.market.titles", '.')
.addIgnoredRoute(configVersion, "other-settings.placeholder-register", '.') .addIgnoredRoute(configVersion, "other-settings.placeholder-register", '.')
.build() .build()
); );
@@ -300,8 +301,12 @@ public class BukkitConfigManager extends ConfigManager {
try { try {
YamlDocument document = plugin.getConfigManager().loadData(subFile); YamlDocument document = plugin.getConfigManager().loadData(subFile);
for (Map.Entry<String, Object> entry : document.getStringRouteMappedValues(false).entrySet()) { for (Map.Entry<String, Object> entry : document.getStringRouteMappedValues(false).entrySet()) {
if (entry.getValue() instanceof Section section) { try {
type.parse(entry.getKey(), section, nodes); if (entry.getValue() instanceof Section section) {
type.parse(entry.getKey(), section, nodes);
}
} catch (Exception e) {
plugin.getPluginLogger().warn("Invalid config " + subFile.getPath() + " - Failed to parse section " + entry.getKey(), e);
} }
} }
} catch (ConstructorException e) { } catch (ConstructorException e) {

View File

@@ -86,6 +86,7 @@ public class BukkitGameManager implements GameManager {
@Override @Override
public void unload() { public void unload() {
this.gameMap.clear(); this.gameMap.clear();
this.gameConditions.clear();
} }
private ConditionalElement<List<Pair<String, WeightOperation>>, Player> parseGameConditions(Section section) { private ConditionalElement<List<Pair<String, WeightOperation>>, Player> parseGameConditions(Section section) {

View File

@@ -67,6 +67,9 @@ public class BukkitMarketManager implements MarketManager, Listener {
protected boolean sellFishingBag; protected boolean sellFishingBag;
protected TextValue<Player> title; protected TextValue<Player> title;
protected TextValue<Player> denyTitle;
protected TextValue<Player> allowTitle;
protected TextValue<Player> limitTitle;
protected String[] layout; protected String[] layout;
protected final HashMap<Character, Pair<CustomFishingItem, Action<Player>[]>> decorativeIcons; protected final HashMap<Character, Pair<CustomFishingItem, Action<Player>[]>> decorativeIcons;
protected final ConcurrentHashMap<UUID, MarketGUI> marketGUICache; protected final ConcurrentHashMap<UUID, MarketGUI> marketGUICache;
@@ -74,7 +77,6 @@ public class BukkitMarketManager implements MarketManager, Listener {
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;
@@ -137,7 +139,8 @@ public class BukkitMarketManager implements MarketManager, Listener {
this.formula = config.getString("price-formula", "{base} + {bonus} * {size}"); this.formula = config.getString("price-formula", "{base} + {bonus} * {size}");
this.layout = config.getStringList("layout").toArray(new String[0]); this.layout = config.getStringList("layout").toArray(new String[0]);
this.title = TextValue.auto(config.getString("title", "market.title")); String defaultTitle = config.getString("title", "mechanics.market.title");
this.title = TextValue.auto(defaultTitle);
this.itemSlot = config.getString("item-slot.symbol", "I").charAt(0); this.itemSlot = config.getString("item-slot.symbol", "I").charAt(0);
this.allowItemWithNoPrice = config.getBoolean("item-slot.allow-items-with-no-price", true); this.allowItemWithNoPrice = config.getBoolean("item-slot.allow-items-with-no-price", true);
this.allowBundle = config.getBoolean("allow-bundle", true); this.allowBundle = config.getBoolean("allow-bundle", true);
@@ -198,6 +201,17 @@ public class BukkitMarketManager implements MarketManager, Listener {
} }
} }
} }
Section titleSection = config.getSection("titles");
if (titleSection != null) {
this.denyTitle = TextValue.auto(titleSection.getString("deny", defaultTitle));
this.limitTitle = TextValue.auto(titleSection.getString("limit", defaultTitle));
this.allowTitle = TextValue.auto(titleSection.getString("allow", defaultTitle));
} else {
this.denyTitle = null;
this.allowTitle = null;
this.limitTitle = null;
}
} }
/** /**
@@ -220,7 +234,8 @@ public class BukkitMarketManager implements MarketManager, Listener {
for (Map.Entry<Character, Pair<CustomFishingItem, Action<Player>[]>> entry : decorativeIcons.entrySet()) { for (Map.Entry<Character, Pair<CustomFishingItem, Action<Player>[]>> entry : decorativeIcons.entrySet()) {
gui.addElement(new MarketGUIElement(entry.getKey(), entry.getValue().left().build(context))); gui.addElement(new MarketGUIElement(entry.getKey(), entry.getValue().left().build(context)));
} }
gui.build().refresh().show(); gui.build().show();
gui.refresh();
marketGUICache.put(player.getUniqueId(), gui); marketGUICache.put(player.getUniqueId(), gui);
return true; return true;
} }

View File

@@ -123,10 +123,16 @@ public class MarketGUI {
.arg(ContextKeys.SOLD_ITEM_AMOUNT, soldAmount); .arg(ContextKeys.SOLD_ITEM_AMOUNT, soldAmount);
if (totalWorth <= 0) { if (totalWorth <= 0) {
sellElement.setItemStack(manager.sellIconDenyItem.build(context)); sellElement.setItemStack(manager.sellIconDenyItem.build(context));
if (manager.denyTitle != null)
SparrowHeart.getInstance().updateInventoryTitle(context.holder(), AdventureHelper.componentToJson(AdventureHelper.miniMessage(manager.denyTitle.render(context))));
} else if (earningLimit != -1 && (earningLimit - earningData.earnings < totalWorth)) { } else if (earningLimit != -1 && (earningLimit - earningData.earnings < totalWorth)) {
sellElement.setItemStack(manager.sellIconLimitItem.build(context)); sellElement.setItemStack(manager.sellIconLimitItem.build(context));
if (manager.limitTitle != null)
SparrowHeart.getInstance().updateInventoryTitle(context.holder(), AdventureHelper.componentToJson(AdventureHelper.miniMessage(manager.limitTitle.render(context))));
} else { } else {
sellElement.setItemStack(manager.sellIconAllowItem.build(context)); sellElement.setItemStack(manager.sellIconAllowItem.build(context));
if (manager.allowTitle != null)
SparrowHeart.getInstance().updateInventoryTitle(context.holder(), AdventureHelper.componentToJson(AdventureHelper.miniMessage(manager.allowTitle.render(context))));
} }
} }

View File

@@ -1,6 +1,6 @@
# Project settings # Project settings
# Rule: [major update].[feature update].[bug fix] # Rule: [major update].[feature update].[bug fix]
project_version=2.3.1 project_version=2.3.2
config_version=38 config_version=38
project_group=net.momirealms project_group=net.momirealms