Merge branch 'master' of 60.1.1.230:backend/jieling_server

wangyuan 2019-06-05 10:47:28 +08:00
commit 3069ff56e1
2 changed files with 9 additions and 10 deletions

View File

@ -11,12 +11,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class ItemManager extends MongoBase {
private static Set<Integer> notDelete = new HashSet<>();
static {
notDelete.add(Global.STAMINA);
notDelete.add(Global.HEROSTORY_TICKET);
notDelete.add(Global.GENERALSTORY_TICKET);
}
private Map<Integer, Item> 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);

View File

@ -23,6 +23,13 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class ItemUtil {
private static Map<Integer,String> dropRewardMap = new ConcurrentHashMap<>();
private static final Logger LOGGER = LoggerFactory.getLogger(ItemUtil.class);
private static Set<Integer> 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);