back_recharge
jiahuiwen 2019-01-23 09:53:11 +08:00
commit 4d1ae3caf3
7 changed files with 63 additions and 23 deletions

View File

@ -8,6 +8,7 @@ version '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}

View File

@ -8,6 +8,7 @@ version '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
@ -16,6 +17,8 @@ dependencies {
}
jar {
baseName = 'hotfix'
version = '1.0.0'
manifest{
attributes 'Manifest-Version':'1.0'
attributes 'Premain-Class':'com.ljsd.jieling.hotfix.JavaAgent'

View File

@ -8,6 +8,7 @@ version '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}

View File

@ -36,4 +36,21 @@ jar {
manifest {
attributes 'Main-Class': 'com.ljsd.jieling.ServerlogicApplication'
}
}
//JAR
task taskJar(type:Jar, dependsOn: compileJava) {
from 'build/classes/main'
destinationDir = file('build/libs')
}
//libjar
task clearJars(type:Delete){
delete 'lib'
}
task copyJars(type: Copy, dependsOn:clearJars) {
from configurations.runtime
into 'lib' //
}

View File

@ -3,11 +3,12 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.HashMap;
import java.util.Map;
@Table(name = "HeroRankupConfig")
public class SCHeroRankUpConfig implements BaseConfig{
public static Map<Integer,SCHeroRankUpConfig> scHeroRankUpConfigMap;
public static Map<Integer,Map<Integer,SCHeroRankUpConfig>> scHeroRankUpConfigByType;
private int id;
@ -23,17 +24,28 @@ public class SCHeroRankUpConfig implements BaseConfig{
private int openStar;
private int consumeMaterial[];
private int[] consumeCard[];
private int consumeMaterial[][];
@Override
public void init() throws Exception {
// scHeroRankUpConfigMap = STableManager.getConfig(SCHeroRankUpConfig.class);
Map<Integer,Map<Integer,SCHeroRankUpConfig>> result = new HashMap<>();
Map<Integer, SCHeroRankUpConfig> config = STableManager.getConfig(SCHeroRankUpConfig.class);
for(SCHeroRankUpConfig scHeroRankUpConfig: config.values()){
int type = scHeroRankUpConfig.getType();
if(!result.containsKey(type)){
result.put(type,new HashMap<>());
}
if(type == 1){
result.get(type).put(scHeroRankUpConfig.getLimitLevel(),scHeroRankUpConfig);
}else{
result.get(type).put(scHeroRankUpConfig.getLimitStar(),scHeroRankUpConfig);
}
}
scHeroRankUpConfigByType = result;
}
public static Map<Integer, SCHeroRankUpConfig> getScHeroRankUpConfigMap() {
return scHeroRankUpConfigMap;
public static Map<Integer, SCHeroRankUpConfig> getScHeroRankUpConfigByType(int type) {
return scHeroRankUpConfigByType.get(type);
}
public int getId() {
@ -64,11 +76,7 @@ public class SCHeroRankUpConfig implements BaseConfig{
return openStar;
}
public int[] getConsumeMaterial() {
public int[][] getConsumeMaterial() {
return consumeMaterial;
}
public int[][] getConsumeCard() {
return consumeCard;
}
}

View File

@ -256,6 +256,13 @@ public class ProtocolsManager implements ProtocolsAbstract {
private int checkAndRefresh(ISession session, PacketNetData packetNetData) {
int myToken = 0;
if (packetNetData.getMsgId()== MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE){
if (OnlineUserManager.checkUidOnline(session.getUid())){
ISession iSession = OnlineUserManager.getSessionByUid(session.getUid());
MessageUtil.sendErrorCode(session, ErrorCode.reloginCode);
OnlineUserManager.userOffline(iSession.getUid());
iSession.close();
}
OnlineUserManager.userOnline(session.getUid(),session);
//TODO 更新token
@ -266,12 +273,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
}
if (OnlineUserManager.checkUidOnline(session.getUid())){
ISession iSession = OnlineUserManager.getSessionByUid(session.getUid());
MessageUtil.sendErrorCode(session, ErrorCode.reloginCode);
iSession.close();
}
// if (myToken != packetNetData.getToken()){
// return 1;
// }

View File

@ -1,14 +1,18 @@
package com.ljsd.jieling.util;
import com.google.protobuf.GeneratedMessage;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.netty.PackageConstant;
import com.ljsd.jieling.netty.cocdex.Tea;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Base64;
public class MessageUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
@ -79,11 +83,16 @@ public class MessageUtil {
session.writeAndFlush(byteBuf);
}
// public static void sendErrorResponse(Msg msg, GeneratedMessage error_message, int msgId) throws Exception {
// String protoEntity = Base64.getEncoder().encodeToString(error_message.toByteArray());
// BaseGlobal.redisApp.hset(RedisKey.RESPONSE, String.valueOf(msg.getUid()), String.valueOf(Math.abs(msg.getIndex())), new ProtoEntity(msgId, protoEntity), -1);
// sendMessage(msg.getSession(), msg.getUid(), msg.getIndex(), 1, msgId, error_message, true);
// }
public static void sendErrorResponse(ISession session,int errorCode,int msgId,String errMsg) throws Exception {
GeneratedMessage generatedMessage = null;
if(errorCode!=1 && !StringUtil.isEmpty(errMsg)){
generatedMessage = CommonProto.ErrorResponse.newBuilder().setErrCode(errorCode).setErrMsg(errMsg).build();
}
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(),
errorCode,msgId, generatedMessage);
session.writeAndFlush(byteBuf);
}
//
// public static void sendResponse(Msg msg, int msgId, GeneratedMessage generatedMessage) throws Exception {
// String protoEntity = Base64.getEncoder().encodeToString(generatedMessage.toByteArray());