generated from root/miduo_server
修改跨服相关逻辑
parent
c0e8e00d0e
commit
1580d2adff
|
|
@ -2103,4 +2103,5 @@ public class TimeUtils {
|
||||||
return startOfWeek1.equals(startOfWeek2);
|
return startOfWeek1.equals(startOfWeek2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -13,6 +13,7 @@ import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||||
import com.ljsd.jieling.db.redis.RedisKey;
|
import com.ljsd.jieling.db.redis.RedisKey;
|
||||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
import com.ljsd.jieling.ktbeans.ReportUtil;
|
import com.ljsd.jieling.ktbeans.ReportUtil;
|
||||||
|
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||||
import com.ljsd.jieling.logic.dao.ServerConfig;
|
import com.ljsd.jieling.logic.dao.ServerConfig;
|
||||||
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
import com.ljsd.jieling.logic.dao.root.GlobalSystemControl;
|
||||||
import com.ljsd.jieling.logic.rankReward.RankRewardLogic;
|
import com.ljsd.jieling.logic.rankReward.RankRewardLogic;
|
||||||
|
|
@ -95,6 +96,8 @@ public class GameApplication {
|
||||||
new WorldServerListListener().start();
|
new WorldServerListListener().start();
|
||||||
new ReportUtil().start();
|
new ReportUtil().start();
|
||||||
NetManager.getInstance().init();
|
NetManager.getInstance().init();
|
||||||
|
//设置开服分组
|
||||||
|
GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
//控制台gm
|
//控制台gm
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
while (sc.hasNext()) {
|
while (sc.hasNext()) {
|
||||||
|
|
|
||||||
|
|
@ -476,7 +476,9 @@ public class RedisKey {
|
||||||
public static final String USER_SIMPLE_INFO = "USER_SIMPLE_INFO";
|
public static final String USER_SIMPLE_INFO = "USER_SIMPLE_INFO";
|
||||||
public static final String DEFTRAINING_RANK_MARK = "DEFTRAINING_RANK_MARK";
|
public static final String DEFTRAINING_RANK_MARK = "DEFTRAINING_RANK_MARK";
|
||||||
public static final String F5_PRE_REWARD = "F5_PRE_REWARD";//F5谷歌预注册奖励
|
public static final String F5_PRE_REWARD = "F5_PRE_REWARD";//F5谷歌预注册奖励
|
||||||
public static final String RANK_REWARD_SLAVE_SERVERS = "RANK_REWARD_SLAVE_SERVERS";//主服对应的从服服务器id集合,合并离线奖励用
|
public static final String RANK_REWARD_SLAVE_SERVERS = "RANK_REWARD_SLAVE_SERVERS";
|
||||||
|
public static final String CROSS_SERVER_GROUP = "CROSS_SERVER_GROUP";//
|
||||||
|
public static final String MAIL_REWARD_MARK = "MAIL_REWARD_MARK";// 邮件奖励
|
||||||
|
|
||||||
//public static Set<String> worldDeathPathCacChe = new HashSet<>();
|
//public static Set<String> worldDeathPathCacChe = new HashSet<>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1573,7 +1573,8 @@ public class RedisUtil {
|
||||||
||RedisKey.CROSS_ARENA_ROBOT_INFO.equals(type)||RedisKey.CROSS_SERVICE_ARENA.equals(type)
|
||RedisKey.CROSS_ARENA_ROBOT_INFO.equals(type)||RedisKey.CROSS_SERVICE_ARENA.equals(type)
|
||||||
||RedisKey.WORLD_ARENA_RANK_MY_MATH.equals(type)||RedisKey.WORLD_ARENA_MY_PRON.equals(type)
|
||RedisKey.WORLD_ARENA_RANK_MY_MATH.equals(type)||RedisKey.WORLD_ARENA_MY_PRON.equals(type)
|
||||||
||RedisKey.WORLD_ARENA_RRECORD.equals(type)||RedisKey.GLOBAL_DEATH_PATH_WORLD.equals(type)
|
||RedisKey.WORLD_ARENA_RRECORD.equals(type)||RedisKey.GLOBAL_DEATH_PATH_WORLD.equals(type)
|
||||||
||RedisKey.CUser_ServerId_Key.equals(type) || RedisKey.DEATH_PATH_STATUS.equals(type)) {
|
||RedisKey.CUser_ServerId_Key.equals(type) || RedisKey.DEATH_PATH_STATUS.equals(type)
|
||||||
|
||RedisKey.CROSS_SERVER_GROUP.equals(type)) {
|
||||||
return type + RedisKey.Delimiter_colon + key;
|
return type + RedisKey.Delimiter_colon + key;
|
||||||
}
|
}
|
||||||
// if(RedisKey.familyKey.contains(type)){
|
// if(RedisKey.familyKey.contains(type)){
|
||||||
|
|
@ -1715,4 +1716,42 @@ public class RedisUtil {
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <K,T> Map<K,T> getmapvaluekeyclass(String key, Class<K> keyClazz, Class<T> valueClazz){
|
||||||
|
Map<K,T> result = new HashMap<>();
|
||||||
|
Map<Object, Object> entries = redisTemplate.opsForHash().entries(key);
|
||||||
|
for(Map.Entry<Object,Object> item : entries.entrySet()){
|
||||||
|
Object key1 = item.getKey();
|
||||||
|
Object value = item.getValue();
|
||||||
|
result.put(gson.fromJson(gson.toJson(key1),keyClazz),gson.fromJson(value.toString(),valueClazz));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void putmap(String key, String mapKey, T value){
|
||||||
|
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().put(key,mapKey,gson.toJson(value));
|
||||||
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
TimeUtils.sleep(FAILED_SLEEP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定缓存失效时间
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param time 时间(毫秒)
|
||||||
|
*/
|
||||||
|
public void expireMills(String key, long time) {
|
||||||
|
try {
|
||||||
|
if (time > 0) {
|
||||||
|
redisTemplate.expire(key, time, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,17 @@ public class GetWorldArenaChallengeResponseHandler extends gtGBaseHandler<WorldP
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSplitInfo(int serverId) {
|
public int getSplitInfo(int serverId) {
|
||||||
Map<String, Integer> splitInfo = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
|
Integer group = RedisUtil.getInstence().getMapValue(RedisKey.SERVER_SPLIT_INFO,"", String.valueOf(serverId), Integer.class);
|
||||||
|
// 当本地无跨服id时,读取gm的跨服分组,开服用
|
||||||
return splitInfo.getOrDefault(String.valueOf(serverId), -1);
|
if (group == null){
|
||||||
|
Integer entry = RedisUtil.getInstence().getMapValue(RedisKey.CROSS_SERVER_GROUP, "", String.valueOf(serverId), Integer.class);
|
||||||
|
if (entry != null){
|
||||||
|
RedisUtil.getInstence().putMapEntry(RedisKey.SERVER_SPLIT_INFO, "", String.valueOf(serverId),entry);
|
||||||
|
group = entry;
|
||||||
|
}else {
|
||||||
|
group = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,61 +179,52 @@ public class GlobleSystemLogic implements IEventHandler {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//跨服竞技场服务器分组,跨服分组
|
public void doSplit(){
|
||||||
public void doSplit() {
|
LOGGER.info("跨服分组验证处理");
|
||||||
if (!GameApplication.serverProperties.isArenaCross()) {
|
if(!GameApplication.serverProperties.isArenaCross()){
|
||||||
|
LOGGER.error("跨服分组,测试服不做分组");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||||
Object matched = redisUtil.get(RedisKey.MATCHED_SPLIT_KEY);
|
Object matched = redisUtil.get(RedisKey.MATCHED_SPLIT_KEY);
|
||||||
if (matched != null) {
|
if(matched!=null){
|
||||||
|
LOGGER.error("跨服分组,获取key:【MATCHED_SPLIT_KEY】失败, info:{}", matched);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
|
||||||
//使用分布式锁,保证只有一个服来分组
|
//使用分布式锁,保证只有一个服来分组
|
||||||
boolean lock = redisUtil.lock("SERVER_SPLIT_REDIS_LOCK", TimeUtils.ONE_MINUTE * 2);
|
boolean lock = redisUtil.lock("SERVER_SPLIT_REDIS_LOCK", TimeUtils.ONE_MINUTE * 2);
|
||||||
if (!lock) {
|
if(!lock){
|
||||||
//没有拿到锁直接返回
|
//没有拿到锁直接返回
|
||||||
|
LOGGER.error("跨服分组,未获取到锁");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//这里为所有服务器的世界等级
|
|
||||||
Map<String, Integer> worldLevelMap = redisUtil.getMapValues(RedisKey.SERVER_WORLDLEVE_INFO, "", String.class, Integer.class);
|
|
||||||
LOGGER.info("跨服开始分组");
|
LOGGER.info("跨服开始分组");
|
||||||
|
// 周一零点时间戳,毫秒
|
||||||
long lastHour = TimeUtils.getLastOrUnderHour(TimeUtils.now(), 1, 0, 0, true);
|
long lastHour = TimeUtils.getLastOrUnderHour(TimeUtils.now(), 1, 0, 0, true);
|
||||||
lastHour += TimeUtils.WEEK;
|
// 加上七天,秒
|
||||||
int expireTime = (int) ((lastHour - TimeUtils.now()) / 1000);
|
lastHour = (lastHour + TimeUtils.WEEK)/1000;
|
||||||
redisUtil.set(RedisKey.MATCHED_SPLIT_KEY, String.valueOf(1), expireTime - 60);
|
// 当前时间
|
||||||
|
long expireTime = lastHour-TimeUtils.nowInt();
|
||||||
|
redisUtil.set(RedisKey.MATCHED_SPLIT_KEY,String.valueOf(1),expireTime-60);
|
||||||
//提前两分钟结算
|
//提前两分钟结算
|
||||||
redisUtil.set(RedisKey.MATCHED_VERSION, TimeUtils.getTimeStampYMD(System.currentTimeMillis()), expireTime - 120);
|
redisUtil.set(RedisKey.MATCHED_VERSION,TimeUtils.getTimeStampYMD(System.currentTimeMillis()),expireTime-120);
|
||||||
worldLevelMap.forEach((k, v) -> {
|
// 分组逻辑
|
||||||
if (v > setting.getWorldLevel()) {
|
Map<String, Integer> cross = redisUtil.getMapValues(RedisKey.CROSS_SERVER_GROUP, "", String.class, Integer.class);
|
||||||
redisUtil.zsetAddOne(RedisKey.SERVER_LEVEL_RANK, k, v);
|
Map<String, Integer> split = new HashMap<>();
|
||||||
|
// 遍历gm分组,剔除所有分组id小于等于0的分组,这些默认不跨服
|
||||||
|
for (Map.Entry<String, Integer> entry : cross.entrySet()) {
|
||||||
|
if (entry.getValue()<=0){
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
});
|
split.put(entry.getKey(),entry.getValue());
|
||||||
Set<ZSetOperations.TypedTuple<String>> zsetRevRangeWithScore = redisUtil.getZsetreverseRangeByRangeWithScores(RedisKey.SERVER_LEVEL_RANK, setting.getWorldLevel(), 999);
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
int areaId = 1;
|
|
||||||
Map<String, Integer> split = new HashMap<>(zsetRevRangeWithScore.size());
|
|
||||||
for (ZSetOperations.TypedTuple<String> data : zsetRevRangeWithScore) {
|
|
||||||
if (index >= setting.getServerNum()) {
|
|
||||||
if ((zsetRevRangeWithScore.size() - areaId * setting.getServerNum()) > setting.getServerNum() / 2) {
|
|
||||||
areaId++;
|
|
||||||
}
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
split.put(data.getValue(), areaId);
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
redisUtil.putMapEntrys(RedisKey.SERVER_SPLIT_INFO, "", split);
|
// 删除上期分组数据,并赋值新分组数据
|
||||||
//发分组邮件
|
redisUtil.remove(RedisKey.SERVER_SPLIT_INFO+RedisKey.Delimiter_colon);
|
||||||
split.keySet().forEach(server -> redisUtil.putMapEntry(RedisKey.SERVER_SPLIT_MAIL_INFO, "", server, 0));
|
redisUtil.putMapEntrys(RedisKey.SERVER_SPLIT_INFO,"",split);
|
||||||
|
|
||||||
//释放分布式锁
|
//释放分布式锁
|
||||||
redisUtil.del("SERVER_SPLIT_REDIS_LOCK");
|
redisUtil.del("SERVER_SPLIT_REDIS_LOCK");
|
||||||
LOGGER.info("跨服分组结束");
|
LOGGER.info("跨服分组结束");
|
||||||
// splitInfo = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO,"",String.class,Integer.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取当前区服的跨服区组 -1为未在分组内
|
//获取当前区服的跨服区组 -1为未在分组内
|
||||||
|
|
@ -244,9 +235,16 @@ public class GlobleSystemLogic implements IEventHandler {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Integer group = RedisUtil.getInstence().getMapValue(RedisKey.SERVER_SPLIT_INFO,"", String.valueOf(GameApplication.serverId), Integer.class);
|
Integer group = RedisUtil.getInstence().getMapValue(RedisKey.SERVER_SPLIT_INFO,"", String.valueOf(GameApplication.serverId), Integer.class);
|
||||||
// Map<String,Integer> groups = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
|
// 当本地无跨服id时,读取gm的跨服分组,开服用
|
||||||
// Integer group = groups.get(String.valueOf(GameApplication.serverId));
|
if (group == null){
|
||||||
// Integer group = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class).get(String.valueOf(GameApplication.serverId));
|
Integer entry = RedisUtil.getInstence().getMapValue(RedisKey.CROSS_SERVER_GROUP, "", String.valueOf(GameApplication.serverId), Integer.class);
|
||||||
|
if (entry != null){
|
||||||
|
RedisUtil.getInstence().putMapEntry(RedisKey.SERVER_SPLIT_INFO, "", String.valueOf(GameApplication.serverId),entry);
|
||||||
|
group = entry;
|
||||||
|
}else {
|
||||||
|
group = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
LOGGER.info("GameApplication.serverId={},group={}",GameApplication.serverId,group);
|
LOGGER.info("GameApplication.serverId={},group={}",GameApplication.serverId,group);
|
||||||
crossGroup = group == null ? -1 : group;
|
crossGroup = group == null ? -1 : group;
|
||||||
|
|
||||||
|
|
@ -264,7 +262,6 @@ public class GlobleSystemLogic implements IEventHandler {
|
||||||
Integer group = RedisUtil.getInstence().getMapValues(RedisKey.DeathPath_SERVER_SPLIT_INFO, String.class, Integer.class).get(String.valueOf(GameApplication.serverId));
|
Integer group = RedisUtil.getInstence().getMapValues(RedisKey.DeathPath_SERVER_SPLIT_INFO, String.class, Integer.class).get(String.valueOf(GameApplication.serverId));
|
||||||
LOGGER.info("GameApplication.serverId={},group={}",GameApplication.serverId,group);
|
LOGGER.info("GameApplication.serverId={},group={}",GameApplication.serverId,group);
|
||||||
crossGroup = group == null ? -1 : group;
|
crossGroup = group == null ? -1 : group;
|
||||||
|
|
||||||
return crossGroup;
|
return crossGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import com.ljsd.jieling.globals.BIReason;
|
||||||
import com.ljsd.jieling.globals.Global;
|
import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||||
|
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.dao.*;
|
import com.ljsd.jieling.logic.dao.*;
|
||||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||||
|
|
@ -802,6 +803,48 @@ public class ArenaLogic {
|
||||||
|
|
||||||
//跨服竞技场结算 (跨服竞技场活动结束排行结算)(跨服竞技场邮件)
|
//跨服竞技场结算 (跨服竞技场活动结束排行结算)(跨服竞技场邮件)
|
||||||
public void worldSendReward() {
|
public void worldSendReward() {
|
||||||
|
// TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.World_Arena);
|
||||||
|
//
|
||||||
|
// if (null == timeControllerOfFunction) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// long diff = (System.currentTimeMillis() - timeControllerOfFunction.getStartTime()) / 1000;
|
||||||
|
//
|
||||||
|
// SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||||
|
//
|
||||||
|
// TreeMap<Integer, SSkyLadderReward> rewardMapByRank = SSkyLadderReward.rewardMapByRank;
|
||||||
|
// if (setting == null) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (diff >= setting.getBattleTime()[1] && diff < setting.getBattleTime()[1] + 50) {
|
||||||
|
// int myGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
|
// if (myGroup == 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// WorldProto.GetArenaRankRewardResponse response = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.GetArenaRankRewardRequest.newBuilder().setGroupId(myGroup).build(), WorldProto.GetArenaRankRewardResponse.class);
|
||||||
|
// if (response == null || response.getRankInfoList().size() == 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// for (WorldProto.ArenaRank rank : response.getRankInfoList()) {
|
||||||
|
// int myRank = rank.getRank();
|
||||||
|
// //sendmail
|
||||||
|
// String title = SErrorCodeEerverConfig.getI18NMessage("SkyLadder_title");
|
||||||
|
// List<String> content = SErrorCodeEerverConfig.getI18NMessageNew("SkyLadder_txt", new Object[]{myRank});
|
||||||
|
//
|
||||||
|
// Map.Entry<Integer, SSkyLadderReward> entry = rewardMapByRank.floorEntry(myRank);
|
||||||
|
// String mailReward = ItemUtil.getMailReward(entry.getValue().getRankAwards());
|
||||||
|
// MailLogic.getInstance().sendMail(rank.getUid(), title, content, mailReward, TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||||
|
// //MailLogic.getInstance().sendMail(rank.getUid(), "跨服竞技场奖励", "跨服竞技场奖励", StringUtil.parseArrayToString(entry.getValue().getRankAwards()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// LOGGER.error("world arena reward error", e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void worldSendRewardNew() {
|
||||||
TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.World_Arena);
|
TimeControllerOfFunction timeControllerOfFunction = GlobalDataManaager.getInstance().getTimeControllerOfFunctionByFunctinoType(FunctionIdEnum.World_Arena);
|
||||||
|
|
||||||
if (null == timeControllerOfFunction) {
|
if (null == timeControllerOfFunction) {
|
||||||
|
|
@ -816,10 +859,19 @@ public class ArenaLogic {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (diff >= setting.getBattleTime()[1] && diff < setting.getBattleTime()[1] + 50) {
|
if (diff >= setting.getBattleTime()[1] && diff < setting.getBattleTime()[1] + 50) {
|
||||||
int myGroup = WorldHelper.getGroupByServerId();
|
int myGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
if (myGroup == 0) {
|
if (myGroup <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
long start = TimeUtils.now();
|
||||||
|
//分布式锁,保证一个组只有一个服进行初始化
|
||||||
|
String lockKey = "CROSS_ARENA_SEND_REWARD_LOCK:" + myGroup;
|
||||||
|
boolean lock = RedisUtil.getInstence().lock(lockKey, TimeUtils.ONE_HOUR);
|
||||||
|
if (!lock) {
|
||||||
|
LOGGER.error("跨服天梯发奖退出, 未获取到锁!耗时:{} ms, 当前时间:{}", TimeUtils.now() - start, TimeUtils.getTimeStamp(TimeUtils.now()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOGGER.info("跨服天梯,开始发奖。。。");
|
||||||
try {
|
try {
|
||||||
WorldProto.GetArenaRankRewardResponse response = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.GetArenaRankRewardRequest.newBuilder().setGroupId(myGroup).build(), WorldProto.GetArenaRankRewardResponse.class);
|
WorldProto.GetArenaRankRewardResponse response = WorldHelper.sendMessageToWorldWithResult(0, WorldProto.GetArenaRankRewardRequest.newBuilder().setGroupId(myGroup).build(), WorldProto.GetArenaRankRewardResponse.class);
|
||||||
if (response == null || response.getRankInfoList().size() == 0) {
|
if (response == null || response.getRankInfoList().size() == 0) {
|
||||||
|
|
@ -833,7 +885,7 @@ public class ArenaLogic {
|
||||||
|
|
||||||
Map.Entry<Integer, SSkyLadderReward> entry = rewardMapByRank.floorEntry(myRank);
|
Map.Entry<Integer, SSkyLadderReward> entry = rewardMapByRank.floorEntry(myRank);
|
||||||
String mailReward = ItemUtil.getMailReward(entry.getValue().getRankAwards());
|
String mailReward = ItemUtil.getMailReward(entry.getValue().getRankAwards());
|
||||||
MailLogic.getInstance().sendMail(rank.getUid(), title, content, mailReward, TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
MailLogic.getInstance().sendMailToRedis(rank.getUid(), title, content.get(0), mailReward, TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||||
//MailLogic.getInstance().sendMail(rank.getUid(), "跨服竞技场奖励", "跨服竞技场奖励", StringUtil.parseArrayToString(entry.getValue().getRankAwards()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
//MailLogic.getInstance().sendMail(rank.getUid(), "跨服竞技场奖励", "跨服竞技场奖励", StringUtil.parseArrayToString(entry.getValue().getRankAwards()), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class ArenaWorldLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close() throws Exception {
|
public static void close() throws Exception {
|
||||||
int myGroup = WorldHelper.getGroupByServerId();
|
int myGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
if(myGroup==0){
|
if(myGroup==0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +124,7 @@ public class ArenaWorldLogic {
|
||||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||||
SGlobalSystemConfig globalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(84);
|
SGlobalSystemConfig globalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(84);
|
||||||
|
|
||||||
int worldLevel = GlobleSystemLogic.getGloableWorldLeveCache(); //世界等级
|
int worldLevel = 0; //取消世界等级限制,这里设置999肯定大于配置的世界等级需求
|
||||||
boolean unLock = false; //true解锁,false未解锁
|
boolean unLock = false; //true解锁,false未解锁
|
||||||
|
|
||||||
int level = user.getPlayerInfoManager().getLevel(); //玩家等级
|
int level = user.getPlayerInfoManager().getLevel(); //玩家等级
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class MailManager extends MongoBase {
|
||||||
return mailMap;
|
return mailMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMail(Mail mail) throws Exception {
|
public void addMail(Mail mail){
|
||||||
mail.init(mail.getRoleUid(), getMongoKey() + ".mailMap." + mail.getId());
|
mail.init(mail.getRoleUid(), getMongoKey() + ".mailMap." + mail.getId());
|
||||||
updateString("mailMap." + mail.getId(), mail);
|
updateString("mailMap." + mail.getId(), mail);
|
||||||
mailMap.put(mail.getId(), mail);
|
mailMap.put(mail.getId(), mail);
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@ public class DeathPathLogic {
|
||||||
|
|
||||||
//跨服公会战 是否解锁 true解锁,false未解锁
|
//跨服公会战 是否解锁 true解锁,false未解锁
|
||||||
private boolean isUnlock = false;
|
private boolean isUnlock = false;
|
||||||
|
//上次请求跨服公会战是否解锁的时间
|
||||||
|
private long isUnlockTime = 0;
|
||||||
|
|
||||||
//private BlockingQueue<DeathPathTask> tasks = new BlockingUniqueQueue<>();
|
//private BlockingQueue<DeathPathTask> tasks = new BlockingUniqueQueue<>();
|
||||||
private LinkedBlockingQueue<DeathPathTask> tasks = new LinkedBlockingQueue<>();
|
private LinkedBlockingQueue<DeathPathTask> tasks = new LinkedBlockingQueue<>();
|
||||||
|
|
@ -106,6 +108,11 @@ public class DeathPathLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnlock() {
|
public boolean isUnlock() {
|
||||||
|
long now = TimeUtils.now();
|
||||||
|
//1秒内多次请求取内存缓存
|
||||||
|
if( now - isUnlockTime < 1000 * 2) {
|
||||||
|
return this.isUnlock;
|
||||||
|
}
|
||||||
String redisKey = RedisKey.getKey(RedisKey.GLOBAL_DEATH_PATH_WORLD, RedisKey.DEATH_PATH_WORLD_UNLOCK, true);
|
String redisKey = RedisKey.getKey(RedisKey.GLOBAL_DEATH_PATH_WORLD, RedisKey.DEATH_PATH_WORLD_UNLOCK, true);
|
||||||
String unlock = (String) RedisUtil.getInstence().get(redisKey);
|
String unlock = (String) RedisUtil.getInstence().get(redisKey);
|
||||||
boolean curIsReached;
|
boolean curIsReached;
|
||||||
|
|
@ -115,9 +122,13 @@ public class DeathPathLogic {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
if (unlock != null && unlock.equals("true") && curIsReached) {
|
if (unlock != null && unlock.equals("true") && curIsReached) {
|
||||||
return true;
|
this.isUnlock = true;
|
||||||
|
this.isUnlockTime = now;
|
||||||
|
return this.isUnlock;
|
||||||
}
|
}
|
||||||
return false;
|
this.isUnlock =false;
|
||||||
|
this.isUnlockTime = now;
|
||||||
|
return this.isUnlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -525,7 +536,8 @@ public class DeathPathLogic {
|
||||||
|
|
||||||
//当前阵公会伤害 挑战之前 第一的guildId
|
//当前阵公会伤害 挑战之前 第一的guildId
|
||||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScoresBefore;
|
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScoresBefore;
|
||||||
if(isUnlock()) { //跨服
|
boolean isUnlock = isUnlock();
|
||||||
|
if(isUnlock) { //跨服
|
||||||
zSetReverseRangeWithScoresBefore = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + groupId() + ":" + RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(pathId), 0, -1);
|
zSetReverseRangeWithScoresBefore = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + groupId() + ":" + RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(pathId), 0, -1);
|
||||||
}else { //单服
|
}else { //单服
|
||||||
AbstractRank guildRankBefore = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
AbstractRank guildRankBefore = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||||
|
|
@ -565,7 +577,7 @@ public class DeathPathLogic {
|
||||||
FightRecordLogic.getInstance().addRecordMap(user,fightData);
|
FightRecordLogic.getInstance().addRecordMap(user,fightData);
|
||||||
|
|
||||||
//更新排行榜数据
|
//更新排行榜数据
|
||||||
tasks.offer(new DeathPathTask(uid, guildId, damage, pathId,groupId(),isUnlock()));
|
tasks.offer(new DeathPathTask(uid, guildId, damage, pathId,groupId(),isUnlock));
|
||||||
//挑战次数记录
|
//挑战次数记录
|
||||||
RedisUtil.getInstence().increment(RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT,String.valueOf(uid),false)); //挑战次数
|
RedisUtil.getInstence().increment(RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT,String.valueOf(uid),false)); //挑战次数
|
||||||
|
|
||||||
|
|
@ -852,7 +864,8 @@ public class DeathPathLogic {
|
||||||
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType());
|
||||||
|
|
||||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores;
|
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores;
|
||||||
if(isUnlock()){
|
boolean isUnlock = isUnlock();
|
||||||
|
if(isUnlock){
|
||||||
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||||
}else{
|
}else{
|
||||||
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||||
|
|
@ -872,7 +885,7 @@ public class DeathPathLogic {
|
||||||
firstGuildId = Integer.valueOf(next.getValue());
|
firstGuildId = Integer.valueOf(next.getValue());
|
||||||
doRankAdd(personRank,guildRank,task);
|
doRankAdd(personRank,guildRank,task);
|
||||||
Set<ZSetOperations.TypedTuple<String>> currScores;
|
Set<ZSetOperations.TypedTuple<String>> currScores;
|
||||||
if(isUnlock()){
|
if(isUnlock){
|
||||||
currScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
currScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||||
}else{
|
}else{
|
||||||
currScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
currScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(guildRank.getRedisKey(), String.valueOf(task.getPathId()), 0, 0);
|
||||||
|
|
@ -941,7 +954,8 @@ public class DeathPathLogic {
|
||||||
|
|
||||||
int guildRank = getGuildRankByGuildId(guildId);
|
int guildRank = getGuildRankByGuildId(guildId);
|
||||||
List<SGuildWarRewardBOX> list = null;
|
List<SGuildWarRewardBOX> list = null;
|
||||||
if (isUnlock()) { //跨服
|
boolean isUnlock = isUnlock();
|
||||||
|
if (isUnlock) { //跨服
|
||||||
list = SGuildWarRewardBOX.worldGuildWarRewardBoxMap.get(guildRank);
|
list = SGuildWarRewardBOX.worldGuildWarRewardBoxMap.get(guildRank);
|
||||||
} else { //单服
|
} else { //单服
|
||||||
list = SGuildWarRewardBOX.guildWarRewardBoxMap.get(guildRank);
|
list = SGuildWarRewardBOX.guildWarRewardBoxMap.get(guildRank);
|
||||||
|
|
@ -950,7 +964,7 @@ public class DeathPathLogic {
|
||||||
//SGuildWarRewardBOX表里有当前排行数据
|
//SGuildWarRewardBOX表里有当前排行数据
|
||||||
if (list != null && list.size() > 0) {
|
if (list != null && list.size() > 0) {
|
||||||
Map<String, DeathReward> rewardBoxMap;
|
Map<String, DeathReward> rewardBoxMap;
|
||||||
if (isUnlock()) { //跨服
|
if (isUnlock) { //跨服
|
||||||
rewardBoxMap = RedisUtil.getInstence().getMapValuesWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD,groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名 DEATH_PATH_REWARD_BOX=战果宝箱记录
|
rewardBoxMap = RedisUtil.getInstence().getMapValuesWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD,groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名 DEATH_PATH_REWARD_BOX=战果宝箱记录
|
||||||
} else { //单服
|
} else { //单服
|
||||||
rewardBoxMap = RedisUtil.getInstence().getMapValues(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名 DEATH_PATH_REWARD_BOX=战果宝箱记录
|
rewardBoxMap = RedisUtil.getInstence().getMapValues(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名 DEATH_PATH_REWARD_BOX=战果宝箱记录
|
||||||
|
|
@ -1000,7 +1014,7 @@ public class DeathPathLogic {
|
||||||
position++;
|
position++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUnlock()) { //跨服
|
if (isUnlock) { //跨服
|
||||||
RedisUtil.getInstence().putMapEntrys(RedisKey.GLOBAL_DEATH_PATH_WORLD, groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), rewardBoxMap);
|
RedisUtil.getInstence().putMapEntrys(RedisKey.GLOBAL_DEATH_PATH_WORLD, groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), rewardBoxMap);
|
||||||
} else { //单服
|
} else { //单服
|
||||||
RedisUtil.getInstence().putMapEntrys(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), rewardBoxMap);
|
RedisUtil.getInstence().putMapEntrys(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), rewardBoxMap);
|
||||||
|
|
@ -1044,8 +1058,9 @@ public class DeathPathLogic {
|
||||||
int itemId = 0;
|
int itemId = 0;
|
||||||
int itemCount = 0;
|
int itemCount = 0;
|
||||||
int[][] itemArray;
|
int[][] itemArray;
|
||||||
|
boolean isUnlock = isUnlock();
|
||||||
try {
|
try {
|
||||||
if (isUnlock()) { //跨服
|
if (isUnlock) { //跨服
|
||||||
rewardBoxMap = RedisUtil.getInstence().getMapValuesWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD,groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名
|
rewardBoxMap = RedisUtil.getInstence().getMapValuesWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD,groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名
|
||||||
} else { //单服
|
} else { //单服
|
||||||
rewardBoxMap = RedisUtil.getInstence().getMapValues(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名
|
rewardBoxMap = RedisUtil.getInstence().getMapValues(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), String.class, DeathReward.class); //kei= 公会排名
|
||||||
|
|
@ -1092,8 +1107,7 @@ public class DeathPathLogic {
|
||||||
deathReward.setItemCount(itemCount);
|
deathReward.setItemCount(itemCount);
|
||||||
|
|
||||||
rewardBoxMap.put(String.valueOf(position), deathReward);
|
rewardBoxMap.put(String.valueOf(position), deathReward);
|
||||||
|
if(isUnlock){ //跨服
|
||||||
if(isUnlock()){ //跨服
|
|
||||||
RedisUtil.getInstence().putMapEntrys(RedisKey.GLOBAL_DEATH_PATH_WORLD,groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), rewardBoxMap);
|
RedisUtil.getInstence().putMapEntrys(RedisKey.GLOBAL_DEATH_PATH_WORLD,groupId() + ":" + RedisKey.DEATH_PATH_REWARD_BOX + ":" + String.valueOf(guildRank), rewardBoxMap);
|
||||||
}else { //单服
|
}else { //单服
|
||||||
RedisUtil.getInstence().putMapEntrys(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), rewardBoxMap);
|
RedisUtil.getInstence().putMapEntrys(RedisKey.DEATH_PATH_REWARD_BOX, String.valueOf(guildRank), rewardBoxMap);
|
||||||
|
|
@ -1264,12 +1278,12 @@ public class DeathPathLogic {
|
||||||
//公会战活动结束,结算发邮件
|
//公会战活动结束,结算发邮件
|
||||||
public void activityEndEmailReward() throws Exception {
|
public void activityEndEmailReward() throws Exception {
|
||||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||||
|
boolean isUnlock = isUnlock();
|
||||||
boolean haveGuildRank = false;
|
boolean haveGuildRank = false;
|
||||||
for (int i = 1; i <= 10; i++) {
|
for (int i = 1; i <= 10; i++) {
|
||||||
AbstractRank everyGuildRank = null;
|
AbstractRank everyGuildRank = null;
|
||||||
Set<ZSetOperations.TypedTuple<String>> guildRankSet = null;
|
Set<ZSetOperations.TypedTuple<String>> guildRankSet = null;
|
||||||
if (isUnlock()) {
|
if (isUnlock) {
|
||||||
guildRankSet = redisUtil.getZsetreverseRangeWithScoresWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + groupId() + ":" + RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(i), 0, -1);
|
guildRankSet = redisUtil.getZsetreverseRangeWithScoresWorld(RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + groupId() + ":" + RedisKey.DEATH_PATH_EVERY_GUILD_RANK, String.valueOf(i), 0, -1);
|
||||||
} else {
|
} else {
|
||||||
everyGuildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
everyGuildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType());
|
||||||
|
|
@ -1310,7 +1324,7 @@ public class DeathPathLogic {
|
||||||
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType()); //玩家总伤害 排行
|
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType()); //玩家总伤害 排行
|
||||||
Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet;
|
Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet;
|
||||||
Set<ZSetOperations.TypedTuple<String>> personRankSet;
|
Set<ZSetOperations.TypedTuple<String>> personRankSet;
|
||||||
if(isUnlock()){
|
if(isUnlock){
|
||||||
guildTotalRankSet = guildTotalRank.getRankByKeyWorld("", 0, -1);
|
guildTotalRankSet = guildTotalRank.getRankByKeyWorld("", 0, -1);
|
||||||
personRankSet = personRank.getRankByKeyWorld("", 0, -1);
|
personRankSet = personRank.getRankByKeyWorld("", 0, -1);
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -1492,12 +1506,12 @@ public class DeathPathLogic {
|
||||||
*/
|
*/
|
||||||
public List<Map.Entry<Integer, Integer>> getDeathPathFirstRank(){
|
public List<Map.Entry<Integer, Integer>> getDeathPathFirstRank(){
|
||||||
Map<Integer, Integer> guildFirstNumMap = new TreeMap<>(); //十绝阵: Map<公会ID,占领公会个数> 占领:当前阵公会伤害排行第一
|
Map<Integer, Integer> guildFirstNumMap = new TreeMap<>(); //十绝阵: Map<公会ID,占领公会个数> 占领:当前阵公会伤害排行第一
|
||||||
|
boolean isUnlock = isUnlock();
|
||||||
AbstractRank everyGuildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType()); //当前阵公会伤害 排行
|
AbstractRank everyGuildRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getType()); //当前阵公会伤害 排行
|
||||||
for(int i=1;i<=10;i++) {
|
for(int i=1;i<=10;i++) {
|
||||||
String redisKey = null;
|
String redisKey = null;
|
||||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores;
|
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores;
|
||||||
if(isUnlock()){ //跨服
|
if(isUnlock){ //跨服
|
||||||
redisKey = RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + groupId() + ":" + everyGuildRank.getRedisKey();
|
redisKey = RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + groupId() + ":" + everyGuildRank.getRedisKey();
|
||||||
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(redisKey, String.valueOf(i), 0, -1);
|
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(redisKey, String.valueOf(i), 0, -1);
|
||||||
}else { //单服
|
}else { //单服
|
||||||
|
|
@ -1534,7 +1548,7 @@ public class DeathPathLogic {
|
||||||
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType()); //公会总伤害 排行
|
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType()); //公会总伤害 排行
|
||||||
//Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
//Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
||||||
Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet; //获取 公会总伤害排行
|
Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet; //获取 公会总伤害排行
|
||||||
if(isUnlock()){
|
if(isUnlock){
|
||||||
guildTotalRankSet = guildTotalRank.getRankByKeyWorld("", 0, -1); //获取 公会总伤害排行
|
guildTotalRankSet = guildTotalRank.getRankByKeyWorld("", 0, -1); //获取 公会总伤害排行
|
||||||
}else{
|
}else{
|
||||||
guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
||||||
|
|
@ -1869,7 +1883,8 @@ public class DeathPathLogic {
|
||||||
public static void getDeathPathTotalPersonRank(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
public static void getDeathPathTotalPersonRank(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||||
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType()); //玩家总伤害 排行
|
AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType()); //玩家总伤害 排行
|
||||||
Set<ZSetOperations.TypedTuple<String>> personRankSet = null;
|
Set<ZSetOperations.TypedTuple<String>> personRankSet = null;
|
||||||
if(DeathPathLogic.getInstance().isUnlock()){
|
boolean isUnlock = getInstance().isUnlock();
|
||||||
|
if(isUnlock){
|
||||||
int groupId = DeathPathLogic.getInstance().groupId();
|
int groupId = DeathPathLogic.getInstance().groupId();
|
||||||
personRankSet = personRank.getRankByKeyWorld("", 0, -1);
|
personRankSet = personRank.getRankByKeyWorld("", 0, -1);
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -1885,7 +1900,7 @@ public class DeathPathLogic {
|
||||||
int uid = Integer.parseInt(value);
|
int uid = Integer.parseInt(value);
|
||||||
long score = item.getScore().longValue();
|
long score = item.getScore().longValue();
|
||||||
|
|
||||||
if(getInstance().isUnlock()){ //跨服
|
if(isUnlock){ //跨服
|
||||||
String userName = null;
|
String userName = null;
|
||||||
int head = 0;
|
int head = 0;
|
||||||
int headFrame = 0;
|
int headFrame = 0;
|
||||||
|
|
@ -1989,12 +2004,12 @@ public class DeathPathLogic {
|
||||||
int rank = 1;
|
int rank = 1;
|
||||||
List<Family.DeathPathCurGuildCountRankInfo> rankInfoList = new ArrayList<>();
|
List<Family.DeathPathCurGuildCountRankInfo> rankInfoList = new ArrayList<>();
|
||||||
List<Map.Entry<Integer, Integer>> deathPathFirstNumRank = getDeathPathFirstRank();
|
List<Map.Entry<Integer, Integer>> deathPathFirstNumRank = getDeathPathFirstRank();
|
||||||
|
boolean isUnlock = getInstance().isUnlock();
|
||||||
//获取公会总伤害 排行
|
//获取公会总伤害 排行
|
||||||
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType()); //公会总伤害 排行
|
AbstractRank guildTotalRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_GUILD_RANK.getType()); //公会总伤害 排行
|
||||||
//Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
//Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
||||||
Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet; //获取 公会总伤害排行
|
Set<ZSetOperations.TypedTuple<String>> guildTotalRankSet; //获取 公会总伤害排行
|
||||||
if(getInstance().isUnlock()){
|
if(isUnlock){
|
||||||
guildTotalRankSet = guildTotalRank.getRankByKeyWorld("", 0, -1); //获取 公会总伤害排行
|
guildTotalRankSet = guildTotalRank.getRankByKeyWorld("", 0, -1); //获取 公会总伤害排行
|
||||||
}else {
|
}else {
|
||||||
guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
guildTotalRankSet = guildTotalRank.getRankByKey("", 0, -1); //获取 公会总伤害排行
|
||||||
|
|
@ -2016,7 +2031,7 @@ public class DeathPathLogic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getInstance().isUnlock()){ //跨服
|
if(isUnlock){ //跨服
|
||||||
//GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
//GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||||
//获取会长名
|
//获取会长名
|
||||||
//Set<Integer> chairMan = guildInfo.getMembers().get(GlobalsDef.CHAIRMAN);
|
//Set<Integer> chairMan = guildInfo.getMembers().get(GlobalsDef.CHAIRMAN);
|
||||||
|
|
@ -2128,12 +2143,12 @@ public class DeathPathLogic {
|
||||||
|
|
||||||
//公会战当前阵玩家伤害排行
|
//公会战当前阵玩家伤害排行
|
||||||
public static void getDeathPathCurPersonRank(ISession session,int pathId,int type, MessageTypeProto.MessageType messageType) throws Exception {
|
public static void getDeathPathCurPersonRank(ISession session,int pathId,int type, MessageTypeProto.MessageType messageType) throws Exception {
|
||||||
|
boolean isUnlock = getInstance().isUnlock();
|
||||||
//当前阵:1=个人排行,2=公会排行,3=本会排行
|
//当前阵:1=个人排行,2=公会排行,3=本会排行
|
||||||
if(type == 1){ //当前阵:1=个人排行
|
if(type == 1){ //当前阵:1=个人排行
|
||||||
// AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType()); //当前阵玩家伤害排行
|
// AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType()); //当前阵玩家伤害排行
|
||||||
AbstractRank personRank;
|
AbstractRank personRank;
|
||||||
if(getInstance().isUnlock()){
|
if(isUnlock){
|
||||||
personRank = RankContext.getRankEnum(RankEnum.WORLD_DEATH_PATH_EVERY_PERSON_RANK.getType()); //当前阵玩家伤害排行
|
personRank = RankContext.getRankEnum(RankEnum.WORLD_DEATH_PATH_EVERY_PERSON_RANK.getType()); //当前阵玩家伤害排行
|
||||||
// personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType()); //当前阵玩家伤害排行
|
// personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getType()); //当前阵玩家伤害排行
|
||||||
}else {
|
}else {
|
||||||
|
|
@ -2145,7 +2160,7 @@ public class DeathPathLogic {
|
||||||
}
|
}
|
||||||
//String redisKey = null;
|
//String redisKey = null;
|
||||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = null;
|
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores = null;
|
||||||
if(getInstance().isUnlock()){ //跨服
|
if(isUnlock){ //跨服
|
||||||
String keyType = RedisKey.GLOBAL_DEATH_PATH_WORLD + ":"+ getInstance().groupId() +":"+ personRank.getRedisKey();
|
String keyType = RedisKey.GLOBAL_DEATH_PATH_WORLD + ":"+ getInstance().groupId() +":"+ personRank.getRedisKey();
|
||||||
//redisKey = RedisKey.getKey(keyType,String.valueOf(i),true);
|
//redisKey = RedisKey.getKey(keyType,String.valueOf(i),true);
|
||||||
//redisKey = RedisKey.getKey(keyType,"",true);
|
//redisKey = RedisKey.getKey(keyType,"",true);
|
||||||
|
|
@ -2167,7 +2182,7 @@ public class DeathPathLogic {
|
||||||
int uid = Integer.parseInt(value);
|
int uid = Integer.parseInt(value);
|
||||||
long score = item.getScore().longValue();
|
long score = item.getScore().longValue();
|
||||||
|
|
||||||
if (getInstance().isUnlock()) { //跨服
|
if (isUnlock) { //跨服
|
||||||
String userName = "";
|
String userName = "";
|
||||||
int head = 0;
|
int head = 0;
|
||||||
int headFrame = 0;
|
int headFrame = 0;
|
||||||
|
|
@ -2235,7 +2250,7 @@ public class DeathPathLogic {
|
||||||
|
|
||||||
String redisKey = null;
|
String redisKey = null;
|
||||||
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores;
|
Set<ZSetOperations.TypedTuple<String>> zSetReverseRangeWithScores;
|
||||||
if (getInstance().isUnlock()) { //跨服
|
if (isUnlock) { //跨服
|
||||||
// redisKey = getInstance().groupId +":"+ guildRank.getRedisKey();
|
// redisKey = getInstance().groupId +":"+ guildRank.getRedisKey();
|
||||||
redisKey = RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + getInstance().groupId() + ":" + guildRank.getRedisKey();
|
redisKey = RedisKey.GLOBAL_DEATH_PATH_WORLD + ":" + getInstance().groupId() + ":" + guildRank.getRedisKey();
|
||||||
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(redisKey, String.valueOf(i), 0, -1);
|
zSetReverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScoresWorld(redisKey, String.valueOf(i), 0, -1);
|
||||||
|
|
@ -2253,7 +2268,7 @@ public class DeathPathLogic {
|
||||||
int guildId = Integer.parseInt(item.getValue());
|
int guildId = Integer.parseInt(item.getValue());
|
||||||
long score = item.getScore().longValue();
|
long score = item.getScore().longValue();
|
||||||
|
|
||||||
if (getInstance().isUnlock()) { //跨服
|
if (isUnlock) { //跨服
|
||||||
GuildInfoCache guildInfoCache = getCrossGuild(guildId);
|
GuildInfoCache guildInfoCache = getCrossGuild(guildId);
|
||||||
if (guildInfoCache != null) {
|
if (guildInfoCache != null) {
|
||||||
int chairmanUserId = guildInfoCache.getChairmanUserId();
|
int chairmanUserId = guildInfoCache.getChairmanUserId();
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,46 @@ public class MailLogic {
|
||||||
sendSystemMail(title, new ArrayList<>(), content, sendTime, reward, mailEffectiveTime, "system", TimeUtils.now(), "0");
|
sendSystemMail(title, new ArrayList<>(), content, sendTime, reward, mailEffectiveTime, "system", TimeUtils.now(), "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件
|
||||||
|
*/
|
||||||
|
public void sendMail(Mail mail){
|
||||||
|
int roleUid = mail.getRoleUid();
|
||||||
|
User user = UserManager.getUser(roleUid);
|
||||||
|
if (user != null){
|
||||||
|
user.getMailManager().addMail(mail);
|
||||||
|
LOGGER.info("领取redis标记的邮件==>uid={},mail={}",roleUid, mail);
|
||||||
|
MessageUtil.sendRedIndication(roleUid, GlobalsDef.MAIL_RED_TYPE);
|
||||||
|
}else {
|
||||||
|
LOGGER.error("用户为空,error sendMail==>uid={},mail={}",roleUid,mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getMailToRedis(int uid){
|
||||||
|
String key = RedisKey.MAIL_REWARD_MARK + RedisKey.Delimiter_colon + uid;
|
||||||
|
Map<String, Mail> mailMap = RedisUtil.getInstence().getmapvaluekeyclass(key, String.class, Mail.class);
|
||||||
|
if (mailMap == null || mailMap.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Mail mail : mailMap.values()) {
|
||||||
|
sendMail(mail);
|
||||||
|
}
|
||||||
|
RedisUtil.getInstence().del(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送邮件到redis
|
||||||
|
*/
|
||||||
|
public void sendMailToRedis(int uid, String title, String content, String reward, int sendTime, int mailEffectiveTime){
|
||||||
|
Mail mail = new Mail(uid,title,content,reward,sendTime, mailEffectiveTime,"system",Global.MAIL_TYPE_SYS);
|
||||||
|
String key = RedisKey.MAIL_REWARD_MARK + RedisKey.Delimiter_colon + uid;
|
||||||
|
String timeKey = String.valueOf(TimeUtils.now());
|
||||||
|
RedisUtil.getInstence().putmap(key,timeKey,mail);
|
||||||
|
// 有新邮件就增加10天的有效时间
|
||||||
|
RedisUtil.getInstence().expireMills(key, TimeUtils.ONE_DAY * 10);
|
||||||
|
LOGGER.info("redis邮件标记:key:{}, time:{}, mail:{}",key,timeKey,mail);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*每分钟检测是否有需要发的邮件
|
*每分钟检测是否有需要发的邮件
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
import com.ljsd.jieling.exception.ErrorCode;
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
import com.ljsd.jieling.globals.BIReason;
|
import com.ljsd.jieling.globals.BIReason;
|
||||||
|
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||||
import com.ljsd.jieling.logic.dao.PlayerInfoCache;
|
import com.ljsd.jieling.logic.dao.PlayerInfoCache;
|
||||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
|
|
@ -86,7 +87,7 @@ public class RankLogic {
|
||||||
AbstractRank rank = RankContext.getRankEnum(type);
|
AbstractRank rank = RankContext.getRankEnum(type);
|
||||||
if (RankContext.isCrossRank(type)) {
|
if (RankContext.isCrossRank(type)) {
|
||||||
//跨服
|
//跨服
|
||||||
int myGroup = WorldHelper.getGroupByServerId();
|
int myGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||||
|
|
||||||
int protoId = session.getUid();
|
int protoId = session.getUid();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,13 @@ public class WorldHelper extends GlobalProtocolsManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每周执行有一次分组
|
* 每周执行有一次分组
|
||||||
* 每个星期从redis取一次就可以
|
* 每天从redis取一次就可以
|
||||||
* 获取服务器分组
|
* 获取服务器分组
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static int getGroupByServerId() {
|
public static int getGroupByServerId() {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if(splitInfo == null || !TimeUtils.isSameWeek222(System.currentTimeMillis(), lastGetTime)) {
|
if(splitInfo == null || !TimeUtils.isSameDay(System.currentTimeMillis(), lastGetTime)) {
|
||||||
splitInfo = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class,Integer.class);
|
splitInfo = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class,Integer.class);
|
||||||
lastGetTime = now;
|
lastGetTime = now;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.ljsd.jieling.db.redis.RedisKey;
|
||||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
import com.ljsd.jieling.handler.map.MapLogic;
|
import com.ljsd.jieling.handler.map.MapLogic;
|
||||||
import com.ljsd.jieling.logic.DefTraining.DefTrainingLogic;
|
import com.ljsd.jieling.logic.DefTraining.DefTrainingLogic;
|
||||||
|
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.SituationLogic;
|
import com.ljsd.jieling.logic.SituationLogic;
|
||||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||||
|
|
@ -35,6 +36,8 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分钟定时器
|
* 分钟定时器
|
||||||
*/
|
*/
|
||||||
|
|
@ -86,6 +89,8 @@ public class MinuteTask extends Thread {
|
||||||
try {
|
try {
|
||||||
//计算世界等级
|
//计算世界等级
|
||||||
ActivityLogic.getInstance().checkSecretBoxSeason();
|
ActivityLogic.getInstance().checkSecretBoxSeason();
|
||||||
|
//跨服分组
|
||||||
|
everyMondayZeroClockTask();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Exception::5=>{}", e.toString());
|
LOGGER.error("Exception::5=>{}", e.toString());
|
||||||
}
|
}
|
||||||
|
|
@ -112,6 +117,7 @@ public class MinuteTask extends Thread {
|
||||||
GuildFightLogic.familyFightStatus(); //修改公会战状态分钟定时器
|
GuildFightLogic.familyFightStatus(); //修改公会战状态分钟定时器
|
||||||
QuestionLogic.getInstence().checkQuestion();
|
QuestionLogic.getInstence().checkQuestion();
|
||||||
MailLogic.getInstance().checkReadyToMail();
|
MailLogic.getInstance().checkReadyToMail();
|
||||||
|
everySundaySpecialClockTask();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
LOGGER.error("Exception::13=>{}", e.toString());
|
LOGGER.error("Exception::13=>{}", e.toString());
|
||||||
|
|
@ -169,6 +175,33 @@ public class MinuteTask extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//每周一凌晨0点执行
|
||||||
|
public void everyMondayZeroClockTask() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
|
int minute = calendar.get(Calendar.MINUTE);
|
||||||
|
int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
|
|
||||||
|
if (w == 1 && hour == 0 && minute == 0) {
|
||||||
|
LOGGER.info("everyMondayZeroClockTask start ...");
|
||||||
|
GlobleSystemLogic.getInstence().doSplit();
|
||||||
|
LOGGER.info("everyMondayZeroClockTask end ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void everySundaySpecialClockTask() {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
|
int minute = calendar.get(Calendar.MINUTE);
|
||||||
|
int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||||
|
if (w == 0 && hour == 23 && minute == 0) {
|
||||||
|
LOGGER.info("everySundaySpecialClockTask worldArena send reward start ...");
|
||||||
|
//九州每周日23.00分执行
|
||||||
|
ArenaLogic.getInstance().worldSendRewardNew();
|
||||||
|
LOGGER.info("everySundaySpecialClockTask worldArena send reward end ...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不用每分钟创建一个线程然后销毁
|
* 不用每分钟创建一个线程然后销毁
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ public class MessageUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sendRedIndication(int sendUid, int redType) throws Exception {
|
public static void sendRedIndication(int sendUid, int redType) {
|
||||||
ISession session = OnlineUserManager.sessionMap.get(sendUid);
|
ISession session = OnlineUserManager.sessionMap.get(sendUid);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
PlayerInfoProto.RedPointInfo redPointInfo = PlayerInfoProto.RedPointInfo.newBuilder().setType(redType).build();
|
PlayerInfoProto.RedPointInfo redPointInfo = PlayerInfoProto.RedPointInfo.newBuilder().setType(redType).build();
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ public class WorldArenaRewardJobHandler {
|
||||||
public void arenaDailyRewardJobHandler() throws Exception {
|
public void arenaDailyRewardJobHandler() throws Exception {
|
||||||
|
|
||||||
XxlJobHelper.log("worldArenaRewardJob start....");
|
XxlJobHelper.log("worldArenaRewardJob start....");
|
||||||
ArenaLogic.getInstance().worldSendReward();
|
// ArenaLogic.getInstance().worldSendReward();
|
||||||
MongoUtil.getInstence().lastUpdate();
|
// MongoUtil.getInstence().lastUpdate();
|
||||||
XxlJobHelper.log("worldArenaRewardJob end....");
|
XxlJobHelper.log("worldArenaRewardJob end....");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ public class GetArenaRankRewardRequestHandler extends gtGBaseHandler<WorldProto
|
||||||
}
|
}
|
||||||
Map<Integer, ArenaEnemy> rankMap = ArenaLogic.ranInfo.get(proto.getGroupId());
|
Map<Integer, ArenaEnemy> rankMap = ArenaLogic.ranInfo.get(proto.getGroupId());
|
||||||
for(Map.Entry<Integer, ArenaEnemy> entry:rankMap.entrySet()){
|
for(Map.Entry<Integer, ArenaEnemy> entry:rankMap.entrySet()){
|
||||||
if(entry.getValue().getServerID()!=serverId){
|
// if(entry.getValue().getServerID()!=serverId){
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
response.addRankInfo(WorldProto.ArenaRank.newBuilder().setRank(entry.getKey()).setUid(entry.getValue().getEnemyId()).build());
|
response.addRankInfo(WorldProto.ArenaRank.newBuilder().setRank(entry.getKey()).setUid(entry.getValue().getEnemyId()).build());
|
||||||
}
|
}
|
||||||
return response.build();
|
return response.build();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.world.logic;
|
package com.world.logic;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.jieling.db.redis.RedisKey;
|
import com.ljsd.jieling.db.redis.RedisKey;
|
||||||
import com.world.redis.RedisUtil;
|
import com.world.redis.RedisUtil;
|
||||||
import config.SGuildWarSetting;
|
import config.SGuildWarSetting;
|
||||||
|
|
@ -47,38 +48,51 @@ public class GlobalLogic {
|
||||||
* 分组
|
* 分组
|
||||||
*/
|
*/
|
||||||
public void doSplit() {
|
public void doSplit() {
|
||||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
LOGGER.info("跨服分组验证处理");
|
||||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
if(!GameApplication.serverProperties.isArenaCross()){
|
||||||
//这里为所有服务器的世界等级
|
LOGGER.error("跨服分组,测试服不做分组");
|
||||||
Map<String,Integer> worldLevelMap = redisUtil.getMapValues(RedisKey.SERVER_WORLDLEVE_INFO+":",String.class,Integer.class);
|
return;
|
||||||
|
}
|
||||||
|
com.ljsd.jieling.db.redis.RedisUtil redisUtil = com.ljsd.jieling.db.redis.RedisUtil.getInstence();
|
||||||
|
Object matched = redisUtil.get(RedisKey.MATCHED_SPLIT_KEY);
|
||||||
|
if(matched!=null){
|
||||||
|
LOGGER.error("跨服分组,获取key:【MATCHED_SPLIT_KEY】失败, info:{}", matched);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//使用分布式锁,保证只有一个服来分组
|
||||||
|
boolean lock = redisUtil.lock("SERVER_SPLIT_REDIS_LOCK", TimeUtils.ONE_MINUTE * 2);
|
||||||
|
if(!lock){
|
||||||
|
//没有拿到锁直接返回
|
||||||
|
LOGGER.error("跨服分组,未获取到锁");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.info("Global跨服竞技场 开始分组");
|
LOGGER.info("跨服开始分组");
|
||||||
|
// 周一零点时间戳,毫秒
|
||||||
long lastHour = TimeUtils.getLastOrUnderHour(TimeUtils.now(), 1, 0, 0, true);
|
long lastHour = TimeUtils.getLastOrUnderHour(TimeUtils.now(), 1, 0, 0, true);
|
||||||
lastHour+=(1*TimeUtils.WEEK);
|
// 加上七天,秒
|
||||||
int expireTime =(int)((lastHour-TimeUtils.now())/1000);
|
lastHour = (lastHour + TimeUtils.WEEK)/1000;
|
||||||
|
// 当前时间
|
||||||
|
long expireTime = lastHour-TimeUtils.nowInt();
|
||||||
|
redisUtil.set(RedisKey.MATCHED_SPLIT_KEY,String.valueOf(1),expireTime-60);
|
||||||
//提前两分钟结算
|
//提前两分钟结算
|
||||||
redisUtil.set(RedisKey.MATCHED_VERSION,TimeUtils.getTimeStampYMD(System.currentTimeMillis()),expireTime-120);
|
redisUtil.set(RedisKey.MATCHED_VERSION,TimeUtils.getTimeStampYMD(System.currentTimeMillis()),expireTime-120);
|
||||||
worldLevelMap.forEach((k,v)->redisUtil.zsetAddOne(RedisKey.SERVER_LEVEL_RANK,k,v));
|
// 分组逻辑
|
||||||
Set<ZSetOperations.TypedTuple<String>> zsetRevRangeWithScore = redisUtil.getZsetRevRangeWithScore(RedisKey.SERVER_LEVEL_RANK, setting.getWorldLevel(), 999);
|
Map<String, Integer> cross = redisUtil.getMapValues(RedisKey.CROSS_SERVER_GROUP, "", String.class, Integer.class);
|
||||||
|
Map<String, Integer> split = new HashMap<>();
|
||||||
int index = 0;
|
// 遍历gm分组,剔除所有分组id小于等于0的分组,这些默认不跨服
|
||||||
int areaId = 1;
|
for (Map.Entry<String, Integer> entry : cross.entrySet()) {
|
||||||
Map<String,Integer> split = new HashMap<>(zsetRevRangeWithScore.size());
|
if (entry.getValue()<=0){
|
||||||
for(ZSetOperations.TypedTuple<String> data:zsetRevRangeWithScore){
|
continue;
|
||||||
if(index>=setting.getServerNum()){
|
|
||||||
if((zsetRevRangeWithScore.size()-areaId*setting.getServerNum())>setting.getServerNum()/2){
|
|
||||||
areaId++;
|
|
||||||
}
|
|
||||||
index=0;
|
|
||||||
}
|
}
|
||||||
split.put(data.getValue(),areaId);
|
split.put(entry.getKey(),entry.getValue());
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
redisUtil.putMapEntrys(RedisKey.SERVER_SPLIT_INFO,split);
|
// 删除上期分组数据,并赋值新分组数据
|
||||||
LOGGER.info("Global跨服竞技场 分组结束");
|
redisUtil.remove(RedisKey.SERVER_SPLIT_INFO+RedisKey.Delimiter_colon);
|
||||||
splitInfo = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO,String.class,Integer.class);
|
redisUtil.putMapEntrys(RedisKey.SERVER_SPLIT_INFO,"",split);
|
||||||
|
//释放分布式锁
|
||||||
|
redisUtil.del("SERVER_SPLIT_REDIS_LOCK");
|
||||||
|
LOGGER.info("跨服分组结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSplitInfo(int serverId) {
|
public int getSplitInfo(int serverId) {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import manager.STableManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.core.Cursor;
|
import org.springframework.data.redis.core.Cursor;
|
||||||
|
import util.TimeUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -61,7 +62,7 @@ public class ArenaLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getAndUpdateAllServerGroup(){
|
public List<Integer> getAndUpdateAllServerGroup(){
|
||||||
Map<String, Integer> newServerSplit = RedisUtil.getInstence().getMapValues(com.world.redis.RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
|
Map<String, Integer> newServerSplit = RedisUtil.getInstence().getMapValues(com.world.redis.RedisKey.SERVER_SPLIT_INFO+RedisKey.Delimiter_colon, String.class, Integer.class);
|
||||||
ArenaLogic.serverSplit = newServerSplit;
|
ArenaLogic.serverSplit = newServerSplit;
|
||||||
return new ArrayList<>(serverSplit.values().stream().distinct().collect(Collectors.toList()));
|
return new ArrayList<>(serverSplit.values().stream().distinct().collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +96,7 @@ public class ArenaLogic {
|
||||||
|
|
||||||
public static void initRank() throws Exception {
|
public static void initRank() throws Exception {
|
||||||
|
|
||||||
Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
|
Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO+RedisKey.Delimiter_colon, String.class, Integer.class);
|
||||||
serverSplit.forEach((s, integer) -> {
|
serverSplit.forEach((s, integer) -> {
|
||||||
HashSet<String> strings = map.getOrDefault(integer, new HashSet<>());
|
HashSet<String> strings = map.getOrDefault(integer, new HashSet<>());
|
||||||
strings.add(s);
|
strings.add(s);
|
||||||
|
|
@ -126,7 +127,6 @@ public class ArenaLogic {
|
||||||
//跨服竞技场开启调用:初始化数据
|
//跨服竞技场开启调用:初始化数据
|
||||||
public void arenaWorldOpen() {
|
public void arenaWorldOpen() {
|
||||||
|
|
||||||
// if (TimeUtils.getDayOfWeek(time) == 5 && TimeUtils.getHourOfDay(time) == 23 && TimeUtils.getMiunte(time) == 30) {
|
|
||||||
LOGGER.info("跨服竞技场 进入新的一期");
|
LOGGER.info("跨服竞技场 进入新的一期");
|
||||||
onfinish();
|
onfinish();
|
||||||
LOGGER.info("-------onfinish---------");
|
LOGGER.info("-------onfinish---------");
|
||||||
|
|
@ -136,7 +136,7 @@ public class ArenaLogic {
|
||||||
//重新获取分组信息
|
//重新获取分组信息
|
||||||
// redisUtil.set(RedisKey.MATCHED_MY_VERSION, matched);
|
// redisUtil.set(RedisKey.MATCHED_MY_VERSION, matched);
|
||||||
|
|
||||||
Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, String.class, Integer.class);
|
Map<String, Integer> serverSplit = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO+RedisKey.Delimiter_colon, String.class, Integer.class);
|
||||||
serverSplit.forEach((s, integer) -> {
|
serverSplit.forEach((s, integer) -> {
|
||||||
HashSet<String> strings = map.getOrDefault(integer, new HashSet<>());
|
HashSet<String> strings = map.getOrDefault(integer, new HashSet<>());
|
||||||
strings.add(s);
|
strings.add(s);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.world.logic.arean.ArenaLogic;
|
||||||
import org.apache.dubbo.common.utils.NetUtils;
|
import org.apache.dubbo.common.utils.NetUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import util.TimeUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author: zsx
|
* Author: zsx
|
||||||
|
|
@ -27,6 +28,12 @@ public class MinuteTask extends Thread {
|
||||||
ArenaLogic.getInstance().minCheckSave();
|
ArenaLogic.getInstance().minCheckSave();
|
||||||
//每分钟检测服务器是否注册
|
//每分钟检测服务器是否注册
|
||||||
serverRegister2ZkCheck();
|
serverRegister2ZkCheck();
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
int w = TimeUtils.getWeekOfYear(time) - 1;
|
||||||
|
//每周五23:30开启跨服竞技场
|
||||||
|
if (w == 5 && TimeUtils.getHourOfDay(time) == 23 && TimeUtils.getMiunte(time) == 30) {
|
||||||
|
ArenaLogic.getInstance().arenaWorldOpen();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("e",e);
|
LOGGER.error("e",e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public class ArenaLogicCrossServerFightJobHandler {
|
||||||
public void arenaLogicCrossServerFightJob() throws Exception {
|
public void arenaLogicCrossServerFightJob() throws Exception {
|
||||||
|
|
||||||
XxlJobHelper.log("arenaLogicCrossServerFightJob start....");
|
XxlJobHelper.log("arenaLogicCrossServerFightJob start....");
|
||||||
ArenaLogic.getInstance().arenaWorldOpen();
|
// ArenaLogic.getInstance().arenaWorldOpen();
|
||||||
XxlJobHelper.log("arenaLogicCrossServerFightJob end....");
|
XxlJobHelper.log("arenaLogicCrossServerFightJob end....");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,9 @@ import org.springframework.stereotype.Component;
|
||||||
public class EveryMondayZeroDoSplitHandler {
|
public class EveryMondayZeroDoSplitHandler {
|
||||||
@XxlJob("globalArenaDoSplitJobHandler")
|
@XxlJob("globalArenaDoSplitJobHandler")
|
||||||
public void serverSplitJob() throws Exception {
|
public void serverSplitJob() throws Exception {
|
||||||
|
//弃用,xxljob的方法全部弃用
|
||||||
XxlJobHelper.log("serverSplitJob start....");
|
XxlJobHelper.log("serverSplitJob start....");
|
||||||
GlobalLogic.getInstance().doSplit();
|
// GlobalLogic.getInstance().doSplit();
|
||||||
XxlJobHelper.log("serverSplitJob end....");
|
XxlJobHelper.log("serverSplitJob end....");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue