Skip to content

Commit 3d4c8db

Browse files
author
Evan Hu
committed
协议生成工具完善
1 parent 25a1b72 commit 3d4c8db

File tree

104 files changed

+16142
-15246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+16142
-15246
lines changed

game-hall/pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>GameServer</artifactId>
7+
<groupId>info.xiaomo</groupId>
8+
<version>2019.1</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>hall</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>1.8</maven.compiler.source>
16+
<maven.compiler.target>1.8</maven.compiler.target>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>info.xiaomo</groupId>
22+
<artifactId>gameCore</artifactId>
23+
<version>2.0.7</version>
24+
</dependency>
25+
</dependencies>
26+
27+
</project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package info.xiaomo.hall;
2+
3+
import java.io.File;
4+
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import com.jzy.game.engine.redis.jedis.JedisManager;
8+
import com.jzy.game.engine.redis.redisson.RedissonManager;
9+
import com.jzy.game.engine.script.ScriptManager;
10+
import com.jzy.game.hall.manager.MongoManager;
11+
import com.jzy.game.hall.server.HallServer;
12+
13+
/**
14+
* 大厅启动类
15+
*
16+
* @author JiangZhiYong
17+
* @QQ 359135103 2017年6月28日 上午11:30:49
18+
*/
19+
public final class AppHall {
20+
private static final Logger LOGGER = LoggerFactory.getLogger(AppHall.class);
21+
private static String configPath;
22+
protected static JedisManager redisManager;
23+
private static HallServer bydrServer;
24+
25+
private AppHall() {
26+
}
27+
28+
public static void main(String[] args) {
29+
initConfigPath();
30+
// redis
31+
redisManager = new JedisManager(configPath);
32+
// RedissonManager.connectRedis(configPath);
33+
34+
// 创建mongodb连接
35+
MongoManager.getInstance().createConnect(configPath);
36+
37+
// 加载脚本
38+
ScriptManager.getInstance().init(str -> System.exit(0));
39+
40+
// 启动通信连接
41+
bydrServer = new HallServer(configPath);
42+
new Thread(bydrServer).start();
43+
}
44+
45+
private static void initConfigPath() {
46+
File file = new File(System.getProperty("user.dir"));
47+
if ("target".equals(file.getName())) {
48+
configPath = file.getPath() + File.separatorChar + "config";
49+
} else {
50+
configPath = file.getPath() + File.separatorChar + "target" + File.separatorChar + "config";
51+
}
52+
LOGGER.info("配置路径为:" + configPath);
53+
}
54+
55+
public static HallServer getBydrServer() {
56+
return bydrServer;
57+
}
58+
59+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package info.xiaomo.hall.manager;
2+
3+
import java.util.Map;
4+
import java.util.concurrent.ConcurrentHashMap;
5+
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
8+
import com.jzy.game.model.mongo.bydr.entity.CFish;
9+
10+
/**
11+
* 配置表
12+
* @author JiangZhiYong
13+
* @QQ 359135103
14+
* 2017年10月18日 下午2:31:04
15+
*/
16+
public class ConfigManager {
17+
private static final Logger LOGGER=LoggerFactory.getLogger(ConfigManager.class);
18+
public static volatile ConfigManager configManager;
19+
20+
/**鱼配置信息*/
21+
private Map<Integer, CFish> fishMap=new ConcurrentHashMap<>();
22+
23+
private ConfigManager() {
24+
25+
}
26+
27+
public static ConfigManager getInstance() {
28+
if(configManager==null) {
29+
synchronized (ConfigManager.class) {
30+
if(configManager==null) {
31+
configManager=new ConfigManager();
32+
}
33+
}
34+
}
35+
return configManager;
36+
}
37+
38+
public Map<Integer, CFish> getFishMap() {
39+
return fishMap;
40+
}
41+
42+
public void setFishMap(Map<Integer, CFish> fishMap) {
43+
this.fishMap = fishMap;
44+
}
45+
46+
/**
47+
* 鱼配置信息
48+
* @author JiangZhiYong
49+
* @QQ 359135103
50+
* 2017年10月18日 下午3:18:43
51+
* @param configId
52+
* @return
53+
*/
54+
public CFish getFish(int configId) {
55+
if(fishMap.containsKey(configId)) {
56+
return fishMap.get(configId);
57+
}
58+
LOGGER.warn("CFish配置错误:{}未配置",configId);
59+
return null;
60+
}
61+
62+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package info.xiaomo.hall.manager;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
/**
7+
* 公会管理
8+
*
9+
* @author JiangZhiYong
10+
* @QQ 359135103 2017年9月22日 上午9:56:19
11+
*/
12+
public final class GuildManager {
13+
private static final Logger LOGGER = LoggerFactory.getLogger(GuildManager.class);
14+
private static volatile GuildManager guildManager;
15+
16+
private GuildManager() {
17+
18+
}
19+
20+
public static GuildManager getInstance() {
21+
if (guildManager == null) {
22+
synchronized (GuildManager.class) {
23+
if (guildManager == null) {
24+
guildManager = new GuildManager();
25+
}
26+
}
27+
}
28+
return guildManager;
29+
}
30+
31+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package info.xiaomo.hall.manager;
2+
3+
import java.util.function.Consumer;
4+
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import com.jzy.game.message.hall.HallChatMessage.MailInfo;
8+
import com.jzy.game.engine.script.ScriptManager;
9+
import com.jzy.game.hall.script.IMailScript;
10+
import com.jzy.game.model.mongo.hall.dao.MailDao;
11+
import com.jzy.game.model.struct.Mail;
12+
import com.jzy.game.model.struct.Mail.MailType;
13+
14+
/**
15+
* 邮件
16+
* <p>
17+
* 个人邮件单独存储,系统通用邮件只存一封,直接操作mongodb,不缓存
18+
* </p>
19+
*
20+
* @author JiangZhiYong
21+
* @QQ 359135103 2017年9月21日 下午3:25:17
22+
*/
23+
public class MailManager {
24+
private static final Logger LOGGER = LoggerFactory.getLogger(MailManager.class);
25+
private static volatile MailManager mailManager;
26+
27+
private MailManager() {
28+
29+
}
30+
31+
public static MailManager getInstance() {
32+
if (mailManager == null) {
33+
synchronized (MailManager.class) {
34+
if (mailManager == null) {
35+
mailManager = new MailManager();
36+
}
37+
}
38+
}
39+
return mailManager;
40+
}
41+
42+
public Mail getMail(long mailId) {
43+
return MailDao.getMail(mailId);
44+
}
45+
46+
/**
47+
* 发送邮件
48+
*
49+
* @author JiangZhiYong
50+
* @QQ 359135103 2017年9月21日 下午4:26:31
51+
* @param title
52+
* @param content
53+
* @param type
54+
* @param mailConsumer
55+
*/
56+
public void sendMail(long senderId,long receiverId,String title, String content, MailType type, Consumer<Mail> mailConsumer) {
57+
ScriptManager.getInstance().getBaseScriptEntry().executeScripts(IMailScript.class,
58+
script -> script.sendMail(senderId,receiverId,title, content, type, mailConsumer));
59+
}
60+
61+
/**
62+
* 构建邮箱信息
63+
*
64+
* @author JiangZhiYong
65+
* @QQ 359135103 2017年9月21日 下午5:45:09
66+
* @param mail
67+
* @return
68+
*/
69+
public MailInfo buildMailInfo(Mail mail) {
70+
MailInfo.Builder builder = MailInfo.newBuilder();
71+
builder.setContent(mail.getContent());
72+
builder.setTitle(mail.getTitle());
73+
builder.setCreateTime(mail.getCreateTime().getTime());
74+
builder.setId(mail.getId());
75+
builder.setSenderId(mail.getSenderId());
76+
builder.setState(mail.getState());
77+
return builder.build();
78+
}
79+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package info.xiaomo.hall.manager;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import com.jzy.game.engine.mongo.AbsMongoManager;
6+
import com.jzy.game.model.mongo.hall.dao.HallInfoDao;
7+
import com.jzy.game.model.mongo.hall.dao.MailDao;
8+
import com.jzy.game.model.mongo.hall.dao.RoleDao;
9+
import com.jzy.game.model.mongo.hall.dao.UserDao;
10+
11+
/**
12+
* mongodb
13+
*
14+
* @author JiangZhiYong
15+
* @QQ 359135103 2017年6月28日 下午3:33:14
16+
*/
17+
public class MongoManager extends AbsMongoManager {
18+
private static final Logger LOGGER = LoggerFactory.getLogger(MongoManager.class);
19+
private static final MongoManager INSTANCE_MANAGER = new MongoManager();
20+
21+
public static MongoManager getInstance() {
22+
return INSTANCE_MANAGER;
23+
}
24+
25+
@Override
26+
protected void initDao() {
27+
HallInfoDao.getDB(INSTANCE_MANAGER);
28+
UserDao.getDB(INSTANCE_MANAGER);
29+
RoleDao.getDB(INSTANCE_MANAGER);
30+
MailDao.getDB(INSTANCE_MANAGER);
31+
}
32+
33+
}

0 commit comments

Comments
 (0)