diff --git a/core/AllMusic.java b/core/AllMusic.java index db1bd190..432ff074 100644 --- a/core/AllMusic.java +++ b/core/AllMusic.java @@ -7,7 +7,6 @@ import com.coloryr.allmusic.server.core.music.PlayRuntime; import com.coloryr.allmusic.server.core.objs.CookieObj; import com.coloryr.allmusic.server.core.objs.config.ConfigObj; import com.coloryr.allmusic.server.core.objs.message.MessageObj; -import com.coloryr.allmusic.server.core.objs.music.SearchPageObj; import com.coloryr.allmusic.server.core.objs.music.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; import com.coloryr.allmusic.server.core.side.IAllMusicLogger; @@ -51,11 +50,11 @@ public class AllMusic { /** * 配置文件版本号 */ - public static final String configVersion = "206"; + public static final String configVersion = "207"; /** * 语言文件配置版本号 */ - public static final String messageVersion = "210"; + public static final String messageVersion = "211"; /** * 日志 */ @@ -348,9 +347,9 @@ public class AllMusic { AllMusic.side.sendHudPos(player1); AllMusic.side.sendMusic(player1, PlayMusic.url); AllMusic.side.sendPic(player1, music.getPicUrl()); - AllMusic.side.sendPos(player1, (int) PlayMusic.musicNowTime); + AllMusic.side.runTask(() -> AllMusic.side.sendPos(player1, (int) PlayMusic.musicNowTime), 20); } - }, 20); + }); }); } @@ -376,7 +375,7 @@ public class AllMusic { AllMusic.side.sendPic(player1, music.getPicUrl()); AllMusic.side.runTask(() -> AllMusic.side.sendPos(player1, (int) PlayMusic.musicNowTime), 50); } - }); + }, AllMusic.config.joinDelay); }); } diff --git a/core/command/CommandEX.java b/core/command/CommandEX.java index e4bacdd6..ebf9091e 100644 --- a/core/command/CommandEX.java +++ b/core/command/CommandEX.java @@ -41,6 +41,7 @@ public class CommandEX { commandList.put("lastpage", new CommandLastPage()); commandList.put("hud", new CommandHud()); commandList.put("push", new CommandPush()); + commandList.put("join", new CommandJoin()); commandList.put("cancel", new CommandCancel()); commandAdminList.put("reload", new CommandReload()); diff --git a/core/command/sub/CommandHelp.java b/core/command/sub/CommandHelp.java index cc72b24d..f1502381 100644 --- a/core/command/sub/CommandHelp.java +++ b/core/command/sub/CommandHelp.java @@ -56,6 +56,8 @@ public class CommandHelp extends ACommand { .append(AllMusic.miniMessageSuggest(AllMusic.getMessage().click.clickCheck, "/music hud pic rotate "))); AllMusic.side.sendMessage(sender, AllMusic.miniMessage(AllMusic.getMessage().help.normal.hud5) .append(AllMusic.miniMessageSuggest(AllMusic.getMessage().click.clickCheck, "/music hud pic speed "))); + AllMusic.side.sendMessage(sender, AllMusic.miniMessage(AllMusic.getMessage().help.normal.join) + .append(AllMusic.miniMessageRun(AllMusic.getMessage().click.clickRun, "/music join"))); if (AllMusic.side.checkPermission(sender)) { AllMusic.side.sendMessage(sender, AllMusic.miniMessage(AllMusic.getMessage().help.admin.reload) .append(AllMusic.miniMessageRun(AllMusic.getMessage().click.clickRun, "/music reload"))); diff --git a/core/command/sub/CommandJoin.java b/core/command/sub/CommandJoin.java new file mode 100644 index 00000000..30f518b8 --- /dev/null +++ b/core/command/sub/CommandJoin.java @@ -0,0 +1,11 @@ +package com.coloryr.allmusic.server.core.command.sub; + +import com.coloryr.allmusic.server.core.AllMusic; +import com.coloryr.allmusic.server.core.command.ACommand; + +public class CommandJoin extends ACommand { + @Override + public void execute(Object sender, String name, String[] args) { + AllMusic.side.joinPlay(name); + } +} diff --git a/core/objs/config/ConfigObj.java b/core/objs/config/ConfigObj.java index 169d085b..09918a40 100644 --- a/core/objs/config/ConfigObj.java +++ b/core/objs/config/ConfigObj.java @@ -118,6 +118,10 @@ public class ConfigObj { * 信息更新延迟 */ public int sendDelay; + /** + * 中途加入延迟 + */ + public int joinDelay; public static ConfigObj make() { ConfigObj config = new ConfigObj(); @@ -165,6 +169,7 @@ public class ConfigObj { maxPlayList = 10; minVote = 3; voteTime = 30; + adminList = new HashSet<>(); adminList.add("color_yr"); muteServer = new HashSet<>(); @@ -188,6 +193,7 @@ public class ConfigObj { ktvLyricDelay = 0; lyricDelay = 0; sendDelay = 1000; + joinDelay = 1000; version = AllMusic.configVersion; } } \ No newline at end of file diff --git a/core/objs/message/HelpNormalObj.java b/core/objs/message/HelpNormalObj.java index 90c5157b..c3fb6c1c 100644 --- a/core/objs/message/HelpNormalObj.java +++ b/core/objs/message/HelpNormalObj.java @@ -26,6 +26,7 @@ public class HelpNormalObj { public String hud8; public String hud9; public String hud10; + public String join; public static HelpNormalObj make() { HelpNormalObj obj = new HelpNormalObj(); @@ -83,6 +84,8 @@ public class HelpNormalObj { return true; if (lastpage == null) return true; + if (join == null) + return true; return hud5 == null; } @@ -137,5 +140,7 @@ public class HelpNormalObj { hud4 = "[AllMusic3]/music hud pic rotate [开关] 设置图片旋转模式"; if (hud5 == null) hud5 = "[AllMusic3]/music hud pic speed [数值] 设置图片旋转速度"; + if (join == null) + join = "[AllMusic3]/music join 重新播放当前歌曲"; } } diff --git a/core/side/BaseSide.java b/core/side/BaseSide.java index b5d06933..f79f0caf 100644 --- a/core/side/BaseSide.java +++ b/core/side/BaseSide.java @@ -150,6 +150,12 @@ public abstract class BaseSide { */ public abstract void broadcast(Component data); + /** + * 重新发送播放包 + * @param data 播放包 + */ + public abstract void joinPlay(String data); + /** * 重载 */ diff --git a/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java b/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java index 9559f731..5db3b5b4 100644 --- a/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java +++ b/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java @@ -21,12 +21,10 @@ public class ListenerVelocity { @Subscribe public void onPostLoginEvent(PostLoginEvent event) { - AllMusic.side.runTask(() -> { - Player player = event.getPlayer(); - Optional serverConnection = player.getCurrentServer(); - serverConnection.ifPresent(connection -> - AllMusic.joinPlay(event.getPlayer().getUsername(), connection.getServerInfo().getName())); - }, 1000); + Player player = event.getPlayer(); + Optional serverConnection = player.getCurrentServer(); + serverConnection.ifPresent(connection -> + AllMusic.joinPlay(event.getPlayer().getUsername(), connection.getServerInfo().getName())); } @Subscribe diff --git a/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java b/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java index 1450e3b3..680bd6db 100644 --- a/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java +++ b/velocity/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java @@ -140,6 +140,20 @@ public class SideVelocity extends BaseSide implements IEconomy { } } + @Override + public void joinPlay(String name) { + Optional player = AllMusicVelocity.plugin.server.getPlayer(name); + if (player.isPresent()) { + Player player1 = player.get(); + Optional server = player1.getCurrentServer(); + if (server.isPresent()) { + AllMusic.joinPlay(name, server.get().getServerInfo().getName()); + } else { + AllMusic.joinPlay(name); + } + } + } + @Override public boolean needPlay(boolean islist) { for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { diff --git a/version b/version index 4764627f..03d70eae 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.9.2 \ No newline at end of file +3.9.3 \ No newline at end of file