Skip to content

Commit 20826b3

Browse files
committed
feat: 后端接口切换到新系统
feat: 支持配置是否检查更新,并移除自动更新功能 fix: 修复了哔哩哔哩无法播放的问题 fix: 修复了网易云热评功能失效的问题 chore: 修改配置文件结构
1 parent 2b1b86e commit 20826b3

File tree

15 files changed

+176
-115
lines changed

15 files changed

+176
-115
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634634
ZMusic
635-
Copyright (C) 2020 真心
635+
Copyright (C) 2024 ZhenXin
636636

637637
This program is free software: you can redistribute it and/or modify
638638
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652652
If the program does terminal interaction, make it output a short
653653
notice like this when it starts in an interactive mode:
654654

655-
ZMusic Copyright (C) 2020 真心
655+
ZMusic Copyright (C) 2024 ZhenXin
656656
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657
This is free software, and you are welcome to redistribute it
658658
under certain conditions; type `show c' for details.

README.md

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,86 @@
1-
# ZMusic
1+
<div align="center">
22

3-
[![Build Status](https://ci.zhenxin.xyz/buildStatus/icon?job=Minecraft%2FZMusic)](https://ci.zhenxin.xyz/job/Minecraft/job/ZMusic/)
3+
![][banner]
44

5-
# 简介
5+
![][tested-versions]
6+
![][players]
7+
![][servers]
8+
9+
![][releases]
10+
![][downloads]
11+
![][license]
12+
13+
[文档][docs-link] | [QQ 群][qq-group-link] | [Discord][discord-link]
14+
15+
</div>
16+
17+
## 简介
618

719
这是一个功能强大的音乐系统,支持以下功能。
820

921
* 全服点歌
1022
* 单独播放
1123
* 歌词显示
12-
* 歌词翻译显示(目前仅支持网易云音乐)
13-
* 多搜索源(网易云/酷狗/酷我)
24+
* 歌词翻译显示
25+
* 多搜索源
1426
* 关键词搜索
1527
* 个人歌单
1628
* 全服歌单
17-
* 歌单播放(网易云)
18-
* 音量调节(AllMusic支持)
29+
* 歌单播放
30+
* 音量调节
31+
* 支持BungeeCord
32+
33+
## 文档
34+
35+
[点击查看使用文档][docs-link]
36+
37+
## 仓库
38+
39+
* [ZMusic](https://github.com/RealHeart/ZMusic) - 插件
40+
* [ZMusic Mod](https://github.com/RealHeart/ZMusic-Mod) - 配套模组
41+
* [ZMusic Docs](https://github.com/RealHeart/ZMusic-Docs) - 使用文档
42+
43+
## 开源协议
44+
45+
本项目使用 [GPL-3.0](LICENSE) 协议开放源代码
46+
47+
```text
48+
ZMusic - Powerful Music System
49+
Copyright (C) 2024 ZhenXin
50+
This program is free software: you can redistribute it and/or modify
51+
it under the terms of the GNU General Public License as published by
52+
the Free Software Foundation, either version 3 of the License, or
53+
(at your option) any later version.
54+
This program is distributed in the hope that it will be useful,
55+
but WITHOUT ANY WARRANTY; without even the implied warranty of
56+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57+
GNU General Public License for more details.
58+
You should have received a copy of the GNU General Public License
59+
along with this program. If not, see <http://www.gnu.org/licenses/>.
60+
```
61+
62+
## 贡献者
63+
64+
[![][contrib]](https://github.com/RealHeart/ZMusic/graphs/contributors)
1965

20-
# 视频
66+
[banner]: https://socialify.git.ci/RealHeart/ZMusic/image?description=1&forks=1&issues=1&language=1&name=1&owner=1&pulls=1&stargazers=1&theme=Auto
2167

22-
[点击前往哔哩哔哩查看演示视频](https://www.bilibili.com/video/av92156922)
68+
[license]: https://img.shields.io/github/license/RealHeart/ZMusic?style=for-the-badge
2369

24-
# 反馈
70+
[players]: https://img.shields.io/bstats/players/7291?label=players&style=for-the-badge
2571

26-
* 提交 [Issues](../../issues)
27-
* 加入交流群:[1032722724](https://jq.qq.com/?_wv=1027&k=5oIs7cc) 反馈
72+
[servers]: https://img.shields.io/bstats/servers/7291?label=servers&style=for-the-badge
2873

29-
# 使用文档
74+
[tested-versions]: https://img.shields.io/spiget/tested-versions/83027?style=for-the-badge
3075

31-
[点击查看使用文档](https://zmusic.zhenxin.xyz/)
76+
[releases]: https://img.shields.io/github/v/release/RealHeart/ZMusic?style=for-the-badge
3277

33-
# 本地化
78+
[downloads]: https://img.shields.io/github/downloads/RealHeart/ZMusic/total?style=for-the-badge
3479

35-
你可以通过翻译语言文件来达到插件本地化的意图
80+
[contrib]: https://contrib.rocks/image?repo=RealHeart/ZMusic
3681

37-
#### 操作步骤:
82+
[docs-link]: https://zmusic.zhenxin.me
3883

39-
1. Fork本仓库
40-
2. 本地修改/添加语言文件
41-
3. 提交Pull Request
84+
[qq-group-link]: https://jq.qq.com/?_wv=1027&k=9Xs1RMt5
4285

43-
语言文件修改/添加请参考 [示例文件](ZMusic-Plugin/src/main/resources/language/zh_CN.json)
86+
[discord-link]: https://discord.gg/twQgJNufYn

zmusic-plugin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'com.github.johnrengelman.shadow' version '8.1.1'
33
}
44

5-
version = '2.8.2'
5+
version = '2.8.5'
66

77
dependencies {
88
compileOnly 'ink.ptms:nms-all:1.0.0'

zmusic-plugin/src/main/java/me/zhenxin/zmusic/ZMusic.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public final class ZMusic {
2828

2929
public static File dataFolder;
3030
public static String thisVer;
31-
public static int thisVerCode = 202307220;
32-
public static boolean bilibiliIsVIP = false;
31+
public static int thisVerCode = 202402210;
32+
public static boolean isVip = false;
3333
public static boolean isViaVer = true;
3434
public static boolean isEnable = true;
3535
public static boolean isEnableEd = false;
@@ -49,7 +49,7 @@ public static void disable() {
4949
}
5050
}
5151
ZMusic.log.sendNormalMessage("插件作者: 真心");
52-
ZMusic.log.sendNormalMessage("博客:www.zhenxin.xyz");
52+
ZMusic.log.sendNormalMessage("主页:zhenxin.me");
5353
ZMusic.log.sendNormalMessage("QQ:1307993674");
5454
ZMusic.log.sendNormalMessage("插件交流群:1032722724");
5555
ZMusic.log.sendNormalMessage("插件已卸载完成!");
@@ -67,7 +67,7 @@ public static void loadEnd(Object sender) {
6767
NeteaseLogin.anonymous();
6868
}
6969
ZMusic.log.sendNormalMessage("插件作者: 真心");
70-
ZMusic.log.sendNormalMessage("博客:www.zhenxin.xyz");
70+
ZMusic.log.sendNormalMessage("主页:zhenxin.me");
7171
ZMusic.log.sendNormalMessage("QQ:1307993674");
7272
ZMusic.log.sendNormalMessage("插件交流群:1032722724");
7373
ZMusic.log.sendNormalMessage("插件已加载完成!");

zmusic-plugin/src/main/java/me/zhenxin/zmusic/command/Cmd.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,10 @@ public void run() {
282282
}
283283
break;
284284
case "163hot":
285-
if (ZMusic.player.isPlayer(sender)) {
286-
if (args.length == 2) {
287-
OtherUtils.neteaseHotComments(sender, OtherUtils.argsXin1(args, ""));
288-
} else {
289-
HelpUtils.sendHelp("main", sender);
290-
}
285+
if (args.length == 2) {
286+
OtherUtils.neteaseHotComments(sender, OtherUtils.argsXin1(args, ""));
291287
} else {
292-
ZMusic.message.sendErrorMessage("错误: 该命令只能由玩家使用", sender);
288+
HelpUtils.sendHelp("main", sender);
293289
}
294290
break;
295291
case "test":

zmusic-plugin/src/main/java/me/zhenxin/zmusic/config/Config.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ public class Config {
77
// Version
88
public static int version;
99
// LatestVersion
10-
public static int latestVersion = 10;
10+
public static int latestVersion = 11;
1111
// Debug
1212
public static boolean debug;
13-
// Update
14-
public static boolean update;
13+
// CheckUpdate
14+
public static boolean checkUpdate;
1515
// Api
1616
public static String neteaseApiRoot;
17-
// Account
18-
// Netease
17+
// NeteaseFollow
1918
public static boolean neteaseFollow;
20-
// Bilibili
21-
public static String bilibiliQQ;
22-
public static String bilibiliKey;
19+
// VIP
20+
public static String vipAccount;
21+
public static String vipSecret;
2322
// Music
2423
public static int money;
2524
public static int cooldown;

zmusic-plugin/src/main/java/me/zhenxin/zmusic/config/LoadConfig.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private void init(JsonObject config) {
6060
Config.version = config.get("version").getAsInt();
6161
// Debug
6262
Config.debug = config.get("debug").getAsBoolean();
63-
Config.update = config.get("update").getAsBoolean();
63+
Config.checkUpdate = config.get("check-update").getAsBoolean();
6464
// Prefix
6565
Config.prefix = config.get("prefix").getAsString().replaceAll("&", "§");
6666
// Api
@@ -70,21 +70,25 @@ private void init(JsonObject config) {
7070
neteaseApiRoot += "/";
7171
}
7272
Config.neteaseApiRoot = neteaseApiRoot;
73-
// Account
74-
JsonObject account = config.get("account").getAsJsonObject();
75-
// Netease
76-
JsonObject netease = account.get("netease").getAsJsonObject();
77-
Config.neteaseFollow = netease.get("follow").getAsBoolean();
78-
// Bilibili
79-
JsonObject bilibili = account.get("bilibili").getAsJsonObject();
80-
Config.bilibiliQQ = bilibili.get("qq").getAsString();
81-
Config.bilibiliKey = bilibili.get("key").getAsString();
82-
if (!Config.bilibiliKey.equalsIgnoreCase("none")) {
73+
// NeteaseFollow
74+
Config.neteaseFollow = config.get("netease-follow").getAsBoolean();
75+
// VIP
76+
JsonObject vip = config.get("vip").getAsJsonObject();
77+
Config.vipAccount = vip.get("account").getAsString();
78+
Config.vipSecret = vip.get("secret").getAsString();
79+
if (!Config.vipSecret.equalsIgnoreCase("none")) {
8380
ZMusic.runTask.runAsync(() -> {
8481
Gson gson = new GsonBuilder().create();
85-
String jsonText = NetUtils.getNetString("https://api.zhenxin.xyz/minecraft/plugins/ZMusic/bilibili/checkVIP.php", null, "qq=" + Config.bilibiliQQ + "&key=" + Config.bilibiliKey);
82+
JsonObject data = new JsonObject();
83+
data.addProperty("account", Config.vipAccount);
84+
data.addProperty("secret", Config.vipSecret);
85+
String jsonText = NetUtils.postNetString("https://api.zhenxin.me/zmusic/vip/check", null, data);
8686
JsonObject json = gson.fromJson(jsonText, JsonObject.class);
87-
ZMusic.bilibiliIsVIP = json.get("isVIP").getAsBoolean();
87+
int code = json.get("code").getAsInt();
88+
if (code == 200) {
89+
JsonObject dataJson = json.get("data").getAsJsonObject();
90+
ZMusic.isVip = dataJson.get("isVip").getAsBoolean();
91+
}
8892
});
8993
}
9094
// Music

zmusic-plugin/src/main/java/me/zhenxin/zmusic/login/NeteaseLogin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ public static void anonymous() {
6464

6565
public static Boolean isLogin() {
6666
String result = NetUtils.getNetString(API + "login/status?timestamp=" + time(), null);
67-
JsonObject data = GSON.fromJson(result, JsonObject.class);
67+
JsonObject root = GSON.fromJson(result, JsonObject.class);
6868
try {
69+
JsonObject data = root.getAsJsonObject("data");
6970
data.get("profile").getAsJsonObject();
7071
return true;
7172
} catch (Exception e) {

zmusic-plugin/src/main/java/me/zhenxin/zmusic/music/PlayMusic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static void play(String searchKey, String source, Object player, String t
5656
searchSourceName = "酷我音乐";
5757
break;
5858
case "bilibili":
59-
if (ZMusic.bilibiliIsVIP) {
59+
if (ZMusic.isVip) {
6060
ZMusic.message.sendNormalMessage("哔哩哔哩音乐需要在插件服务器将M4A转换为MP3。", player);
6161
ZMusic.message.sendNormalMessage("第一次搜索将会耗时很久,如有其他用户使用过,将会返回缓存文件。", player);
6262
ZMusic.message.sendNormalMessage("请耐心等待。。。。", player);

zmusic-plugin/src/main/java/me/zhenxin/zmusic/music/searchSource/BiliBiliMusic.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ public static JsonObject getMusic(String keyword) {
3939
.split("<audio preload=\"auto\" src=\"")[1]
4040
.split("\"")[0];
4141
musicUrl = musicUrl.replaceAll("&amp;", "&");
42-
musicUrl = NetUtils.getNetString("https://api.zhenxin.xyz/minecraft/plugins/ZMusic/bilibili/getMp3.php", null,
43-
"qq=" + Config.bilibiliQQ + "&key=" + Config.bilibiliKey + "&id=" + musicId + "&url=" + URLEncoder.encode(musicUrl, "UTF-8"));
42+
43+
JsonObject data = new JsonObject();
44+
data.addProperty("account", Config.vipAccount);
45+
data.addProperty("secret", Config.vipSecret);
46+
data.addProperty("id", "bilibili_" + musicId);
47+
data.addProperty("url", musicUrl);
48+
musicUrl = NetUtils.postNetString("https://api.zhenxin.me/zmusic/vip/m4a2mp3", null, data);
49+
4450
JsonObject returnJSON = new JsonObject();
4551
returnJSON.addProperty("id", musicId);
4652
returnJSON.addProperty("url", musicUrl);

0 commit comments

Comments
 (0)