From bfedd247e0b5fb51b4638ca9cd1fa4c68c2eea05 Mon Sep 17 00:00:00 2001 From: Color_yr <402067010@qq.com> Date: Thu, 4 Apr 2019 20:06:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/Color_yr/ALLmusic/ALLmusic_BC.java | 3 +- .../java/Color_yr/ALLmusic/PlayMusic.java | 3 +- src/main/java/Color_yr/ALLmusic/command.java | 61 ++++++++++--------- src/main/resources/config.yml | 2 + 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/main/java/Color_yr/ALLmusic/ALLmusic_BC.java b/src/main/java/Color_yr/ALLmusic/ALLmusic_BC.java index a6ff0ca1..d3984747 100644 --- a/src/main/java/Color_yr/ALLmusic/ALLmusic_BC.java +++ b/src/main/java/Color_yr/ALLmusic/ALLmusic_BC.java @@ -19,11 +19,11 @@ public class ALLmusic_BC extends Plugin { public static String Version = "1.0.0"; public static int Maxlist = 0; + public static int min_vote = 0; public static String Music_Api1 = null; public static Configuration config; private static File FileName; - public static Configuration Banconfig; public static File BanFileName; @@ -34,6 +34,7 @@ public class ALLmusic_BC extends Plugin { + ",你的配置文件版本为:" + config.getString("Version")); Maxlist = config.getInt("Maxlist", 10); + min_vote = config.getInt("min_vote", 3); Music_Api1 = config.getString("Music_Api1", "http://music.163.com/song/media/outer/url?id="); } diff --git a/src/main/java/Color_yr/ALLmusic/PlayMusic.java b/src/main/java/Color_yr/ALLmusic/PlayMusic.java index 49914233..3acc4e23 100644 --- a/src/main/java/Color_yr/ALLmusic/PlayMusic.java +++ b/src/main/java/Color_yr/ALLmusic/PlayMusic.java @@ -129,7 +129,8 @@ class playgo extends Thread { Music_time--; if (PlayMusic.Vote_time > 0) { PlayMusic.Vote_time--; - if (PlayMusic.Vote.size() >= ProxyServer.getInstance().getOnlineCount()) { + int players = ProxyServer.getInstance().getOnlineCount(); + if (PlayMusic.Vote.size() > ALLmusic_BC.min_vote || (players < ALLmusic_BC.min_vote && players == PlayMusic.Vote.size())) { ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + "已切歌")); PlayMusic.SendToPlayer("[Stop]"); Music_time = 0; diff --git a/src/main/java/Color_yr/ALLmusic/command.java b/src/main/java/Color_yr/ALLmusic/command.java index 946fdcd6..e5c6fbff 100644 --- a/src/main/java/Color_yr/ALLmusic/command.java +++ b/src/main/java/Color_yr/ALLmusic/command.java @@ -20,42 +20,38 @@ public class command extends Command { return pattern.matcher(str).matches(); } + public void add_music(CommandSender sender, String[] args) { ; + String music_id = null; + if (isInteger(args[0]) == true) { + music_id = args[0]; + if (PlayMusic.playlist.size() == ALLmusic_BC.Maxlist) { + sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,队列已满")); + return; + } else if (ALLmusic_BC.Banconfig.getBoolean(music_id, false) == true) { + sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,这首歌被禁点了")); + return; + } + 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)); + logs logs = new logs(); + logs.log_write("玩家:" + sender.getName() + " 点歌:" + music_id); + } else + sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请输入歌曲数字ID")); + } + public void execute(CommandSender sender, String[] args) { if (args.length == 0) { sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请使用/music help 获取帮助")); return; } else if (args[0].equalsIgnoreCase("help")) { sender.sendMessage(new TextComponent("§d[ALLmusic]§2帮助手册")); - sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music play [音乐ID] 来点歌")); + sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music [音乐ID] 来点歌")); sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music stop 停止播放歌曲")); sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music now 查看歌曲队列")); sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music vote 投票切歌")); return; - } else if (args[0].equalsIgnoreCase("play")) { - if (args.length < 2) { - sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请输入歌曲ID")); - return; - } else { - if (isInteger(args[1]) == true) { - if (PlayMusic.playlist.size() == ALLmusic_BC.Maxlist) { - sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,队列已满")); - return; - } - else if(ALLmusic_BC.Banconfig.getBoolean(args[1],false)==true) - { - sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,这首歌被禁点了")); - return; - } - PlayMusic.playlist.put(String.valueOf(PlayMusic.All_music), args[1]); - PlayMusic.All_music++; - ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + sender.getName() + - "点歌" + args[1])); - logs logs = new logs(); - logs.log_write("玩家:" + sender.getName() + " 点歌:" + args[1]); - } else - sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请输入歌曲数字ID")); - return; - } } else if (args[0].equalsIgnoreCase("stop")) { PlayMusic.SendToOnePlayer("[Stop]", sender.getName()); sender.sendMessage(new TextComponent("§d[ALLmusic]§2已停止" + sender.getName() + "的音乐播放")); @@ -86,10 +82,17 @@ public class command extends Command { PlayMusic.Vote.size() + "名玩家同意切歌。")); } } - }else if(args[0].equalsIgnoreCase("reload")) - { + } else if (args[0].equalsIgnoreCase("reload")) { ALLmusic_BC.reloadConfig(); sender.sendMessage(new TextComponent("§d[ALLmusic]§2已重读配置文件")); - } + } else if (args[0].equalsIgnoreCase("next") && sender.hasPermission("ALLmusic.admin")) { + PlayMusic.SendToOnePlayer("[Stop]", sender.getName()); + if (PlayMusic.Vote_time <= 3) + return; + else + PlayMusic.Vote_time = 0; + sender.sendMessage(new TextComponent("§d[ALLmusic]§2已切歌")); + } else + add_music(sender, args); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4d227318..90911cc7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,5 +2,7 @@ Maxlist: 10 #音乐网页API Music_Api1: http://music.163.com/song/media/outer/url?id= +#最小投票人数 +min_vote: 3 #配置文件版本号 Version: 1.0.0 \ No newline at end of file