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 java.util.Objects;
import java.util.Set;
/**
* Represents keys for accessing context values with specific types.

View File

@@ -17,7 +17,9 @@
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 {

View File

@@ -43,6 +43,6 @@ public class ListUtils {
} else if (obj instanceof List<?> 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-icons", '.')
.addIgnoredRoute(configVersion, "mechanics.market.decorative-icons", '.')
.addIgnoredRoute(configVersion, "mechanics.market.titles", '.')
.addIgnoredRoute(configVersion, "other-settings.placeholder-register", '.')
.build()
);
@@ -300,8 +301,12 @@ public class BukkitConfigManager extends ConfigManager {
try {
YamlDocument document = plugin.getConfigManager().loadData(subFile);
for (Map.Entry<String, Object> entry : document.getStringRouteMappedValues(false).entrySet()) {
if (entry.getValue() instanceof Section section) {
type.parse(entry.getKey(), section, nodes);
try {
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) {

View File

@@ -86,6 +86,7 @@ public class BukkitGameManager implements GameManager {
@Override
public void unload() {
this.gameMap.clear();
this.gameConditions.clear();
}
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 TextValue<Player> title;
protected TextValue<Player> denyTitle;
protected TextValue<Player> allowTitle;
protected TextValue<Player> limitTitle;
protected String[] layout;
protected final HashMap<Character, Pair<CustomFishingItem, Action<Player>[]>> decorativeIcons;
protected final ConcurrentHashMap<UUID, MarketGUI> marketGUICache;
@@ -74,7 +77,6 @@ public class BukkitMarketManager implements MarketManager, Listener {
protected char itemSlot;
protected char sellSlot;
protected char sellAllSlot;
protected char closeSlot;
protected CustomFishingItem sellIconAllowItem;
protected CustomFishingItem sellIconDenyItem;
@@ -137,7 +139,8 @@ public class BukkitMarketManager implements MarketManager, Listener {
this.formula = config.getString("price-formula", "{base} + {bonus} * {size}");
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.allowItemWithNoPrice = config.getBoolean("item-slot.allow-items-with-no-price", 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()) {
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);
return true;
}

View File

@@ -123,10 +123,16 @@ public class MarketGUI {
.arg(ContextKeys.SOLD_ITEM_AMOUNT, soldAmount);
if (totalWorth <= 0) {
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)) {
sellElement.setItemStack(manager.sellIconLimitItem.build(context));
if (manager.limitTitle != null)
SparrowHeart.getInstance().updateInventoryTitle(context.holder(), AdventureHelper.componentToJson(AdventureHelper.miniMessage(manager.limitTitle.render(context))));
} else {
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
# Rule: [major update].[feature update].[bug fix]
project_version=2.3.1
project_version=2.3.2
config_version=38
project_group=net.momirealms