mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
2.3.2
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user