优化代码

back_recharge
jiahuiwen 2020-09-01 14:45:47 +08:00
parent f6d885559b
commit c3be084f49
24 changed files with 58 additions and 68 deletions

View File

@ -1,26 +1,22 @@
package com.ljsd;
import com.google.gson.Gson;
import com.ljsd.common.mogodb.util.MongoKeys;
import com.ljsd.jieling.config.json.CoreSettings;
import com.ljsd.jieling.config.json.ServerConfiguration;
import com.ljsd.jieling.config.json.ServerProperties;
import com.ljsd.jieling.core.CoreLogic;
import com.ljsd.jieling.db.mongo.AreaManager;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.network.NetManager;
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
import util.TimeUtils;
import com.ljsd.jieling.logic.dao.ServerConfig;
import com.ljsd.jieling.network.NetManager;
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import util.TimeUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

View File

@ -103,7 +103,7 @@ public class LjsdMongoTemplate implements MongoUpdateImp {
}
public <T> T findById(String collectionName, String id, Class<T> clazz) throws Exception {
int serverIdByUid = AreaManager.getInstance().getServerIdByUid(Integer.valueOf(id), GameApplication.serverId);
int serverIdByUid = AreaManager.getInstance().getServerIdByUid(Integer.parseInt(id), GameApplication.serverId);
MongoTemplate otherMonogTemplate = getMongoTemplate(serverIdByUid);
return otherMonogTemplate.findById(id,clazz,collectionName);
}
@ -179,7 +179,7 @@ public class LjsdMongoTemplate implements MongoUpdateImp {
MongoTemplate otherMonogTemplate=null;
if(collection.equals("guildInfo")){
Integer guilderverId = MongoUtil.getInstence().findGuilderverId(Integer.valueOf(id));
Integer guilderverId = MongoUtil.getInstence().findGuilderverId(Integer.parseInt(id));
otherMonogTemplate = MongoUtil.getInstence().getMonogTemplate(guilderverId);
}else {
int serverIdByUid = AreaManager.getInstance().getServerIdByUid(Integer.valueOf(id), GameApplication.serverId);

View File

@ -69,7 +69,7 @@ public class ReliveExpeditionHeroRequest extends BaseHandler<Expedition.ReliveEx
if(!b){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
Set<String> ids = new HashSet<>();
// Set<String> ids = new HashSet<>();
// 更新队伍血量
//List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(1001);
// Iterator<TeamPosHeroInfo> iterator = teamPosHeroInfos.iterator();
@ -125,14 +125,14 @@ public class ReliveExpeditionHeroRequest extends BaseHandler<Expedition.ReliveEx
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EXPEDITION_RELIVE_HERO_RESONSE_VALUE, build, true);
}
private void relive(User user,String heroId)throws Exception{
private void relive(User user, String heroId) throws Exception {
int reCoverHp = STableManager.getConfig(SExpeditionSetting.class).get(1).getRevive()[1];
double reCoverPer = reCoverHp/10000d;
double reCoverPer = reCoverHp / 10000d;
if(null != heroId||!heroId.isEmpty()){
if (null != heroId && !heroId.isEmpty()) {
// if (expeditionManager.getHeroHP().getOrDefault(heroId, 0d) == 0) {
user.getExpeditionManager().getHeroHPWithChange().put(heroId, reCoverPer);
// if (expeditionManager.getHeroHP().getOrDefault(heroId, 0d) == 0) {
user.getExpeditionManager().getHeroHPWithChange().put(heroId, reCoverPer);
// } else {
// throw new ErrorCodeException(ErrorCode.newDefineCode("英雄复活失败 英雄还存活"));
// }

View File

@ -45,8 +45,7 @@ public class GetArenaRecordHandler extends BaseHandler {
Collections.sort(arenaRecordList, new Comparator<ArenaRecord>() {
@Override
public int compare(ArenaRecord o1, ArenaRecord o2) {
Integer createTime = o1.getCreateTime();
return createTime.compareTo(o2.getCreateTime());
return Integer.valueOf(o1.getCreateTime()).compareTo(Integer.valueOf(o2.getCreateTime()));
}
});
int size = arenaRecordList.size();

View File

@ -2612,8 +2612,8 @@ public class MapLogic {
if(endlessHeroInfo.get(heroEntry.getKey())==null){
mapManager.addEndlessHero(heroEntry.getKey(),10000);
}
LOGGER.info("英雄ID{},血量{}",heroEntry.getKey(),endlessHeroInfo.get(heroEntry.getKey()).intValue());
CommonProto.endlessHero endlessHero = CommonProto.endlessHero.newBuilder().setHeroId(heroEntry.getKey()).setHp(endlessHeroInfo.get(heroEntry.getKey()).intValue()).build();
LOGGER.info("英雄ID{},血量{}",heroEntry.getKey(),endlessHeroInfo.get(heroEntry.getKey()));
CommonProto.endlessHero endlessHero = CommonProto.endlessHero.newBuilder().setHeroId(heroEntry.getKey()).setHp(endlessHeroInfo.get(heroEntry.getKey())).build();
response.addHeroInfo(endlessHero);
}
endlessMapInfo.setEndlessHeroInfo(endlessHeroInfo);

View File

@ -21,7 +21,7 @@ public class Cmd_addfete extends GmRoleAbstract {
if(args.length!=2){
return true;
}
int guildId = Integer.valueOf(args[0]);
int guildId = Integer.parseInt(args[0]);
int addexp = Integer.valueOf(args[1]);
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);

View File

@ -27,7 +27,7 @@ public class Cmd_addholy extends GmRoleAbstract{
if(args.length!=1){
return true;
}
int itemId = Integer.valueOf(args[0]);
int itemId = Integer.parseInt(args[0]);
ISession iSession = OnlineUserManager.getSessionByUid(getUser().getId());
SExpeditionHolyConfig sExpeditionHolyConfig = STableManager.getConfig(SExpeditionHolyConfig.class).get(itemId);

View File

@ -19,7 +19,7 @@ public class Cmd_restart extends GmRoleAbstract{
if(args.length!=1){
return true;
}
String name = ProtocolsManager.handlerThreads[Integer.valueOf(args[0])].getName();
String name = ProtocolsManager.handlerThreads[Integer.parseInt(args[0])].getName();
LOGGER.error("Exception to change thread name"+ name);
System.out.println("name = " + name);
try {

View File

@ -37,7 +37,7 @@ public class Cmd_role_gm extends GmRoleAbstract {
@Override
public boolean exec(String[] args) throws Exception {
if(args.length==1){
thisleve = Integer.valueOf(args[0]);
thisleve = Integer.parseInt(args[0]);
}
int NODESTATE_PASS = 3;//已完成

View File

@ -20,8 +20,8 @@ public class Cmd_sendmsg extends GmAbstract {
return false;
}
int speed = Integer.valueOf(args[0]);
int multime = Integer.valueOf(args[1]);
int speed = Integer.parseInt(args[0]);
int multime = Integer.parseInt(args[1]);
double sendTime = args.length <= 3 ? 0 : Float.valueOf(args[2]);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 3; i < args.length; i++) {

View File

@ -36,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.DefaultTypedTuple;
import org.springframework.data.redis.core.ZSetOperations;
import util.MathUtils;
import util.StringUtil;
import util.TimeUtils;
@ -303,8 +304,8 @@ public class ChampionshipLogic {
TreeMap<Integer, SArenaRobotConfig> sArenaRobotConfigMap = new TreeMap<Integer, SArenaRobotConfig>(new Comparator<Integer>() {
public int compare(Integer a, Integer b) {
int randomOne = (int) (Math.random() * 10);
int randomTwo = (int) (Math.random() * 10);
int randomOne = MathUtils.randomInt();
int randomTwo = MathUtils.randomInt();
if (randomOne == randomTwo) {
randomOne += 1;
}

View File

@ -162,7 +162,7 @@ public class UserMissionManager extends MongoBase {
break;
case SERVENHAPPY_REFRESH:
List<STreasureTaskConfig> sTreasureTaskConfigs = null;
sTreasureTaskConfigs = STableManager.getFigureConfig(TaskStaticConfig.class).getsTreasureTaskConfigListByActivityMap().get((int) parm[0]);
sTreasureTaskConfigs = STableManager.getFigureConfig(TaskStaticConfig.class).getsTreasureTaskConfigListByActivityMap().get(parm[0]);
sevenHappyMissionType.getDoingMissionIds().clear();
sevenHappyMissionType.getFinishMissionIds().clear();
sevenHappyMissionType.getRewardedMissionIds().clear();

View File

@ -279,7 +279,7 @@ public class DeathPathLogic {
continue;
}
ZSetOperations.TypedTuple<String> next = iterator.next();
int guildId = Integer.valueOf(next.getValue());
int guildId = Integer.parseInt(next.getValue());
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
Family.DeathPathInfo info = Family.DeathPathInfo.newBuilder().setGuildName(guildInfo.getName()).setPathId(i).setGid(guildId).build();
response.addInfos(info);
@ -388,12 +388,12 @@ public class DeathPathLogic {
}else{
ZSetOperations.TypedTuple<String> next = iterator.next();
firstGuildId = Integer.valueOf(next.getValue());
firstGuildId = Integer.parseInt(next.getValue());
doRankAdd(personRank,guildRank,task);
Set<ZSetOperations.TypedTuple<String>> currScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
Iterator<ZSetOperations.TypedTuple<String>> currIterator = currScores.iterator();
ZSetOperations.TypedTuple<String> currNext = currIterator.next();
int currFirstGuildId = Integer.valueOf(currNext.getValue());
int currFirstGuildId = Integer.parseInt(currNext.getValue());
if(currFirstGuildId==firstGuildId){
guildTotalRank.addRank(task.getGuildId(),"",task.getDamage());
}else{

View File

@ -1,11 +1,8 @@
package com.ljsd.jieling.logic.family;
import com.googlecode.protobuf.format.JsonFormat;
import com.ljsd.GameApplication;
import com.ljsd.fight.FightType;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
@ -33,13 +30,16 @@ import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.rank.RankEnum;
import com.ljsd.jieling.logic.rank.rankImpl.GuildBossRank;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.*;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.thread.ThreadManager;
import com.ljsd.jieling.thread.task.GuildFightMatchingTask;
import com.ljsd.jieling.util.*;
import config.SGuildLevelConfig;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.*;
import manager.STableManager;
import org.slf4j.Logger;

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Map;
public class FightEvent {
private String id;
private int attackUid;
private int teamId;
private int mostTime;
@ -50,10 +49,6 @@ public class FightEvent {
return frames;
}
public String getId() {
return id;
}
public List<Integer> getMonsterRemainHp() {
return monsterRemainHp;
}

View File

@ -610,37 +610,37 @@ public class ItemLogic {
public void especialEquipUpStar(ISession session, String heroId) throws Exception {
User user = UserManager.getUser(session.getUid());
Hero hero = user.getHeroManager().getHero(heroId);
if(hero==null){
if (hero == null) {
throw new ErrorCodeException(ErrorCode.newDefineCode("当前法宝不存在"));
}
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
if(scHero.getEquipTalismana()==null && hero.getStar()<scHero.getEquipTalismana()[0]){
if (scHero.getEquipTalismana() == null && hero.getStar() < scHero.getEquipTalismana()[0]) {
throw new ErrorCodeException(ErrorCode.newDefineCode("当前英雄无法升级法宝"));
}
int especialEquipId = scHero.getEquipTalismana()[1];
SEquipTalismana sEquipTalismana = SEquipTalismana.equipTalismanaStarMap.get(especialEquipId).get(hero.getEspecialEquipLevel());
if(sEquipTalismana!=null&&sEquipTalismana.getRankupBasicMaterial()==null){
if (sEquipTalismana == null || sEquipTalismana.getRankupBasicMaterial() == null) {
throw new ErrorCodeException(ErrorCode.newDefineCode("法宝已最大等级"));
}
boolean b = ItemUtil.itemCost(user, sEquipTalismana.getRankupBasicMaterial(), BIReason.ESPECIAL_EQUIP_UP_LEVEL_CONSUME, 1);
if(b){
hero.updateEspecial(hero.getEspecialEquipLevel()+1);
Poster.getPoster().dispatchEvent(new EspecialEquipUpEvent(user.getId(),especialEquipId, hero.getEspecialEquipLevel()));
user.getUserMissionManager().onGameEvent(user, GameEvent.ESPECIAL_EQUIP,hero.getEspecialEquipLevel(),heroId);
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE,null,true);
if(hero.getEspecialEquipLevel()>=SSpecialConfig.getIntegerValue(SSpecialConfig.lamp_rankup_equiptalisman_content_parm)){
if (b) {
hero.updateEspecial(hero.getEspecialEquipLevel() + 1);
Poster.getPoster().dispatchEvent(new EspecialEquipUpEvent(user.getId(), especialEquipId, hero.getEspecialEquipLevel()));
user.getUserMissionManager().onGameEvent(user, GameEvent.ESPECIAL_EQUIP, hero.getEspecialEquipLevel(), heroId);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE, null, true);
if (hero.getEspecialEquipLevel() >= SSpecialConfig.getIntegerValue(SSpecialConfig.lamp_rankup_equiptalisman_content_parm)) {
SItem sItem = SItem.getsItemMap().get(especialEquipId);
if(sItem.getQuantity()<5){
if (sItem.getQuantity() < 5) {
return;
}
String message = SErrorCodeEerverConfig.getI18NMessage("lamp_rankup_equiptalisman_content", new Object[]{user.getPlayerInfoManager().getNickName(), sItem.getName(),hero.getEspecialEquipLevel()});
ChatLogic.getInstance().sendSysChatMessage(message,Global.DILIGENT,sItem.getId(),0,0,0,0,0);
String message = SErrorCodeEerverConfig.getI18NMessage("lamp_rankup_equiptalisman_content", new Object[]{user.getPlayerInfoManager().getNickName(), sItem.getName(), hero.getEspecialEquipLevel()});
ChatLogic.getInstance().sendSysChatMessage(message, Global.DILIGENT, sItem.getId(), 0, 0, 0, 0, 0);
}
if(HeroLogic.getInstance().isInTeam(user,heroId,1)){
if (HeroLogic.getInstance().isInTeam(user, heroId, 1)) {
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(session.getUid()));
}
}else{
} else {
throw new ErrorCodeException(ErrorCode.ITEM_ESPECIAL_EQUIP_UP_ITEM_NOT);
}
}

View File

@ -79,8 +79,8 @@ public class QuestionLogic {
long time = System.currentTimeMillis() / 1000;
for (Map.Entry<Integer, CQuestionBean> entry : questionBeanMap.entrySet()) {
long start = Long.valueOf(entry.getValue().getStart());
long end = Long.valueOf(entry.getValue().getEnd());
long start = Long.parseLong(entry.getValue().getStart());
long end = Long.parseLong(entry.getValue().getEnd());
if (start > time) {
continue;
}
@ -115,7 +115,7 @@ public class QuestionLogic {
if (last.size() != 0) {
//开启
CQuestionBean cQuestionBean = last.first();
int qid = Integer.valueOf(cQuestionBean.getId());
int qid = Integer.parseInt(cQuestionBean.getId());
if (qid != globalSystemControl.getQuestId()) {
globalSystemControl.setQuestId(Integer.valueOf(cQuestionBean.getId()));
globalSystemControl.addQuestion(new Question(cQuestionBean.getId(), cQuestionBean.getQuestDes(), cQuestionBean.getReward(), cQuestionBean.getStart(), cQuestionBean.getEnd(), cQuestionBean.getcQuestionOptionBeans()));

View File

@ -109,7 +109,7 @@ public class BuyGoodsLogic {
int goodsId = 0;
SRechargeCommodityConfig sRechargeCommodityConfig;
if(isNumeric(sdkGoodsId)){
goodsId = Integer.valueOf(sdkGoodsId);
goodsId = Integer.parseInt(sdkGoodsId);
sRechargeCommodityConfig =SRechargeCommodityConfig.rechargeCommodityConfigMap.get(goodsId);
}else {
sRechargeCommodityConfig = SRechargeCommodityConfig.sdkRechargeCommodityConfigMap.get(sdkGoodsId);

View File

@ -174,7 +174,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
try {
String crowdnum = RedisUtil.getInstence().getMapValue(RedisKey.GLOBAL_SYS_PRO,"","onlinenum",String.class);
if(null!=crowdnum&&!crowdnum.equals("")){
Blocker.maxAllowedOnlineAccountCount.set(Integer.valueOf(crowdnum));
Blocker.maxAllowedOnlineAccountCount.set(Integer.parseInt(crowdnum));
}
}catch (Exception e){
}

View File

@ -296,7 +296,7 @@ public class FightDataUtil {
if (StringUtil.isEmpty(skillId)){
return skill;
}
SSkillLogicVo sSkillLogicVo = SSkillLogicConfig.getsSkillLogicVo(Integer.valueOf(skillId));
SSkillLogicVo sSkillLogicVo = SSkillLogicConfig.getsSkillLogicVo(Integer.parseInt(skillId));
if (sSkillLogicVo != null && sSkillLogicVo.getSkillTargetVoList().size()>0) {
// float cd = sSkillLogicVo.getCd();
// if(args!=null&&args.length>0){

View File

@ -360,7 +360,7 @@ public class ItemUtil {
String[] rewards= rewardStr.split("#");
String[] weights= weight.split("#");
for (int i = 0; i < rewards.length; i++) {
int rewardId = Integer.valueOf(rewards[i]);
int rewardId = Integer.parseInt(rewards[i]);
if (dropAddition.contains(rewardId)) {
int dropWeight = Integer.valueOf(weights[i]);
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(rewardId);

View File

@ -100,7 +100,7 @@ public class SSpecialConfig implements BaseConfig {
if (value == null) {
return -1;
}
return Integer.valueOf(value);
return Integer.parseInt(value);
}
public static int[] getOnceArrayValue(String key) {

View File

@ -229,7 +229,7 @@ public class STableManager {
try {
dealParams(clazz, map, key, type, obj, prarms);
}catch (Exception e){
System.out.println("clazz = [" + clazz + "], line = [" + line.substring(0,10) + "]"+prarms.toString() );
LOGGER.error("clazz = [" + clazz + "], line = [" + line.substring(0,10) + "]"+prarms.toString() );
throw e;
}
break;

View File

@ -35,7 +35,6 @@ public class ExcelUtils {
}
public static void genJavaFile(String fileName){
Map<String,String> fieldInfo = new HashMap<>();
File file = new File("conf/server/"+fileName +".txt");
StringBuffer stringBuffer = new StringBuffer("package config;\n" +
"\n" +