This commit is contained in:
Coloryr committed 2020-02-29 22:09:52 +08:00
1 parent 66521bf400
commit 30aaf01e22
19 files changed
+395 -281

No files matched your search

@@ -1,146 +1,18 @@
package Color_yr.ALLMusic.Command;
import Color_yr.ALLMusic.ALLMusic;
import Color_yr.ALLMusic.ALLMusicBC;
import Color_yr.ALLMusic.Play.PlayMusic;
import Color_yr.ALLMusic.PlayList.GetList;
import Color_yr.ALLMusic.Utils.Function;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
public class CommandBC extends Command implements TabExecutor {
public CommandBC() {
super("music");
}
private void AddMusic(CommandSender sender, String[] args) {
String MusicID;
if (args[0].contains("id=")) {
if (args[0].contains("&user"))
MusicID = Function.getString(args[0], "id=", "&user");
else
MusicID = Function.getString(args[0], "id=", null);
} else if (args[0].contains("song/")) {
if (args[0].contains("/?userid"))
MusicID = Function.getString(args[0], "song/", "/?userid");
else
MusicID = Function.getString(args[0], "song/", null);
} else
MusicID = args[0];
if (Function.isInteger(MusicID)) {
if (PlayMusic.PlayList.size() == ALLMusic.Config.getMaxList()) {
sender.sendMessage(new TextComponent("§d[ALLMusic]§c错误,队列已满"));
} else if (ALLMusic.Config.getBanMusic().contains(MusicID)) {
sender.sendMessage(new TextComponent("§d[ALLMusic]§c错误,这首歌被禁点了"));
} else {
ALLMusic.Config.RemoveNoMusicPlayer(sender.getName());
if (ALLMusic.Side.NeedPlay()) {
PlayMusic.AddMusic(MusicID, sender.getName());
if (PlayMusic.isList && ALLMusic.Config.isPlayListSwitch()) {
PlayMusic.MusicAllTime = 1;
PlayMusic.isList = false;
}
sender.sendMessage(new TextComponent("§d[ALLMusic]§2点歌成功"));
}
else
sender.sendMessage(new TextComponent("§d[ALLMusic]§c没有播放的玩家"));
}
} else
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请输入歌曲数字ID"));
}
public void execute(CommandSender sender, String[] args) {
String name = sender.getName();
if (args.length == 0) {
sender.sendMessage(new TextComponent("§d[ALLMusic]§c错误,请使用/music help 获取帮助"));
} else if (args[0].equalsIgnoreCase("help")) {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2帮助手册"));
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 list 查看歌曲队列"));
sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music vote 投票切歌"));
sender.sendMessage(new TextComponent("§d[ALLMusic]§2使用/music nomusic 不再参与点歌"));
} else if (args[0].equalsIgnoreCase("stop")) {
ALLMusic.Side.Send("[Stop]", name, false);
sender.sendMessage(new TextComponent("§d[ALLMusic]§2已停止" + name + "的音乐播放"));
} else if (args[0].equalsIgnoreCase("list")) {
if (PlayMusic.NowPlayMusic == null) {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2无正在播放的歌曲"));
} else {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2正在播放:" + PlayMusic.NowPlayMusic.getInfo()));
}
if (PlayMusic.PlayList.size() == 0) {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2队列中无歌曲"));
} else {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2队列中有歌曲数:" + PlayMusic.PlayList.size()));
sender.sendMessage(new TextComponent(PlayMusic.getList()));
}
} 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 = 30;
PlayMusic.Vote.add(name);
sender.sendMessage(new TextComponent("§d[ALLMusic]§2已发起切歌投票"));
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLMusic]§2" + name +
"发起了切歌投票,30秒后结束,输入/music vote 同意切歌。"));
} else if (PlayMusic.Vote_time > 0) {
if (!PlayMusic.Vote.contains(name)) {
PlayMusic.Vote.add(name);
sender.sendMessage(new TextComponent("§d[ALLMusic]§2你已同意"));
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLMusic]§2" + name + "同意切歌,共有" +
PlayMusic.Vote.size() + "名玩家同意切歌。"));
} else {
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLMusic]§2你已申请切歌"));
}
}
} else if (args[0].equalsIgnoreCase("reload")) {
ALLMusicBC.setConfig();
sender.sendMessage(new TextComponent("§d[ALLMusic]§2已重读配置文件"));
} else if (args[0].equalsIgnoreCase("v")) {
if (args.length == 2) {
ALLMusic.Side.Send("[V]" + args[1], sender.getName(), null);
sender.sendMessage(new TextComponent("§d[ALLMusic]§2已设置你的音量为:" + args[1]));
} else
sender.sendMessage(new TextComponent("§d[ALLMusic]§4请输入音量"));
} else if (args[0].equalsIgnoreCase("next") && ALLMusic.Config.getAdmin().contains(name)) {
PlayMusic.MusicAllTime = 1;
sender.sendMessage(new TextComponent("§d[ALLMusic]§2已强制切歌"));
} else if (args[0].equalsIgnoreCase("nomusic")) {
ALLMusic.Side.Send("[Stop]", name, false);
ALLMusic.Config.AddNoMusicPlayer(sender.getName());
sender.sendMessage(new TextComponent("§d[ALLMusic]§2你不会再收到点歌了!想要再次参与点歌就点一首歌吧!"));
} else if (args[0].equalsIgnoreCase("ban") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(name)) {
if (Function.isInteger(args[1])) {
ALLMusic.Config.addBanID(args[1]);
sender.sendMessage(new TextComponent("§d[ALLMusic]§2已禁止" + args[1]));
} else {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2请输入有效的ID"));
}
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(name)) {
if (Function.isInteger(args[1])) {
int music = Integer.parseInt(args[1]);
PlayMusic.PlayList.remove(music);
sender.sendMessage(new TextComponent("§d[ALLMusic]§2已删除序列" + music));
} else {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2请输入有效的序列ID"));
}
} else if (args[0].equalsIgnoreCase("addlist") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(name)) {
if (Function.isInteger(args[1])) {
GetList.GetL(args[1]);
sender.sendMessage(new TextComponent("§d[ALLMusic]§2添加音乐列表" + args[1]));
} else {
sender.sendMessage(new TextComponent("§d[ALLMusic]§2请输入有效的音乐列表ID"));
}
} else
AddMusic(sender, args);
CommandEX.EX(sender, sender.getName(), args);
}
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
@@ -1,11 +1,5 @@
package Color_yr.ALLMusic.Command;
import Color_yr.ALLMusic.ALLMusic;
import Color_yr.ALLMusic.ALLMusicBukkit;
import Color_yr.ALLMusic.Play.PlayMusic;
import Color_yr.ALLMusic.PlayList.GetList;
import Color_yr.ALLMusic.Utils.Function;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -15,133 +9,10 @@ import java.util.List;
public class CommandBukkit implements CommandExecutor, TabExecutor {
private void AddMusic(CommandSender sender, String[] args) {
String MusicID;
if (args[0].contains("id=")) {
if (args[0].contains("&user"))
MusicID = Function.getString(args[0], "id=", "&user");
else
MusicID = Function.getString(args[0], "id=", null);
} else if (args[0].contains("song/")) {
if (args[0].contains("/?userid"))
MusicID = Function.getString(args[0], "song/", "/?userid");
else
MusicID = Function.getString(args[0], "song/", null);
} else
MusicID = args[0];
if (Function.isInteger(MusicID)) {
if (PlayMusic.PlayList.size() == ALLMusic.Config.getMaxList()) {
sender.sendMessage("§d[ALLMusic]§c错误,队列已满");
} else if (ALLMusic.Config.getBanMusic().contains(MusicID)) {
sender.sendMessage("§d[ALLMusic]§c错误,这首歌被禁点了");
} else {
ALLMusic.Config.RemoveNoMusicPlayer(sender.getName());
if (ALLMusic.Side.NeedPlay()) {
PlayMusic.AddMusic(MusicID, sender.getName());
if (PlayMusic.isList && ALLMusic.Config.isPlayListSwitch()) {
PlayMusic.MusicAllTime = 1;
PlayMusic.isList = false;
}
sender.sendMessage("§d[ALLMusic]§2点歌成功");
}
else
sender.sendMessage("§d[ALLMusic]§c没有播放的玩家");
}
} else
sender.sendMessage("§d[ALLmusic]§c错误,请输入歌曲数字ID");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("music")) {
String name = sender.getName();
if (args.length == 0) {
sender.sendMessage("§d[ALLMusic]§c错误,请使用/music help 获取帮助");
} else if (args[0].equalsIgnoreCase("help")) {
sender.sendMessage("§d[ALLMusic]§2帮助手册");
sender.sendMessage("§d[ALLMusic]§2使用/music [音乐ID] 来点歌");
sender.sendMessage("§d[ALLMusic]§2使用/music stop 停止播放歌曲");
sender.sendMessage("§d[ALLMusic]§2使用/music list 查看歌曲队列");
sender.sendMessage("§d[ALLmusic]§2使用/music vote 投票切歌");
sender.sendMessage("§d[ALLMusic]§2使用/music nomusic 不再参与点歌");
} else if (args[0].equalsIgnoreCase("stop")) {
ALLMusic.Side.Send("[Stop]", name, false);
sender.sendMessage("§d[ALLMusic]§2已停止" + name + "的音乐播放");
} else if (args[0].equalsIgnoreCase("list")) {
if (PlayMusic.NowPlayMusic == null) {
sender.sendMessage("§d[ALLMusic]§2无正在播放的歌曲");
} else {
sender.sendMessage("§d[ALLMusic]§2正在播放:" + PlayMusic.NowPlayMusic.getInfo());
}
if (PlayMusic.PlayList.size() == 0) {
sender.sendMessage("§d[ALLMusic]§2队列中无歌曲");
} else {
sender.sendMessage("§d[ALLMusic]§2队列中有歌曲数:" + PlayMusic.PlayList.size());
sender.sendMessage(PlayMusic.getList());
}
} else if (args[0].equalsIgnoreCase("vote")) {
if (PlayMusic.PlayList.size() == 0) {
sender.sendMessage("§d[ALLMusic]§2队列中无歌曲");
} else if (PlayMusic.Vote_time == 0) {
PlayMusic.Vote_time = 30;
PlayMusic.Vote.add(name);
sender.sendMessage("§d[ALLMusic]§2已发起切歌投票");
Bukkit.broadcastMessage("§d[ALLMusic]§2" + name +
"发起了切歌投票,30秒后结束,输入/music vote 同意切歌。");
} else if (PlayMusic.Vote_time > 0) {
if (!PlayMusic.Vote.contains(name)) {
PlayMusic.Vote.add(name);
sender.sendMessage("§d[ALLMusic]§2你已同意");
Bukkit.broadcastMessage("§d[ALLMusic]§2" + name + "同意切歌,共有" +
PlayMusic.Vote.size() + "名玩家同意切歌。");
} else {
Bukkit.broadcastMessage("§d[ALLMusic]§2你已申请切歌");
}
}
} else if (args[0].equalsIgnoreCase("reload")) {
ALLMusicBukkit.setConfig();
sender.sendMessage("§d[ALLMusic]§2已重读配置文件");
} else if (args[0].equalsIgnoreCase("v")) {
if (args.length == 2) {
ALLMusic.Side.Send("[V]" + args[1], sender.getName(), null);
sender.sendMessage("§d[ALLMusic]§2已设置你的音量为:" + args[1]);
} else
sender.sendMessage("§d[ALLMusic]§4请输入音量");
} else if (args[0].equalsIgnoreCase("next") && ALLMusic.Config.getAdmin().contains(name)) {
PlayMusic.MusicAllTime = 1;
sender.sendMessage("§d[ALLMusic]§2已强制切歌");
} else if (args[0].equalsIgnoreCase("nomusic")) {
ALLMusic.Side.Send("[Stop]", name, false);
ALLMusic.Config.AddNoMusicPlayer(sender.getName());
sender.sendMessage("§d[ALLMusic]§2你不会再收到点歌了!想要再次参与点歌就点一首歌吧!");
} else if (args[0].equalsIgnoreCase("ban") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(name)) {
if (Function.isInteger(args[1])) {
ALLMusic.Config.addBanID(args[1]);
sender.sendMessage("§d[ALLMusic]§2已禁止" + args[1]);
} else {
sender.sendMessage("§d[ALLMusic]§2请输入有效的ID");
}
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(name)) {
if (Function.isInteger(args[1])) {
int music = Integer.parseInt(args[1]);
PlayMusic.PlayList.remove(music);
sender.sendMessage("§d[ALLMusic]§2已删除序列" + music);
} else {
sender.sendMessage("§d[ALLMusic]§2请输入有效的序列ID");
}
} else if (args[0].equalsIgnoreCase("addlist") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(name)) {
if (Function.isInteger(args[1])) {
GetList.GetL(args[1]);
sender.sendMessage("§d[ALLMusic]§2添加音乐列表" + args[1]);
} else {
sender.sendMessage("§d[ALLMusic]§2请输入有效的音乐列表ID");
}
} else
AddMusic(sender, args);
CommandEX.EX(sender, sender.getName(), args);
return true;
}
return false;
@@ -0,0 +1,165 @@
package Color_yr.ALLMusic.Command;
import Color_yr.ALLMusic.ALLMusic;
import Color_yr.ALLMusic.Play.PlayMusic;
import Color_yr.ALLMusic.PlayList.GetList;
import Color_yr.ALLMusic.Search.PlayerSearch;
import Color_yr.ALLMusic.Search.Search;
import Color_yr.ALLMusic.Utils.Function;
public class CommandEX {
private static void AddMusic(Object sender, String Name, String[] args) {
String MusicID;
if (args[0].contains("id=")) {
if (args[0].contains("&user"))
MusicID = Function.getString(args[0], "id=", "&user");
else
MusicID = Function.getString(args[0], "id=", null);
} else if (args[0].contains("song/")) {
if (args[0].contains("/?userid"))
MusicID = Function.getString(args[0], "song/", "/?userid");
else
MusicID = Function.getString(args[0], "song/", null);
} else
MusicID = args[0];
if (Function.isInteger(MusicID)) {
if (PlayMusic.PlayList.size() == ALLMusic.Config.getMaxList()) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c错误,队列已满");
} else if (ALLMusic.Config.getBanMusic().contains(MusicID)) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c错误,这首歌被禁点了");
} else if (PlayMusic.isHave(MusicID)) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c错误,这首歌已经存在了");
} else {
ALLMusic.Config.RemoveNoMusicPlayer(Name);
if (ALLMusic.Side.NeedPlay()) {
PlayMusic.AddMusic(MusicID, Name);
if (PlayMusic.isList && ALLMusic.Config.isPlayListSwitch()) {
PlayMusic.MusicAllTime = 1;
PlayMusic.isList = false;
}
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2点歌成功");
} else
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c没有播放的玩家");
}
} else
ALLMusic.Side.SendMessage(sender, "§d[ALLmusic]§c错误,请输入歌曲数字ID");
}
public static void EX(Object sender, String Name, String[] args) {
if (args.length == 0) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c错误,请使用/music help 获取帮助");
} else if (args[0].equalsIgnoreCase("help")) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2帮助手册");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music [音乐ID] 来点歌");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music stop 停止播放歌曲");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music list 查看歌曲队列");
ALLMusic.Side.SendMessage(sender, "§d[ALLmusic]§2使用/music vote 投票切歌");
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2使用/music nomusic 不再参与点歌");
} else if (args[0].equalsIgnoreCase("stop")) {
ALLMusic.Side.Send("[Stop]", Name, false);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已停止" + Name + "的音乐播放");
} else if (args[0].equalsIgnoreCase("list")) {
if (PlayMusic.NowPlayMusic == null) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2无正在播放的歌曲");
} else {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2正在播放:" + PlayMusic.NowPlayMusic.getInfo());
}
if (PlayMusic.PlayList.size() == 0) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2队列中无歌曲");
} else {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2队列中有歌曲数:" + PlayMusic.PlayList.size());
ALLMusic.Side.SendMessage(sender, PlayMusic.getList());
}
} else if (args[0].equalsIgnoreCase("vote")) {
if (PlayMusic.PlayList.size() == 0) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2队列中无歌曲");
} else if (PlayMusic.Vote_time == 0) {
PlayMusic.Vote_time = 30;
PlayMusic.Vote.add(Name);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已发起切歌投票");
ALLMusic.Side.bq("§d[ALLMusic]§2" + Name +
"发起了切歌投票,30秒后结束,输入/music vote 同意切歌。");
} else if (PlayMusic.Vote_time > 0) {
if (!PlayMusic.Vote.contains(Name)) {
PlayMusic.Vote.add(Name);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2你已同意");
ALLMusic.Side.bq("§d[ALLMusic]§2" + Name + "同意切歌,共有" +
PlayMusic.Vote.size() + "名玩家同意切歌。");
} else {
ALLMusic.Side.bq("§d[ALLMusic]§2你已申请切歌");
}
}
} else if (args[0].equalsIgnoreCase("reload")) {
ALLMusic.Side.reload();
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已重读配置文件");
} else if (args[0].equalsIgnoreCase("v")) {
if (args.length == 2) {
ALLMusic.Side.Send("[V]" + args[1], Name, null);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已设置你的音量为:" + args[1]);
} else
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§4请输入音量");
} else if (args[0].equalsIgnoreCase("next") && ALLMusic.Config.getAdmin().contains(Name)) {
PlayMusic.MusicAllTime = 1;
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已强制切歌");
} else if (args[0].equalsIgnoreCase("nomusic")) {
ALLMusic.Side.Send("[Stop]", Name, false);
ALLMusic.Config.AddNoMusicPlayer(Name);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2你不会再收到点歌了!想要再次参与点歌就点一首歌吧!");
} else if (args[0].equalsIgnoreCase("ban") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(Name)) {
if (Function.isInteger(args[1])) {
ALLMusic.Config.addBanID(args[1]);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已禁止" + args[1]);
} else {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2请输入有效的ID");
}
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(Name)) {
if (Function.isInteger(args[1])) {
int music = Integer.parseInt(args[1]);
PlayMusic.PlayList.remove(music);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2已删除序列" + music);
} else {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2请输入有效的序列ID");
}
} else if (args[0].equalsIgnoreCase("addlist") && args.length == 2
&& ALLMusic.Config.getAdmin().contains(Name)) {
if (Function.isInteger(args[1])) {
GetList.GetL(args[1]);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2添加音乐列表" + args[1]);
} else {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2请输入有效的音乐列表ID");
}
} else if (args[0].equalsIgnoreCase("search") && args.length == 2) {
ALLMusic.Side.RunTask(() -> {
Search search = new Search(args[1]);
if (!search.isDone())
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c无法搜索歌曲:" + args[1]);
else {
ALLMusic.Side.SendMessage(sender, "§2" + search.GetInfo());
PlayerSearch.SearchSave.put(Name, search);
}
});
} else if (args[0].equalsIgnoreCase("select") && args.length == 2) {
Search obj = PlayerSearch.SearchSave.get(Name);
if (obj == null) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有搜索音乐");
} else if (!args[1].isEmpty() && Function.isInteger(args[1])) {
int a = Integer.parseInt(args[1]);
if (a == 0) {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c请输入正确的序号");
return;
}
String[] ID = new String[1];
ID[0] = obj.GetSong(a - 1);
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2你选择了序号" + a);
AddMusic(sender, Name, ID);
PlayerSearch.SearchSave.remove(Name);
} else {
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c请输入正确的序号");
}
} else
AddMusic(sender, Name, args);
}
}
@@ -12,6 +12,8 @@ public class TabCommand {
arguments.add("list");
arguments.add("vote");
arguments.add("nomusic");
arguments.add("search");
arguments.add("select");
if (ALLMusic.Config.getAdmin().contains(name)) {
arguments.add("reload");
arguments.add("next");
@@ -8,6 +8,7 @@ public class ConfigOBJ {
private String Lyric_Api1;
private String Info_Api1;
private String List_Api1;
private String Search_Api1;
private int MaxList;
private int MinVote;
@@ -29,6 +30,7 @@ public class ConfigOBJ {
Lyric_Api1 = "https://api.imjad.cn/cloudmusic/?type=lyric&id=";
Info_Api1 = "https://api.imjad.cn/cloudmusic/?type=detail&id=";
List_Api1 = "https://api.imjad.cn/cloudmusic/?type=playlist&id=";
Search_Api1 = "https://music.163.com/api/search/get/web?type=1&s=";
MaxList = 10;
MinVote = 3;
Delay = 2;
@@ -43,6 +45,10 @@ public class ConfigOBJ {
Version = ALLMusic.Version;
}
public String getSearch_Api1() {
return Search_Api1;
}
public boolean isPlayListRandom() {
return PlayListRandom;
}
@@ -22,8 +22,7 @@ class PlayGo extends Thread {
PlayMusic.nowLyric = now != null ? now : PlayMusic.nowLyric;
times = 0;
ALLMusic.Side.SendLyric(PlayMusic.nowLyric);
}
else {
} else {
times++;
if (times == 200) {
times = 0;
@@ -74,7 +73,6 @@ class PlayGo extends Thread {
PlayMusic.PlayList.remove(0);
PlayMusic.MusicNowTime = 0;
PlayMusic.MusicAllTime = 0;
close();
PlayMusic.Lyric = null;
PlayMusic.nowLyric = "";
PlayMusic.haveLyric = false;
@@ -130,10 +128,12 @@ class PlayGo extends Thread {
ALLMusic.log.warning("§d[ALLMusic]§c歌曲播放出现错误");
e.printStackTrace();
}
if (PlayMusic.haveLyric)
close();
} else {
ALLMusic.Side.bq("§d[ALLMusic]§2" + "无效歌曲歌曲" + PlayMusic.NowPlayMusic.getID());
PlayMusic.NowPlayMusic = null;
}
PlayMusic.NowPlayMusic = null;
}
}
}
@@ -3,7 +3,7 @@ package Color_yr.ALLMusic.Play;
import Color_yr.ALLMusic.ALLMusic;
import Color_yr.ALLMusic.Lyric.LyricDo;
import Color_yr.ALLMusic.Song.GetInfo;
import Color_yr.ALLMusic.Song.Info;
import Color_yr.ALLMusic.Song.SongInfo;
import Color_yr.ALLMusic.Utils.logs;
import java.util.ArrayList;
@@ -11,14 +11,14 @@ import java.util.List;
public class PlayMusic {
public static List<Info> PlayList = new ArrayList<>();
public static List<SongInfo> PlayList = new ArrayList<>();
public static List<String> Vote = new ArrayList<>();
public static List<String> NowPlay = new ArrayList<>();
public static int Vote_time = 0;
public static int MusicAllTime = 0;
public static int MusicNowTime = 0;
public static Info NowPlayMusic;
public static SongInfo NowPlayMusic;
public static LyricDo Lyric;
public static boolean haveLyric;
@@ -40,11 +40,13 @@ public class PlayMusic {
PlayGo.start();
}
public static void AddMusic(String ID, String player) {
public static boolean AddMusic(String ID, String player) {
if (isHave(ID))
return false;
ALLMusic.Side.bq("§d[ALLMusic]§2" + player +
"点歌" + ID);
logs.log_write("玩家:" + player + " 点歌:" + ID);
Info info = new Info(null, null, ID, null, player);
SongInfo info = new SongInfo(null, null, ID, null, player);
try {
info = GetInfo.Get(ID, player);
} catch (Exception e) {
@@ -52,15 +54,26 @@ public class PlayMusic {
e.printStackTrace();
}
PlayList.add(info);
return true;
}
public static String getList() {
StringBuilder list = new StringBuilder();
for (int i = 0; i < PlayList.size(); i++) {
Info info = PlayList.get(i);
list.append("§2").append(i).append("->").append(info.getInfo()).append("\n");
SongInfo info = PlayList.get(i);
list.append("§2").append(i + 1).append("->").append(info.getInfo()).append("\n");
}
return list.toString();
}
public static boolean isHave(String ID) {
if (NowPlayMusic != null && NowPlayMusic.getID().equalsIgnoreCase(ID))
return true;
for (SongInfo item : PlayList) {
if (item.getID().equalsIgnoreCase(ID))
return true;
}
return false;
}
}
@@ -0,0 +1,58 @@
package Color_yr.ALLMusic.Search;
import java.util.List;
public class DataOBJ {
private result result;
public List<songs> getResult() {
return result.getSongs();
}
}
class result{
private List<songs> songs;
public List<songs> getSongs() {
return songs;
}
}
class songs {
private int id;
private String name;
private List<artists> artists;
private album album;
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getAlbum() {
return album.getName();
}
public String getArtists() {
StringBuilder a = new StringBuilder();
for (artists temp : artists) {
a.append(temp.getName()).append(",");
}
return a.substring(0, a.length() - 1);
}
}
class artists{
private String name;
public String getName() {
return name;
}
}
class album{
private String name;
public String getName() {
return name;
}
}
@@ -0,0 +1,8 @@
package Color_yr.ALLMusic.Search;
import java.util.HashMap;
import java.util.Map;
public class PlayerSearch {
public final static Map<String, Search> SearchSave = new HashMap<>();
}
@@ -0,0 +1,47 @@
package Color_yr.ALLMusic.Search;
import Color_yr.ALLMusic.ALLMusic;
import Color_yr.ALLMusic.Http.Get;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
public class Search {
private List<SearchOBJ> res = new ArrayList<>();
private boolean done = false;
public Search(String name) {
String data = Get.realData(ALLMusic.Config.getSearch_Api1() + name);
if (data != null) {
DataOBJ obj = new Gson().fromJson(data, DataOBJ.class);
if (obj != null && obj.getResult() != null) {
List<songs> res1 = obj.getResult();
SearchOBJ item;
for (songs temp : res1) {
item = new SearchOBJ(String.valueOf(temp.getId()), temp.getName(), temp.getArtists(), temp.getAlbum());
res.add(item);
}
done = true;
}
}
}
public String GetSong(int index) {
return res.get(index).getID();
}
public String GetInfo() {
StringBuilder Info = new StringBuilder();
int a = 1;
for (SearchOBJ item : res) {
Info.append(a).append("->").append(item.getName()).append(" | ").append(item.getAuthor()).append(" | ").append(item.getAila()).append("\n");
a++;
}
return Info.substring(0, Info.length() - 1);
}
public boolean isDone() {
return done;
}
}
@@ -0,0 +1,31 @@
package Color_yr.ALLMusic.Search;
public class SearchOBJ {
private String ID;
private String Name;
private String Author;
private String Aila;
public SearchOBJ(String ID, String Name, String Author, String Aila) {
this.ID = ID;
this.Name = Name;
this.Author = Author;
this.Aila = Aila;
}
public String getName() {
return Name;
}
public String getAuthor() {
return Author;
}
public String getID() {
return ID;
}
public String getAila() {
return Aila;
}
}
@@ -16,4 +16,10 @@ public interface ISide {
void save();
boolean NeedPlay();
void SendMessage(Object obj, String Message);
void RunTask(Runnable run);
void reload();
}
@@ -5,6 +5,7 @@ import Color_yr.ALLMusic.ALLMusicBC;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo;
@@ -95,6 +96,22 @@ public class SideBC implements ISide {
return online > 0;
}
@Override
public void SendMessage(Object obj, String Message) {
CommandSender sender = (CommandSender) obj;
sender.sendMessage(new TextComponent(Message));
}
@Override
public void RunTask(Runnable run) {
ProxyServer.getInstance().getScheduler().runAsync(ALLMusicBC.ALLMusicP, run);
}
@Override
public void reload() {
ALLMusicBC.setConfig();
}
private void Send(ProxiedPlayer players, String data, Boolean isplay) {
try {
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
@@ -6,6 +6,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
@@ -75,6 +76,22 @@ public class SideBukkit implements ISide {
return online > 0;
}
@Override
public void SendMessage(Object obj, String Message) {
CommandSender sender = (CommandSender) obj;
sender.sendMessage(Message);
}
@Override
public void RunTask(Runnable run) {
Bukkit.getScheduler().runTask(ALLMusicP, run);
}
@Override
public void reload() {
ALLMusicBukkit.setConfig();
}
private void Send(Player players, String data, Boolean isplay) {
try {
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
@@ -5,12 +5,12 @@ import Color_yr.ALLMusic.Http.Get;
import com.google.gson.Gson;
public class GetInfo {
public static Info Get(String ID, String player) {
public static SongInfo Get(String ID, String player) {
String data = Get.realData(ALLMusic.Config.getInfo_Api1() + ID);
Info info = new Info(null, null, ID, null, player);
SongInfo info = new SongInfo(null, null, ID, null, player);
if (data != null) {
InfoOBJ temp = new Gson().fromJson(data, InfoOBJ.class);
info = new Info(temp.getAuthor(), temp.getName(), ID, temp.getAlia(), player);
info = new SongInfo(temp.getAuthor(), temp.getName(), ID, temp.getAlia(), player);
}
return info;
}
@@ -1,13 +1,13 @@
package Color_yr.ALLMusic.Song;
public class Info {
public class SongInfo {
private String Author;
private String Name;
private String ID;
private String Alia;
private String Call;
public Info(String Author, String Name, String ID, String Alia, String Call) {
public SongInfo(String Author, String Name, String ID, String Alia, String Call) {
this.Author = Author;
this.Name = Name;
this.ID = ID;
@@ -24,10 +24,10 @@ public class Info {
if (Name != null && !Name.isEmpty()) {
info += Name;
if (Author != null && !Author.isEmpty()) {
info += " " + Author;
info += " | " + Author;
}
if (Alia != null && !Alia.isEmpty()) {
info += " " + Alia;
info += " | " + Alia;
}
} else
info = ID;
+1 -1
View File
@@ -1,4 +1,4 @@
name: ALLMusic
main: Color_yr.ALLMusic.ALLMusicBC
author: Color_yr
version: 1.5.0
version: 1.6.0
+2 -1
View File
@@ -3,6 +3,7 @@
"Lyric_Api1": "https://api.imjad.cn/cloudmusic/?type=lyric&id=",
"Info_Api1": "https://api.imjad.cn/cloudmusic/?type=detail&id=",
"List_Api1": "https://api.imjad.cn/cloudmusic/?type=playlist&id=",
"Search_Api1": "https://music.163.com/api/search/get/web?type=1&s=",
"MaxList": 10,
"MinVote": 3,
"Delay": 2,
@@ -13,5 +14,5 @@
"PlayList": [],
"PlayListSwitch": true,
"PlayListRandom": true,
"Version": "1.5.0"
"Version": "1.6.0"
}
+1 -1
View File
@@ -1,7 +1,7 @@
name: ALLMusic
main: Color_yr.ALLMusic.ALLMusicBukkit
author: Color_yr
version: 1.5.0
version: 1.6.0
commands:
music: