Skip to content

Commit 095f604

Browse files
authored
Merge pull request #109 from anlingyi/release
1.6.7-beta
2 parents e098d3e + 542507f commit 095f604

66 files changed

Lines changed: 2803 additions & 63 deletions

Some content is hidden

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

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ENV JAVA_OPTS="-Xms512m -Xmx512m"
55
ENV PARAMS="-path /home/xechat/config/config.setting"
66
ENV TZ="Asia/Shanghai"
77

8-
EXPOSE 1024
8+
EXPOSE 1024 1025
99

1010
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
1111
ADD xechat-server/target/xechat-server-*.jar /home/xechat/server.jar

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# XEChat-Idea
22

3-
> Version 1.6.6-beta
3+
> Version 1.6.7-beta
44
55
> 基于Netty的IDEA即时聊天插件:让你能够在IDEA里实现聊天、下棋、斗地主!(理论上支持JetBrains全系列开发工具🙂)
66
@@ -43,6 +43,8 @@
4343
* 数独(作者 @[Speciallei](https://github.com/Specialleiliei) ,感谢PR😊)
4444
* 推箱子(作者 @[Speciallei](https://github.com/Specialleiliei) ,感谢PR😊)
4545
* 中国象棋(支持2人联机、人机对战,作者 @[15738383930](https://github.com/15738383930) ,感谢PR😊)
46+
* 俄罗斯方块(作者 @[SherlockerSun](https://github.com/SherlockerSun) ,感谢PR😊)
47+
* 扫雷(作者 @[SherlockerSun](https://github.com/SherlockerSun) ,感谢PR😊)
4648

4749
**工具类**
4850

@@ -66,6 +68,12 @@
6668

6769
![](https://oss.xeblog.cn/prod/76dee7f5bb924dd59a5ffaaf333fc45c.png)
6870

71+
![](https://oss.xeblog.cn/prod/ad9a78cf91b94ec0b0a622a8de8f38d9.png)
72+
73+
![](https://oss.xeblog.cn/prod/8adc57b65371469ab6dec2d9e34cb38b.png)
74+
75+
![](https://oss.xeblog.cn/prod/d5706e73906f4377921231898c3ddceb.png)
76+
6977
### 项目结构
7078

7179
```
@@ -150,6 +158,7 @@ java -jar target/xechat-server-xxx.jar
150158
* **设置ip2region文件**`-ipfile {文件路径}`
151159
* **设置管理员令牌**`-token {令牌}`
152160
* **指定外部配置文件**`-path {文件路径}`
161+
* **开放WS协议**`-enableWS {true|false}`
153162

154163
具体的外部配置文件信息请看:`xechat-server/src/main/resources/config.setting`
155164

@@ -163,6 +172,8 @@ java -jar target/xechat-server-xxx.jar -p 1024 -swfile /Users/anlingyi/local/tes
163172

164173
[和风天气相关配置参考](https://xeblog.cn/articles/101)
165174

175+
[开放WS协议相关配置参考](https://xeblog.cn/articles/113)
176+
166177
### IDEA插件端
167178

168179
#### 修改IDEA版本
@@ -171,7 +182,7 @@ java -jar target/xechat-server-xxx.jar -p 1024 -swfile /Users/anlingyi/local/tes
171182

172183
```
173184
intellij {
174-
version '2021.2'
185+
version '2021.3'
175186
}
176187
```
177188

@@ -237,11 +248,12 @@ http://plugins.xeblog.cn
237248
version: '3'
238249
services:
239250
xechat:
240-
image: anlingyi/xechat-server:1.6.5-beta
251+
image: anlingyi/xechat-server:1.6.7-beta
241252
container_name: xechat-server
242253
restart: always
243254
ports:
244255
- 1024:1024
256+
- 1025:1025
245257
volumes:
246258
- /home/xechat/logs:/var/log/xechat-server
247259
- /home/xechat/config/config.setting:/home/xechat/config/config.setting

server_list.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@
1313
"name": "光之乐园",
1414
"ip": "zhangruoyu.top",
1515
"port": 1024
16+
},
17+
{
18+
"name": "摸鱼先炸窝",
19+
"ip": "121.36.64.134",
20+
"port": 1024
1621
}
1722
]

xechat-commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>cn.xeblog</groupId>
88
<artifactId>xechat-commons</artifactId>
9-
<version>1.6.6-beta</version>
9+
<version>1.6.7-beta</version>
1010
<build>
1111
<plugins>
1212
<plugin>

xechat-commons/src/main/java/cn/xeblog/commons/entity/User.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package cn.xeblog.commons.entity;
22

3+
import cn.hutool.core.map.MapUtil;
4+
import cn.xeblog.commons.constants.IpConstants;
35
import cn.xeblog.commons.enums.Permissions;
46
import cn.xeblog.commons.enums.Platform;
57
import cn.xeblog.commons.enums.UserStatus;
@@ -47,19 +49,26 @@ public class User implements Serializable {
4749
@Setter
4850
private UserStatus status;
4951

52+
/**
53+
* 地区简称
54+
*/
55+
@Getter
56+
@Setter
57+
private String shortRegion;
58+
5059
/**
5160
* 用户IP
5261
*/
5362
@Getter
5463
@Setter
55-
private String ip;
64+
private transient String ip;
5665

5766
/**
5867
* 用户所在区域
5968
*/
6069
@Getter
6170
@Setter
62-
private IpRegion region;
71+
private transient IpRegion region;
6372

6473
/**
6574
* 用户角色
@@ -104,6 +113,7 @@ public User(String id, String username, UserStatus status, String ip, IpRegion r
104113
this.region = region;
105114
this.channel = channel;
106115
this.platform = Platform.IDEA;
116+
this.shortRegion = MapUtil.getStr(IpConstants.SHORT_PROVINCE, region.getProvince(), region.getCountry());
107117
}
108118

109119
public void send(Response response) {

xechat-commons/src/main/java/cn/xeblog/commons/enums/Game.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ public enum Game {
1818
GAME_2048("2048", false),
1919
SUDOKU("数独", false),
2020
PUSH_BOX("推箱子", false),
21-
CHINESE_CHESS("中国象棋", false);
21+
CHINESE_CHESS("中国象棋", false),
22+
TETRIS("俄罗斯方块", false),
23+
MINESWEEPER("扫雷", false),
24+
;
2225

2326
/**
2427
* 游戏名称
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cn.xeblog.commons.util;
2+
3+
import cn.hutool.core.util.ReUtil;
4+
5+
/**
6+
* @author anlingyi
7+
* @date 2023/9/17 5:25 PM
8+
*/
9+
public class CheckUtils {
10+
11+
/**
12+
* 校验用户名
13+
*
14+
* @param username
15+
* @return
16+
*/
17+
public static boolean checkUsername(String username) {
18+
return !ReUtil.isMatch(".*[\\u200B-\\u200D\\uFEFF\\xA0\\s\\t\\r\\n].*", username);
19+
}
20+
21+
}

xechat-plugin/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'cn.xeblog'
7-
version '1.6.6-beta'
7+
version '1.6.7-beta'
88

99
sourceCompatibility = 11
1010
targetCompatibility = 11
@@ -20,7 +20,7 @@ repositories {
2020
}
2121

2222
ext {
23-
xechatCommonsVersion = '1.6.6-beta'
23+
xechatCommonsVersion = '1.6.7-beta'
2424
lombokVersion = '1.18.24'
2525
}
2626

@@ -35,7 +35,7 @@ dependencies {
3535

3636
// See https://github.com/JetBrains/gradle-intellij-plugin/
3737
intellij {
38-
version '2021.2'
38+
version '2021.3'
3939
intellij.updateSinceUntilBuild false
4040
}
4141
patchPluginXml {

xechat-plugin/src/main/java/cn/xeblog/plugin/action/handler/command/LoginCommandHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import cn.hutool.core.util.NumberUtil;
77
import cn.hutool.core.util.StrUtil;
88
import cn.xeblog.commons.entity.OnlineServer;
9+
import cn.xeblog.commons.util.CheckUtils;
910
import cn.xeblog.commons.util.ServerUtils;
1011
import cn.xeblog.plugin.action.ConnectionAction;
1112
import cn.xeblog.plugin.action.ConsoleAction;
@@ -90,7 +91,11 @@ public void process(String[] args) {
9091
return;
9192
}
9293

93-
username = username.replaceAll("\\s*|\t|\r|\n", "");
94+
if (!CheckUtils.checkUsername(username)) {
95+
ConsoleAction.showSimpleMsg("用户名不合法,请修改后重试!");
96+
return;
97+
}
98+
9499
if (username.length() > 12) {
95100
ConsoleAction.showSimpleMsg("用户名长度不能超过12个字符!");
96101
return;

xechat-plugin/src/main/java/cn/xeblog/plugin/action/handler/message/UserMessageHandler.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package cn.xeblog.plugin.action.handler.message;
22

33
import cn.hutool.core.io.FileUtil;
4-
import cn.hutool.core.map.MapUtil;
54
import cn.hutool.core.thread.GlobalThreadPool;
6-
import cn.xeblog.commons.constants.IpConstants;
7-
import cn.xeblog.commons.entity.IpRegion;
85
import cn.xeblog.commons.entity.Response;
96
import cn.xeblog.commons.entity.User;
107
import cn.xeblog.commons.entity.UserMsgDTO;
@@ -67,16 +64,14 @@ protected void process(Response<UserMsgDTO> response) {
6764

6865
private void renderName(Response<UserMsgDTO> response) {
6966
User user = response.getUser();
70-
IpRegion region = user.getRegion();
71-
final String shortProvince = MapUtil.getStr(IpConstants.SHORT_PROVINCE, region.getProvince(), region.getCountry());
7267
String platform = user.getPlatform() == Platform.WEB ? " ༄" : " ♨";
7368
String roleDisplay = "";
7469
if (user.getRole() == User.Role.ADMIN) {
7570
roleDisplay = " ☆";
7671
}
7772

7873
ConsoleAction.renderText(
79-
String.format("[%s][%s] %s (%s)%s%s:", response.getTime(), shortProvince, user.getUsername(),
74+
String.format("[%s][%s] %s (%s)%s%s:", response.getTime(), user.getShortRegion(), user.getUsername(),
8075
user.getStatus().getName(), platform, roleDisplay), Style.USER_NAME);
8176
}
8277

0 commit comments

Comments
 (0)