修复bug

This commit is contained in:
Color_yr committed 2019-06-17 15:32:48 +08:00
1 parent 34235194fc
commit a355e4d507
2 files changed
+25 -20

No files matched your search

+16 -13
View File
@@ -22,9 +22,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Map;
public class PlayMusic {
static Map<Integer, String> playlist = new HashMap<Integer, String>();
public static Map<String, String> playlist = new HashMap<String, String>();
public static Map<String, String> Vote = new HashMap<String, String>();
public static Map<String, Integer> stop = new HashMap<String, Integer>();
public static Map<String, String> stop = new HashMap<String, String>();
public static int Vote_time = 0;
public static int All_music = 0;
@@ -36,14 +36,17 @@ public class PlayMusic {
playgo.start();
}
public static void SendToPlayer(String data)
{
public static void SendToPlayer(String data) {
Collection<ProxiedPlayer> values = ProxyServer.getInstance().getPlayers();
Iterator<ProxiedPlayer> iterator = values.iterator();
while (iterator.hasNext()) {
ProxiedPlayer players = iterator.next();
if(stop.get(players.getDisplayName())!=2)
players.sendData("AudioBuffer", data.getBytes());
if (stop.size() != 0) {
if (stop.get(players.getDisplayName()).equals("true") == false)
players.sendData("AudioBuffer", data.getBytes());
} else
players.sendData("AudioBuffer", data.getBytes());
}
}
public static void SendToOnePlayer(String data, String Player)
@@ -95,14 +98,14 @@ public class PlayMusic {
class playgo extends Thread {
public static void music_list() {
if (PlayMusic.playlist.size() == 1) {
String a = PlayMusic.playlist.get(1);
PlayMusic.playlist.put(0, a);
PlayMusic.playlist.remove(1);
String a = PlayMusic.playlist.get("1");
PlayMusic.playlist.put("0", a);
PlayMusic.playlist.remove("1");
} else if (PlayMusic.playlist.size() > 1) {
int i = 0;
for (; PlayMusic.playlist.size() - 1 > i; i++) {
String a = PlayMusic.playlist.get(String.valueOf(i + 1));
PlayMusic.playlist.put(i, a);
PlayMusic.playlist.put(String.valueOf(i), a);
}
PlayMusic.playlist.remove(String.valueOf(PlayMusic.All_music - 1));
}
@@ -118,13 +121,13 @@ class playgo extends Thread {
e.getMessage();
}
} else {
String playsong = PlayMusic.playlist.get(0);
String playsong = PlayMusic.playlist.get("0");
String song = PlayMusic.realURL(ALLmusic_BC.Music_Api1 + playsong);
if (song != null) {
PlayMusic.Music_time = PlayMusic.Music_Time(song);
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + "正在播放歌曲" + playsong));
PlayMusic.SendToPlayer("[Net]" + song);
PlayMusic.playlist.remove(0);
PlayMusic.playlist.remove("0");
music_list();
try {
while (PlayMusic.Music_time > 0) {
@@ -149,7 +152,7 @@ class playgo extends Thread {
}
} else {
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + "无效歌曲歌曲" + playsong));
PlayMusic.playlist.remove(0);
PlayMusic.playlist.remove("0");
music_list();
}
}
+9 -7
View File
@@ -52,10 +52,12 @@ public class command extends Command {
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,这首歌已经在队列了"));
return;
}
if (PlayMusic.stop.get(sender.getName()) == 2) {
PlayMusic.stop.put(sender.getName(), 1);
if(PlayMusic.stop.size() !=0 ) {
if (PlayMusic.stop.get(sender.getName()).equals("true") == true) {
PlayMusic.stop.put(sender.getName(), "false");
}
}
PlayMusic.playlist.put(PlayMusic.All_music, music_id);
PlayMusic.playlist.put(String.valueOf(PlayMusic.All_music), music_id);
PlayMusic.All_music++;
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + sender.getName() +
"点歌" + music_id));
@@ -85,9 +87,9 @@ public class command extends Command {
sender.sendMessage(new TextComponent("§d[ALLmusic]§2队列中无歌曲"));
}
sender.sendMessage(new TextComponent("§d[ALLmusic]§2队列中有歌曲数:" + PlayMusic.playlist.size()));
Iterator<Integer> iterator = PlayMusic.playlist.keySet().iterator();
Iterator<String> iterator = PlayMusic.playlist.keySet().iterator();
while (iterator.hasNext()) {
Integer key = iterator.next();
String key = iterator.next();
sender.sendMessage(new TextComponent("§d[ALLmusic]§2当前队列" + key + "->" + PlayMusic.playlist.get(key)));
}
} else if (args[0].equalsIgnoreCase("vote")) {
@@ -116,9 +118,9 @@ public class command extends Command {
PlayMusic.SendToPlayer("[Stop]");
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已切歌"));
} else if (args[0].equalsIgnoreCase("nomusic")) {
PlayMusic.stop.put(sender.getName(), 2);
PlayMusic.stop.put(sender.getName(), "true");
PlayMusic.SendToOnePlayer("[Stop]", sender.getName());
sender.sendMessage(new TextComponent("§d[ALLmusic]§2你不会再收到点歌了!"));
sender.sendMessage(new TextComponent("§d[ALLmusic]§2你不会再收到点歌了!想要再次参与点歌就点一首歌吧!"));
} else
add_music(sender, args);
}