Skip to content

Commit 31ca438

Browse files
authored
Merge pull request #68 from anlingyi/release
1.6.3-beta
2 parents ee84684 + 437ea26 commit 31ca438

31 files changed

Lines changed: 2275 additions & 38 deletions

File tree

README.md

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

3-
> Version 1.6.2-beta
3+
> Version 1.6.3-beta
44
55
> 基于Netty的IDEA即时聊天插件:让你能够在IDEA里实现聊天、下棋、斗地主!(理论上支持JetBrains全系列开发工具🙂)
66
@@ -37,11 +37,14 @@
3737
* 五子棋(支持2人联机、人机对战,内置"人工制杖")
3838
* 斗地主(支持2~3人联机、人机对战)
3939
* 不贪吃蛇
40+
* 2048(作者 @[浓睡不消残酒](https://github.com/CodeNoobLH) ,感谢PR😊)
41+
* 数独(作者 @[Speciallei](https://github.com/Specialleiliei) ,感谢PR😊)
4042

4143
**工具类**
4244

4345
* 阅读(作者 @[MINIPuffer](https://github.com/MINIPuffer) ,感谢PR😊)
4446
* 天气查询(基于[和风天气](https://dev.qweather.com/),作者 @[猎隼丶止戈](https://github.com/nn200433) ,感谢PR😊)
47+
* 浏览器
4548

4649
[了解更多...](https://xeblog.cn/?tag=xechat-idea)
4750

@@ -51,6 +54,8 @@
5154

5255
![](https://oss.xeblog.cn/prod/40ddad661991451889acea177c7f5293.png)
5356

57+
![](https://oss.xeblog.cn/prod/3af16813518b4e4592ece13b0330be9b.png)
58+
5459
### 项目结构
5560

5661
```

server_list.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
"name": "野生鱼塘",
99
"ip": "1649991905.cn",
1010
"port": 1024
11+
},
12+
{
13+
"name": "有鱼溪",
14+
"ip": "47.96.115.18",
15+
"port": 1024
1116
}
1217
]

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.2-beta</version>
9+
<version>1.6.3-beta</version>
1010
<build>
1111
<plugins>
1212
<plugin>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
public enum Game {
1515
GOBANG("五子棋", false),
1616
LANDLORDS("斗地主", false),
17-
NON_GLUTTONOUS_SNAKE("不贪吃蛇", false);
17+
NON_GLUTTONOUS_SNAKE("不贪吃蛇", false),
18+
GAME_2048("2048", false),
19+
SUDOKU("数独", false);
1820

1921
/**
2022
* 游戏名称

xechat-plugin/build.gradle

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

66
group 'cn.xeblog'
7-
version '1.6.2-beta'
7+
version '1.6.3-beta'
88

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

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ public void process(String[] args) {
7878
username = name;
7979
}
8080
}
81-
username = StrUtil.trim(username);
8281

8382
if (StringUtils.isBlank(username)) {
8483
ConsoleAction.showSimpleMsg("用户名不能为空!");
8584
return;
8685
}
86+
87+
username = username.replaceAll("\\s*|\t|\r|\n", "");
8788
if (username.length() > 12) {
8889
ConsoleAction.showSimpleMsg("用户名长度不能超过12个字符!");
8990
return;

xechat-plugin/src/main/java/cn/xeblog/plugin/factory/MainWindowFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cn.xeblog.plugin.factory;
22

33
import cn.hutool.core.thread.GlobalThreadPool;
4+
import cn.xeblog.commons.util.ThreadUtils;
45
import cn.xeblog.plugin.action.InputAction;
56
import cn.xeblog.plugin.cache.DataCache;
67
import cn.xeblog.plugin.ui.MainWindow;
@@ -30,8 +31,8 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
3031
@Override
3132
public void ancestorAdded(AncestorEvent event) {
3233
GlobalThreadPool.execute(() -> {
33-
while (!InputAction.restCursor()) {
34-
}
34+
ThreadUtils.spinMoment(800);
35+
InputAction.restCursor();
3536
});
3637
}
3738
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package cn.xeblog.plugin.game.game2048;
2+
3+
import java.awt.*;
4+
5+
public class Block {
6+
int value;
7+
8+
public Block() {
9+
this(0);
10+
}
11+
12+
public Block(int num) {
13+
value = num;
14+
}
15+
16+
public boolean isEmpty() {
17+
return value == 0;
18+
}
19+
20+
public Color getForeground() {
21+
return value < 16 ? new Color(0x776e65) : new Color(0xf9f6f2);
22+
}
23+
24+
public Color getBackground() {
25+
switch (value) {
26+
case 2:
27+
return new Color(0xeee4da);
28+
case 4:
29+
return new Color(0xF1E1CA);
30+
case 8:
31+
return new Color(0xF6B17A);
32+
case 16:
33+
return new Color(0xF99563);
34+
case 32:
35+
return new Color(0xFB7B5E);
36+
case 64:
37+
return new Color(0xFA5D3A);
38+
case 128:
39+
return new Color(0xF1D071);
40+
case 256:
41+
return new Color(0xF1CC61);
42+
case 512:
43+
return new Color(0xF1C94E);
44+
case 1024:
45+
return new Color(0xF1C73F);
46+
case 2048:
47+
return new Color(0xF2C32D);
48+
}
49+
return new Color(0xcdc1b4);
50+
}
51+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package cn.xeblog.plugin.game.game2048;
2+
3+
import cn.xeblog.commons.enums.Game;
4+
import cn.xeblog.plugin.annotation.DoGame;
5+
import cn.xeblog.plugin.game.AbstractGame;
6+
7+
import javax.swing.*;
8+
import java.awt.*;
9+
10+
/**
11+
* @author 浓睡不消残酒
12+
* @date 2022/8/11 15:11 PM
13+
*/
14+
@DoGame(Game.GAME_2048)
15+
public class Game2048 extends AbstractGame {
16+
17+
@Override
18+
protected void init() {
19+
initMainPanel();
20+
mainPanel.setMinimumSize(new Dimension(150, 200));
21+
JPanel startPanel = new JPanel();
22+
startPanel.setBounds(10, 10, 120, 200);
23+
mainPanel.add(startPanel);
24+
25+
JLabel title = new JLabel("2048小游戏");
26+
title.setFont(new Font("", 1, 14));
27+
startPanel.add(title);
28+
29+
Box vBox = Box.createVerticalBox();
30+
startPanel.add(vBox);
31+
vBox.add(Box.createVerticalStrut(5));
32+
vBox.add(getStartGameButton());
33+
vBox.add(getExitButton());
34+
mainPanel.updateUI();
35+
}
36+
37+
@Override
38+
protected void start() {
39+
initMainPanel();
40+
int width = 240;
41+
int height = 300;
42+
mainPanel.setMinimumSize(new Dimension(width + 10, height + 10));
43+
mainPanel.setLayout(new BorderLayout());
44+
mainPanel.add(Box.createVerticalStrut(10), BorderLayout.NORTH);
45+
GameUI gameUI = new GameUI();
46+
mainPanel.add(gameUI, BorderLayout.CENTER);
47+
48+
JPanel buttonPanel = new JPanel();
49+
buttonPanel.add(getBackGameButton());
50+
buttonPanel.add(getExitButton());
51+
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
52+
mainPanel.updateUI();
53+
54+
gameUI.requestFocusInWindow();
55+
}
56+
57+
private JButton getStartGameButton() {
58+
JButton button = new JButton("开始游戏");
59+
button.addActionListener(e -> start());
60+
return button;
61+
}
62+
63+
private JButton getBackGameButton() {
64+
JButton button = new JButton("返回游戏");
65+
button.addActionListener(e -> init());
66+
return button;
67+
}
68+
69+
}

0 commit comments

Comments
 (0)