大部分进行修改

This commit is contained in:
Color_yr committed 2019-03-30 19:03:14 +08:00
1 parent 363276e715
commit 0ea6d5fd13
4 files changed
+110 -79

No files matched your search

@@ -18,19 +18,29 @@ public class ALLmusic_BC extends Plugin {
public static String Version = "1.0.0";
public static int Maxlist = 0;
public static String Music_Api1 = null;
public static Configuration config;
private static File FileName;
public static Configuration Banconfig;
public static File BanFileName;
public static Logger log = ProxyServer.getInstance().getLogger();
public static void loadconfig() {
ProxyServer.getInstance().getLogger().info("§d[ALLmusic_BC]§e当前插件版本为:" + Version
ProxyServer.getInstance().getLogger().info("§d[ALLmusic]§e当前插件版本为:" + Version
+ ",你的配置文件版本为:" + config.getString("Version"));
Maxlist = config.getInt("Maxlist", 10);
Music_Api1 = config.getString("Music_Api1", "http://music.163.com/song/media/outer/url?id=");
}
public static void reloadConfig() {
try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(FileName);
Banconfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(BanFileName);
loadconfig();
} catch (Exception arg0) {
log.warning("§d[ALLmusic_BC]§c配置文件读取失败:" + arg0);
@@ -43,6 +53,7 @@ public class ALLmusic_BC extends Plugin {
public void setConfig() {
FileName = new File(getDataFolder(), "config.yml");
BanFileName = new File(getDataFolder(), "banlist.yml");
logs.file = new File(getDataFolder(), "logs.log");
if (!getDataFolder().exists())
getDataFolder().mkdir();
@@ -50,7 +61,12 @@ public class ALLmusic_BC extends Plugin {
try (InputStream in = getResourceAsStream("config.yml")) {
Files.copy(in, FileName.toPath());
} catch (IOException e) {
log.warning("§d[ALLmusic_BC]§c配置文件创建失败:" + e);
log.warning("§d[ALLmusic]§c配置文件创建失败:" + e);
}
try (InputStream in = getResourceAsStream("banlist.yml")) {
Files.copy(in, BanFileName.toPath());
} catch (IOException e) {
log.warning("§d[ALLmusic]§c禁用列表创建失败:" + e);
}
}
try {
@@ -58,22 +74,26 @@ public class ALLmusic_BC extends Plugin {
logs.file.createNewFile();
}
} catch (IOException e) {
log.warning("§d[ALLmusic_BC]§c日志文件错误:" + e);
log.warning("§d[ALLmusic]§c日志文件错误:" + e);
}
}
@Override
public void onEnable() {
log.info("§d[ALLmusic_BC]§e正在启动,感谢使用,本插件交流群:571239090");
log.info("§d[ALLmusic]§e正在启动,感谢使用,本插件交流群:571239090");
setConfig();
reloadConfig();
PlayMusic_Start();
ProxyServer.getInstance().getPluginManager().registerCommand(this, new command());
log.info("§d[ALLmusic_BC]§e已启动-" + Version);;
log.info("§d[ALLmusic]§e已启动-" + Version);
;
}
@Override
public void onDisable() {
log.info("§d[ALLmusic_BC]§e已停止,感谢使用");
PlayMusic.playlist.clear();
PlayMusic.Vote.clear();
PlayMusic.SendToPlayer("[Stop]");
log.info("§d[ALLmusic]§e已停止,感谢使用");
}
}
+9 -10
View File
@@ -3,6 +3,7 @@ package Color_yr.ALLmusic;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.security.AlgorithmConstraints;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -115,11 +116,11 @@ 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);
if(song!=null) {
String song = PlayMusic.realURL(ALLmusic_BC.Music_Api1 + playsong);
if (song != null) {
int Music_time = PlayMusic.Music_Time(song);
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "正在播放歌曲" + playsong));
PlayMusic.SendToPlayer("[Net]" +song);
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + "正在播放歌曲" + playsong));
PlayMusic.SendToPlayer("[Net]" + song);
PlayMusic.playlist.remove("0");
music_list();
try {
@@ -129,11 +130,11 @@ class playgo extends Thread {
if (PlayMusic.Vote_time > 0) {
PlayMusic.Vote_time--;
if (PlayMusic.Vote.size() >= ProxyServer.getInstance().getOnlineCount()) {
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "已切歌"));
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + "已切歌"));
PlayMusic.SendToPlayer("[Stop]");
Music_time = 0;
if (PlayMusic.All_music == 0) {
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "队列中无歌曲"));
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + "队列中无歌曲"));
}
PlayMusic.Vote_time = 0;
}
@@ -142,10 +143,8 @@ class playgo extends Thread {
} catch (InterruptedException e) {
e.getMessage();
}
}
else
{
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "无效歌曲歌曲" + playsong));
} else {
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + "无效歌曲歌曲" + playsong));
PlayMusic.playlist.remove("0");
music_list();
}
+71 -63
View File
@@ -5,74 +5,82 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
import java.lang.reflect.Proxy;
import java.util.Iterator;
import java.util.regex.Pattern;
public class command extends Command {
public command() {
super("music");
}
public command() {
super("music");
}
public boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
public boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
public void execute(CommandSender sender, String[] args) {
if (args.length == 0) {
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§c错误,请使用/music help 获取帮助"));
return;
} else if (args[0].equalsIgnoreCase("help")) {
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2帮助手册"));
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2使用/music play [音乐ID] 来点歌"));
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2使用/music stop 停止播放歌曲"));
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2使用/music now 查看歌曲队列"));
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2使用/music vote 投票切歌"));
return;
} else if (args[0].equalsIgnoreCase("play")) {
if (args.length < 2) {
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§c错误,请输入歌曲ID"));
return;
} else {
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"));
return;
}
} else if (args[0].equalsIgnoreCase("stop")) {
PlayMusic.SendToOnePlayer("[Stop]",sender.getName());
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2已停止" + sender.getName() + "的音乐播放"));
} else if (args[0].equalsIgnoreCase("now")) {
if (PlayMusic.playlist.size() == 0) {
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2队列中无歌曲"));
}
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2队列中有歌曲数:"+PlayMusic.playlist.size()));
Iterator<String> iterator = PlayMusic.playlist.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2当前队列" + key + "->" + PlayMusic.playlist.get(key)));
}
} else if (args[0].equalsIgnoreCase("vote")) {
if (PlayMusic.playlist.size() == 0) {
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2队列中无歌曲"));
} else if (PlayMusic.Vote_time == 0) {
PlayMusic.Vote_time = 10;
PlayMusic.Vote.put(sender.getName(), "true");
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2已发起切歌投票"));
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + sender.getName()+
"发起了切歌投票,10秒后结束,输入/music vote 同意切歌"));
} else if (PlayMusic.Vote_time > 0) {
if (PlayMusic.Vote.get(sender.getName()) != "true") {
PlayMusic.Vote.put(sender.getName(), "true");
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2已同意切歌"));
}
}
}
}
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 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;
}
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() + "的音乐播放"));
} else if (args[0].equalsIgnoreCase("now")) {
if (PlayMusic.playlist.size() == 0) {
sender.sendMessage(new TextComponent("§d[ALLmusic]§2队列中无歌曲"));
}
sender.sendMessage(new TextComponent("§d[ALLmusic]§2队列中有歌曲数:" + PlayMusic.playlist.size()));
Iterator<String> iterator = PlayMusic.playlist.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
sender.sendMessage(new TextComponent("§d[ALLmusic]§2当前队列" + key + "->" + PlayMusic.playlist.get(key)));
}
} else if (args[0].equalsIgnoreCase("vote")) {
if (PlayMusic.playlist.size() == 0) {
sender.sendMessage(new TextComponent("§d[ALLmusic]§2队列中无歌曲"));
} else if (PlayMusic.Vote_time == 0) {
PlayMusic.Vote_time = 10;
PlayMusic.Vote.clear();
PlayMusic.Vote.put(sender.getName(), "true");
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已发起切歌投票"));
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + sender.getName() +
"发起了切歌投票,10秒后结束,输入/music vote 同意切歌。"));
} else if (PlayMusic.Vote_time > 0) {
if (PlayMusic.Vote.get(sender.getName()) != "true") {
PlayMusic.Vote.put(sender.getName(), "true");
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + sender.getName() + "同意切歌,共有" +
PlayMusic.Vote.size() + "名玩家同意切歌。"));
}
}
}
}
}