back_recharge
parent
aa89c05d4f
commit
d6b0063066
|
@ -1,5 +1,7 @@
|
|||
package com.ljsd.jieling.db.redis;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
|
||||
public class RedisKey {
|
||||
|
||||
private final static String Delimiter_colon = ":";
|
||||
|
@ -81,10 +83,14 @@ public class RedisKey {
|
|||
*/
|
||||
public static final String NEXT_EVENT_ID = "NEXT_EVENT_ID";
|
||||
|
||||
public static final String C_User_Name_Key = "C_User_Name_Key";
|
||||
|
||||
/**
|
||||
* 过期事件
|
||||
*/
|
||||
public static final int EXPIRE_TIME = 3600 * 24;
|
||||
public static final int REDIS_OVER_FOREVER = -1;
|
||||
|
||||
|
||||
public static final String LEVE_DIFFICULTY_INFO = "LEVE_DIFFICULTY_INFO";
|
||||
|
||||
|
@ -95,7 +101,7 @@ public class RedisKey {
|
|||
if (withServerId) {
|
||||
return areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
} else {
|
||||
return type + Delimiter_colon + String.valueOf(key);
|
||||
return GameApplication.serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ public class RandomNameRequestHandler extends BaseHandler{
|
|||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
String randomName = PlayerLogic.getInstance().getRandomName2();
|
||||
System.out.println(randomName);
|
||||
PlayerInfoProto.RandomNameResponse randomNameResponse = PlayerInfoProto.RandomNameResponse.newBuilder()
|
||||
.setRandomName(randomName)
|
||||
.build();
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.HeroInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.luaj.vm2.ast.Str;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ReNameRequestHandler extends BaseHandler{
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.RENAME_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
PlayerInfoProto.ReNameRequest reNameRequest = PlayerInfoProto.ReNameRequest.parseFrom(bytes);
|
||||
String name = reNameRequest.getName();
|
||||
int type = reNameRequest.getType();
|
||||
int teamPosId = reNameRequest.getTeamPosId();
|
||||
PlayerLogic.getInstance().resetUserName(iSession,name,type,teamPosId);
|
||||
}
|
||||
}
|
|
@ -35,6 +35,10 @@ public class TakeMailHandler extends BaseHandler {
|
|||
PlayerInfoProto.TakeMailRequest takeMailRequest = PlayerInfoProto.TakeMailRequest.parseFrom(message);
|
||||
List<String> mailIdsList = takeMailRequest.getMailIdsList();
|
||||
CommonProto.Drop.Builder dropBuilder = MailLogic.getInstance().takeMail(mailIdsList, userId);
|
||||
if(dropBuilder == null){
|
||||
MessageUtil.sendErrorResponse(iSession,0,MessageTypeProto.MessageType.MAIL_TAKE_MAIL_ITEM_RESPONESE_VALUE,"");
|
||||
return;
|
||||
}
|
||||
PlayerInfoProto.TakeMailResponse takeMailResponse = PlayerInfoProto.TakeMailResponse.newBuilder()
|
||||
.setDrop(dropBuilder)
|
||||
.buildPartial();
|
||||
|
|
|
@ -167,7 +167,7 @@ public class MailLogic {
|
|||
for (String mailId : mailIdsList){
|
||||
Mail mail = mailManager.getMail(mailId);
|
||||
if (mail == null){
|
||||
continue;
|
||||
return null;
|
||||
}
|
||||
if (mailItem.length() == 0){
|
||||
mailItem = new StringBuilder(mail.getMailItem());
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.ljsd.jieling.logic.player;
|
||||
|
||||
import com.ljsd.jieling.config.SRandomName;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
@ -8,6 +13,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
import com.ljsd.jieling.util.MathUtils;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.SensitivewordFilter;
|
||||
import org.luaj.vm2.ast.Str;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -44,4 +50,41 @@ public class PlayerLogic {
|
|||
private boolean checkNameShield(String name) {
|
||||
return SensitivewordFilter.isContaintSensitiveWord(name, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 起名字
|
||||
* @param name
|
||||
* @param type
|
||||
*/
|
||||
public void resetUserName(ISession iSession, String name, int type,int teamPosId) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
int msgId = MessageTypeProto.MessageType.RENAME_RESPONSE_VALUE;
|
||||
User user = UserManager.getUser(uid);
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
if (type == 1) {
|
||||
// 检查名字是否被占用
|
||||
if (PlayerLogic.getInstance().isExistName(name)) {
|
||||
MessageUtil.sendErrorResponse(iSession, 0, msgId, "");
|
||||
return;
|
||||
}
|
||||
playerInfoManager.setNickName(name);
|
||||
String key = RedisKey.getKey(RedisKey.C_User_Name_Key, name, false);
|
||||
RedisUtil.getInstence().set(key, String.valueOf(uid),RedisKey.REDIS_OVER_FOREVER);
|
||||
}else{
|
||||
if (!teamPosManager.getTeamNames().containsKey(teamPosId)){
|
||||
MessageUtil.sendErrorResponse(iSession, 0, msgId, "");
|
||||
return;
|
||||
}
|
||||
teamPosManager.getTeamNames().put(teamPosId,name);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession,1,msgId,null,true);
|
||||
}
|
||||
|
||||
private boolean isExistName(String name) {
|
||||
String key = RedisKey.getKey(RedisKey.C_User_Name_Key, name, false);
|
||||
Object myUid = RedisUtil.getInstence().get(key);
|
||||
return myUid != null ;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue