fix(idle_music): update get music randomly

This commit is contained in:
thehrz 2025-03-15 09:49:43 +08:00
parent eecc3178b1
commit 219f43243d
Signed by: thehrz
GPG Key ID: C84CBCE7D5F88855
2 changed files with 5 additions and 3 deletions

View File

@ -24,6 +24,7 @@ import java.util.*;
public class AllMusic { public class AllMusic {
public static final Gson gson = new Gson(); public static final Gson gson = new Gson();
public static final Random random = new Random();
/** /**
* 客户端插件信道名 * 客户端插件信道名

View File

@ -471,6 +471,7 @@ public class PlayMusic {
} }
public static void clearIdleList() { public static void clearIdleList() {
deep.clear();
playIdleList.clear(); playIdleList.clear();
DataSql.clearIdleList(); DataSql.clearIdleList();
} }
@ -499,16 +500,16 @@ public class PlayMusic {
if (size > playIdleList.size() / 2) { if (size > playIdleList.size() / 2) {
size = playIdleList.size() / 2; size = playIdleList.size() / 2;
} }
if (deep.size() >= size) { while (deep.size() >= size) {
deep.poll(); deep.poll();
} }
do { do {
id = playIdleList.get(new Random().nextInt(playIdleList.size())); id = playIdleList.get(AllMusic.random.nextInt(playIdleList.size()));
} }
while (deep.contains(id)); while (deep.contains(id));
deep.add(id); deep.add(id);
} else { } else {
id = playIdleList.get(new Random().nextInt(playIdleList.size())); id = playIdleList.get(AllMusic.random.nextInt(playIdleList.size()));
} }
} else { } else {
id = playIdleList.get(idleNow); id = playIdleList.get(idleNow);