渔民小镇 1 år sedan
förälder
incheckning
bb3e306ec3

+ 3 - 3
one-client/src/main/java/com/iohao/mmo/client/common/item/ItemNode.java

@@ -19,10 +19,10 @@
 package com.iohao.mmo.client.common.item;
 
 /**
- * @param itemId   物品 id
- * @param quantity 物品数量
+ * @param itemTypeId 物品 id
+ * @param quantity   物品数量
  * @author 渔民小镇
  * @date 2023-08-15
  */
-public record ItemNode(String itemId, int quantity) {
+public record ItemNode(String itemTypeId, int quantity) {
 }

+ 0 - 49
one-client/src/main/java/com/iohao/mmo/client/common/item/ItemNodeMap.java

@@ -1,49 +0,0 @@
-/*
- * ioGame
- * Copyright (C) 2021 - 2023  渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
- * # iohao.com . 渔民小镇
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-package com.iohao.mmo.client.common.item;
-
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.experimental.FieldDefaults;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author 渔民小镇
- * @date 2023-08-15
- */
-@Getter
-@Setter
-@FieldDefaults(level = AccessLevel.PRIVATE)
-public class ItemNodeMap {
-    final Map<String, ItemTypeNode> map = new HashMap<>();
-
-    public void add(String itemTypeId, String name, String description) {
-        var itemTypeNode = new ItemTypeNode(itemTypeId, name, description);
-
-        map.put(itemTypeId, itemTypeNode);
-    }
-
-    public ItemTypeNode getItem(String itemId) {
-        return map.get(itemId);
-    }
-
-}

+ 1 - 1
one-client/src/main/java/com/iohao/mmo/client/common/item/ItemTypeNode.java

@@ -25,5 +25,5 @@ package com.iohao.mmo.client.common.item;
  * @author 渔民小镇
  * @date 2023-08-22
  */
-public record ItemTypeNode(String itemTypeId, String name, String description) {
+record ItemTypeNode(String itemTypeId, String name, String description) {
 }

+ 13 - 4
one-client/src/main/java/com/iohao/mmo/client/common/item/ItemTypeNodeKit.java

@@ -22,6 +22,9 @@ import com.alibaba.fastjson2.JSONObject;
 import com.iohao.mmo.common.provide.kit.JsonKit;
 import lombok.experimental.UtilityClass;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 客户端 - 物品通用工具
  *
@@ -30,10 +33,16 @@ import lombok.experimental.UtilityClass;
  */
 @UtilityClass
 public class ItemTypeNodeKit {
-    public ItemNodeMap itemNodeMap = new ItemNodeMap();
+    final Map<String, ItemTypeNode> map = new HashMap<>();
+
+    public void add(String itemTypeId, String name, String description) {
+        var itemTypeNode = new ItemTypeNode(itemTypeId, name, description);
+
+        map.put(itemTypeId, itemTypeNode);
+    }
 
     public String toString(ItemNode itemNode) {
-        var node = itemNodeMap.getItem(itemNode.itemId());
+        var node = map.get(itemNode.itemTypeId());
         String line = "\n物品信息:[%s x %s];物品描述:%s";
 
         return String.format(line
@@ -43,8 +52,8 @@ public class ItemTypeNodeKit {
         );
     }
 
-    public JSONObject toJSON(String itemId) {
-        var item = itemNodeMap.getItem(itemId);
+    public JSONObject toJSON(String itemTypeId) {
+        var item = map.get(itemTypeId);
         return JsonKit.toJSON(item);
     }
 }

+ 1 - 1
one-client/src/main/java/com/iohao/mmo/client/input/ItemInputCommandRegion.java

@@ -39,7 +39,7 @@ public class ItemInputCommandRegion extends AbstractInputCommandRegion {
 
         ofCommand(ItemCmd.listItem).callback(ByteValueList.class, result -> {
             List<ItemMessage> list = result.toList(ItemMessage.class);
-            list.forEach(itemMessage -> ItemTypeNodeKit.itemNodeMap.add(itemMessage.itemTypeId, itemMessage.name, itemMessage.description));
+            list.forEach(itemMessage -> ItemTypeNodeKit.add(itemMessage.itemTypeId, itemMessage.name, itemMessage.description));
         }).setDescription("物品配置列表");
     }