Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Coloryr committed Aug 16, 2024
1 parent c80f0e5 commit c76b9d1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 36 deletions.
17 changes: 12 additions & 5 deletions core/music/play/PlayMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ public static void addVote(String player) {
}

public static void startVote(String player) {
voteTime = AllMusic.getConfig().voteTime;
player = player.toLowerCase();
voteSender = player;
votePlayer.add(player);
voteTime = AllMusic.getConfig().voteTime;
}

/**
Expand Down Expand Up @@ -175,6 +175,10 @@ public static int getVoteCount() {
return votePlayer.size();
}

public static int getPushCount() {
return pushPlayer.size();
}

/**
* 清空投票
*/
Expand Down Expand Up @@ -250,8 +254,8 @@ public static void addMusic(Object sender, String id, String player, boolean isL
if (haveMusic(id))
return;
if (sender != null) {
String text = AllMusic.getMessage().musicPlay.checkMusic;
text = text.replace(PAL.musicId, id);
String text = AllMusic.getMessage().musicPlay.checkMusic
.replace(PAL.musicId, id);
AllMusic.side.sendMessageTask(sender, text);
}
Logs.logWrite("player:" + player + " add:" + id);
Expand All @@ -266,7 +270,9 @@ public static void addMusic(Object sender, String id, String player, boolean isL
}
LimitObj limit = AllMusic.getConfig().limit;
if (limit.musicTimeLimit && info.getLength() / 1000 > limit.maxMusicTime) {
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().addMusic.timeOut);
if (sender != null) {
AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().addMusic.timeOut);
}
return;
}
playList.add(info);
Expand All @@ -292,8 +298,9 @@ public static void addMusic(Object sender, String id, String player, boolean isL
if (AllMusic.getConfig().playListSwitch
&& (PlayMusic.nowPlayMusic != null && PlayMusic.nowPlayMusic.isList())) {
PlayMusic.musicLessTime = 1;
if (!isList)
if (!isList) {
AllMusic.side.bqTask(AllMusic.getMessage().musicPlay.switchMusic);
}
}
error = 0;
} catch (Exception e) {
Expand Down
67 changes: 36 additions & 31 deletions core/music/play/PlayRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,46 +164,51 @@ private static boolean checkPush() {
* 事务定时器
*/
private static void time3() {
ping++;
if (ping >= 10) {
AllMusic.side.ping();
}
if (PlayMusic.getPushTime() > 0) {
if (!checkPush()) {
PlayMusic.clearPush();
AllMusic.side.bqTask(AllMusic.getMessage().push.cancel);
} else {
PlayMusic.pushTick();
if (PlayMusic.getPushTime() == 0) {
try {
ping++;
if (ping >= 10) {
AllMusic.side.ping();
}
if (PlayMusic.getPushTime() > 0) {
if (!checkPush()) {
PlayMusic.clearPush();
AllMusic.side.bqTask(AllMusic.getMessage().push.timeOut);
AllMusic.side.bqTask(AllMusic.getMessage().push.cancel);
} else {
int players = AllMusic.side.getPlayerSize();
if (PlayMusic.getVoteCount() >= AllMusic.getConfig().minVote
|| (players <= AllMusic.getConfig().minVote
&& players <= PlayMusic.getVoteCount())) {
PlayMusic.pushMusic();
PlayMusic.pushTick();
if (PlayMusic.getPushTime() == 0) {
PlayMusic.clearPush();
AllMusic.side.bqTask(AllMusic.getMessage().push.doPush);
AllMusic.side.bqTask(AllMusic.getMessage().push.timeOut);
} else {
int players = AllMusic.side.getPlayerSize();
if (PlayMusic.getPushCount() >= AllMusic.getConfig().minVote
|| (players <= AllMusic.getConfig().minVote
&& players <= PlayMusic.getPushCount())) {
PlayMusic.pushMusic();
PlayMusic.clearPush();
AllMusic.side.bqTask(AllMusic.getMessage().push.doPush);
}
}
}
}
}
if (PlayMusic.getVoteTime() > 0) {
PlayMusic.voteTick();
if (PlayMusic.getVoteTime() == 0) {
PlayMusic.clearVote();
AllMusic.side.bqTask(AllMusic.getMessage().vote.timeOut);
} else {
int players = AllMusic.side.getPlayerSize();
if (PlayMusic.getVoteCount() >= AllMusic.getConfig().minVote
|| (players <= AllMusic.getConfig().minVote
&& players <= PlayMusic.getVoteCount())) {

if (PlayMusic.getVoteTime() > 0) {
PlayMusic.voteTick();
if (PlayMusic.getVoteTime() == 0) {
PlayMusic.clearVote();
PlayMusic.musicLessTime = 0;
AllMusic.side.bqTask(AllMusic.getMessage().vote.voteDone);
AllMusic.side.bqTask(AllMusic.getMessage().vote.timeOut);
} else {
int players = AllMusic.side.getPlayerSize();
if (PlayMusic.getVoteCount() >= AllMusic.getConfig().minVote
|| (players <= AllMusic.getConfig().minVote
&& players <= PlayMusic.getVoteCount())) {
PlayMusic.musicLessTime = 0;
PlayMusic.clearVote();
AllMusic.side.bqTask(AllMusic.getMessage().vote.voteDone);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

Expand Down

0 comments on commit c76b9d1

Please sign in to comment.