From 6079a3302aca28c51c5ef460f615eaebfbae6cb0 Mon Sep 17 00:00:00 2001 From: Color_yr <402067010@qq.com> Date: Sun, 24 Mar 2019 16:19:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Color_yr/ALLmusic/ChannelListener.java | 9 +-- .../java/Color_yr/ALLmusic/PlayMusic.java | 62 ++++++++++--------- src/main/java/Color_yr/ALLmusic/command.java | 2 + 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/main/java/Color_yr/ALLmusic/ChannelListener.java b/src/main/java/Color_yr/ALLmusic/ChannelListener.java index 9a062d82..cd28e09b 100644 --- a/src/main/java/Color_yr/ALLmusic/ChannelListener.java +++ b/src/main/java/Color_yr/ALLmusic/ChannelListener.java @@ -23,14 +23,11 @@ public class ChannelListener implements Listener { ServerInfo server = ProxyServer.getInstance().getPlayer(e.getReceiver().toString()).getServer().getInfo(); String input = in.readUTF(); // the inputstring if (input.equals("test")) { - } - } } catch (IOException e1) { e1.printStackTrace(); } - } } @@ -45,9 +42,9 @@ public class ChannelListener implements Listener { } Map Server = ProxyServer.getInstance().getServers(); Collection values = Server.values(); - Iterator iterator2 = values.iterator(); - while (iterator2.hasNext()) { - ServerInfo server = iterator2.next(); + Iterator iterator = values.iterator(); + while (iterator.hasNext()) { + ServerInfo server = iterator.next(); server.sendData("ALLmusic", stream.toByteArray()); } } diff --git a/src/main/java/Color_yr/ALLmusic/PlayMusic.java b/src/main/java/Color_yr/ALLmusic/PlayMusic.java index 352dc77d..0c939aac 100644 --- a/src/main/java/Color_yr/ALLmusic/PlayMusic.java +++ b/src/main/java/Color_yr/ALLmusic/PlayMusic.java @@ -23,6 +23,7 @@ public class PlayMusic { public static int All_music = 0; public static Map Vote = new HashMap(); public static int Vote_time = 0; + public static void PlayMusic_Start() { playgo.start(); } @@ -59,16 +60,13 @@ public class PlayMusic { if (connection == null) { var5.printStackTrace(); return null; - } else { - if (warningTimes > 0) { - Integer var3 = warningTimes; - warningTimes = warningTimes - 1; - ALLmusic_BC.log.warning("> 警告: 网页请求反馈出错."); - } - - return connection.getURL().toString(); } + } catch (NullPointerException e) { + e.getMessage(); + return null; + } + return null; } } @@ -100,30 +98,38 @@ class playgo extends Thread { } else { String playsong = PlayMusic.playlist.get("0"); String song = PlayMusic.realURL("http://music.163.com/song/media/outer/url?id=" + playsong); - int Music_time = PlayMusic.Music_Time(song); - ChannelListener.sendToBukkit("play", playsong); - ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "正在播放歌曲" + playsong)); - PlayMusic.playlist.remove("0"); - music_list(); - try { - while (Music_time > 0) { - Thread.sleep(1000); - Music_time--; - if(PlayMusic.Vote_time>0) { - PlayMusic.Vote_time--; - if (PlayMusic.Vote.size() >= ProxyServer.getInstance().getOnlineCount()) { - ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "已切歌")); - ChannelListener.sendToBukkit("stopALL", ""); - Music_time = 0; - if (PlayMusic.All_music == 0) { - ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "队列中无歌曲")); + if(song!=null) { + int Music_time = PlayMusic.Music_Time(song); + ChannelListener.sendToBukkit("play", playsong); + ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "正在播放歌曲" + playsong)); + PlayMusic.playlist.remove("0"); + music_list(); + try { + while (Music_time > 0) { + Thread.sleep(1000); + Music_time--; + if (PlayMusic.Vote_time > 0) { + PlayMusic.Vote_time--; + if (PlayMusic.Vote.size() >= ProxyServer.getInstance().getOnlineCount()) { + ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "已切歌")); + ChannelListener.sendToBukkit("stopALL", ""); + Music_time = 0; + if (PlayMusic.All_music == 0) { + ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "队列中无歌曲")); + } + PlayMusic.Vote_time = 0; } - PlayMusic.Vote_time=0; } } + } catch (InterruptedException e) { + e.getMessage(); } - } catch (InterruptedException e) { - e.getMessage(); + } + else + { + ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "无效歌曲歌曲" + playsong)); + PlayMusic.playlist.remove("0"); + music_list(); } } } diff --git a/src/main/java/Color_yr/ALLmusic/command.java b/src/main/java/Color_yr/ALLmusic/command.java index 31f50faf..de3e6dad 100644 --- a/src/main/java/Color_yr/ALLmusic/command.java +++ b/src/main/java/Color_yr/ALLmusic/command.java @@ -38,6 +38,8 @@ public class command extends Command { if (isInteger(args[1]) == true) { PlayMusic.playlist.put(String.valueOf(PlayMusic.All_music), args[1]); PlayMusic.All_music++; + ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + sender.getName()+ + "点歌"+args[1])); sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2已添加" + args[1])); } else sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§c错误,请输入歌曲数字ID"));