Class MapleShopFactory

java.lang.Object
server.MapleShopFactory

public class MapleShopFactory extends Object
MapleShop 的單例工廠,按需從資料庫載入並快取商店資料。

維護兩張對應表:以商店 ID 為鍵的 shops 與以 NPC ID 為鍵的 npcShops, 均在首次查詢時惰性載入(MapleShop.createFromDB)後快取於記憶體中。 查詢入口為 getShop(int)(依商店 ID)與 getShopForNPC(int)(依 NPC ID), 由 NPC 封包處理器在玩家開啟商店時呼叫。clear() 可清空全部快取以便重新載入。

  • Constructor Details

    • MapleShopFactory

      public MapleShopFactory()
  • Method Details

    • getInstance

      public static MapleShopFactory getInstance()
    • clear

      public void clear()
    • getShop

      public MapleShop getShop(int shopId)
    • getShopForNPC

      public MapleShop getShopForNPC(int npcId)