Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
2420c68092
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"version":"1"
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ dependencies {
|
|||
compile("com.google.protobuf:protobuf-java:2.5.0")
|
||||
compile("com.fasterxml.jackson.core:jackson-core:2.3.1")
|
||||
compile("com.fasterxml.jackson.core:jackson-databind:2.3.3")
|
||||
compile files("${System.properties['java.home']}/../lib/tools.jar")
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.ljsd;
|
||||
|
||||
import com.ljsd.jieling.config.json.ServerConfiguration;
|
||||
import com.ljsd.jieling.config.json.ServerProperties;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
|
|
@ -30,7 +32,7 @@ public class GameApplication {
|
|||
private static SpringApplication app = null;
|
||||
private static ConfigurableApplicationContext configurableApplicationContext = null;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GameApplication.class);
|
||||
|
||||
public static ServerProperties serverProperties;
|
||||
private static NettyGameServer nettyServer = null;
|
||||
public static int serverId = 0;
|
||||
// public static ServerProperties serverProperties;
|
||||
|
|
@ -43,8 +45,10 @@ public class GameApplication {
|
|||
app.setWebEnvironment(false);
|
||||
|
||||
configurableApplicationContext = app.run(args);
|
||||
|
||||
|
||||
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
|
||||
serverProperties = serverConfiguration.getServerProperties();
|
||||
serverId = serverProperties.getId();
|
||||
LOGGER.info("ServerProperties ->{},coreIp=>{}", serverProperties.toString());
|
||||
//注册消息处理方法
|
||||
ProtocolsManager protocolsManager = ProtocolsManager.getInstance();
|
||||
// protocolsManager.initContext();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.ljsd.jieling.logic.Table;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "s_c_map")
|
||||
@Table(name = "1.Map")
|
||||
public class SCMap implements BaseConfig {
|
||||
public static Map<Integer, Map<Integer, SCMap>> sCMap;
|
||||
private int id;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.ljsd.jieling.config;
|
||||
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "1.MapConfig")
|
||||
public class SCMapConfig implements BaseConfig {
|
||||
public static Map<Integer, SCMapConfig> sCMapSize;
|
||||
private int id;
|
||||
private String info;
|
||||
private int[] size; // 0:行 1列
|
||||
private int confused; //地图消耗
|
||||
private String openRule; // 开启条件
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sCMapSize = STableManager.getConfig(SCMapConfig.class);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public int[] getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int getConfused() {
|
||||
return confused;
|
||||
}
|
||||
|
||||
public String getOpenRule() {
|
||||
return openRule;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import com.ljsd.jieling.logic.Table;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name = "s_c_map_event")
|
||||
@Table(name = "2.MapEventsConfig")
|
||||
public class SCMapEvent implements BaseConfig{
|
||||
|
||||
public static Map<Integer, SCMapEvent> scMapEventMap;
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
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 = "s_c_map_size")
|
||||
public class SCMapSize implements BaseConfig {
|
||||
public Map<Integer, SCMapSize> sCMapSize;
|
||||
public Map<Integer, SCMapSize> sCardMapSizeById;
|
||||
private int id;
|
||||
private int length;
|
||||
private int width;
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sCMapSize = STableManager.getConfig(SCMapSize.class);
|
||||
sCardMapSizeById = new HashMap<>();
|
||||
for (Map.Entry<Integer, SCMapSize> entry : sCMapSize.entrySet()) {
|
||||
sCardMapSizeById.put(entry.getValue().getId(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Map<Integer, SCMapSize> getsCMapSize() {
|
||||
return sCMapSize;
|
||||
}
|
||||
|
||||
public Map<Integer, SCMapSize> getsCardMapSizeById() {
|
||||
return sCardMapSizeById;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.ljsd.jieling.config.json;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ConfMessage {
|
||||
|
||||
private static String currVerion;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ConfMessage.class);
|
||||
|
||||
//加载配置开关
|
||||
public static void doWork() throws IOException {
|
||||
File file = new File("conf/plat-configure.json");
|
||||
// File file = new File("C://ljsd/gameserver_new/conf/plat-configure.json");
|
||||
if (!file.exists()) {
|
||||
LOGGER.error("the file plat-configure.json is not exists");
|
||||
return;
|
||||
}
|
||||
InputStream in = new FileInputStream(file);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
|
||||
PlatConfigure platConfigure = mapper.readValue(in, PlatConfigure.class);
|
||||
in.close();
|
||||
|
||||
String version = platConfigure.getVersion();
|
||||
if (version.equalsIgnoreCase(currVerion)) {
|
||||
return;
|
||||
}
|
||||
GlobalPlatConfigure.platConfigure = platConfigure;
|
||||
currVerion = version;
|
||||
LOGGER.info("PlatConfigure ->{}", GlobalPlatConfigure.platConfigure.toString());
|
||||
LOGGER.debug("doWork update PlatConfigure->currVerion={},version={}", currVerion, version);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.ljsd.jieling.config.json;
|
||||
|
||||
public class GlobalPlatConfigure {
|
||||
public static PlatConfigure platConfigure = new PlatConfigure();
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.ljsd.jieling.config.json;
|
||||
|
||||
public class PlatConfigure {
|
||||
public String version = "1";
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlatConfigure{" +
|
||||
"version='" + version + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ljsd.jieling.config.json;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Created by a on 2017/7/5.
|
||||
*/
|
||||
@Configuration(value = "serverConfiguration")
|
||||
@EnableConfigurationProperties(ServerProperties.class)
|
||||
public class ServerConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ServerProperties serverProperties;
|
||||
|
||||
public ServerProperties getServerProperties() {
|
||||
return serverProperties;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.ljsd.jieling.config.json;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Created by a on 2017/7/5.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "server")
|
||||
public class ServerProperties {
|
||||
|
||||
private int id;
|
||||
|
||||
private String plat;
|
||||
|
||||
private String channel;
|
||||
|
||||
private int isLAN;
|
||||
|
||||
private String openTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPlat() {
|
||||
return plat;
|
||||
}
|
||||
|
||||
public void setPlat(String plat) {
|
||||
this.plat = plat;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public int getIsLAN() {
|
||||
return isLAN;
|
||||
}
|
||||
|
||||
public void setIsLAN(int isLAN) {
|
||||
this.isLAN = isLAN;
|
||||
}
|
||||
|
||||
public String getOpenTime() {
|
||||
return openTime;
|
||||
}
|
||||
|
||||
public void setOpenTime(String openTime) {
|
||||
this.openTime = openTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerProperties{" +
|
||||
"id=" + id +
|
||||
", plat='" + plat + '\'' +
|
||||
", channel='" + channel + '\'' +
|
||||
", isLAN=" + isLAN +
|
||||
", openTime=" + openTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ljsd.jieling.logic.map;
|
||||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ljsd.jieling.logic.map;
|
||||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
public class EventType {
|
||||
// 事件点类型 1怪物 2怪物群 3矿 4入口 5出口 6一次性事件 7重复事件 8npc 9地图boss
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
public class LittleEventType {
|
||||
|
||||
/**
|
||||
* 1 战斗
|
||||
* 2 判断属性(属性id#(0,-1,1)#num
|
||||
* 3 消耗物品
|
||||
* 4 做选择给奖励
|
||||
* 5 侦察
|
||||
* 6 离开
|
||||
* 7 做选择不同跳转文本
|
||||
*/
|
||||
public static final int fight = 1;
|
||||
public static final int attribute = 2;
|
||||
public static final int item = 3;
|
||||
public static final int reward = 4;
|
||||
public static final int scout = 5;
|
||||
public static final int leave = 6;
|
||||
public static final int choice = 7;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.ljsd.jieling.handler.map;
|
|||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -15,6 +16,8 @@ public class MapEnterRequestHandler extends BaseHandler{
|
|||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
MapInfoProto.MapInfo.MapEnterRequest mapEnterRequest = MapInfoProto.MapInfo.MapEnterRequest.parseFrom(message);
|
||||
MapLogic.getInstance().enterMap(iSession, mapEnterRequest.getMapId(), MessageTypeProto.MessageType.MAP_ENTER_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ljsd.jieling.logic.map;
|
||||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.MapManager;
|
||||
import com.ljsd.jieling.logic.dao.User;
|
||||
|
|
@ -44,8 +44,8 @@ public class MapLogic {
|
|||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
MapManager mapManager = user.getMapManager();
|
||||
if (mapManager == null) {
|
||||
mapManager = initMap(uid, 1);
|
||||
if (mapManager.getCurMapId() == 0) {
|
||||
mapManager = initMap( 1);
|
||||
user.setMapManager(mapManager);
|
||||
}
|
||||
MapInfoProto.MapInfo.MapEnterResponse mapEnterResponse = MapInfoProto.MapInfo.MapEnterResponse
|
||||
|
|
@ -55,7 +55,7 @@ public class MapLogic {
|
|||
}
|
||||
|
||||
|
||||
private MapManager initMap(int uid, int mapId) throws Exception {
|
||||
private MapManager initMap(int mapId) throws Exception {
|
||||
if (mapId == 0) {
|
||||
mapId = 1;
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ public class MapLogic {
|
|||
crossMapInfos.get(cMap.getCurMapId()).addAll(cell.getEventIds());
|
||||
}
|
||||
if (scMapEvent.getStyle() == EventType.exit) {
|
||||
initMap(uid, cMap.getCurMapId() + 1);
|
||||
initMap(cMap.getCurMapId() + 1);
|
||||
return;
|
||||
}
|
||||
cell.setFinish(true);
|
||||
|
|
@ -92,6 +92,9 @@ public class STableManager {
|
|||
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||
LOGGER.info("initMap:{}", clazz.getSimpleName());
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
if (line.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
T obj = clazz.newInstance();
|
||||
String[] prarms = line.split("\\t");
|
||||
switch (lineNum) {
|
||||
|
|
@ -121,13 +124,16 @@ public class STableManager {
|
|||
public static <T> Map<Integer, Map<Integer, T>> getMapConfig(Class<T> clazz) throws Exception {
|
||||
Map<Integer, Map<Integer, T>> map = new HashMap<>();
|
||||
String tableName = clazz.getAnnotation(Table.class).name();
|
||||
for (int i = 1; i < 100; i++) {
|
||||
int mapType = 101;
|
||||
for (int i = 101; i < 1000; i++) {
|
||||
Map<Integer, T> mapConf = new HashMap<>();
|
||||
tableName = tableName + i;
|
||||
tableName = tableName + "_"+ i;
|
||||
String path = SysUtil.getPath("conf", "server", tableName + ".txt");
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
break;
|
||||
mapType += 100;
|
||||
i = mapType;
|
||||
continue;
|
||||
}
|
||||
String line;
|
||||
List<String> key = new ArrayList<>();
|
||||
|
|
@ -153,7 +159,7 @@ public class STableManager {
|
|||
lineNum++;
|
||||
}
|
||||
map.put(i, mapConf);
|
||||
tableName = tableName.substring(0, 7);
|
||||
tableName = tableName.substring(0, 5);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
@ -162,7 +168,7 @@ public class STableManager {
|
|||
* 处理参数
|
||||
*/
|
||||
private static <T> void dealParams(Class<T> clazz, Map<Integer, T> map, List<String> key, List<String> type, T obj, String[] prarms) throws NoSuchFieldException, IllegalAccessException {
|
||||
int id = Integer.parseInt(prarms[0]);
|
||||
int id = Integer.parseInt(prarms[0]);
|
||||
for (int i = 0; i < prarms.length; i++) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(key.get(i));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.ljsd.jieling.logic.dao;
|
|||
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.logic.map.Cell;
|
||||
import com.ljsd.jieling.handler.map.Cell;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ljsd.jieling.thread;
|
||||
|
||||
import com.ljsd.jieling.thread.task.TestTask;
|
||||
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
|
@ -15,14 +15,14 @@ public class ThreadManager {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(ThreadManager.class);
|
||||
|
||||
|
||||
private TestTask testTask;
|
||||
private PlatConfigureTask testTask;
|
||||
|
||||
|
||||
private ScheduledThreadPoolExecutor scheduledExecutor; //管理task
|
||||
|
||||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||
|
||||
testTask = configurableApplicationContext.getBean(TestTask.class);
|
||||
testTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
||||
|
||||
go();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.ljsd.jieling.thread.task;
|
||||
|
||||
import com.ljsd.jieling.config.json.ConfMessage;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class PlatConfigureTask implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlatConfigureTask.class);
|
||||
private int SLEEP_INTEVAL_TIME = 60 * 1000; //每1分钟检查一次
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
doLogic();
|
||||
}
|
||||
|
||||
private void doLogic() {
|
||||
while (true){
|
||||
try {
|
||||
ConfMessage.doWork();
|
||||
TimeUtils.sleep(SLEEP_INTEVAL_TIME);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.ljsd.jieling.thread.task;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestTask implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TestTask.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
doLogic();
|
||||
}
|
||||
|
||||
private void doLogic() {
|
||||
long str = RedisUtil.getInstence().incr("TestTask",1L);
|
||||
LOGGER.info("--> RedisUtil.incr : str = "+str);
|
||||
LOGGER.info("TestTask ... ");
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue