This commit is contained in:
Coloryr committed 2026-11-02 22:01:21 +08:00
1 parent 64e08b4bd3
commit e9dfb3078d
33 files changed
+541 -313

No files matched your search

+9 -8
View File
@@ -33,20 +33,20 @@
1. 安装AllMusic_Server
Paper服务器
复制`[paper]AllMusic_Server-4.2.9.jar`到你的`plugins`文件夹
复制`[paper]AllMusic_Server-4.3.0.jar`到你的`plugins`文件夹
Folia服务器
复制`[folia]AllMusic_Server-4.2.9.jar`到你的`plugins`文件夹
复制`[folia]AllMusic_Server-4.3.0.jar`到你的`plugins`文件夹
Velocity服务器
复制`[velocity]AllMusic_Server-4.2.9.jar`到你的`plugins`文件夹
复制`[velocity]AllMusic_Server-4.3.0.jar`到你的`plugins`文件夹
BungeeCord服务器
复制`[bungeecord]AllMusic_Server-4.2.9.jar`到你的`plugins`文件夹
复制`[bungeecord]AllMusic_Server-4.3.0.jar`到你的`plugins`文件夹
Forge/Fabric/NeoForge类服务器
复制`[xxx-xxx]AllMusic_Server-4.2.9.jar`到你的`mods`文件夹
复制`[xxx-xxx]AllMusic_Server-4.3.0.jar`到你的`mods`文件夹
注:Release页面下载的文件名会把方括号换成点,比如`paper.AllMusic_Server-4.2.9.jar`,和上面是同一个文件
注:Release页面下载的文件名会把方括号换成点,比如`paper.AllMusic_Server-4.3.0.jar`,和上面是同一个文件
2. 安装客户端mod
复制`[xxx-xxx]AllMusic_Client-4.2.9.jar`到客户端的`mods`文件夹
复制`[xxx-xxx]AllMusic_Client-4.3.0.jar`到客户端的`mods`文件夹
重启客户端
如果你是单人游戏使用或者联机使用OneJar版本
@@ -64,7 +64,7 @@ AllMusic不会内置音乐api,你想要正常使用需要自己安装
- 插件端(Paper/Folia/BungeeCord/Velocity):使用 MiniMessage 颜色输出
- 模组端(Forge/Fabric/NeoForge):输出到对应模组日志,颜色会被去掉
启动时会依次打印插件版本、配置文件版本、语言文件版本、注册的音乐API,最后是`已启动-4.0.0`
启动时会依次打印插件版本、配置文件版本、语言文件版本、注册的音乐API,最后是`已启动-4.3.0`
| 日志 | 说明 |
| --- | --- |
@@ -141,6 +141,7 @@ AllMusic不会内置音乐api,你想要正常使用需要自己安装
| `/music hud pic size <像素>` | 设置封面尺寸 |
| `/music hud pic rotate [true/false]` | 设置封面旋转 |
| `/music hud pic speed <数值>` | 设置封面旋转速度(每多少毫秒转1度) |
| `/music hud pic bg [true/false]` | 设置图片底图是否渲染 |
对齐方式取值:`TOP_LEFT`、`TOP_CENTER`、`TOP_RIGHT`、`LEFT`、`CENTER`、`RIGHT`、`BOTTOM_LEFT`、`BOTTOM_CENTER`、`BOTTOM_RIGHT`
@@ -1,12 +1,14 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
/**
* Fabric(1.16.5)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,16 +17,17 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(ClientCommandManager.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,15 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +17,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,13 +1,16 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.minecraft.commands.Commands;
/**
* Fabric(1.19.3+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里。
* 注意这里必须用 ClientCommandManager 建节点,客户端指令的 source 是 FabricClientCommandSource
*/
public final class CommandMusicClientFabric {
private CommandMusicClientFabric() {
@@ -15,18 +18,19 @@ public final class CommandMusicClientFabric {
public static void register() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) ->
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
dispatcher.register(ClientCommandManager.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args")))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(ClientCommandManager.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(ClientCommandManager.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(ClientCommandManager.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))}))))));
}
}
@@ -1,5 +1,6 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
@@ -1,14 +1,16 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
/**
* Forge(1.16.5+)的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
public final class CommandMusicClientForge {
private CommandMusicClientForge() {
@@ -17,16 +19,17 @@ public final class CommandMusicClientForge {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,5 +1,6 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
@@ -1,7 +1,8 @@
package com.coloryr.allmusic.client;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +13,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +26,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,7 +1,9 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +14,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +27,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,7 +1,9 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +14,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +27,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,7 +1,9 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +14,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +27,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,7 +1,9 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +14,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +27,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,7 +1,9 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +14,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +27,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,7 +1,9 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +14,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +27,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -1,7 +1,9 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
import com.coloryr.allmusic.client.core.CommandMusicClient;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
@@ -12,7 +14,7 @@ import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
/**
* NeoForge 的 /music_client 指令壳
* <p>
* 只负责注册指令,具体逻辑都在通用的 {@link CommandMusicClient} 里
* 只负责注册指令(包括 Tab 补全用的子指令节点),具体逻辑都在通用的 {@link CommandMusicClient} 里
*/
@EventBusSubscriber(modid = AllMusicClient.MODID, value = Dist.CLIENT)
public final class CommandMusicClientNeoForge {
@@ -25,16 +27,17 @@ public final class CommandMusicClientNeoForge {
dispatcher.register(Commands.literal(CommandMusicClient.NAME)
.executes(context -> CommandMusicClient.run(new String[0]))
.then(Commands.argument("args", StringArgumentType.greedyString())
.executes(context -> CommandMusicClient.run(
split(StringArgumentType.getString(context, "args"))))));
}
private static String[] split(String args) {
String text = args == null ? "" : args.trim();
if (text.isEmpty()) {
return new String[0];
}
return text.split("\\s+");
.then(Commands.literal(CommandMusicClient.ARG_HELP)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_HELP})))
.then(Commands.literal(CommandMusicClient.ARG_INFO)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_INFO})))
.then(Commands.literal(CommandMusicClient.ARG_TEST)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_TEST})))
.then(Commands.literal(CommandMusicClient.ARG_IMAGE_SIZE)
.executes(context -> CommandMusicClient.run(new String[]{CommandMusicClient.ARG_IMAGE_SIZE}))
.then(Commands.argument("size", IntegerArgumentType.integer(AllMusicCore.MIN_PIC_SIZE, AllMusicCore.MAX_PIC_SIZE))
.executes(context -> CommandMusicClient.run(new String[]{
CommandMusicClient.ARG_IMAGE_SIZE,
Integer.toString(IntegerArgumentType.getInteger(context, "size"))})))));
}
}
@@ -14,11 +14,13 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.IntBuffer;
import java.nio.charset.StandardCharsets;
@@ -26,7 +28,10 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -46,14 +51,12 @@ public class AllMusicCore {
/**
* 默认静音的日志
* <p>
* httpclient 的调试输出会刷 debug.log;
* 旅行者地图则是按 debug 等级在屏幕上画调试标签(TileDrawStep 里 isDebugEnabled() 就画),
* 所以一起压到 INFO,避免 debug.log 和屏幕都被刷
* httpclient 的调试输出会刷 debug.log(http-outgoing 之类),压到 INFO 就够了;
* 别的 mod 不动,尤其是旅行者地图:它会按自己的 debug 等级在屏幕上画调试标签
*/
public static final List<String> DEFAULT_LOG_QUIET = Arrays.asList(
"org.apache.hc.client5",
"org.apache.hc.core5",
"journeymap");
"org.apache.hc.core5");
private static final Gson gson = new Gson();
/**
@@ -142,13 +145,100 @@ public class AllMusicCore {
AllMusicCore.bridge = bridge;
player = new AllMusicPlayer(source);
// LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
// Configuration logConfig = ctx.getConfiguration();
//
// setLoggerLevel(logConfig, "org.apache.hc.client5", Level.INFO);
// setLoggerLevel(logConfig, "org.apache.hc.core5", Level.INFO);
//
// ctx.updateLoggers(logConfig);
applyLogLevels();
}
/**
* 按配置把日志压到 INFO
* <p>
* 不能直接 setLevel 根 logger(getLoggerConfig 找不到同名 logger 时会返回根 logger)。
* 但只建 LoggerConfig 也不行:{@code updateLoggers} 会按配置重建所有 logger 的等级,
* 把别的 mod 运行时自己 setLevel 的设置一起重置——旅行者地图就是这样,
* 它的 journeymap logger 会被重置回继承的 DEBUG,然后开始在屏幕上画调试标签。
* 所以这里先记下所有 logger 的等级,更新完再把不属于静音范围的恢复回去。
*/
private static void applyLogLevels() {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration logConfig = ctx.getConfiguration();
Map<String, Level> levels = snapshotLevels(ctx);
for (String name : config.logQuiet) {
if (name == null || name.isEmpty()) {
continue;
}
setLoggerLevel(logConfig, name, Level.INFO);
}
ctx.updateLoggers(logConfig);
for (Map.Entry<String, Level> entry : levels.entrySet()) {
if (entry.getValue() == null || isQuiet(config.logQuiet, entry.getKey())) {
continue;
}
Logger logger = ctx.getLogger(entry.getKey());
if (!entry.getValue().equals(logger.getLevel())) {
logger.setLevel(entry.getValue());
}
}
}
/**
* 记下当前所有 logger 的等级
* <p>
* log4j 2.8+ 有 {@code getLoggers()};1.7.10/1.12.2 自带的 2.0-beta9 没有,退到私有字段
*
* @param ctx 日志上下文
* @return logger 名字到等级的映射
*/
private static Map<String, Level> snapshotLevels(LoggerContext ctx) {
Map<String, Level> levels = new HashMap<>();
try {
Method method = LoggerContext.class.getMethod("getLoggers");
Object result = method.invoke(ctx);
if (result instanceof Collection) {
for (Object item : (Collection<?>) result) {
if (item instanceof Logger) {
Logger logger = (Logger) item;
levels.put(logger.getName(), logger.getLevel());
}
}
}
return levels;
} catch (Throwable ignored) {
// 老版本没有 getLoggers
}
try {
Field field = LoggerContext.class.getDeclaredField("loggers");
field.setAccessible(true);
Object result = field.get(ctx);
if (result instanceof Map) {
for (Object item : ((Map<?, ?>) result).values()) {
if (item instanceof Logger) {
Logger logger = (Logger) item;
levels.put(logger.getName(), logger.getLevel());
}
}
}
} catch (Throwable ignored) {
// 拿不到就算了,至少不会去改根 logger
}
return levels;
}
/**
* 是否属于要静音的日志
*/
private static boolean isQuiet(List<String> quiet, String name) {
for (String prefix : quiet) {
if (prefix != null && (name.equals(prefix) || name.startsWith(prefix + "."))) {
return true;
}
}
return false;
}
/**
@@ -788,13 +788,13 @@ public class AllMusicHud {
}
//绘制图片
if (save.pic.enable && haveImg) {
if (save.pic.rotate) {
if (save.pic.bg && save.pic.rotate) {
bg1.drawPic(save.pic.x, save.pic.y, save.pic.size, save.pic.size, save.pic.pos, save.pic.alpha);
}
picRender.draw(save.pic.rotate, save.pic.size, save.pic.x, save.pic.y, ang, save.pic.pos, save.pic.alpha);
if (save.pic.rotate) {
if (save.pic.bg && save.pic.rotate) {
bg3.drawPic(save.pic.x, save.pic.y, save.pic.size, save.pic.size, save.pic.pos, save.pic.alpha);
}
}
@@ -1,6 +1,4 @@
package com.coloryr.allmusic.client;
import com.coloryr.allmusic.client.core.AllMusicCore;
package com.coloryr.allmusic.client.core;
import java.util.ArrayList;
import java.util.List;
@@ -16,10 +14,22 @@ import java.util.Locale;
public class CommandMusicClient {
public static final String NAME = "music_client";
private static final String ARG_HELP = "help";
private static final String ARG_INFO = "info";
private static final String ARG_TEST = "test";
private static final String ARG_IMAGE_SIZE = "imagesize";
/**
* 子指令:帮助
*/
public static final String ARG_HELP = "help";
/**
* 子指令:状态
*/
public static final String ARG_INFO = "info";
/**
* 子指令:自检
*/
public static final String ARG_TEST = "test";
/**
* 子指令:图片大小
*/
public static final String ARG_IMAGE_SIZE = "imagesize";
/**
* 所有子指令,Tab 补全用
@@ -4,6 +4,7 @@ public class HudPicPosObj extends HudBasePosObj {
public int size;
public boolean rotate;
public int speed;
public boolean bg;
public HudPicPosObj copy() {
HudPicPosObj obj = new HudPicPosObj();
@@ -15,6 +16,7 @@ public class HudPicPosObj extends HudBasePosObj {
obj.enable = enable;
obj.alpha = alpha;
obj.speed = speed;
obj.bg = bg;
return obj;
}
}
@@ -65,6 +65,7 @@ public class HudPosObj {
obj.rotate = true;
obj.alpha = 1.0f;
obj.speed = 30;
obj.bg = true;
return obj;
}
@@ -53,15 +53,15 @@ public class AllMusic {
/**
* 插件版本号
*/
public static final String version = "4.0.0";
public static final String version = "4.3.0";
/**
* 配置文件版本号
*/
public static final String configVersion = "402";
public static final String configVersion = "403";
/**
* 语言文件配置版本号
*/
public static final String messageVersion = "401";
public static final String messageVersion = "402";
/**
* 日志
*/
@@ -60,6 +60,7 @@ public class CommandHudSet extends AHudCommand {
commandList.put("size", new PicSize());
commandList.put("rotate", new PicRotate());
commandList.put("speed", new PicRotateSpeed());
commandList.put("bg", new PicBg());
} else if (type == HudType.INFO) {
commandList.put("color", new HudColor(type));
commandList.put("shadow", new HudShadow(type));
@@ -426,4 +427,26 @@ public class CommandHudSet extends AHudCommand {
AllMusic.getMessage().hud.picSpeed.replace(ARG.value, args[3]));
}
}
private static class PicBg extends ACommand {
@Override
public void execute(Object sender, String name, String[] args) {
if (args.length == 3 || args.length == 4) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.picRotate
.replace(ARG.value, HudUtils.setPicBg(name, args.length == 4 ? args[3] : null)
? AllMusic.getMessage().hudList.enable
: AllMusic.getMessage().hudList.disable));
return;
}
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
}
@Override
public List<String> tab(Object player, String name, String[] args, int index) {
if (args.length == index + 1) {
return CommandHud.tf;
}
return Collections.emptyList();
}
}
}
@@ -31,6 +31,7 @@ public class HelpNormalObj {
public String hud12;
public String hud13;
public String hud14;
public String hud15;
public String join;
public static HelpNormalObj make() {
@@ -99,6 +100,8 @@ public class HelpNormalObj {
return true;
if (hud14 == null)
return true;
if (hud15 == null)
return true;
if (agree == null)
return true;
return hud5 == null;
@@ -157,6 +160,8 @@ public class HelpNormalObj {
hud13 = "<light_purple>[AllMusic]<yellow>/music hud [位置] maxwidth [长度] 设置滚动模式开启后,最大渲染长度";
if (hud14 == null)
hud14 = "<light_purple>[AllMusic]<yellow>/music hud [位置] gap [值] 设置文本之间的间隔";
if (hud15 == null)
hud15 = "<light_purple>[AllMusic]<yellow>/music hud pic bg [开关] 设置底图是否显示";
if (hud3 == null)
hud3 = "<light_purple>[AllMusic]<yellow>/music hud pic size [尺寸] 设置图片尺寸";
if (hud4 == null)
@@ -17,6 +17,7 @@ public class HudObj {
public String picSize;
public String picRotate;
public String picSpeed;
public String picBg;
public String music;
public String lyric;
public String tlyric;
@@ -66,6 +67,8 @@ public class HudObj {
return true;
if (picSpeed == null)
return true;
if (picBg == null)
return true;
return klyric == null;
}
@@ -102,6 +105,8 @@ public class HudObj {
picRotate = "<light_purple>[AllMusic]<yellow>设置图片旋转为[" + ARG.value + "]";
if (picSpeed == null)
picSpeed = "<light_purple>[AllMusic]<yellow>设置图片旋转速度为[" + ARG.value + "]";
if (picBg == null)
picBg = "<light_purple>[AllMusic]<yellow>设置图片底图为[" + ARG.value + "]";
if (music == null)
music = ARG.name + " " + ARG.musicAuthor + "\n" + ARG.musicAlia + "\n" + ARG.musicAl
+ "\nby: " + ARG.player;
@@ -332,6 +332,27 @@ public class HudUtils {
return obj.pic.rotate;
}
/**
* 图片旋转开关
*
* @param player 用户名
* @param open 开关
* @return 结果
*/
public static boolean setPicBg(String player, String open) {
HudPosObj obj = HudSave.getOrNew(player);
if (open != null) {
obj.pic.bg = Boolean.parseBoolean(open);
} else {
obj.pic.bg = !obj.pic.bg;
}
HudSave.update(player, obj);
HudUtils.sendHudPos(player);
return obj.pic.bg;
}
/**
* 图片旋转速度设置
*