Skip to content

Commit 62f8394

Browse files
authored
Merge pull request #54 from GregTaoo/dev
Dev
2 parents 1a4166c + 6aecbcd commit 62f8394

30 files changed

+432
-175
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
-----------------------------
1212

1313

14-
**Wiki 基准模组版本:1.3.5**
14+
**Wiki 基准模组版本:1.3.7**
1515

16-
目前已知支持版本:1.21.4, 1.21.1, 1.20.6, 1.20.1, 1.19.4, 1.18.2, 1.17.1, 1.16.5,其余版本未经测试
16+
目前已知支持版本:1.21.5, 1.21.4, 1.21.1, 1.20.6, 1.20.1, 1.19.4, 1.18.2, 1.17.1, 1.16.5,其余版本未经测试
1717

1818
### 安全提醒!
1919

@@ -48,6 +48,8 @@
4848

4949
`reload`: 重新加载播放队列和客户端配置文件
5050

51+
`restart`: 重新启动播放器(可修复卡死)
52+
5153
`list [页码]`: 显示第 `[页码]` 页播放队列(10条歌曲一页)
5254

5355
`save`: 缓存当前歌曲(详见 可缓存歌曲)
@@ -97,7 +99,7 @@
9799

98100
4. `/musicroom`(客户端指令,服务端必须安装 Concerto 才能正常使用)
99101

100-
`create`: 新建并加入音乐室,并自动复制音乐室的 UUID(详见 音乐室)
102+
`create`: 新建并加入音乐室,并自动复制音乐室的 UUID,默认需要管理员(详见 音乐室、服务端配置文件
101103

102104
`join [UUID]`: 加入编号为 `[UUID]` 的音乐室
103105

@@ -195,6 +197,7 @@
195197
- `timeProgressTextColor`: 歌曲播放进度文字颜色(格式详见下方 颜色配置,默认为 `#ffffffff`
196198
- `timeProgressColor`: 歌曲播放进度条颜色(格式详见下方 颜色配置,默认为 `#ff0155bc`
197199
- `timeProgressBgColor`: 歌曲播放进度条背景颜色(格式详见下方 颜色配置,默认为 `#ffa1c7f6`
200+
- `textShadow`: 歌词/音乐信息显示文字阴影(默认开启)
198201

199202
### 位置格式配置
200203

@@ -225,12 +228,16 @@
225228
- Q: 网易云音乐用密码或验证码登录时出现“当前登录存在安全风险”
226229
- A: 网易云风控导致,请优先考虑使用二维码登录
227230

231+
232+
- Q: QQ音乐无法查看个人歌单/无法播放
233+
- A: 只能重新登录,目前无解决方法,每次开游戏都得重新登录
234+
228235
### 使用的开源项目
229236

230237
- [java-stream-player](https://github.com/goxr3plus/java-stream-player)
231238
- [ZXing](https://github.com/zxing/zxing)
232239
- [soundlibs](https://github.com/pdudits/soundlibs)
233-
- [jflac](https://github.com/nguillaumin/jflac)
240+
- [JustFlac](https://github.com/drogatkin/JustFLAC)
234241
- [java-vorbis-support](https://github.com/Trilarion/java-vorbis-support)
235242
- [jaudiotagger](https://github.com/marcoc1712/jaudiotagger)
236243
- [Fabric](https://github.com/FabricMC/fabric)

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ dependencies {
3131
my('com.googlecode.soundlibs:mp3spi:1.9.5.4') {
3232
exclude group: 'com.googlecode.soundlibs', module: 'tritonus-share'
3333
}
34-
my 'org.jflac:jflac-codec:1.5.2'
34+
// my 'org.jflac:jflac-codec:1.5.2'
35+
my 'com.github.GregTaoo:JustFLAC:85f0934435'
3536
my 'com.github.trilarion:vorbis-support:1.1.0'
3637
my('com.googlecode.soundlibs:tritonus-all:0.3.7.2') {
3738
exclude group: 'com.googlecode.soundlibs', module: 'tritonus-share'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ loader_version=0.16.10
99
fabric_version=0.119.5+1.21.5
1010

1111
# Mod Properties
12-
mod_version=1.3.6
12+
mod_version=1.3.7
1313
maven_group=top.gregtao.concerto
1414
archives_base_name=Concerto-fabric

src/main/java/top/gregtao/concerto/ConcertoServer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import top.gregtao.concerto.command.ConcertoServerCommand;
1313
import top.gregtao.concerto.config.PresetRadioConfig;
1414
import top.gregtao.concerto.config.ServerConfig;
15+
import top.gregtao.concerto.http.netease.NeteaseCloudApiClient;
16+
import top.gregtao.concerto.http.qq.QQMusicApiClient;
1517
import top.gregtao.concerto.network.ConcertoNetworking;
1618
import top.gregtao.concerto.network.ServerMusicNetworkHandler;
1719

@@ -41,5 +43,7 @@ public void reload(ResourceManager manager) {
4143
public static void reload() {
4244
ServerConfig.INSTANCE.readOptions();
4345
PresetRadioConfig.INSTANCE.read();
46+
NeteaseCloudApiClient.INSTANCE.readCookie();
47+
QQMusicApiClient.INSTANCE.readCookie();
4448
}
4549
}

src/main/java/top/gregtao/concerto/api/DynamicPath.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public interface DynamicPath {
66

77
String updateRawPath();
88

9+
String getLastSuffix();
10+
911
String getLastLyrics();
1012

1113
String getLastSubLyrics();

src/main/java/top/gregtao/concerto/command/ConcertoServerCommand.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import net.minecraft.text.Text;
1111
import net.minecraft.util.Formatting;
1212
import top.gregtao.concerto.ConcertoServer;
13+
import top.gregtao.concerto.http.netease.NeteaseCloudApiClient;
14+
import top.gregtao.concerto.http.qq.QQMusicApiClient;
1315
import top.gregtao.concerto.network.MusicDataPacket;
1416
import top.gregtao.concerto.network.room.ServerMusicAgent;
1517
import top.gregtao.concerto.network.ServerMusicNetworkHandler;
@@ -71,9 +73,16 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher, C
7173
).then(
7274
CommandManager.literal("reload").requires(source -> source.hasPermissionLevel(2))
7375
.executes(context -> {
74-
ConcertoServer.reload();
75-
return 0;
76-
})
76+
ConcertoServer.reload();
77+
return 0;
78+
})
79+
).then(
80+
CommandManager.literal("reload-cookie").requires(source -> source.hasPermissionLevel(2))
81+
.executes(context -> {
82+
NeteaseCloudApiClient.INSTANCE.readCookie();
83+
QQMusicApiClient.INSTANCE.readCookie();
84+
return 0;
85+
})
7786
).then(
7887
CommandManager.literal("fetch-radios")
7988
.requires(source -> source.hasPermissionLevel(0)).executes(context -> {

src/main/java/top/gregtao/concerto/command/MusicCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ public static LiteralArgumentBuilder<FabricClientCommandSource> registerPlayerCo
121121
TextUtil.commandMessageClient(context, Text.translatable("concerto.player.clear"));
122122
return 0;
123123
})
124+
).then(
125+
ClientCommandManager.literal("restart").executes(context -> {
126+
MusicPlayer.resetInstance();
127+
TextUtil.commandMessageClient(context, Text.translatable("concerto.success"));
128+
return 0;
129+
})
124130
).then(
125131
ClientCommandManager.literal("mode").then(
126132
ClientCommandManager.argument("mode", OrderTypeArgumentType.orderType()).executes((context -> {
@@ -209,11 +215,13 @@ public static LiteralArgumentBuilder<FabricClientCommandSource> registerPlayerCo
209215
).then(
210216
ClientCommandManager.literal("download-current").executes(context -> {
211217
MusicPlayerHandler.downloadMusics(List.of(MusicPlayerHandler.INSTANCE.getCurrentMusic()));
218+
context.getSource().getPlayer().sendMessage(Text.translatable("concerto.success"), false);
212219
return 0;
213220
})
214221
).then(
215222
ClientCommandManager.literal("download-all").executes(context -> {
216223
MusicPlayerHandler.downloadMusics(MusicPlayerHandler.INSTANCE.getMusicList());
224+
context.getSource().getPlayer().sendMessage(Text.translatable("concerto.success"), false);
217225
return 0;
218226
})
219227
).then(

src/main/java/top/gregtao/concerto/config/ClientConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public static class ClientConfigOptions {
7575
public String timeProgressTextColor = "#ffffffff";
7676
public String timeProgressColor = "#ff0155bc";
7777
public String timeProgressBgColor = "#ffa1c7f6";
78+
79+
public boolean textShadow = true;
7880
}
7981

8082
public static class PositionXYSupplier {

src/main/java/top/gregtao/concerto/http/HttpApiClient.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public HttpApiClient(String name, Map<String, String> defaultHeaders, Map<String
3434
this.cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
3535
this.client = HttpClient.newBuilder().cookieHandler(this.cookieManager).build();
3636
this.defaultHeaders = defaultHeaders;
37-
this.cookieFile.read(this.cookieManager);
37+
this.readCookie();
3838
initCookies.forEach((url, list) -> {
3939
try {
4040
this.cookieManager.put(new URI(url), Map.of("Set-Cookie", list));
@@ -67,10 +67,14 @@ public String getName() {
6767
return this.name;
6868
}
6969

70-
public void updateCookie() {
70+
public void writeCookie() {
7171
this.cookieFile.write(this.cookieManager);
7272
}
7373

74+
public void readCookie() {
75+
this.cookieFile.read(this.cookieManager);
76+
}
77+
7478
public void clearCookie() {
7579
this.cookieManager = new CookieManager();
7680
this.cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
@@ -91,11 +95,11 @@ public String getCookie(String url, String key) throws IOException, URISyntaxExc
9195

9296
public void setCookie(String url, String key, String value) throws IOException, URISyntaxException {
9397
this.cookieManager.put(new URI(url), Map.of("Set-Cookie", List.of(key + "=" + value)));
94-
this.updateCookie();
98+
this.writeCookie();
9599
}
96100

97101
public static Map<Character, Character> ESCAPE_MAP = Map.of(
98-
'\u00a0', ' ', '\r', '\n'
102+
'\u00a0', ' ', '\ufeff', ' ', '\r', '\n'
99103
); // escape illegal spaces
100104

101105
public static String escapeChars(String string) {

src/main/java/top/gregtao/concerto/http/HttpRequestBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public HttpResponse<InputStream> openStream() {
8383
try {
8484
HttpResponse<InputStream> response = this.client.getClient().send(request, HttpResponse.BodyHandlers.ofInputStream());
8585
this.client.getLogger().info("STREAM {} GET {}", response.statusCode(), this.url);
86-
this.client.updateCookie();
86+
this.client.writeCookie();
8787
return response;
8888
} catch (IOException | InterruptedException e) {
8989
this.client.getLogger().error("ERROR GET STREAM {} : {}", this.url, e.getMessage());
@@ -102,7 +102,7 @@ public <T> HttpResponse<T> get(HttpResponse.BodyHandler<T> bodyHandler) {
102102
} else {
103103
this.client.getLogger().info("{} GET {}", response.statusCode(), this.url);
104104
}
105-
this.client.updateCookie();
105+
this.client.writeCookie();
106106
return response;
107107
} catch (IOException | InterruptedException e) {
108108
this.client.getLogger().error("ERROR GET {} : {}", this.url, e.getMessage());
@@ -126,7 +126,7 @@ public <T> HttpResponse<T> post(HttpResponse.BodyHandler<T> bodyHandler, Content
126126
} else {
127127
this.client.getLogger().info("{} POST {}", response.statusCode(), this.url);
128128
}
129-
this.client.updateCookie();
129+
this.client.writeCookie();
130130
return response;
131131
} catch (IOException | InterruptedException e) {
132132
this.client.getLogger().error("ERROR POST {} : {}", this.url, e.getMessage());

0 commit comments

Comments
 (0)