diff --git a/src/main/java/fengliu/cloudmusic/command/MusicCommand.java b/src/main/java/fengliu/cloudmusic/command/MusicCommand.java index 84d7b44..458c4d9 100644 --- a/src/main/java/fengliu/cloudmusic/command/MusicCommand.java +++ b/src/main/java/fengliu/cloudmusic/command/MusicCommand.java @@ -42,6 +42,7 @@ public class MusicCommand { Text.translatable("cloudmusic.help.music.similar.playlist"), Text.translatable("cloudmusic.help.music.comment"), Text.translatable("cloudmusic.help.music.hot.comment"), + Text.translatable("cloudmusic.help.music.send.comment"), Text.translatable("cloudmusic.help.playlist"), Text.translatable("cloudmusic.help.playlist.play"), @@ -51,6 +52,7 @@ public class MusicCommand { Text.translatable("cloudmusic.help.playlist.del"), Text.translatable("cloudmusic.help.playlist.comment"), Text.translatable("cloudmusic.help.playlist.hot.comment"), + Text.translatable("cloudmusic.help.playlist.send.comment"), Text.translatable("cloudmusic.help.artist"), Text.translatable("cloudmusic.help.artist.top"), @@ -65,15 +67,18 @@ public class MusicCommand { Text.translatable("cloudmusic.help.album.unsubscribe"), Text.translatable("cloudmusic.help.album.comment"), Text.translatable("cloudmusic.help.album.hot.comment"), + Text.translatable("cloudmusic.help.album.send.comment"), Text.translatable("cloudmusic.help.dj"), Text.translatable("cloudmusic.help.dj.play"), Text.translatable("cloudmusic.help.dj.music"), Text.translatable("cloudmusic.help.dj.music.play"), + Text.translatable("cloudmusic.help.dj.music.send.comment"), Text.translatable("cloudmusic.help.dj.music.comment"), Text.translatable("cloudmusic.help.dj.music.hot.comment"), Text.translatable("cloudmusic.help.dj.subscribe"), Text.translatable("cloudmusic.help.dj.unsubscribe"), + Text.translatable("cloudmusic.help.dj.send.comment"), Text.translatable("cloudmusic.help.dj.comment"), Text.translatable("cloudmusic.help.dj.hot.comment"), @@ -357,7 +362,7 @@ protected TextClickItem putPageItem(Object data) { argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { Music music = music163.music(LongArgumentType.getLong(contextData, "id")); - page = music.getComments(false); + page = music.comments(false); page.setInfoText(Text.translatable("cloudmusic.info.page.music.comments", music.name)); page.look(context.getSource()); }); @@ -370,7 +375,7 @@ protected TextClickItem putPageItem(Object data) { argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { Music music = music163.music(LongArgumentType.getLong(contextData, "id")); - page = music.getComments(true); + page = music.comments(true); page.setInfoText(Text.translatable("cloudmusic.info.page.music.hot.comments", music.name)); page.look(context.getSource()); }); @@ -378,6 +383,19 @@ protected TextClickItem putPageItem(Object data) { }) ))); + // cloudmusic music send comment id content + CloudMusic.then(Music.then(literal("send").then(literal("comment").then( + argument("id", LongArgumentType.longArg()).then( + argument("content", StringArgumentType.string()).executes(contextData -> { + runCommand(contextData, context -> { + Music music = music163.music(LongArgumentType.getLong(context, "id")); + music.send(StringArgumentType.getString(context, "content")); + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.send.comment", music.name)); + }); + return Command.SINGLE_SUCCESS; + }) + ))))); + // cloudmusic playlist id CloudMusic.then(PlayList.then( argument("id", LongArgumentType.longArg()).executes(contextData -> { @@ -402,12 +420,26 @@ protected TextClickItem putPageItem(Object data) { }) ))); + // cloudmusic playlist send comment id content + CloudMusic.then(PlayList.then(literal("send").then(literal("comment").then( + argument("id", LongArgumentType.longArg()).then( + argument("content", StringArgumentType.string()).executes(contextData -> { + runCommand(contextData, context -> { + PlayList playlist = music163.playlist(LongArgumentType.getLong(context, "id")); + playlist.send(StringArgumentType.getString(context, "content")); + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.send.comment", playlist.name)); + }); + return Command.SINGLE_SUCCESS; + }) + ))))); + + // cloudmusic playlist comment id CloudMusic.then(PlayList.then(literal("comment").then( argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { PlayList playList = music163.playlist(LongArgumentType.getLong(contextData, "id")); - page = playList.getComments(false); + page = playList.comments(false); page.setInfoText(Text.translatable("cloudmusic.info.page.playlist.comments", playList.name)); page.look(context.getSource()); }); @@ -420,7 +452,7 @@ protected TextClickItem putPageItem(Object data) { argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { PlayList playList = music163.playlist(LongArgumentType.getLong(contextData, "id")); - page = playList.getComments(true); + page = playList.comments(true); page.setInfoText(Text.translatable("cloudmusic.info.page.playlist.hot.comments", playList.name)); page.look(context.getSource()); }); @@ -591,12 +623,26 @@ protected TextClickItem putPageItem(Object data) { }) ))); + // cloudmusic album send comment id content + CloudMusic.then(Album.then(literal("send").then(literal("comment").then( + argument("id", LongArgumentType.longArg()).then( + argument("content", StringArgumentType.string()).executes(contextData -> { + runCommand(contextData, context -> { + Album album = music163.album(LongArgumentType.getLong(context, "id")); + album.send(StringArgumentType.getString(context, "content")); + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.send.comment", album.name)); + }); + return Command.SINGLE_SUCCESS; + }) + ))))); + + // cloudmusic album comment id CloudMusic.then(Album.then(literal("comment").then( argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { Album album = music163.album(LongArgumentType.getLong(context, "id")); - page = album.getComments(false); + page = album.comments(false); page.setInfoText(Text.translatable("cloudmusic.info.page.album.comments", album.name)); page.look(context.getSource()); }); @@ -609,7 +655,7 @@ protected TextClickItem putPageItem(Object data) { argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { Album album = music163.album(LongArgumentType.getLong(context, "id")); - page = album.getComments(true); + page = album.comments(true); page.setInfoText(Text.translatable("cloudmusic.info.page.album.hot.comments", album.name)); page.look(context.getSource()); }); @@ -654,23 +700,36 @@ protected TextClickItem putPageItem(Object data) { // cloudmusic dj play id CloudMusic.then(Dj.then(literal("play").then( - argument("id", LongArgumentType.longArg()).executes(contextData -> { - runCommand(contextData, context -> { - DjRadio djRadio = music163.djRadio(LongArgumentType.getLong(context, "id")); - resetPlayer(djRadio); - context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.dj.play", djRadio.name)); - player.start(); - }); - return Command.SINGLE_SUCCESS; - }) + argument("id", LongArgumentType.longArg()).executes(contextData -> { + runCommand(contextData, context -> { + DjRadio djRadio = music163.djRadio(LongArgumentType.getLong(context, "id")); + resetPlayer(djRadio); + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.dj.play", djRadio.name)); + player.start(); + }); + return Command.SINGLE_SUCCESS; + }) ))); + // cloudmusic dj send comment id content + CloudMusic.then(Dj.then(literal("send").then(literal("comment").then( + argument("id", LongArgumentType.longArg()).then( + argument("content", StringArgumentType.string()).executes(contextData -> { + runCommand(contextData, context -> { + DjRadio djRadio = music163.djRadio(LongArgumentType.getLong(context, "id")); + djRadio.send(StringArgumentType.getString(context, "content")); + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.send.comment", djRadio.name)); + }); + return Command.SINGLE_SUCCESS; + }) + ))))); + // cloudmusic dj comment id CloudMusic.then(Dj.then(literal("comment").then( argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { DjRadio djRadio = music163.djRadio(LongArgumentType.getLong(context, "id")); - page = djRadio.getComments(false); + page = djRadio.comments(false); page.setInfoText(Text.translatable("cloudmusic.info.page.dj.radio.comments", djRadio.name)); page.look(context.getSource()); }); @@ -683,7 +742,7 @@ protected TextClickItem putPageItem(Object data) { argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { DjRadio djRadio = music163.djRadio(LongArgumentType.getLong(context, "id")); - page = djRadio.getComments(true); + page = djRadio.comments(true); page.setInfoText(Text.translatable("cloudmusic.info.page.dj.radio.hot.comments", djRadio.name)); page.look(context.getSource()); }); @@ -718,12 +777,26 @@ protected TextClickItem putPageItem(Object data) { }) )))); + // cloudmusic dj music send comment id content + CloudMusic.then(Dj.then(DjMusic.then(literal("send").then(literal("comment").then( + argument("id", LongArgumentType.longArg()).then( + argument("content", StringArgumentType.string()).executes(contextData -> { + runCommand(contextData, context -> { + DjMusic music = music163.djMusic(LongArgumentType.getLong(context, "id")); + music.send(StringArgumentType.getString(context, "content")); + + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.send.comment", music.name)); + }); + return Command.SINGLE_SUCCESS; + }) + )))))); + // cloudmusic dj music comment id CloudMusic.then(Dj.then(DjMusic.then(literal("comment").then( argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { DjMusic music = music163.djMusic(LongArgumentType.getLong(context, "id")); - page = music.getComments(false); + page = music.comments(false); page.setInfoText(Text.translatable("cloudmusic.info.page.dj.music.comments", music.name)); page.look(context.getSource()); }); @@ -736,7 +809,7 @@ protected TextClickItem putPageItem(Object data) { argument("id", LongArgumentType.longArg()).executes(contextData -> { runCommand(contextData, context -> { DjMusic music = music163.djMusic(LongArgumentType.getLong(context, "id")); - page = music.getComments(true); + page = music.comments(true); page.setInfoText(Text.translatable("cloudmusic.info.page.dj.music.hot.comments", music.name)); page.look(context.getSource()); }); @@ -1309,39 +1382,31 @@ protected TextClickItem putPageItem(Object data) { LiteralArgumentBuilder Comment = literal("comment"); - // cloudmusic comment + // cloudmusic comment id threadId CloudMusic.then(Comment.then( argument("id", LongArgumentType.longArg()).then( - argument("commentId", StringArgumentType.string()).executes(context -> { + argument("threadId", StringArgumentType.string()).executes(context -> { long id = LongArgumentType.getLong(context, "id"); - JsonObject json = page.getJsonItem(jsonObject -> { - return jsonObject.get("commentId").getAsLong() == id; - }); + JsonObject json = page.getJsonItem(jsonObject -> jsonObject.get("commentId").getAsLong() == id); if (json == null) { return Command.SINGLE_SUCCESS; } - Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(context, "commentId")); + Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(context, "threadId")); comment.printToChatHud(context.getSource()); - - context.getSource().sendFeedback(TextClickItem.combine( - new TextClickItem("comment.floors", "/cloudmusic comment floors %s %s".formatted(id, comment.threadId)), - new TextClickItem("comment.reply", "/cloudmusic comment reply %s %s".formatted(id, comment.threadId)), - new TextClickItem("comment.like", "/cloudmusic comment like %s %s".formatted(id, comment.threadId)), - new TextClickItem("comment.delete", "/cloudmusic comment delete %s %s".formatted(id, comment.threadId)) - )); return Command.SINGLE_SUCCESS; }) )) ); + // cloudmusic comment floors id threadId CloudMusic.then(Comment.then(literal("floors").then(argument("id", LongArgumentType.longArg()).then( - argument("commendId", StringArgumentType.string()).executes(contextData -> { + argument("threadId", StringArgumentType.string()).executes(contextData -> { long id = LongArgumentType.getLong(contextData, "id"); JsonObject json = page.getJsonItem(jsonObject -> jsonObject.get("commentId").getAsLong() == id); if (json == null) { return Command.SINGLE_SUCCESS; } - Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(contextData, "commentId")); + Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(contextData, "threadId")); runCommand(contextData, context -> { page = comment.floors(); page.setInfoText(Text.translatable("cloudmusic.info.page.comment.floors", comment.id)); @@ -1351,6 +1416,83 @@ protected TextClickItem putPageItem(Object data) { }) )))); + // cloudmusic comment like id threadId + CloudMusic.then(Comment.then(literal("like").then(argument("id", LongArgumentType.longArg()).then( + argument("threadId", StringArgumentType.string()).executes(contextData -> { + long id = LongArgumentType.getLong(contextData, "id"); + JsonObject json = page.getJsonItem(jsonObject -> jsonObject.get("commentId").getAsLong() == id); + if (json == null) { + return Command.SINGLE_SUCCESS; + } + + runCommand(contextData, context -> { + Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(context, "threadId")); + comment.like(); + + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.comment.like", comment.content)); + }); + return Command.SINGLE_SUCCESS; + }) + )))); + + // cloudmusic comment unlike id threadId + CloudMusic.then(Comment.then(literal("unlike").then(argument("id", LongArgumentType.longArg()).then( + argument("threadId", StringArgumentType.string()).executes(contextData -> { + long id = LongArgumentType.getLong(contextData, "id"); + JsonObject json = page.getJsonItem(jsonObject -> jsonObject.get("commentId").getAsLong() == id); + if (json == null) { + return Command.SINGLE_SUCCESS; + } + + runCommand(contextData, context -> { + Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(context, "threadId")); + comment.unlike(); + + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.comment.unlike", comment.content)); + }); + return Command.SINGLE_SUCCESS; + }) + )))); + + // cloudmusic comment delete id threadId + CloudMusic.then(Comment.then(literal("delete").then(argument("id", LongArgumentType.longArg()).then( + argument("threadId", StringArgumentType.string()).executes(contextData -> { + long id = LongArgumentType.getLong(contextData, "id"); + JsonObject json = page.getJsonItem(jsonObject -> jsonObject.get("commentId").getAsLong() == id); + if (json == null) { + return Command.SINGLE_SUCCESS; + } + + runCommand(contextData, context -> { + Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(context, "threadId")); + comment.delete(); + + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.comment.delete", comment.content)); + }); + return Command.SINGLE_SUCCESS; + }) + )))); + + // cloudmusic comment reply id threadId content + CloudMusic.then(Comment.then(literal("reply").then(argument("id", LongArgumentType.longArg()).then( + argument("threadId", StringArgumentType.string()).then( + argument("content", StringArgumentType.string()).executes(contextData -> { + long id = LongArgumentType.getLong(contextData, "id"); + JsonObject json = page.getJsonItem(jsonObject -> jsonObject.get("commentId").getAsLong() == id); + if (json == null) { + return Command.SINGLE_SUCCESS; + } + + runCommand(contextData, context -> { + Comment comment = new Comment(music163.getHttpClient(), json, StringArgumentType.getString(context, "threadId")); + comment.reply(StringArgumentType.getString(context, "content")); + + context.getSource().sendFeedback(Text.translatable("cloudmusic.info.command.comment.reply", comment.content)); + }); + return Command.SINGLE_SUCCESS; + }) + ))))); + // cloudmusic volume CloudMusic.then(Volume.executes(context -> { context.getSource().sendFeedback(Text.translatable("cloudmusic.info.volume", Configs.PLAY.VOLUME.getIntegerValue())); diff --git a/src/main/java/fengliu/cloudmusic/music163/ICanComment.java b/src/main/java/fengliu/cloudmusic/music163/ICanComment.java index 23b2258..15031a0 100644 --- a/src/main/java/fengliu/cloudmusic/music163/ICanComment.java +++ b/src/main/java/fengliu/cloudmusic/music163/ICanComment.java @@ -13,15 +13,26 @@ import java.util.Map; public interface ICanComment { - ApiPage getComments(boolean hot); + String getThreadId(); - default ApiPage comments(HttpClient api, long id, String threadId, boolean hot) { + HttpClient getApi(); + + default void send(String content) { + Map data = new HashMap(); + data.put("threadId", this.getThreadId()); + data.put("content", content); + + this.getApi().POST_API("/api/resource/comments/add", data); + } + + default ApiPage comments(boolean hot) { Map data = new HashMap(); - data.put("rid", id); + data.put("rid", this.getThreadId().split("_")[3]); data.put("limit", 24); + String threadId = this.getThreadId(); String path = "/api/v1/resource/%s/%s".formatted(hot ? "hotcomments" : "comments", threadId); - JsonObject json = api.POST_API(path, data); + JsonObject json = this.getApi().POST_API(path, data); int total = json.get("total").getAsInt(); if (total == 0) { @@ -29,7 +40,7 @@ default ApiPage comments(HttpClient api, long id, String threadId, boolean hot) } String arrayKey = hot ? "hotComments" : "comments"; - return new ApiPage(json.getAsJsonArray(arrayKey), json.get("total").getAsInt(), path, api, data) { + return new ApiPage(json.getAsJsonArray(arrayKey), json.get("total").getAsInt(), path, this.getApi(), data) { @Override protected JsonArray getNewPageDataJsonArray(JsonObject result) { return result.getAsJsonArray(arrayKey); diff --git a/src/main/java/fengliu/cloudmusic/music163/data/Album.java b/src/main/java/fengliu/cloudmusic/music163/data/Album.java index 063040e..dd7c3fe 100644 --- a/src/main/java/fengliu/cloudmusic/music163/data/Album.java +++ b/src/main/java/fengliu/cloudmusic/music163/data/Album.java @@ -7,7 +7,6 @@ import fengliu.cloudmusic.util.HttpClient; import fengliu.cloudmusic.util.IdUtil; import fengliu.cloudmusic.util.TextClickItem; -import fengliu.cloudmusic.util.page.ApiPage; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -52,8 +51,13 @@ public Album(HttpClient api, JsonObject album) { } @Override - public ApiPage getComments(boolean hot) { - return this.comments(this.api, this.id, this.threadId, hot); + public String getThreadId() { + return this.threadId; + } + + @Override + public HttpClient getApi() { + return this.api; } @Override @@ -102,6 +106,7 @@ public void printToChatHud(FabricClientCommandSource source) { source.sendFeedback(TextClickItem.combine( new TextClickItem("play", "/cloudmusic album play " + this.id), + new TextClickItem("send.comment", "/cloudmusic album send comment " + this.id), new TextClickItem("hot.comment", "/cloudmusic album hotComment " + this.id), new TextClickItem("comment", "/cloudmusic album comment " + this.id), new TextClickItem("subscribe", "/cloudmusic album subscribe " + this.id), diff --git a/src/main/java/fengliu/cloudmusic/music163/data/Comment.java b/src/main/java/fengliu/cloudmusic/music163/data/Comment.java index e3cfd55..6195c95 100644 --- a/src/main/java/fengliu/cloudmusic/music163/data/Comment.java +++ b/src/main/java/fengliu/cloudmusic/music163/data/Comment.java @@ -11,6 +11,7 @@ import fengliu.cloudmusic.util.page.ApiPage; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import java.util.HashMap; import java.util.Map; @@ -34,7 +35,7 @@ public class Comment extends Music163Obj implements IPrint { */ public Comment(HttpClient api, JsonObject data, String threadId) { super(api, data); - this.id = data.get("commentId").getAsLong(); + this.id = data.has("commentId") ? data.get("commentId").getAsLong() : data.get("beRepliedCommentId").getAsLong(); this.threadId = threadId; this.content = data.get("content").getAsString(); this.time = data.get("time").getAsLong(); @@ -47,22 +48,22 @@ public Comment(HttpClient api, JsonObject data, String threadId) { public ApiPage floors() { String threadId = this.threadId; - Map data = new HashMap(); + Map data = new HashMap<>(); data.put("parentCommentId", this.id); data.put("threadId", threadId); data.put("limit", 24); JsonObject json = api.POST_API("/api/resource/comment/floor/get", data); - int total = json.get("total").getAsInt(); + int total = json.getAsJsonObject("data").get("totalCount").getAsInt(); if (total == 0) { - throw new ActionException(Text.translatable("cloudmusic.exception.not.hot.comments")); + throw new ActionException(Text.translatable("cloudmusic.exception.not.comment.floors")); } - return new ApiPage(json.getAsJsonArray("comments"), json.get("total").getAsInt(), "/api/resource/comment/floor/get", api, data) { + return new ApiPage(json.getAsJsonObject("data").getAsJsonArray("comments"), total, "/api/resource/comment/floor/get", api, data) { @Override protected JsonArray getNewPageDataJsonArray(JsonObject result) { - return result.getAsJsonArray("comments"); + return result.getAsJsonObject("data").getAsJsonArray("comments"); } @Override @@ -98,15 +99,65 @@ public String getPageItem() { this.content, Text.translatable("cloudmusic.page.item.comments.like", this.likedCount).getString(), this.id); } + public void reply(String content) { + Map data = new HashMap<>(); + data.put("threadId", this.threadId); + data.put("commentId", this.id); + data.put("content", content); + + this.api.POST_API("/api/resource/comments/reply", data); + } + + protected void like(boolean _in) { + Map data = new HashMap<>(); + data.put("threadId", this.threadId); + data.put("commentId", this.id); + + this.api.POST_API("/api/v1/comment/" + (_in ? "like" : "unlike"), data); + } + + public void like() { + this.like(true); + } + + public void unlike() { + this.like(false); + } + + public void delete() { + Map data = new HashMap<>(); + data.put("threadId", this.threadId); + data.put("commentId", this.id); + + this.api.POST_API("/api/resource/comments/delete", data); + } + @Override public void printToChatHud(FabricClientCommandSource source) { if (!this.beReplied.isEmpty()) { +// source.sendFeedback(new TextClickItem( +// (MutableText) this.getBeContent(), +// Text.translatable(IdUtil.getShowInfo("page.comment")), +// "/cloudmusic comment %s %s".formatted(this.beReplied.get(0).getAsJsonObject().get("beRepliedCommentId").getAsLong(), this.threadId) +// ).build()); source.sendFeedback(this.getBeContent()); - source.sendFeedback(Text.literal("")); + source.sendFeedback(Text.literal("========================").formatted(Formatting.GRAY)); } - source.sendFeedback(Text.literal("%s - %s: %s".formatted(this.user.get("nickname").getAsString(), this.ipLocation.get("location").getAsString(), this.content))); + source.sendFeedback(new TextClickItem( + Text.literal("%s - %s: %s".formatted(this.user.get("nickname").getAsString(), this.ipLocation.get("location").getAsString(), this.content)), + Text.translatable(IdUtil.getShowInfo("comment.user")), + "/cloudmusic user " + this.user.get("userId").getAsLong() + ).build()); source.sendFeedback(Text.translatable("cloudmusic.info.comment.time", this.timeStr)); source.sendFeedback(Text.translatable("cloudmusic.page.item.comments.like", this.likedCount)); + + source.sendFeedback(TextClickItem.combine( + new TextClickItem("comment.floors", "/cloudmusic comment floors %s %s".formatted(id, this.threadId)), + new TextClickItem("comment.reply", "/cloudmusic comment reply %s %s".formatted(id, this.threadId)), + new TextClickItem("comment.like", "/cloudmusic comment like %s %s".formatted(id, this.threadId)), + new TextClickItem("comment.unlike", "/cloudmusic comment unlike %s %s".formatted(id, this.threadId)), + new TextClickItem("comment.delete", "/cloudmusic comment delete %s %s".formatted(id, this.threadId)) + )); } } diff --git a/src/main/java/fengliu/cloudmusic/music163/data/DjMusic.java b/src/main/java/fengliu/cloudmusic/music163/data/DjMusic.java index acf2b11..b40722d 100644 --- a/src/main/java/fengliu/cloudmusic/music163/data/DjMusic.java +++ b/src/main/java/fengliu/cloudmusic/music163/data/DjMusic.java @@ -5,7 +5,6 @@ import fengliu.cloudmusic.music163.*; import fengliu.cloudmusic.util.HttpClient; import fengliu.cloudmusic.util.TextClickItem; -import fengliu.cloudmusic.util.page.ApiPage; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.text.Text; @@ -90,8 +89,13 @@ public long getDuration() { } @Override - public ApiPage getComments(boolean hot) { - return this.comments(this.api, this.id, this.threadId, hot); + public String getThreadId() { + return this.threadId; + } + + @Override + public HttpClient getApi() { + return this.api; } @Override @@ -126,6 +130,7 @@ public void printToChatHud(FabricClientCommandSource source) { source.sendFeedback(TextClickItem.combine( new TextClickItem("play", "/cloudmusic dj music play " + this.id), + new TextClickItem("send.comment", "/cloudmusic dj music send comment " + this.id), new TextClickItem("hot.comment", "/cloudmusic dj music hotComment " + this.id), new TextClickItem("comment", "/cloudmusic dj music comment " + this.id), new TextClickItem("shar", Shares.DJ_MUSIC.getShar(this.id)) diff --git a/src/main/java/fengliu/cloudmusic/music163/data/DjRadio.java b/src/main/java/fengliu/cloudmusic/music163/data/DjRadio.java index 4c012a2..30fb3ac 100644 --- a/src/main/java/fengliu/cloudmusic/music163/data/DjRadio.java +++ b/src/main/java/fengliu/cloudmusic/music163/data/DjRadio.java @@ -11,7 +11,6 @@ import fengliu.cloudmusic.util.IdUtil; import fengliu.cloudmusic.util.MusicPlayer; import fengliu.cloudmusic.util.TextClickItem; -import fengliu.cloudmusic.util.page.ApiPage; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -89,8 +88,13 @@ public void run() { } @Override - public ApiPage getComments(boolean hot) { - return this.comments(this.api, this.id, this.threadId, hot); + public String getThreadId() { + return this.threadId; + } + + @Override + public HttpClient getApi() { + return this.api; } @Override @@ -149,6 +153,7 @@ public void printToChatHud(FabricClientCommandSource source) { source.sendFeedback(TextClickItem.combine( new TextClickItem("play", "/cloudmusic dj play " + this.id), + new TextClickItem("send.comment", "/cloudmusic dj send comment " + this.id), new TextClickItem("hot.comment", "/cloudmusic dj hotComment " + this.id), new TextClickItem("comment", "/cloudmusic dj comment " + this.id), new TextClickItem("subscribe", "/cloudmusic dj subscribe " + this.id), diff --git a/src/main/java/fengliu/cloudmusic/music163/data/Music.java b/src/main/java/fengliu/cloudmusic/music163/data/Music.java index f65ac99..0643f12 100644 --- a/src/main/java/fengliu/cloudmusic/music163/data/Music.java +++ b/src/main/java/fengliu/cloudmusic/music163/data/Music.java @@ -8,7 +8,6 @@ import fengliu.cloudmusic.util.HttpClient; import fengliu.cloudmusic.util.IdUtil; import fengliu.cloudmusic.util.TextClickItem; -import fengliu.cloudmusic.util.page.ApiPage; import fengliu.cloudmusic.util.page.Page; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.text.Text; @@ -237,8 +236,13 @@ public long getDuration() { } @Override - public ApiPage getComments(boolean hot) { - return this.comments(this.api, this.id, this.threadId, hot); + public String getThreadId() { + return this.threadId; + } + + @Override + public HttpClient getApi() { + return this.api; } @Override @@ -287,6 +291,7 @@ public void printToChatHud(FabricClientCommandSource source) { )); source.sendFeedback(TextClickItem.combine( + new TextClickItem("send.comment", "/cloudmusic music send comment " + this.id), new TextClickItem("hot.comment", "/cloudmusic music hotComment " + this.id), new TextClickItem("comment", "/cloudmusic music comment " + this.id), new TextClickItem("playlist.add", "/cloudmusic my playlist add " + this.id), diff --git a/src/main/java/fengliu/cloudmusic/music163/data/PlayList.java b/src/main/java/fengliu/cloudmusic/music163/data/PlayList.java index 075df69..1a72a87 100644 --- a/src/main/java/fengliu/cloudmusic/music163/data/PlayList.java +++ b/src/main/java/fengliu/cloudmusic/music163/data/PlayList.java @@ -7,7 +7,6 @@ import fengliu.cloudmusic.util.HttpClient; import fengliu.cloudmusic.util.IdUtil; import fengliu.cloudmusic.util.TextClickItem; -import fengliu.cloudmusic.util.page.ApiPage; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -99,8 +98,13 @@ public List getMusics(){ } @Override - public ApiPage getComments(boolean hot) { - return this.comments(this.api, this.id, this.threadId, hot); + public String getThreadId() { + return this.threadId; + } + + @Override + public HttpClient getApi() { + return this.api; } @Override @@ -145,6 +149,7 @@ public void printToChatHud(FabricClientCommandSource source) { source.sendFeedback(TextClickItem.combine( new TextClickItem("play", "/cloudmusic playlist play " + this.id), + new TextClickItem("send.comment", "/cloudmusic playlist send comment " + this.id), new TextClickItem("hot.comment", "/cloudmusic playlist hotComment " + this.id), new TextClickItem("comment", "/cloudmusic playlist comment " + this.id), new TextClickItem("subscribe", "/cloudmusic playlist subscribe " + this.id), diff --git a/src/main/resources/assets/cloudmusic/lang/zh_cn.json b/src/main/resources/assets/cloudmusic/lang/zh_cn.json index 8e6dc94..6e84ba1 100644 --- a/src/main/resources/assets/cloudmusic/lang/zh_cn.json +++ b/src/main/resources/assets/cloudmusic/lang/zh_cn.json @@ -7,6 +7,7 @@ "cloudmusic.help.music.similar.playlist": "获取歌曲相似歌单 /cloudmusic music similar playlist [id]", "cloudmusic.help.music.comment": "获取歌曲评论 /cloudmusic music comment [id]", "cloudmusic.help.music.hot.comment": "获取歌曲热评 /cloudmusic music hotComment [id]", + "cloudmusic.help.music.send.comment": "向歌曲发送评论 /cloudmusic music send comment [threadId] [content]", "cloudmusic.help.playlist": "获取歌单 /cloudmusic playlist [id]", "cloudmusic.help.playlist.play": "播放歌单 /cloudmusic music playlist [id]", "cloudmusic.help.playlist.subscribe": "收藏歌单 /cloudmusic playlist subscribe [id]", @@ -15,6 +16,7 @@ "cloudmusic.help.playlist.del": "歌单删除歌曲 /cloudmusic playlist del [id] [歌曲 id]", "cloudmusic.help.playlist.comment": "获取歌单评论 /cloudmusic playlist comment [id]", "cloudmusic.help.playlist.hot.comment": "获取歌单热评 /cloudmusic playlist hotComment [id]", + "cloudmusic.help.playlist.send.comment": "向歌单发送评论 /cloudmusic playlist send comment [threadId] [content]", "cloudmusic.help.artist": "获取歌手 /cloudmusic artist [id]", "cloudmusic.help.artist.top": "播放歌手热门 50 首 /cloudmusic artist top [id]", "cloudmusic.help.artist.album": "查看歌手所有专辑 /cloudmusic artist album [id]", @@ -27,12 +29,15 @@ "cloudmusic.help.album.unsubscribe": "取消收藏专辑 /cloudmusic album unsubscribe [id]", "cloudmusic.help.album.comment": "获取专辑评论 /cloudmusic album comment [id]", "cloudmusic.help.album.hot.comment": "获取专辑热评 /cloudmusic album hotComment [id]", + "cloudmusic.help.album.send.comment": "向专辑发送评论 /cloudmusic album send comment [threadId] [content]", "cloudmusic.help.dj": "获取电台 /cloudmusic dj [id]", "cloudmusic.help.dj.play": "播放电台 /cloudmusic dj play [id]", + "cloudmusic.help.dj.send.comment": "向电台发送评论 /cloudmusic dj send comment [threadId] [content]", "cloudmusic.help.dj.music": "获取电台节目 /cloudmusic dj music [id]", "cloudmusic.help.dj.music.play": "播放电台节目 /cloudmusic dj music play [id]", "cloudmusic.help.dj.music.comment": "获取电台节目评论 /cloudmusic dj music comment [id]", "cloudmusic.help.dj.music.hot.comment": "获取电台节目热评 /cloudmusic dj hotComment [id]", + "cloudmusic.help.dj.send.comment": "向电台节目发送评论 /cloudmusic dj music send comment [threadId] [content]", "cloudmusic.help.dj.subscribe": "收藏电台 /cloudmusic dj subscribe [id]", "cloudmusic.help.dj.unsubscribe": "取消收藏电台 /cloudmusic dj unsubscribe [id]", "cloudmusic.help.dj.comment": "获取电台评论 /cloudmusic dj comment [id]", @@ -195,9 +200,12 @@ "cloudmusic.info.page.dj.radio.comments": "电台 %s 的评论", "cloudmusic.info.page.dj.radio.hot.comments": "电台 %s 的热论", "cloudmusic.info.page.dj.music.comments": "电台节目 %s 的评论", - "cloudmusic.info.page.dj.music.hot.comments": "电台节目 %s 的热论", + "cloudmusic.info.page.dj.music.hot.comments": "评论的子评论", + "cloudmusic.info.page.comment.floors": "电台节目 %s 的热论", "cloudmusic.page.item.comments.like": "点赞数: %s", - "cloudmusic.info.comment.be.replied": "§b回复 %s - %s§r§7: %s", + "cloudmusic.info.comment.be.replied": "§b回复 §b%s - %s§r§7: %s", + "cloudmusic.info.comment.user.show": "点击查看发送评论用户", + "cloudmusic.info.comment.time": "发送时间: %s", "cloudmusic.info.page.comment.null": "该评论已删除", "cloudmusic.info.page.comment.err.null": "该评论涉及违规内容,经举报已被屏蔽", "cloudmusic.info.page.help": "CloudMusic 帮助", @@ -230,6 +238,11 @@ "cloudmusic.info.command.music.play": "播放 %s", "cloudmusic.info.command.trash": "将 %s 扔进垃圾桶", "cloudmusic.info.command.style.not.children": "曲风 %s - %s 没有子曲风", + "cloudmusic.info.command.send.comment": "向资源 %s 发送了一条评论", + "cloudmusic.info.command.comment.like": "点赞了评论 %s", + "cloudmusic.info.command.comment.unlike": "取消点赞了评论 %s", + "cloudmusic.info.command.comment.delete": "删除了评论 %s", + "cloudmusic.info.command.comment.reply": "回复了评论 %s", "cloudmusic.info.command.login": "成功登录至 %s", "cloudmusic.info.command.login.send.captcha": "成功向手机号发送验证码...", "cloudmusic.info.command.country.code": "设置手机号国家码为 %s...", @@ -282,6 +295,8 @@ "cloudmusic.options.style.album.show": "点击查看该曲风的专辑", "cloudmusic.options.children.style": "[子曲风]", "cloudmusic.options.children.style.show": "点击查看曲风所有子类型", + "cloudmusic.options.send.comment": "[发送回复]", + "cloudmusic.options.send.comment.show": "点击并补充回复內容进行发送评论", "cloudmusic.options.hot.comment": "[热评]", "cloudmusic.options.hot.comment.show": "点击查看该资源热评", "cloudmusic.options.comment": "[评论]", @@ -292,6 +307,8 @@ "cloudmusic.options.comment.reply.show": "点击并补充回复內容进行回复评论", "cloudmusic.options.comment.like": "[点赞]", "cloudmusic.options.comment.like.show": "点击点赞评论", + "cloudmusic.options.comment.unlike": "[取消点赞]", + "cloudmusic.options.comment.unlike.show": "点击取消点赞评论", "cloudmusic.options.comment.delete": "[删除]", "cloudmusic.options.comment.delete.show": "点击删除评论", "cloudmusic.options.page.prev": "[上一页]", @@ -317,6 +334,7 @@ "cloudmusic.exception.http.download": "下载文件重试超出最大次数 %s 次, 错误: %s", "cloudmusic.exception.not.comments": "该资源目前没有评论...", "cloudmusic.exception.not.hot.comments": "该资源目前没有热评...", + "cloudmusic.exception.not.comment.floors": "该评论目前没有子评论...", "cloudmusic.play.quality.standard": "标准", "cloudmusic.play.quality.higher": "较高", "cloudmusic.play.quality.exhigh": "极高",