加载静态数据表
parent
1409e0292f
commit
270ba601d9
|
@ -48,6 +48,7 @@ public class GameApplication {
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,8 @@ public class ServerProperties {
|
|||
|
||||
private int isLAN;
|
||||
|
||||
private String openTime;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -48,6 +50,14 @@ public class ServerProperties {
|
|||
this.isLAN = isLAN;
|
||||
}
|
||||
|
||||
public String getOpenTime() {
|
||||
return openTime;
|
||||
}
|
||||
|
||||
public void setOpenTime(String openTime) {
|
||||
this.openTime = openTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerProperties{" +
|
||||
|
@ -55,6 +65,7 @@ public class ServerProperties {
|
|||
", plat='" + plat + '\'' +
|
||||
", channel='" + channel + '\'' +
|
||||
", isLAN=" + isLAN +
|
||||
", openTime=" + openTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
@ -124,7 +127,7 @@ public class STableManager {
|
|||
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()) {
|
||||
|
@ -156,7 +159,7 @@ public class STableManager {
|
|||
lineNum++;
|
||||
}
|
||||
map.put(i, mapConf);
|
||||
tableName = tableName.substring(0, 7);
|
||||
tableName = tableName.substring(0, 5);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue