Skip to content

Commit

Permalink
removed variable {currency} and now format {price} using the ShopMana…
Browse files Browse the repository at this point in the history
…ger, because Shop#getCurrency was always null and resulted in '?'
  • Loading branch information
BlvckBytes committed Oct 28, 2024
1 parent bcdc4e8 commit d50747a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.blvckbytes.quick_shop_search;

import com.cryptomorin.xseries.XMaterial;
import com.ghostchu.quickshop.api.QuickShopAPI;
import com.tcoded.folialib.FoliaLib;
import me.blvckbytes.bukkitevaluable.CommandUpdater;
import me.blvckbytes.bukkitevaluable.ConfigKeeper;
Expand Down Expand Up @@ -54,8 +53,7 @@ public void onEnable() {
stateStore = new SelectionStateStore(this, logger);
displayHandler = new ResultDisplayHandler(scheduler, config, stateStore, chatPromptManager);

var quickShopApi = QuickShopAPI.getInstance();
var shopRegistry = new CachedShopRegistry(scheduler, quickShopApi.getShopManager(), displayHandler, config, logger);
var shopRegistry = new CachedShopRegistry(scheduler, displayHandler, config, logger);

var shopEventHandler = QuickShopListenerFactory.create(logger, shopRegistry);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.blvckbytes.quick_shop_search.cache;

import com.ghostchu.quickshop.api.QuickShopAPI;
import com.ghostchu.quickshop.api.shop.Shop;
import com.tcoded.folialib.impl.PlatformScheduler;
import me.blvckbytes.bukkitevaluable.ConfigKeeper;
Expand Down Expand Up @@ -34,13 +35,13 @@ public CachedShop(

var shopLocation = handle.getLocation();
var shopWorld = shopLocation.getWorld();
var shopManager = QuickShopAPI.getInstance().getShopManager();

this.shopEnvironment = new EvaluationEnvironmentBuilder()
.withLiveVariable("owner", handle.getOwner()::getDisplay)
.withLiveVariable("name", handle::getShopName)
.withLiveVariable("name", () -> shopManager.format(handle.getPrice(), handle))
.withLiveVariable("price", handle::getPrice)
.withLiveVariable("item_type", () -> formatItemType(handle.getItem()))
.withLiveVariable("currency", () -> handle.getCurrency() == null ? "?" : handle.getCurrency())
.withLiveVariable("remaining_stock", () -> this.cachedStock)
.withLiveVariable("remaining_space", () -> this.cachedSpace)
.withLiveVariable("is_buying", handle::isBuying)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.blvckbytes.quick_shop_search.cache;

import com.ghostchu.quickshop.api.QuickShopAPI;
import com.ghostchu.quickshop.api.shop.Shop;
import com.ghostchu.quickshop.api.shop.ShopManager;
import com.ghostchu.quickshop.api.shop.ShopType;
import com.tcoded.folialib.impl.PlatformScheduler;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
Expand All @@ -28,7 +28,6 @@ public class CachedShopRegistry implements QuickShopEventConsumer {

public CachedShopRegistry(
PlatformScheduler scheduler,
ShopManager shopManager,
ResultDisplayHandler displayHandler,
ConfigKeeper<MainSection> config,
Logger logger
Expand All @@ -48,7 +47,7 @@ public CachedShopRegistry(

logger.info("Getting all globally existing shops... This may take a while!");

for (var shop : shopManager.getAllShops())
for (var shop : QuickShopAPI.getInstance().getShopManager().getAllShops())
existingShopByLocation.put(shop.getLocation(), new CachedShop(scheduler, shop, config));

logger.info("Found " + existingShopByLocation.size() + " shops in total");
Expand Down
9 changes: 3 additions & 6 deletions core/src/main/resources/config/de_de.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ REPRESENTATIVE-LORE-OWNER &8♦ &7Besitzer: &e{owner}
# - name: String
REPRESENTATIVE-LORE-NAME &8♦ &7Name: &e{name}
# - price: String
# - currency: String
REPRESENTATIVE-LORE-PRICE &8♦ &7Preis: &e{price} {currency}
REPRESENTATIVE-LORE-PRICE &8♦ &7Preis: &e{price}
# - remaining_space: Integer
REPRESENTATIVE-LORE-REMAINING-SPACE &8♦ &7Kapazität: &e{remaining_space}
# - remaining_stock: Integer
Expand Down Expand Up @@ -100,7 +99,6 @@ MESSAGE-NO-MATCHES {prefix} &cDeine Suche erzielte kein
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-BEFORE-TELEPORTING {prefix} &7Teleportiere zum Shop von &e{owner} &7bei &e{loc_x}&7, &e{loc_y}&7, &e{loc_z}&7.
Expand Down Expand Up @@ -138,12 +136,11 @@ MESSAGE-PREDICATE-ERROR {prefix} {error_message}
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7Gib im Chat ein, wie viele Items an &e{item_type} &7du zum Preis von &e{price} {currency} &7je &eVERKAUFEN &7möchtest; tippe "&ccancel&7" um abzubrechen.
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7Gib im Chat ein, wie viele Items an &e{item_type} &7du zum Preis von &e{price} &7je &eVERKAUFEN &7möchtest; tippe "&ccancel&7" um abzubrechen.
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7Gib im Chat ein, wie viele Items an &e{item_type} &7du zum Preis von &e{price} {currency} &7je &eKAUFEN &7möchtest; tippe "&ccancel&7" um abzubrechen.
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7Gib im Chat ein, wie viele Items an &e{item_type} &7du zum Preis von &e{price} &7je &eKAUFEN &7möchtest; tippe "&ccancel&7" um abzubrechen.
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-TIMEOUT {prefix} &cDeine vorherige Chat-Eingabeaufforderung ist abgelaufen!
# - amount: Integer
Expand Down
9 changes: 3 additions & 6 deletions core/src/main/resources/config/en_us.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ REPRESENTATIVE-LORE-OWNER &8♦ &7Owner: &e{owner}
# - name: String
REPRESENTATIVE-LORE-NAME &8♦ &7Name: &e{name}
# - price: String
# - currency: String
REPRESENTATIVE-LORE-PRICE &8♦ &7Price: &e{price} {currency}
REPRESENTATIVE-LORE-PRICE &8♦ &7Price: &e{price}
# - remaining_space: Integer
REPRESENTATIVE-LORE-REMAINING-SPACE &8♦ &7Space: &e{remaining_space}
# - remaining_stock: Integer
Expand Down Expand Up @@ -100,7 +99,6 @@ MESSAGE-NO-MATCHES {prefix} &cYour query resulted in ze
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-BEFORE-TELEPORTING {prefix} &7Teleporting to the Shop of &e{owner} &7at &e{loc_x}&7, &e{loc_y}&7, &e{loc_z}&7.
Expand Down Expand Up @@ -138,12 +136,11 @@ MESSAGE-PREDICATE-ERROR {prefix} {error_message}
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7Enter in chat, how many items of &e{item_type} &7you wish to &eSELL &7for &e{price} {currency} &7each; type "&ccancel&7" to exit.
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7Enter in chat, how many items of &e{item_type} &7you wish to &eSELL &7for &e{price} &7each; type "&ccancel&7" to exit.
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7Enter in chat, how many items of &e{item_type} &7you wish to &eBUY &7for &e{price} {currency} &7each; type "&ccancel&7" to exit.
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7Enter in chat, how many items of &e{item_type} &7you wish to &eBUY &7for &e{price} &7each; type "&ccancel&7" to exit.
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-TIMEOUT {prefix} &cYour previous chat-prompt timed out!
# - amount: Integer
Expand Down
9 changes: 3 additions & 6 deletions core/src/main/resources/config/tr_tr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ REPRESENTATIVE-LORE-OWNER &8♦ &7Sahibi: &e{owner}
# - name: String
REPRESENTATIVE-LORE-NAME &8♦ &7İsim: &e{name}
# - price: String
# - currency: String
REPRESENTATIVE-LORE-PRICE &8♦ &7Fiyat: &e{price} {currency}
REPRESENTATIVE-LORE-PRICE &8♦ &7Fiyat: &e{price}
# - remaining_space: Integer
REPRESENTATIVE-LORE-REMAINING-SPACE &8♦ &7Space: &e{remaining_space}
# - remaining_stock: Integer
Expand Down Expand Up @@ -100,7 +99,6 @@ MESSAGE-NO-MATCHES {prefix} &cSorgunuza dair hiçbir e
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-BEFORE-TELEPORTING {prefix} &e{owner} &7kişisinin &7&e{loc_x}&7, &e{loc_y}&7, &e{loc_z}&7 &7konumundaki marketine ışınlandın.
Expand Down Expand Up @@ -138,12 +136,11 @@ MESSAGE-PREDICATE-ERROR {prefix} {error_message}
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7Sohbete, &e{item_type} &7öğesinden &e{price} {currency} &7karşılığında kaç adet &esatmak &7istediğinizi yazın; &7işlemi iptal etmek için "&ccancel&7" yazın.
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7Sohbete, &e{item_type} &7öğesinden &e{price} &7karşılığında kaç adet &esatmak &7istediğinizi yazın; &7işlemi iptal etmek için "&ccancel&7" yazın.
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7Sohbete, &e{item_type} &7öğesinden &e{price} {currency} &7karşılığında kaç adet &esatın almak &7istediğinizi yazın; &7işlemi iptal etmek için "&ccancel&7" yazın.
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7Sohbete, &e{item_type} &7öğesinden &e{price} &7karşılığında kaç adet &esatın almak &7istediğinizi yazın; &7işlemi iptal etmek için "&ccancel&7" yazın.
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-TIMEOUT {prefix} &cÖnceki işleminiz zaman aşımına uğradı!
# - amount: Integer
Expand Down
9 changes: 3 additions & 6 deletions core/src/main/resources/config/zh_cn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ REPRESENTATIVE-LORE-OWNER &8♦ &7所有者: &e{owner}
# - name: String
REPRESENTATIVE-LORE-NAME &8♦ &7名称: &e{name}
# - price: String
# - currency: String
REPRESENTATIVE-LORE-PRICE &8♦ &7价格: &e{price} {currency}
REPRESENTATIVE-LORE-PRICE &8♦ &7价格: &e{price}
# - remaining_space: Integer
REPRESENTATIVE-LORE-REMAINING-SPACE &8♦ &7空间: &e{remaining_space}
# - remaining_stock: Integer
Expand Down Expand Up @@ -100,7 +99,6 @@ MESSAGE-NO-MATCHES {prefix} &c您的查询结果为零
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-BEFORE-TELEPORTING {prefix} &7正在传送到商店所有者 &e{owner} &7的商店,在 &e{loc_x}&7, &e{loc_y}&7, &e{loc_z}&7.
Expand Down Expand Up @@ -138,12 +136,11 @@ MESSAGE-PREDICATE-ERROR {prefix} {error_message}
# - distance: Integer
# - remaining_space: Integer
# - remaining_stock: Integer
# - currency: String
# - price: Double
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7在聊天中输入你想要购买的 &e{item_type} 的数量,每个 &e{price} {currency};输入 “&ccancel&7” 以退出.
MESSAGE-SHOP-INTERACT-PROMPT-BUYING {prefix} &7在聊天中输入你想要购买的 &e{item_type} 的数量,每个 &e{price} “&ccancel&7” 以退出.
# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7在聊天中输入你想要出售的 &e{item_type} 的数量,每个 &e{price} {currency};输入 “&ccancel&7” 以退出.
MESSAGE-SHOP-INTERACT-PROMPT-SELLING {prefix} &7在聊天中输入你想要出售的 &e{item_type} 的数量,每个 &e{price} “&ccancel&7” 以退出.

# - prefix: String
MESSAGE-SHOP-INTERACT-PROMPT-TIMEOUT {prefix} &c超时,请再试一次!
Expand Down

0 comments on commit d50747a

Please sign in to comment.