Merge branch 'dh_dev' into master_test_gn
commit
59f9bf9f70
|
@ -13,17 +13,19 @@ import com.ljsd.jieling.logic.activity.event.UserForceChangeEvent;
|
||||||
import com.ljsd.jieling.logic.activity.eventhandler.UserForceUpEventHandler;
|
import com.ljsd.jieling.logic.activity.eventhandler.UserForceUpEventHandler;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.fight.FightRecordLogic;
|
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.thrift.idl.InvalidOperException;
|
import com.ljsd.jieling.thrift.idl.InvalidOperException;
|
||||||
import com.ljsd.jieling.thrift.idl.RPCRequestGMIFace;
|
import com.ljsd.jieling.thrift.idl.RPCRequestGMIFace;
|
||||||
import com.ljsd.jieling.thrift.idl.Result;
|
import com.ljsd.jieling.thrift.idl.Result;
|
||||||
import com.ljsd.jieling.util.*;
|
import com.ljsd.jieling.util.InnerMessageUtil;
|
||||||
import org.apache.thrift.TException;
|
import org.apache.thrift.TException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
import java.util.*;
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class GmService implements RPCRequestGMIFace.Iface {
|
public class GmService implements RPCRequestGMIFace.Iface {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GmService.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(GmService.class);
|
||||||
|
@ -52,7 +54,6 @@ public class GmService implements RPCRequestGMIFace.Iface {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String[] parameters = java.util.Arrays.copyOfRange(arg, 1, arg.length);
|
String[] parameters = java.util.Arrays.copyOfRange(arg, 1, arg.length);
|
||||||
String[] parameters2;
|
|
||||||
// 用户相关性
|
// 用户相关性
|
||||||
if (obj instanceof GmRoleAbstract) {
|
if (obj instanceof GmRoleAbstract) {
|
||||||
List<Integer> sendIds = new LinkedList<>();
|
List<Integer> sendIds = new LinkedList<>();
|
||||||
|
@ -102,12 +103,12 @@ public class GmService implements RPCRequestGMIFace.Iface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int randomTime = sendIds.size();
|
int randomTime = sendIds.size();
|
||||||
parameters2 = java.util.Arrays.copyOfRange(parameters, 1, parameters.length);
|
String[] value = java.util.Arrays.copyOfRange(parameters, 1, parameters.length);
|
||||||
|
|
||||||
//两分钟内发完所有协议
|
//两分钟内发完所有协议
|
||||||
InnerMessageUtil.broadcastWithRandom( user->{
|
InnerMessageUtil.broadcastWithRandom( user->{
|
||||||
((GmRoleAbstract) obj).setUser(user);
|
((GmRoleAbstract) obj).setUser(user);
|
||||||
obj.exec(parameters2);
|
obj.exec(value);
|
||||||
}, sendIds, Math.min(randomTime, 10));
|
}, sendIds, Math.min(randomTime, 10));
|
||||||
}
|
}
|
||||||
// 用户无关性
|
// 用户无关性
|
||||||
|
|
|
@ -16,24 +16,21 @@ import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||||
import com.ljsd.jieling.logic.dao.FriendManager;
|
import com.ljsd.jieling.logic.dao.FriendManager;
|
||||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
|
||||||
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;
|
||||||
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
|
import com.ljsd.jieling.logic.dao.gm.ArenaOfUser;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import rpc.protocols.ChatProto;
|
|
||||||
import rpc.protocols.MessageTypeProto;
|
|
||||||
import com.ljsd.jieling.util.CBean2Proto;
|
import com.ljsd.jieling.util.CBean2Proto;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
import com.ljsd.jieling.util.SensitivewordFilter;
|
import com.ljsd.jieling.util.SensitivewordFilter;
|
||||||
import com.ljsd.jieling.util.ShieldedWordUtils;
|
import com.ljsd.jieling.util.ShieldedWordUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import rpc.protocols.ChatProto;
|
||||||
|
import rpc.protocols.MessageTypeProto;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -136,14 +133,14 @@ public class ChatLogic {
|
||||||
String unSymbolWord = ShieldedWordUtils.replaceUnword(message);
|
String unSymbolWord = ShieldedWordUtils.replaceUnword(message);
|
||||||
String tmp = SensitivewordFilter.replaceSensitiveWord(unSymbolWord, 1, "*");
|
String tmp = SensitivewordFilter.replaceSensitiveWord(unSymbolWord, 1, "*");
|
||||||
|
|
||||||
|
|
||||||
boolean silence = false;
|
boolean silence = false;
|
||||||
if(playerInfoManager.getSilence() == 1 || playerInfoManager.getSkyEyeBanTime()>System.currentTimeMillis()){
|
if(playerInfoManager.getSilence() == 1 || playerInfoManager.getSkyEyeBanTime() > TimeUtils.now()){
|
||||||
silence = true;
|
silence = true;
|
||||||
}else{
|
}else{
|
||||||
MessageUtil.sendSkyEyeMsg(message,user,friendId,chatType);
|
MessageUtil.sendSkyEyeMsg(message,user,friendId,chatType);
|
||||||
}
|
}
|
||||||
if(tmp.contains("*") && !tmp.equals(message)||silence){
|
boolean bol = tmp.contains("*") && !tmp.equals(message) || silence;
|
||||||
|
if(bol){
|
||||||
char[] chars = message.toCharArray();
|
char[] chars = message.toCharArray();
|
||||||
char[] original = unSymbolWord.toCharArray();
|
char[] original = unSymbolWord.toCharArray();
|
||||||
char[] tmpChar = tmp.toCharArray();
|
char[] tmpChar = tmp.toCharArray();
|
||||||
|
|
|
@ -176,6 +176,8 @@ public enum ErrorCode implements IErrorCode {
|
||||||
CROSS_YXLD_OVER(145,"赛季结算中"),
|
CROSS_YXLD_OVER(145,"赛季结算中"),
|
||||||
RIDING_SWARD_BET_TWO(146,"一轮比赛最多押注两次!"),
|
RIDING_SWARD_BET_TWO(146,"一轮比赛最多押注两次!"),
|
||||||
PRACTICE_LEVE_DOWN(147,"修行等级不足"),
|
PRACTICE_LEVE_DOWN(147,"修行等级不足"),
|
||||||
|
|
||||||
|
GUILD_NOT_AUTHORITY(300,"账号因错误发言导致相关功能封禁中,操作失败"),
|
||||||
;
|
;
|
||||||
private static final Set<Integer> CodeSet = new HashSet<>();
|
private static final Set<Integer> CodeSet = new HashSet<>();
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,64 @@
|
||||||
package com.ljsd.jieling.kefu;
|
package com.ljsd.jieling.kefu;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||||
|
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import config.SGuildSetting;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
public class Cmd_skyeye extends GmRoleAbstract {
|
public class Cmd_skyeye extends GmRoleAbstract {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天眼禁言封禁
|
||||||
|
*/
|
||||||
|
public static final int SKYEYE_BAN = 7;
|
||||||
|
/**
|
||||||
|
* 天眼禁言解禁
|
||||||
|
*/
|
||||||
|
public static final int CANCEL_SKYEYE_BAN = 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置公会名称
|
||||||
|
*/
|
||||||
|
public static final int RESET_GUILD_NAME = 9;
|
||||||
|
/**
|
||||||
|
* 重置公会公告
|
||||||
|
*/
|
||||||
|
public static final int RESET_GUILD_ANNOUNCEMENT = 10;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exec(String[] args) throws Exception {
|
public boolean exec(String[] args) throws Exception {
|
||||||
User user = getUser();
|
User user = getUser();
|
||||||
int min = Integer.valueOf(args[0]);
|
PlayerManager playerManager = user.getPlayerInfoManager();
|
||||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
|
||||||
//设置禁言
|
// 默认封禁
|
||||||
playerInfoManager.setSkyEyeBanTime(System.currentTimeMillis()+ min * TimeUtils.ONE_MINUTE);
|
int time = Integer.valueOf(args[1]);
|
||||||
|
playerManager.setSkyEyeBanTime(System.currentTimeMillis() + time * TimeUtils.ONE_MINUTE);
|
||||||
|
|
||||||
|
int type = Integer.parseInt(args[0]);
|
||||||
|
// 获取公会信息
|
||||||
|
GuildInfo guildInfo = null;
|
||||||
|
if (type == RESET_GUILD_NAME || type == RESET_GUILD_ANNOUNCEMENT){
|
||||||
|
guildInfo = GuilidManager.guildInfoMap.get(Integer.parseInt(args[2]));
|
||||||
|
}
|
||||||
|
if (guildInfo == null){
|
||||||
|
LOGGER.error("天眼,修改公会名称报错,找不到公会:{}",args[1]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type){
|
||||||
|
case RESET_GUILD_NAME:
|
||||||
|
//修改公会名称
|
||||||
|
guildInfo.setName(playerManager.getNickName()+"的公会");
|
||||||
|
break;
|
||||||
|
case RESET_GUILD_ANNOUNCEMENT:
|
||||||
|
//修改公会公告
|
||||||
|
guildInfo.setAnnounce(SGuildSetting.sGuildSetting.getDefaultDeclaration());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,6 @@ public class UserManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User getUserNotCache(int uid) {
|
public static User getUserNotCache(int uid) {
|
||||||
// User user = userMap.get(uid);
|
|
||||||
try {
|
try {
|
||||||
User user = userMap.get(uid);
|
User user = userMap.get(uid);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
|
@ -14,7 +14,10 @@ import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.ktbeans.ReportEventEnum;
|
import com.ljsd.jieling.ktbeans.ReportEventEnum;
|
||||||
import com.ljsd.jieling.ktbeans.ReportUtil;
|
import com.ljsd.jieling.ktbeans.ReportUtil;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.activity.event.*;
|
import com.ljsd.jieling.logic.activity.event.CommitSheJiEvent;
|
||||||
|
import com.ljsd.jieling.logic.activity.event.GuildForceChangeEvent;
|
||||||
|
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||||
|
import com.ljsd.jieling.logic.activity.event.UserMainTeamForceEvent;
|
||||||
import com.ljsd.jieling.logic.dao.*;
|
import com.ljsd.jieling.logic.dao.*;
|
||||||
import com.ljsd.jieling.logic.dao.root.*;
|
import com.ljsd.jieling.logic.dao.root.*;
|
||||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||||
|
@ -28,15 +31,15 @@ import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType;
|
||||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import rpc.protocols.CommonProto;
|
|
||||||
import rpc.protocols.Family;
|
|
||||||
import rpc.protocols.MessageTypeProto;
|
|
||||||
import rpc.protocols.PlayerInfoProto;
|
|
||||||
import com.ljsd.jieling.util.*;
|
import com.ljsd.jieling.util.*;
|
||||||
import config.*;
|
import config.*;
|
||||||
import manager.STableManager;
|
import manager.STableManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import rpc.protocols.CommonProto;
|
||||||
|
import rpc.protocols.Family;
|
||||||
|
import rpc.protocols.MessageTypeProto;
|
||||||
|
import rpc.protocols.PlayerInfoProto;
|
||||||
import util.StringUtil;
|
import util.StringUtil;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
|
@ -173,13 +176,21 @@ public class GuildLogic {
|
||||||
if(user.getPlayerInfoManager().getGuildId()!=0){
|
if(user.getPlayerInfoManager().getGuildId()!=0){
|
||||||
throw new ErrorCodeException(ErrorCode.FAMILY_IN);
|
throw new ErrorCodeException(ErrorCode.FAMILY_IN);
|
||||||
}
|
}
|
||||||
|
if (user.getPlayerInfoManager().getSkyEyeBanTime() > TimeUtils.now()){
|
||||||
|
throw new ErrorCodeException(ErrorCode.GUILD_NOT_AUTHORITY);
|
||||||
|
}
|
||||||
if(StringUtil.isEmpty(announce)){
|
if(StringUtil.isEmpty(announce)){
|
||||||
announce= SGuildSetting.sGuildSetting.getDefaultDeclaration();
|
announce= SGuildSetting.sGuildSetting.getDefaultDeclaration();
|
||||||
}
|
}
|
||||||
if(announce.length()==0||announce.length()>32){
|
if(announce.length()==0||announce.length()>32){
|
||||||
throw new ErrorCodeException(ErrorCode.ANNOUNCE_SIZE);
|
throw new ErrorCodeException(ErrorCode.ANNOUNCE_SIZE);
|
||||||
}
|
}
|
||||||
|
// 创建公会
|
||||||
GuildInfo guildInfo = new GuildInfo(user.getId(),familyName,announce);
|
GuildInfo guildInfo = new GuildInfo(user.getId(),familyName,announce);
|
||||||
|
// 天眼查询
|
||||||
|
MessageUtil.sendSkyEyeMsgByGuild(familyName,user,MessageUtil.skyeye_guildName,guildInfo.getId());
|
||||||
|
MessageUtil.sendSkyEyeMsgByGuild(announce,user,MessageUtil.skyeye_guildAnnounce,guildInfo.getId());
|
||||||
|
|
||||||
GuilidManager.addGuildInfo(guildInfo);
|
GuilidManager.addGuildInfo(guildInfo);
|
||||||
user.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
user.getPlayerInfoManager().setGuildId(guildInfo.getId());
|
||||||
addGuildLog(guildInfo.getId(),GuildDef.Log.CREATE,user.getPlayerInfoManager().getNickName());
|
addGuildLog(guildInfo.getId(),GuildDef.Log.CREATE,user.getPlayerInfoManager().getNickName());
|
||||||
|
@ -815,11 +826,16 @@ public class GuildLogic {
|
||||||
if(resultCode==0){
|
if(resultCode==0){
|
||||||
throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE);
|
throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE);
|
||||||
}else{
|
}else{
|
||||||
|
if (user.getPlayerInfoManager().getSkyEyeBanTime() > TimeUtils.now()){
|
||||||
|
throw new ErrorCodeException(ErrorCode.GUILD_NOT_AUTHORITY);
|
||||||
|
}
|
||||||
if(type==1){
|
if(type==1){
|
||||||
if(content.length() > 32){
|
if(content.length() > 32){
|
||||||
throw new ErrorCodeException(ErrorCode.ANNOUNCE_SIZE);
|
throw new ErrorCodeException(ErrorCode.ANNOUNCE_SIZE);
|
||||||
}
|
}
|
||||||
guildInfo.setAnnounce(content);
|
guildInfo.setAnnounce(content);
|
||||||
|
// 天眼查询
|
||||||
|
MessageUtil.sendSkyEyeMsgByGuild(content,user,MessageUtil.skyeye_guildAnnounce,guildInfo.getId());
|
||||||
}else{
|
}else{
|
||||||
checkForCreateGuild(user, content, guildInfo.getAnnounce());
|
checkForCreateGuild(user, content, guildInfo.getAnnounce());
|
||||||
int[][] renameCost = SGuildSetting.sGuildSetting.getRenameCost();
|
int[][] renameCost = SGuildSetting.sGuildSetting.getRenameCost();
|
||||||
|
@ -828,6 +844,8 @@ public class GuildLogic {
|
||||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
guildInfo.setName(content);
|
guildInfo.setName(content);
|
||||||
|
// 天眼查询
|
||||||
|
MessageUtil.sendSkyEyeMsgByGuild(content,user,MessageUtil.skyeye_guildName,guildInfo.getId());
|
||||||
// 缓存同步
|
// 缓存同步
|
||||||
CrossDeathPathLogic.setCrossGuild(guildInfo);
|
CrossDeathPathLogic.setCrossGuild(guildInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package com.ljsd.jieling.util;
|
package com.ljsd.jieling.util;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.protobuf.ByteString;
|
|
||||||
import com.google.protobuf.GeneratedMessage;
|
import com.google.protobuf.GeneratedMessage;
|
||||||
import com.googlecode.protobuf.format.JsonFormat;
|
|
||||||
import com.ljsd.GameApplication;
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.SkyEyeService;
|
import com.ljsd.SkyEyeService;
|
||||||
import com.ljsd.jieling.chat.messge.MessageCache;
|
import com.ljsd.jieling.chat.messge.MessageCache;
|
||||||
|
@ -24,7 +22,6 @@ import com.ljsd.jieling.netty.PackageConstant;
|
||||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.sun.tools.javac.util.StringUtils;
|
|
||||||
import config.SErrorCodeEerverConfig;
|
import config.SErrorCodeEerverConfig;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.PooledByteBufAllocator;
|
import io.netty.buffer.PooledByteBufAllocator;
|
||||||
|
@ -32,7 +29,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
import rpc.protocols.*;
|
import rpc.protocols.*;
|
||||||
import util.StringUtil;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -41,6 +37,12 @@ public class MessageUtil {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
|
||||||
private static HashMap<String, String> skyEyeExtraMap = new HashMap<>();
|
private static HashMap<String, String> skyEyeExtraMap = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天眼的类型,和gm上的对应
|
||||||
|
*/
|
||||||
|
public static int skyeye_guildName = 9;
|
||||||
|
public static int skyeye_guildAnnounce = 10;
|
||||||
|
|
||||||
public static byte[] wrappedBuffer(int uid, int token, int index, int result, int msgId, GeneratedMessage generatedMessage) {
|
public static byte[] wrappedBuffer(int uid, int token, int index, int result, int msgId, GeneratedMessage generatedMessage) {
|
||||||
byte[] backMessage;
|
byte[] backMessage;
|
||||||
if (generatedMessage == null) {
|
if (generatedMessage == null) {
|
||||||
|
@ -459,56 +461,85 @@ public class MessageUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendSkyEyeMsg(String msg,User me,int uid,int channel)throws Exception{
|
public static void sendSkyEyeMsg(String msg,User me,int uid,int channel){
|
||||||
if(channel == 2){
|
// 渠道特殊处理
|
||||||
channel = 4;
|
channel = channel == 2?4:channel;
|
||||||
}else if(channel == 3){
|
channel = channel == 3?8:channel;
|
||||||
channel = 8;
|
// 聊天的玩家
|
||||||
|
User he = UserManager.getUserNotCache(uid);
|
||||||
|
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,me,channel);
|
||||||
|
v3.setTo(buildChatUser(he));
|
||||||
|
skyEyeSendMsg(v3.build());
|
||||||
}
|
}
|
||||||
User he = null;
|
|
||||||
if(uid != 0){
|
/**
|
||||||
he = UserManager.getUser(uid);
|
* 编辑基础信息,天眼
|
||||||
|
* @param msg
|
||||||
|
* @param me
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static ChatProto.ChatV3.Builder buildChatV3(String msg,User me,int type){
|
||||||
|
ChatProto.ChatV3.Builder v3 = ChatProto.ChatV3.newBuilder();
|
||||||
|
String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
||||||
|
v3.setId(uuid);
|
||||||
|
v3.setChannel(String.valueOf(type));
|
||||||
|
v3.setFrom(buildChatUser(me));
|
||||||
|
v3.setContent(msg);
|
||||||
|
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
String url = Optional.ofNullable(ConfigurableApplicationContextManager.getBean(SkyEyeAutoConfigration.class))
|
||||||
|
.map(SkyEyeAutoConfigration::getSkyEyeProperties)
|
||||||
|
.map(SkyEyeProperties::getGmAddress)
|
||||||
|
.orElse("");
|
||||||
|
object.put("url",url);
|
||||||
|
v3.setExtra(object.toJSONString());
|
||||||
|
|
||||||
|
ISession iSession = OnlineUserManager.getSessionByUid(me.getId());
|
||||||
|
String ip = Optional.ofNullable(iSession).map(v->v.getChannel().getLocalAddress().getHostString()).orElse("");
|
||||||
|
v3.setIp(ip);
|
||||||
|
return v3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天眼,公会
|
||||||
|
* @param msg
|
||||||
|
* @param user
|
||||||
|
* @param channel
|
||||||
|
* @param guildId
|
||||||
|
*/
|
||||||
|
public static void sendSkyEyeMsgByGuild(String msg,User user,int channel,int guildId){
|
||||||
|
// 信息封装
|
||||||
|
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,user,channel);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(v3.getExtra());
|
||||||
|
jsonObject.put("guildId",String.valueOf(guildId));
|
||||||
|
v3.setExtra(jsonObject.toJSONString());
|
||||||
|
// 发送消息
|
||||||
|
skyEyeSendMsg(v3.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送天眼信息
|
||||||
|
* @param chatV3
|
||||||
|
*/
|
||||||
|
private static void skyEyeSendMsg(ChatProto.ChatV3 chatV3){
|
||||||
|
LOGGER.info("天眼上报,参数:【{}】",chatV3.toString());
|
||||||
SkyEyeAutoConfigration netServerConfig = ConfigurableApplicationContextManager.getBean(SkyEyeAutoConfigration.class);
|
SkyEyeAutoConfigration netServerConfig = ConfigurableApplicationContextManager.getBean(SkyEyeAutoConfigration.class);
|
||||||
SkyEyeProperties properties = netServerConfig.getSkyEyeProperties();
|
SkyEyeProperties properties = netServerConfig.getSkyEyeProperties();
|
||||||
if(properties == null){
|
if(properties == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,me,he,channel,properties);
|
byte[] byteBuf = wrappedBufferSE(chatV3,properties);
|
||||||
byte[] byteBuf = wrappedBufferSE(v3.build(),properties);
|
|
||||||
// session.writeAndFlush(byteBuf);
|
|
||||||
// session.putBackMassageToMap(byteBuf);
|
|
||||||
ByteBuf bb = PooledByteBufAllocator.DEFAULT.heapBuffer();
|
ByteBuf bb = PooledByteBufAllocator.DEFAULT.heapBuffer();
|
||||||
bb.writeBytes(byteBuf);
|
bb.writeBytes(byteBuf);
|
||||||
SkyEyeService.sendMsg(bb);
|
SkyEyeService.sendMsg(bb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChatProto.ChatV3.Builder buildChatV3(String msg,User me,User he,int type,SkyEyeProperties properties){
|
private static ChatProto.ChatUserV3.Builder buildChatUser(User user){
|
||||||
ChatProto.ChatV3.Builder v3 = ChatProto.ChatV3.newBuilder();
|
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
|
||||||
v3.setId(uuid);
|
|
||||||
v3.setChannel(type+"");
|
|
||||||
v3.setFrom(buildChatUser(me));
|
|
||||||
if(he != null){
|
|
||||||
v3.setTo(buildChatUser(he));
|
|
||||||
}
|
|
||||||
v3.setContent(msg);
|
|
||||||
ISession iSession = OnlineUserManager.getSessionByUid(me.getId());
|
|
||||||
String ip = iSession.getChannel().getLocalAddress().getHostString();
|
|
||||||
v3.setIp(ip);
|
|
||||||
skyEyeExtraMap.clear();
|
|
||||||
String url = properties.getGmAddress();
|
|
||||||
if(url == null){
|
|
||||||
return v3;
|
|
||||||
}
|
|
||||||
LOGGER.info("天眼封禁userId:{},zonId:{},content:{},URL:{}",me.getId(),String.valueOf(GameApplication.serverId),msg,url);
|
|
||||||
skyEyeExtraMap.put("url",url);
|
|
||||||
v3.setExtra(JSON.toJSONString(skyEyeExtraMap));
|
|
||||||
return v3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ChatProto.ChatUserV3.Builder buildChatUser(User user){
|
|
||||||
ChatProto.ChatUserV3.Builder v3 = ChatProto.ChatUserV3.newBuilder();
|
ChatProto.ChatUserV3.Builder v3 = ChatProto.ChatUserV3.newBuilder();
|
||||||
|
if (user == null){
|
||||||
|
return v3;
|
||||||
|
}
|
||||||
v3.setPlayerId(String.valueOf(user.getId()));
|
v3.setPlayerId(String.valueOf(user.getId()));
|
||||||
v3.setUserId(user.getPlayerInfoManager().getOpenId());
|
v3.setUserId(user.getPlayerInfoManager().getOpenId());
|
||||||
v3.setNickname(user.getPlayerInfoManager().getNickName());
|
v3.setNickname(user.getPlayerInfoManager().getNickName());
|
||||||
|
|
Loading…
Reference in New Issue