进度条显示,KTV歌词客户端计时

This commit is contained in:
Color_yr committed 2026-05-23 00:20:36 +08:00
1 parent 650a7e88a1
commit 53248e58dd
19 files changed
+257 -199

No files matched your search

+1 -1
Submodule client updated: 8bd1e1bb5f...c3a69da4bd.
+1 -1
View File
@@ -3,6 +3,6 @@ dependencies {
shadowImplementation("org.apache.httpcomponents.core5:httpcore5:${Versions.httpcore5}")
shadowImplementation("org.apache.httpcomponents.core5:httpcore5-h2:${Versions.httpcore5_h2}")
compileOnly("com.google.code.gson:gson:${Versions.gson}")
implementation("com.google.code.gson:gson:${Versions.gson}")
compileOnly("net.kyori:adventure-text-minimessage:${Versions.minimessage}")
}
@@ -19,6 +19,7 @@ public class CommandHud extends ACommand {
this.add("info");
this.add("list");
this.add("lyric");
this.add("state");
this.add("pic");
}};
private final Map<String, ICommand> commandList = new HashMap<>();
@@ -29,6 +30,7 @@ public class CommandHud extends ACommand {
commandList.put("info", new CommandHudSet(HudType.INFO));
commandList.put("list", new CommandHudSet(HudType.LIST));
commandList.put("lyric", new CommandHudSet(HudType.LYRIC));
commandList.put("state", new CommandHudSet(HudType.STATE));
commandList.put("pic", new CommandHudSet(HudType.PIC));
}
@@ -70,7 +72,7 @@ public class CommandHud extends ACommand {
if (args.length == 2 || args.length == 3) {
boolean temp = HudUtils.setHudEnable(name, null, args.length == 3 ? args[2] : null);
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().hud.state
.replace(ARG.state, temp ? "启用" : "关闭")
.replace(ARG.value, temp ? AllMusic.getMessage().hudList.enable : AllMusic.getMessage().hudList.disable)
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(null)));
return;
}
@@ -2,7 +2,7 @@ package com.coloryr.allmusic.server.core.command.sub;
import com.coloryr.allmusic.codec.HudBasePosObj;
import com.coloryr.allmusic.codec.HudPosType;
import com.coloryr.allmusic.codec.HudItemPosObj;
import com.coloryr.allmusic.codec.HudStatePosObj;
import com.coloryr.allmusic.codec.HudType;
import com.coloryr.allmusic.server.core.AllMusic;
import com.coloryr.allmusic.server.core.command.ACommand;
@@ -32,6 +32,8 @@ public class CommandHudSet extends AHudCommand {
private static final List<String> info = new ArrayList<String>() {{
this.add("color");
this.add("shadow");
this.add("loop");
this.add("maxwidth");
}};
private static final List<String> tf = new ArrayList<String>() {{
this.add("true");
@@ -54,6 +56,7 @@ public class CommandHudSet extends AHudCommand {
commandList.put("color", new HudColor(type));
commandList.put("shadow", new HudShadow(type));
commandList.put("loop", new HudLoop(type));
commandList.put("maxwidth", new HudMaxWidth(type));
}
}
@@ -101,7 +104,7 @@ public class CommandHudSet extends AHudCommand {
if (args.length == 3 || args.length == 4) {
boolean temp = HudUtils.setHudEnable(name, type, args.length == 4 ? args[3] : null);
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().hud.state
.replace(ARG.state, temp
.replace(ARG.value, temp
? AllMusic.getMessage().hudList.enable
: AllMusic.getMessage().hudList.disable)
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(type)));
@@ -178,9 +181,36 @@ public class CommandHudSet extends AHudCommand {
return;
}
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().hud.set4
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().hud.set5
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(type))
.replace(ARG.alpha, String.valueOf(obj.alpha)));
.replace(ARG.value, String.valueOf(obj.alpha)));
} catch (Exception e) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
}
}
}
private static class HudMaxWidth extends AHudCommand {
public HudMaxWidth(HudType type) {
super(type);
}
@Override
public void execute(Object sender, String name, String[] args) {
try {
if (args.length != 4) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
return;
}
int width = HudUtils.setHudHudMaxWidth(name, type, args[3]);
if (width == -1) {
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().command.error);
return;
}
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().hud.set6
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(type))
.replace(ARG.value, String.valueOf(width)));
} catch (Exception e) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error);
}
@@ -211,7 +241,7 @@ public class CommandHudSet extends AHudCommand {
}
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.set1
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(type))
.replace(ARG.dir, AllMusic.getMessage().hudList.getDir(type1)));
.replace(ARG.value, AllMusic.getMessage().hudList.getDir(type1)));
}
@Override
@@ -241,7 +271,7 @@ public class CommandHudSet extends AHudCommand {
}
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.set2
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(type))
.replace(ARG.color, String.format("%06X", color & 0xFFFFFF)));
.replace(ARG.value, String.format("%06X", color & 0xFFFFFF)));
}
}
@@ -255,7 +285,7 @@ public class CommandHudSet extends AHudCommand {
if (args.length == 3 || args.length == 4) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.set3
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(type))
.replace(ARG.state, HudUtils.setShadow(name, type, args.length == 4 ? args[3] : null)
.replace(ARG.value, HudUtils.setShadow(name, type, args.length == 4 ? args[3] : null)
? AllMusic.getMessage().hudList.enable
: AllMusic.getMessage().hudList.disable));
return;
@@ -290,7 +320,7 @@ public class CommandHudSet extends AHudCommand {
}
AllMusic.side.sendMessage(sender, AllMusic.getMessage().hud.set2
.replace(ARG.hud, AllMusic.getMessage().hudList.getHud(type))
.replace(ARG.color, loop));
.replace(ARG.value, loop));
}
@Override
@@ -310,7 +340,7 @@ public class CommandHudSet extends AHudCommand {
return;
}
AllMusic.side.sendMessage(sender,
AllMusic.getMessage().hud.picSize.replace(ARG.size, args[2]));
AllMusic.getMessage().hud.picSize.replace(ARG.value, args[2]));
}
}
@@ -319,7 +349,7 @@ public class CommandHudSet extends AHudCommand {
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.state, HudUtils.setPicRotate(name, args.length == 4 ? args[3] : null)
.replace(ARG.value, HudUtils.setPicRotate(name, args.length == 4 ? args[3] : null)
? AllMusic.getMessage().hudList.enable
: AllMusic.getMessage().hudList.disable));
return;
@@ -344,7 +374,7 @@ public class CommandHudSet extends AHudCommand {
return;
}
AllMusic.side.sendMessage(sender,
AllMusic.getMessage().hud.picSpeed.replace(ARG.size, args[3]));
AllMusic.getMessage().hud.picSpeed.replace(ARG.value, args[3]));
}
}
}
@@ -10,7 +10,7 @@ public class CommandNext extends ACommand {
@Override
public void execute(Object sender, String name, String[] args) {
PlayMusic.musicLessTime = 1;
PlayMusic.musicLessTime = 10;
AllMusic.side.sendMessage(sender, "<light_purple>[AllMusic3]<dark_green>已强制切歌");
BanSave.removeMutePlayer(name);
}
@@ -1,16 +0,0 @@
package com.coloryr.allmusic.server.core.music;
import java.util.ArrayList;
import java.util.List;
public class KtvLyric {
public List<KtvItem> items = new ArrayList<>();
public long start;
public long time;
public static class KtvItem {
public long time;
public long start;
public String key;
}
}
@@ -1,24 +1,32 @@
package com.coloryr.allmusic.server.core.music;
import com.coloryr.allmusic.server.core.objs.music.LyricItemObj;
import com.coloryr.allmusic.codec.KtvLyricObj;
import java.util.HashMap;
import java.util.Map;
public class LyricSave {
protected boolean haveLyric;
protected float kly = 0;
protected LyricItemObj now;
private Map<Long, LyricItemObj> lyric;
private Map<Long, KtvLyric> klyric;
private KtvLyric ktvNow;
private Map<Long, KtvLyricObj> klyric;
private KtvLyricObj ktvNow;
public LyricSave() {
haveLyric = false;
lyric = new HashMap<>();
}
public void setKlyric(Map<Long, KtvLyric> klyric) {
public KtvLyricObj getKtvNow() {
return ktvNow;
}
public LyricItemObj getNow() {
return now;
}
public void setKlyric(Map<Long, KtvLyricObj> klyric) {
this.klyric = klyric;
}
@@ -42,50 +50,17 @@ public class LyricSave {
return now.tlyric;
}
public float getKly() {
return kly;
}
public void kUpdate(long playNow) {
if (now == null || now.lyric == null || now.lyric.isEmpty()
|| ktvNow == null || ktvNow.items == null || ktvNow.items.isEmpty()) {
kly = 0.0f;
return;
}
if (playNow < ktvNow.start) {
kly = 0.0f;
return;
}
if (playNow >= ktvNow.start + ktvNow.time) {
kly = 1.0f;
return;
}
for (int i = 0; i < ktvNow.items.size(); i++) {
KtvLyric.KtvItem item = ktvNow.items.get(i);
if (playNow >= item.start && playNow < item.start + item.time) {
float progressInChar = (float) (playNow - item.start) / item.time;
kly = (i + progressInChar) / ktvNow.items.size();
return;
}
}
kly = 0.0f;
}
private void ktvGetNext(long time) {
public boolean ktvGetNext(long time) {
if (klyric == null)
return;
return false;
KtvLyric temp = klyric.get(time);
KtvLyricObj temp = klyric.get(time);
if (temp != null) {
ktvNow = temp;
kly = 0.0f;
return true;
}
kUpdate(time);
return false;
}
public boolean lyricGetNext(long playNow) {
@@ -94,18 +69,21 @@ public class LyricSave {
LyricItemObj temp = lyric.get(playNow);
if (temp != null && now != temp) {
if (ktvNow != null) {
long time = Math.abs(ktvNow.start - temp.start);
KtvLyricObj.KtvItem start = ktvNow.items.get(0);
if (time > 500 && (start != null && !temp.lyric.startsWith(start.key))) {
ktvNow = null;
}
}
now = temp.copy();
if (now.tlyric == null) {
now.tlyric = "";
}
kly = 0.0f;
return true;
}
return false;
}
public void updateKtv(long playNow) {
ktvGetNext(playNow);
}
}
@@ -296,7 +296,7 @@ public class PlayMusic {
}
if (AllMusic.getConfig().playListSwitch
&& (PlayMusic.nowPlayMusic != null && PlayMusic.nowPlayMusic.isList())) {
PlayMusic.musicLessTime = 1;
PlayMusic.musicLessTime = 10;
if (!isList) {
AllMusic.side.broadcastInTask(AllMusic.getMessage().musicPlay.switchMusic);
}
@@ -18,10 +18,6 @@ public class PlayRuntime {
*/
private static int count = 0;
private static int ping = 0;
/**
* 歌曲更新计数器
*/
private static long times = 0;
/**
* 歌曲定时器
*/
@@ -73,6 +69,7 @@ public class PlayRuntime {
AllMusic.side.updateInfo();
HudUtils.sendClearHud();
HudUtils.sendHudNowData();
HudUtils.sendHudTime();
HudUtils.sendHudLyricData();
HudUtils.sendHudListData();
}
@@ -84,10 +81,10 @@ public class PlayRuntime {
private static void time1() {
if (isPlay) {
PlayMusic.musicNowTime += 10;
count++;
if (count == 100) {
PlayMusic.musicLessTime--;
count = 0;
if (PlayMusic.musicLessTime >= 10) {
PlayMusic.musicLessTime -= 10;
} else {
PlayMusic.musicLessTime = 0;
}
}
@@ -99,17 +96,11 @@ public class PlayRuntime {
if (res) {
HudUtils.sendHudLyricData();
AllMusic.side.updateLyric();
if (AllMusic.getConfig().ktvMode) {
PlayMusic.lyric.updateKtv(PlayMusic.musicNowTime);
HudUtils.sendHudKtv();
}
}
if (AllMusic.getConfig().ktvMode) {
PlayMusic.lyric.updateKtv(PlayMusic.musicNowTime);
if ((PlayMusic.musicNowTime - times) > AllMusic.getConfig().ktvSendDelay) {
times = PlayMusic.musicNowTime;
HudUtils.sendHudKtv();
if (PlayMusic.lyric.ktvGetNext(PlayMusic.musicNowTime)) {
AllMusic.side.sendHudKtv();
}
}
} catch (Exception e) {
@@ -212,6 +203,7 @@ public class PlayRuntime {
} else {
HudUtils.sendClearHud();
HudUtils.sendHudNowData();
HudUtils.sendHudTime();
HudUtils.sendHudLyricData();
HudUtils.sendHudListData();
AllMusic.side.sendHudUtilsAll();
@@ -239,7 +231,7 @@ public class PlayRuntime {
PlayMusic.lyric = new LyricSave();
if (PlayMusic.nowPlayMusic.getLength() != 0) {
PlayMusic.musicAllTime = PlayMusic.musicLessTime = (PlayMusic.nowPlayMusic.getLength() / 1000) + 3;
PlayMusic.musicAllTime = PlayMusic.musicLessTime = PlayMusic.nowPlayMusic.getLength();
isPlay = true;
AllMusic.side.sendMusic(PlayMusic.url);
if (!AllMusic.getConfig().mutePlayMessage) {
@@ -275,9 +267,10 @@ public class PlayRuntime {
while (PlayMusic.musicLessTime > 0) {
HudUtils.sendHudNowData();
HudUtils.sendHudTime();
HudUtils.sendHudListData();
if (PlayMusic.nowPlayMusic == null || !AllMusic.side.needPlay(PlayMusic.nowPlayMusic.isList())) {
PlayMusic.musicLessTime = 1;
PlayMusic.musicLessTime = 10;
}
Thread.sleep(AllMusic.getConfig().sendDelay);
}
@@ -7,28 +7,18 @@ public class TopLyricSave extends LyricSave {
public void setTlyric(String data) {
if (now == null) {
now = new LyricItemObj(data, "");
now = new LyricItemObj(data, "", 0);
}
now.lyric = data;
}
public void setLyric(String data) {
if (now == null) {
now = new LyricItemObj("", data);
now = new LyricItemObj("", data, 0);
}
now.lyric = data;
}
public void setKly(float data) {
kly = data;
}
public void setHaveK(boolean data) {
if (!data) {
kly = 0;
}
}
public void setHaveT(boolean data) {
if (!data) {
now = null;
@@ -31,10 +31,6 @@ public class ConfigObj {
* 歌曲延迟
*/
public int lyricDelay;
/**
* KTV歌词更新延迟
*/
public int ktvSendDelay;
/**
* 默认添加歌曲方式
*/
@@ -175,7 +171,6 @@ public class ConfigObj {
playListSwitch = true;
playListRandom = true;
playListEscapeDeep = 40;
ktvSendDelay = 50;
sendLyric = true;
needPermission = false;
mutePlayMessage = false;
@@ -1,28 +1,22 @@
package com.coloryr.allmusic.server.core.objs.message;
public class ARG {
public static String musicName = "%MusicName%";
public static String musicAuthor = "%MusicAuthor%";
public static String musicAlia = "%MusicAlia%";
public static String musicAl = "%MusicAl%";
public static String musicId = "%MusicID%";
public static String hud = "%Hud%";
public static String cost = "%Cost%";
public static String index = "%Index%";
public static String state = "%State%";
public static String alpha = "%Alpha%";
public static String x = "%X%";
public static String y = "%Y%";
public static String dir = "%Dir%";
public static String color = "%Color%";
public static String size = "%Size%";
public static String name = "%Name%";
public static String allTime = "%AllTime%";
public static String nowTime = "%NowTime%";
public static String player = "%Player%";
public static String lyric = "%Lyric%";
public static String list = "%List%";
public static String count = "%Count%";
public static String countAll = "%CountAll%";
public static String time = "%Time%";
public static String musicName = "%music_name%";
public static String musicAuthor = "%music_author%";
public static String musicAlia = "%music_alia%";
public static String musicAl = "%music_al%";
public static String musicId = "%music_id%";
public static String hud = "%hud%";
public static String cost = "%cost%";
public static String index = "%index%";
public static String value = "%value%";
public static String x = "%x%";
public static String y = "%y%";
public static String name = "%name%";
public static String player = "%player%";
public static String lyric = "%lyric%";
public static String list = "%list%";
public static String count = "%count%";
public static String countAll = "%count_all%";
public static String time = "%time%";
}
@@ -7,6 +7,7 @@ public class HudNameObj {
public String list;
public String lyric;
public String info;
public String state;
public String all;
public String pic;
public String picRoute;
@@ -35,6 +36,8 @@ public class HudNameObj {
return true;
if (lyric == null)
return true;
if (state == null)
return true;
if (info == null)
return true;
if (all == null)
@@ -79,6 +82,8 @@ public class HudNameObj {
return lyric;
case LIST:
return list;
case STATE:
return state;
}
return null;
}
@@ -113,6 +118,8 @@ public class HudNameObj {
public void init() {
if (list == null)
list = "待播放列表";
if (state == null)
state = "播放进度";
if (lyric == null)
lyric = "歌词";
if (info == null)
@@ -7,6 +7,8 @@ public class HudObj {
public String set2;
public String set3;
public String set4;
public String set5;
public String set6;
public String reset;
public String emptyMusic;
public String emptyList;
@@ -40,6 +42,10 @@ public class HudObj {
return true;
if (set4 == null)
return true;
if (set5 == null)
return true;
if (set6 == null)
return true;
if (reset == null)
return true;
if (emptyMusic == null)
@@ -67,17 +73,21 @@ public class HudObj {
public void init() {
if (state == null)
state = "<light_purple>[AllMusic3]<yellow>设置信息位置:" + ARG.hud + ",状态:" + ARG.state;
state = "<light_purple>[AllMusic3]<yellow>设置信息位置:" + ARG.hud + ",状态:" + ARG.value;
if (set == null)
set = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的坐标为[" + ARG.x + ", " + ARG.y + "]";
if (set1 == null)
set1 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的对齐方式为[" + ARG.dir + "]";
set1 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的对齐方式为[" + ARG.value + "]";
if (set2 == null)
set2 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的颜色为[" + ARG.color + "]";
set2 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的颜色为[" + ARG.value + "]";
if (set3 == null)
set3 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的阴影为[" + ARG.state + "]";
set3 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的阴影为[" + ARG.value + "]";
if (set4 == null)
set4 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的透明度为[" + ARG.alpha + "]";
set4 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的透明度为[" + ARG.value + "]";
if (set5 == null)
set5 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的循环模式为[" + ARG.value + "]";
if (set6 == null)
set6 = "<light_purple>[AllMusic3]<yellow>已设置[" + ARG.hud + "]的最大宽度为[" + ARG.value + "]";
if (reset == null)
reset = "<light_purple>[AllMusic3]<yellow>界面[" + ARG.hud + "]恢复至默认位置";
if (emptyMusic == null)
@@ -87,22 +97,21 @@ public class HudObj {
if (emptyLyric == null)
emptyLyric = "无歌词";
if (picSize == null)
picSize = "<light_purple>[AllMusic3]<yellow>设置图片尺寸为[" + ARG.size + "]";
picSize = "<light_purple>[AllMusic3]<yellow>设置图片尺寸为[" + ARG.value + "]";
if (picRotate == null)
picRotate = "<light_purple>[AllMusic3]<yellow>设置图片旋转为[" + ARG.state + "]";
picRotate = "<light_purple>[AllMusic3]<yellow>设置图片旋转为[" + ARG.value + "]";
if (picSpeed == null)
picSpeed = "<light_purple>[AllMusic3]<yellow>设置图片旋转速度为[" + ARG.size + "]";
picSpeed = "<light_purple>[AllMusic3]<yellow>设置图片旋转速度为[" + ARG.value + "]";
if (music == null)
music = ARG.name + " " + ARG.allTime + "/" + ARG.nowTime
+ "\n" + ARG.musicAuthor + "\n" + ARG.musicAlia + "\n" + ARG.musicAl
music = ARG.name + " " + ARG.musicAuthor + "\n" + ARG.musicAlia + "\n" + ARG.musicAl
+ "\nby: " + ARG.player;
if (lyric == null)
lyric = ARG.lyric;
if (tlyric == null)
tlyric = ARG.lyric;
if (klyric == null)
klyric = "§e" + ARG.lyric;
klyric = "§b" + ARG.lyric;
if (list == null)
list = "播放列表里面有" + ARG.size + "首歌\n" + ARG.list;
list = "播放列表里面有" + ARG.value + "首歌\n" + ARG.list;
}
}
@@ -4,12 +4,15 @@ public class LyricItemObj {
public String lyric;
public String tlyric;
public LyricItemObj(String lyric, String tlyric) {
public long start;
public LyricItemObj(String lyric, String tlyric, long start) {
this.lyric = lyric;
this.tlyric = tlyric;
this.start = start;
}
public LyricItemObj copy() {
return new LyricItemObj(this.lyric, this.tlyric);
return new LyricItemObj(this.lyric, this.tlyric, this.start);
}
}
@@ -4,12 +4,13 @@ import com.coloryr.allmusic.codec.CommandType;
import com.coloryr.allmusic.codec.HudPosObj;
import com.coloryr.allmusic.codec.HudType;
import com.coloryr.allmusic.codec.MusicPack;
import com.coloryr.allmusic.codec.KtvLyricObj;
import com.coloryr.allmusic.server.core.AllMusic;
import com.coloryr.allmusic.server.core.music.LyricSave;
import com.coloryr.allmusic.server.core.music.PlayMusic;
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
import com.coloryr.allmusic.server.core.saves.HudSave;
import com.coloryr.allmusic.server.core.utils.HudUtils;
import net.kyori.adventure.text.Component;
import java.io.File;
@@ -258,10 +259,10 @@ public abstract class BaseSide {
/**
* 发送Hud的歌词数据
*
* @param state 数据
*/
public final void sendHudKtv(float state) {
public final void sendHudKtv() {
MusicPack.LyricKtvMusicPack pack = new MusicPack.LyricKtvMusicPack(PlayMusic.musicNowTime, PlayMusic.lyric.getKtvNow());
for (Object player : getPlayers()) {
String name = getPlayerName(player);
if (name == null)
@@ -273,7 +274,7 @@ public abstract class BaseSide {
HudPosObj obj = HudSave.getOrNew(name);
if (!obj.lyric.enable)
continue;
send(player, new MusicPack.FloatMusicPack(CommandType.LYRIC_STATE, state));
send(player, pack);
} catch (Exception e) {
AllMusic.log.data("<light_purple>[AllMusic]<red>歌词发送出错");
e.printStackTrace();
@@ -296,7 +297,7 @@ public abstract class BaseSide {
continue;
try {
HudPosObj obj = HudSave.getOrNew(name);
if (!obj.lyric.enable)
if (!obj.info.enable)
continue;
send(player, new MusicPack.StringMusicPack(CommandType.INFO, data));
} catch (Exception e) {
@@ -306,6 +307,26 @@ public abstract class BaseSide {
}
}
public final void sendHudTime(MusicPack.TimeMusicPack pack) {
for (Object player : getPlayers()) {
String name = getPlayerName(player);
if (name == null)
continue;
name = name.toLowerCase(Locale.ROOT);
if (AllMusic.isSkip(name, getPlayerServer(player), true))
continue;
try {
HudPosObj obj = HudSave.getOrNew(name);
if (!obj.state.enable)
continue;
send(player, pack);
} catch (Exception e) {
AllMusic.log.data("<light_purple>[AllMusic]<red>歌词信息发送出错");
e.printStackTrace();
}
}
}
/**
* 发送Hud的位置信息
*
@@ -41,6 +41,9 @@ public class HudUtils {
case PIC:
posOBJ = obj.pic;
break;
case STATE:
posOBJ = obj.state;
break;
default:
return null;
}
@@ -93,6 +96,42 @@ public class HudUtils {
return posOBJ;
}
/**
* 设置组件透明度
*
* @param player 用户名
* @param pos 位置
* @param width 最大宽度
* @return 组件数据
*/
public static int setHudHudMaxWidth(String player, HudType pos, String width) {
HudPosObj obj = HudSave.getOrNew(player);
if (!Function.isInteger(width))
return -1;
int maxwidth = Integer.parseInt(width);
if (maxwidth <= 0) {
return -1;
}
switch (pos) {
case LYRIC:
obj.lyric.maxWidth = maxwidth;
break;
case LIST:
obj.list.maxWidth = maxwidth;
break;
case INFO:
obj.info.maxWidth = maxwidth;
break;
default:
return -1;
}
HudSave.update(player, obj);
HudUtils.sendHudPos(player);
return maxwidth;
}
/**
* 更新Hud的List数据
*/
@@ -116,25 +155,13 @@ public class HudUtils {
list.append(now).append("\n");
}
info = AllMusic.getMessage().hud.list
.replace(ARG.size, String.valueOf(PlayMusic.getList().size()))
.replace(ARG.value, String.valueOf(PlayMusic.getList().size()))
.replace(ARG.list, list.toString());
}
AllMusic.side.sendHudList(info);
}
/**
* 时间转换
*
* @param time 时间
* @return 结果
*/
private static String tranTime(long time) {
long m = time / 60;
long s = time - m * 60;
return (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
}
/**
* 更新Hud的信息数据
*/
@@ -145,8 +172,6 @@ public class HudUtils {
} else {
info = AllMusic.getMessage().hud.music
.replace(ARG.name, infoLimit(PlayMusic.nowPlayMusic.getName()))
.replace(ARG.allTime, tranTime(PlayMusic.musicAllTime))
.replace(ARG.nowTime, tranTime(PlayMusic.musicNowTime / 1000))
.replace(ARG.musicAuthor, infoLimit(PlayMusic.nowPlayMusic.getAuthor()))
.replace(ARG.musicAlia, infoLimit(PlayMusic.nowPlayMusic.getAlia()))
.replace(ARG.musicAl, infoLimit(PlayMusic.nowPlayMusic.getAl()))
@@ -156,6 +181,11 @@ public class HudUtils {
AllMusic.side.sendHudInfo(info);
}
public static void sendHudTime() {
MusicPack.TimeMusicPack pack = new MusicPack.TimeMusicPack(PlayMusic.musicAllTime, PlayMusic.musicNowTime);
AllMusic.side.sendHudTime(pack);
}
/**
* 更新Hud的歌词数据
*/
@@ -182,18 +212,6 @@ public class HudUtils {
AllMusic.side.sendHudLyric(new MusicPack.LyricMusicPack(lyr, tran, ktv));
}
public static void sendHudKtv() {
float kLyric;
LyricSave obj = PlayMusic.lyric;
if (obj == null) {
kLyric = 0.0f;
} else {
kLyric = obj.getKly();
}
AllMusic.side.sendHudKtv(kLyric);
}
/**
* 更新Hud的开启关闭数据
*
@@ -526,9 +544,6 @@ public class HudUtils {
case LIST:
obj.list.loop = loop;
break;
case LYRIC:
obj.lyric.loop = loop;
break;
case PIC:
return null;
}
@@ -1,7 +1,7 @@
package com.coloryr.allmusic.server.netapi;
import com.coloryr.allmusic.server.core.AllMusic;
import com.coloryr.allmusic.server.core.music.KtvLyric;
import com.coloryr.allmusic.codec.KtvLyricObj;
import com.coloryr.allmusic.server.core.objs.music.LyricItemObj;
import com.coloryr.allmusic.server.core.utils.Function;
import com.coloryr.allmusic.server.netapi.obj.music.lyric.WLyricObj;
@@ -15,13 +15,13 @@ public class LyricDecoder {
private final Map<Long, LyricItemObj> lyrics = new LinkedHashMap<>();
public boolean isHave = false;
public boolean isHaveK = false;
public Map<Long, KtvLyric> kly = new LinkedHashMap<>();
public Map<Long, KtvLyricObj> kly = new LinkedHashMap<>();
public Map<Long, LyricItemObj> getLyrics() {
return lyrics;
}
public Map<Long, KtvLyric> getKLyric() {
public Map<Long, KtvLyricObj> getKLyric() {
return kly;
}
@@ -55,7 +55,7 @@ public class LyricDecoder {
if (temp2 != null && !temp2.isEmpty()) {
String[] klyric = temp2.split("\n");
for (String item : klyric) {
KtvLyric temp4 = getKTime(item, obj.getVersion());
KtvLyricObj temp4 = getKTime(item, obj.getVersion());
if (temp4 != null) {
kly.put(temp4.start, temp4);
}
@@ -65,13 +65,13 @@ public class LyricDecoder {
if (isHaveK) {
for (Map.Entry<Long, String> item : temp.entrySet()) {
this.lyrics.put(item.getKey(), new LyricItemObj(item.getValue(), haveT ? temp1.get(item.getKey()) : null));
this.lyrics.put(item.getKey(), new LyricItemObj(item.getValue(), haveT ? temp1.get(item.getKey()) : null, item.getKey()));
}
} else {
for (Map.Entry<Long, String> item : temp.entrySet()) {
String value = AllMusic.getReplacer().replace(item.getValue());
String value1 = AllMusic.getReplacer().replace(temp1.get(item.getKey()));
this.lyrics.put(item.getKey(), new LyricItemObj(value, haveT ? value1 : null));
this.lyrics.put(item.getKey(), new LyricItemObj(value, haveT ? value1 : null, item.getKey()));
}
}
@@ -121,14 +121,14 @@ public class LyricDecoder {
milt /= 10;
}
time = Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000 + milt * 10;
if (time > 0 && time + AllMusic.getConfig().lyricDelay > 0)
time += AllMusic.getConfig().lyricDelay / 10 * 10;
// if (time > 0 && time + AllMusic.getConfig().lyricDelay > 0)
// time += AllMusic.getConfig().lyricDelay / 10 * 10;
res.put(time, Function.getString(s, "]", null));
}
return res;
}
private KtvLyric getKTime(String lyric, boolean yrc) {
private KtvLyricObj getKTime(String lyric, boolean yrc) {
if (!lyric.startsWith("[") || !lyric.contains("]("))
return null;
@@ -148,12 +148,13 @@ public class LyricDecoder {
long now = Integer.parseInt(temp11[0]) / 10 * 10;
long time = Integer.parseInt(temp11[1]) / 10 * 10;
KtvLyric ktv = new KtvLyric();
KtvLyricObj ktv = new KtvLyricObj();
ktv.start = now;
ktv.time = time;
for (int a = 1; a < datas.length; a++) {
KtvLyric.KtvItem item = new KtvLyric.KtvItem();
KtvLyricObj.KtvItem item = new KtvLyricObj.KtvItem();
item.key = datas[a];
ktv.charCount += item.key.length();
String temp3 = temp1111.get(a - 1);
String[] temp8 = temp3.split(",");
long temp5;
+36
View File
@@ -0,0 +1,36 @@
import com.coloryr.allmusic.server.core.music.LyricSave;
import com.coloryr.allmusic.server.netapi.LyricDecoder;
import com.coloryr.allmusic.server.netapi.obj.music.lyric.WLyricObj;
import com.google.gson.Gson;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
public class LyricTest {
public static String temp = "{\"sgc\":false,\"sfy\":false,\"qfy\":false,\"transUser\":{\"id\":3342458,\"status\":99,\"demand\":1,\"userid\":34139657,\"nickname\":\"槿萝绿绿\",\"uptime\":1435895824331},\"lyricUser\":{\"id\":3342453,\"status\":99,\"demand\":0,\"userid\":3230133,\"nickname\":\"宇宙防衛計画\",\"uptime\":1435895824331},\"lrc\":{\"version\":15,\"lyric\":\"[00:23.99]まっすぐに羽を伸ばし\\n[00:28.86]傷跡癒し続ける旅\\n[00:35.33]私はそれでもいい 誰かのために\\n[00:46.28]飛び立てることにもう少し\\n[00:52.04]喜び感じていたいから\\n[00:57.75]あなたとここで出会えたこと \\n[01:03.50]奇跡と呼ばせてください\\n[01:11.25]Over the sky 遠くを見つめてる\\n[01:16.33]その眼に 光が差すように\\n[01:22.45]Open the mind 世界を きっと変えていく\\n[01:30.24]そして 空へ\\n[01:46.45]時々不安になる\\n[01:51.80]私に何ができるのだろう\\n[01:58.42]時間は無限じゃない そんな中で\\n[02:09.04]生きてきた時間の中には\\n[02:14.90]忘れたいこともあるけど\\n[02:20.66]誰かと分かち合えるのなら \\n[02:26.56]記憶は輝き始める\\n[02:34.02]Over the sky 全てが終わるとき\\n[02:39.82]その手で強く抱きしめて\\n[02:45.50]Open the mind 真実 分かる日がきても ずっと···\\n[02:57.77]突然 見つけた希望 偶然 舞い降りてきた夢\\n[03:27.73]Over the sky 遠くを見つめてる\\n[03:33.41]その眼は 光に満ちている\\n[03:39.22]Open the mind 世界を きっと変えていく\\n[03:47.05]そして···\\n[03:53.16]Over the sky 遥かな物語\\n[03:58.62]まだ見ぬ景色が呼んでる\\n[04:04.36]Open the mind 世界に光が差すとき\\n[04:10.41]笑って どこかで見ているから\\n\"},\"klyric\":{\"version\":0,\"lyric\":\"\"},\"tlyric\":{\"version\":4,\"lyric\":\"[by:槿萝绿绿]\\n[00:23.99]笔直地展翅飞去\\n[00:28.86]持续着抚平伤痕的旅途\\n[00:35.33]对我来说这样就好 为了某人\\n[00:46.28]稍稍迟点出发\\n[00:52.04]因为想感受喜悦\\n[00:57.75]请把能在此与你邂逅\\n[01:03.50]称为奇迹\\n[01:11.25]跨越天空 注视着远方\\n[01:16.33]希望那眼中 能被光芒照耀\\n[01:22.45]打开心扉 世界就一定能为之一变\\n[01:30.24]然后 向着天空\\n[01:46.45]偶尔会感到不安\\n[01:51.80]凭我的力量又能做到什么呢\\n[01:58.42]在这有限的时间里\\n[02:09.04]至今已经活过的时光中\\n[02:14.90]尽管也有试图忘记的事\\n[02:20.66]但如果能和谁分担\\n[02:26.56]记忆就会开始闪烁光辉\\n[02:34.02]跨越天空 全部终结之时\\n[02:39.82]请用那双手抱紧我\\n[02:45.50]打开心扉 即使真实揭晓的一天来临 也一直……\\n[02:57.77]突然找到的希望 偶然降临的梦境\\n[03:27.73]跨越天空 注视着远方\\n[03:33.41]那眼中 充满着光辉\\n[03:39.22]打开心扉 世界就一定能为之一变\\n[03:47.05]并且…\\n[03:53.16]跨越天空 遥远的传说\\n[03:58.62]尚未见过的景色 正在呼唤\\n[04:04.36]打开心扉 当世界被光芒所笼罩\\n[04:10.41]微笑吧 因为我正在某处看着你\\n\"},\"romalrc\":{\"version\":2,\"lyric\":\"[00:23.990]ma ssu gu ni ha ne wo no ba shi\\n[00:28.860]ki zu a to i ya shi tsu zu ke ru ta bi\\n[00:35.330]wa ta shi wa so re de mo i i da re ka no ta me ni\\n[00:46.280]to bi ta te ru ko to ni mo u su ko shi\\n[00:52.040]yo ro ko bi ka n ji te i ta i ka ra\\n[00:57.750]a na ta to ko ko de de a e ta ko to\\n[01:03.500]ki se ki to yo ba se te ku da sa i\\n[01:11.250]Over the sky to o ku wo mi tsu me te ru\\n[01:16.330]so no me ni hi ka ri ga sa su yo u ni\\n[01:22.450]Open the mind se ka i wo ki tto ka e te i ku\\n[01:30.240]so shi te so ra e\\n[01:46.450]to ki do ki fu a n ni na ru\\n[01:51.800]wa ta shi ni na ni ga de ki ru no da ro u\\n[01:58.420]ji ka n wa mu ge n ja na i so n na na ka de\\n[02:09.040]i ki te ki ta ji ka n no na ka ni wa\\n[02:14.900]wa su re ta i ko to mo a ru ke do\\n[02:20.660]da re ka to wa ka chi a e ru no na ra\\n[02:26.560]ki o ku wa ka ga ya ki ha ji me ru\\n[02:34.020]Over the sky su be te ga o wa ru to ki\\n[02:39.820]so no te de tsu yo ku da ki shi me te\\n[02:45.500]Open the mind shi n ji tsu wa ka ru hi ga ki te mo zu tto···\\n[02:57.770]to tsu ze n mi tsu ke ta ki bo u gu u ze n ma i o ri te ki ta yu me\\n[03:27.730]Over the sky to o ku wo mi tsu me te ru\\n[03:33.410]so no me wa hi ka ri ni mi chi te i ru\\n[03:39.220]Open the mind se ka i wo ki tto ka e te i ku\\n[03:47.050]so shi te···\\n[03:53.160]Over the sky ha ru ka na mo no ga ta ri\\n[03:58.620]ma da mi nu ke shi ki ga yo n de ru\\n[04:04.360]Open the mind se ka i ni hi ka ri ga sa su to ki\\n[04:10.410]wa ra tte do ko ka de mi te i ru ka ra\"},\"yrc\":{\"version\":4,\"lyric\":\"[23930,5030](23930,840,0)ま(24770,160,0)っ(24930,230,0)す(25160,300,0)ぐ(25460,840,0)に(26300,600,Line truncated
public static void main(String[] args) {
WLyricObj obj = new Gson().fromJson(temp, WLyricObj.class);
LyricDecoder docoder = new LyricDecoder();
docoder.check(obj);
System.setOut(new PrintStream(System.out, true, StandardCharsets.UTF_8));
LyricSave save = new LyricSave();
save.setLyric(docoder.getLyrics());
save.setKlyric(docoder.getKLyric());
int a = 0;
do {
a += 10;
if (save.lyricGetNext(a)) {
System.out.println("time: " + a + " lyric: " + save.getNow().lyric);
}
if (save.updateKtv(a)) {
System.out.println("time: " + a + " klyric: " + save.getKtvNow().build());
}
} while (a <= 1000000);
}
}