宝器数据丢失异常处理
parent
14f65b8f60
commit
1ad5359982
|
@ -16,7 +16,7 @@ public class MongoPropertyConverter implements Converter<BasicDBObject, Property
|
||||||
// private static final JsonWriterSettings jsonWriterSettings = new JsonWriterSettings();
|
// private static final JsonWriterSettings jsonWriterSettings = new JsonWriterSettings();
|
||||||
@Override
|
@Override
|
||||||
public PropertyItem convert(BasicDBObject source) {
|
public PropertyItem convert(BasicDBObject source) {
|
||||||
if (StringUtil.isEmpty(source.toString()) || !source.containsField("equipId") || !source.containsField("id")) {
|
if (StringUtil.isEmpty(source.toString()) || !source.containsField("equipId") || !source.containsField("_id")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
SItem item = SItem.getsItemMap().get(source.getInt("equipId"));
|
SItem item = SItem.getsItemMap().get(source.getInt("equipId"));
|
||||||
|
|
|
@ -3,12 +3,17 @@ package com.ljsd.jieling.logic.dao;
|
||||||
import com.ljsd.common.mogodb.MongoBase;
|
import com.ljsd.common.mogodb.MongoBase;
|
||||||
import com.ljsd.jieling.globals.GlobalItemType;
|
import com.ljsd.jieling.globals.GlobalItemType;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||||
import config.SItem;
|
import config.SItem;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class EquipManager extends MongoBase {
|
public class EquipManager extends MongoBase {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(EquipManager.class);
|
||||||
|
|
||||||
private Map<String,PropertyItem> equipMap = new HashMap<>();// 属性装备列表
|
private Map<String,PropertyItem> equipMap = new HashMap<>();// 属性装备列表
|
||||||
private Set<Integer> equipBookEnabled = new HashSet<>();// 装备图鉴
|
private Set<Integer> equipBookEnabled = new HashSet<>();// 装备图鉴
|
||||||
private Set<Integer> soulGealList = new HashSet<>();// 魂印列表
|
private Set<Integer> soulGealList = new HashSet<>();// 魂印列表
|
||||||
|
@ -64,13 +69,21 @@ public class EquipManager extends MongoBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, PropertyItem> getEquipMap() {
|
public Map<String, PropertyItem> getEquipMap() {
|
||||||
|
Iterator<Map.Entry<String, PropertyItem>> iterator = equipMap.entrySet().iterator();
|
||||||
|
while (iterator.hasNext()){
|
||||||
|
Map.Entry<String, PropertyItem> next = iterator.next();
|
||||||
|
if (next.getValue() == null){
|
||||||
|
LOGGER.error("属性装备数据出现异常,删除道具:{}",next.getKey());
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
return equipMap;
|
return equipMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PropertyItem> getFaxiangList(){
|
public List<PropertyItem> getFaxiangList(){
|
||||||
ArrayList<PropertyItem> list = new ArrayList<>();
|
ArrayList<PropertyItem> list = new ArrayList<>();
|
||||||
Map<Integer, SItem> itemMap = SItem.getsItemMap();
|
Map<Integer, SItem> itemMap = SItem.getsItemMap();
|
||||||
for (PropertyItem item : equipMap.values()) {
|
for (PropertyItem item : getEquipMap().values()) {
|
||||||
SItem sItem = itemMap.get(item.getEquipId());
|
SItem sItem = itemMap.get(item.getEquipId());
|
||||||
if (sItem == null || sItem.getItemType() != GlobalItemType.FAXIANG_EQUIP){
|
if (sItem == null || sItem.getItemType() != GlobalItemType.FAXIANG_EQUIP){
|
||||||
continue;
|
continue;
|
||||||
|
@ -83,7 +96,7 @@ public class EquipManager extends MongoBase {
|
||||||
public List<PropertyItem> getJewelList(){
|
public List<PropertyItem> getJewelList(){
|
||||||
ArrayList<PropertyItem> list = new ArrayList<>();
|
ArrayList<PropertyItem> list = new ArrayList<>();
|
||||||
Map<Integer, SItem> itemMap = SItem.getsItemMap();
|
Map<Integer, SItem> itemMap = SItem.getsItemMap();
|
||||||
for (PropertyItem item : equipMap.values()) {
|
for (PropertyItem item : getEquipMap().values()) {
|
||||||
SItem sItem = itemMap.get(item.getEquipId());
|
SItem sItem = itemMap.get(item.getEquipId());
|
||||||
if (sItem == null || sItem.getItemType() != GlobalItemType.JEWEL){
|
if (sItem == null || sItem.getItemType() != GlobalItemType.JEWEL){
|
||||||
continue;
|
continue;
|
||||||
|
@ -95,7 +108,7 @@ public class EquipManager extends MongoBase {
|
||||||
|
|
||||||
public List<Baubles> getBaublesList(){
|
public List<Baubles> getBaublesList(){
|
||||||
ArrayList<Baubles> list = new ArrayList<>();
|
ArrayList<Baubles> list = new ArrayList<>();
|
||||||
for (PropertyItem item : equipMap.values()) {
|
for (PropertyItem item : getEquipMap().values()) {
|
||||||
if (item instanceof Baubles){
|
if (item instanceof Baubles){
|
||||||
list.add((Baubles) item);
|
list.add((Baubles) item);
|
||||||
}
|
}
|
||||||
|
@ -104,11 +117,11 @@ public class EquipManager extends MongoBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyItem getEquip(String equipId) {
|
public PropertyItem getEquip(String equipId) {
|
||||||
return equipMap.get(equipId);
|
return getEquipMap().get(equipId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Baubles getBaubles(String equipId) {
|
public Baubles getBaubles(String equipId) {
|
||||||
PropertyItem item = equipMap.get(equipId);
|
PropertyItem item = getEquipMap().get(equipId);
|
||||||
if (item instanceof Baubles){
|
if (item instanceof Baubles){
|
||||||
return (Baubles) item;
|
return (Baubles) item;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue