From 41c2435f5fcea362a035d8a631db8134776ebc44 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Wed, 5 Jun 2019 10:25:55 +0800 Subject: [PATCH] fix item --- .../java/com/ljsd/jieling/logic/dao/ItemManager.java | 10 +--------- .../src/main/java/com/ljsd/jieling/util/ItemUtil.java | 9 ++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java index 74b1b5862..42b6ade99 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/ItemManager.java @@ -11,12 +11,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public class ItemManager extends MongoBase { - private static Set notDelete = new HashSet<>(); - static { - notDelete.add(Global.STAMINA); - notDelete.add(Global.HEROSTORY_TICKET); - notDelete.add(Global.GENERALSTORY_TICKET); - } + private Map itemMap = new ConcurrentHashMap<>(); @@ -43,9 +38,6 @@ public class ItemManager extends MongoBase { } public void removeItem(Integer key) { - if(notDelete.contains(key)){ - return; - } Item item = itemMap.get(key); if (item!=null){ itemMap.remove(key); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java index a47ec0eee..131aacc8f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/util/ItemUtil.java @@ -23,6 +23,13 @@ import java.util.concurrent.CopyOnWriteArrayList; public class ItemUtil { private static Map dropRewardMap = new ConcurrentHashMap<>(); private static final Logger LOGGER = LoggerFactory.getLogger(ItemUtil.class); + private static Set notDelete = new HashSet<>(); + static { + notDelete.add(Global.STAMINA); + notDelete.add(Global.HEROSTORY_TICKET); + notDelete.add(Global.GENERALSTORY_TICKET); + } + //指定道具掉落(如:邮件,初始化物品) public static CommonProto.Drop.Builder drop(User user, int[][] itemArr,int reason) throws Exception { CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder(); @@ -538,7 +545,7 @@ public class ItemUtil { if (null == myItem) { continue; } - if (myItem.getItemNum() <= needCount) { + if (myItem.getItemNum() <= needCount && !notDelete.contains(userItem.getKey())) { itemManager.removeItem(userItem.getKey()); } else { myItem.setItemNum(myItem.getItemNum() - needCount);