mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-28 11:16:04 +00:00
1.10.0
This commit is contained in:
1 parent
e3f520686f
commit
24dc7aa086
49 files changed
+1063
-506
No files matched your search
@@ -1,17 +1,80 @@
|
||||
package Color_yr.ALLMusic;
|
||||
|
||||
import Color_yr.ALLMusic.MusicAPI.IMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.API1;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.API2;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import Color_yr.ALLMusic.Side.ISide;
|
||||
import Color_yr.ALLMusic.VV.VVGet;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit.VV.VVGet;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ALLMusic {
|
||||
public static final String channel = "allmusic:channel";
|
||||
public static final String Version = "1.9.0";
|
||||
public static final String Version = "1.10.0";
|
||||
public final static Map<String, SearchPage> SearchSave = new HashMap<>();
|
||||
|
||||
public static ConfigOBJ Config;
|
||||
public static Logger log;
|
||||
public static File ConfigFile;
|
||||
public static ISide Side;
|
||||
public static VVGet VV;
|
||||
public static IMusic Music;
|
||||
|
||||
public static void save() {
|
||||
try {
|
||||
String data = new Gson().toJson(ALLMusic.Config);
|
||||
if (ALLMusic.ConfigFile.exists()) {
|
||||
Writer out = new FileWriter(ALLMusic.ConfigFile);
|
||||
out.write(data);
|
||||
out.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c配置文件错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadConfig() throws FileNotFoundException {
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(ALLMusic.ConfigFile), StandardCharsets.UTF_8);
|
||||
BufferedReader bf = new BufferedReader(reader);
|
||||
ALLMusic.Config = new Gson().fromJson(bf, ConfigOBJ.class);
|
||||
|
||||
if (ALLMusic.Config == null) {
|
||||
ALLMusic.log.warning("配置文件错误");
|
||||
ALLMusic.Config = new ConfigOBJ();
|
||||
}
|
||||
|
||||
ALLMusic.log.info("§d[ALLMusic]§e当前插件版本为:" + ALLMusic.Version
|
||||
+ ",你的配置文件版本为:" + ALLMusic.Config.getVersion());
|
||||
|
||||
for (String item : ALLMusic.Config.getNoMusicPlayer()) {
|
||||
ALLMusic.log.info("玩家:" + item + "不参与点歌");
|
||||
}
|
||||
|
||||
for (String item : ALLMusic.Config.getNoMusicServer()) {
|
||||
ALLMusic.log.info("服务器:" + item + "不参与点歌");
|
||||
}
|
||||
initAPI();
|
||||
}
|
||||
|
||||
private static void initAPI() {
|
||||
switch (ALLMusic.Config.getMusic_Api()) {
|
||||
case 2: {
|
||||
ALLMusic.Music = new API2();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
default: {
|
||||
ALLMusic.Music = new API1();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,56 +3,18 @@ package Color_yr.ALLMusic;
|
||||
import Color_yr.ALLMusic.Command.CommandBC;
|
||||
import Color_yr.ALLMusic.Event.EventBC;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.ALLMusic.Side.SideBC;
|
||||
import Color_yr.ALLMusic.Side.SideBC.SideBC;
|
||||
import Color_yr.ALLMusic.Utils.logs;
|
||||
import Color_yr.ALLMusic.bStats.MetricsBC;
|
||||
import com.google.gson.Gson;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class ALLMusicBC extends Plugin {
|
||||
public static Plugin ALLMusicP;
|
||||
|
||||
public static void save() {
|
||||
try {
|
||||
String data = new Gson().toJson(ALLMusic.Config);
|
||||
if (ALLMusic.ConfigFile.exists()) {
|
||||
Writer out = new FileWriter(ALLMusic.ConfigFile);
|
||||
out.write(data);
|
||||
out.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c配置文件错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadConfig() throws FileNotFoundException {
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(ALLMusic.ConfigFile), StandardCharsets.UTF_8);
|
||||
BufferedReader bf = new BufferedReader(reader);
|
||||
ALLMusic.Config = new Gson().fromJson(bf, ConfigOBJ.class);
|
||||
|
||||
if (ALLMusic.Config == null) {
|
||||
ALLMusic.Config = new ConfigOBJ();
|
||||
}
|
||||
|
||||
ALLMusic.log.info("§d[ALLMusic]§e当前插件版本为:" + ALLMusic.Version
|
||||
+ ",你的配置文件版本为:" + ALLMusic.Config.getVersion());
|
||||
|
||||
for (String item : ALLMusic.Config.getNoMusicPlayer()) {
|
||||
ALLMusic.log.info("玩家:" + item + "不参与点歌");
|
||||
}
|
||||
|
||||
for (String item : ALLMusic.Config.getNoMusicServer()) {
|
||||
ALLMusic.log.info("服务器:" + item + "不参与点歌");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setConfig() {
|
||||
try {
|
||||
ALLMusic.ConfigFile = new File(ALLMusicP.getDataFolder(), "config.json");
|
||||
@@ -66,7 +28,7 @@ public class ALLMusicBC extends Plugin {
|
||||
if (!logs.file.exists()) {
|
||||
logs.file.createNewFile();
|
||||
}
|
||||
LoadConfig();
|
||||
ALLMusic.LoadConfig();
|
||||
} catch (IOException e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c配置文件错误");
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -3,62 +3,24 @@ package Color_yr.ALLMusic;
|
||||
import Color_yr.ALLMusic.Command.CommandBukkit;
|
||||
import Color_yr.ALLMusic.Event.EventBukkit;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit1_12;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit1_14;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit1_15;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit.SideBukkit;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit.SideBukkit1_12;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit.SideBukkit1_14;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit.SideBukkit1_15;
|
||||
import Color_yr.ALLMusic.Utils.logs;
|
||||
import Color_yr.ALLMusic.VV.VVGet;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit.VV.VVGet;
|
||||
import Color_yr.ALLMusic.bStats.MetricsBukkit;
|
||||
import com.google.gson.Gson;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class ALLMusicBukkit extends JavaPlugin {
|
||||
public static Plugin ALLMusicP;
|
||||
public static boolean VVEnable = false;
|
||||
|
||||
public static void save() {
|
||||
try {
|
||||
String data = new Gson().toJson(ALLMusic.Config);
|
||||
if (ALLMusic.ConfigFile.exists()) {
|
||||
Writer out = new FileWriter(ALLMusic.ConfigFile);
|
||||
out.write(data);
|
||||
out.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c配置文件错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadConfig() throws FileNotFoundException {
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(ALLMusic.ConfigFile), StandardCharsets.UTF_8);
|
||||
BufferedReader bf = new BufferedReader(reader);
|
||||
ALLMusic.Config = new Gson().fromJson(bf, ConfigOBJ.class);
|
||||
|
||||
if (ALLMusic.Config == null) {
|
||||
ALLMusic.Config = new ConfigOBJ();
|
||||
}
|
||||
|
||||
ALLMusic.log.info("§d[ALLMusic]§e当前插件版本为:" + ALLMusic.Version
|
||||
+ ",你的配置文件版本为:" + ALLMusic.Config.getVersion());
|
||||
|
||||
for (String item : ALLMusic.Config.getNoMusicPlayer()) {
|
||||
ALLMusic.log.info("玩家:" + item + "不参与点歌");
|
||||
}
|
||||
|
||||
for (String item : ALLMusic.Config.getNoMusicServer()) {
|
||||
ALLMusic.log.info("服务器:" + item + "不参与点歌");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setConfig() {
|
||||
try {
|
||||
ALLMusic.ConfigFile = new File(ALLMusicP.getDataFolder(), "config.json");
|
||||
@@ -69,7 +31,7 @@ public class ALLMusicBukkit extends JavaPlugin {
|
||||
InputStream in = ALLMusicP.getResource("config_BC.json");
|
||||
Files.copy(in, ALLMusic.ConfigFile.toPath());
|
||||
}
|
||||
LoadConfig();
|
||||
ALLMusic.LoadConfig();
|
||||
} catch (IOException e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c配置文件错误");
|
||||
e.printStackTrace();
|
||||
@@ -116,4 +78,5 @@ public class ALLMusicBukkit extends JavaPlugin {
|
||||
ALLMusic.Side.Send("[Stop]", false);
|
||||
ALLMusic.log.info("§d[ALLMusic]§e已停止,感谢使用");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package Color_yr.ALLMusic.Command;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicList.GetList;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.ALLMusic.SongSearch.PlayerSearch;
|
||||
import Color_yr.ALLMusic.SongSearch.Search;
|
||||
import Color_yr.ALLMusic.SongSearch.SearchOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
|
||||
@@ -44,7 +42,7 @@ public class CommandEX {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLmusic]§c错误,请输入歌曲数字ID");
|
||||
}
|
||||
|
||||
private static void ShowSearch(Object sender, Search search) {
|
||||
private static void ShowSearch(Object sender, SearchPage search) {
|
||||
int index = search.getIndex();
|
||||
SearchOBJ item;
|
||||
for (int a = 0; a < index; a++) {
|
||||
@@ -113,7 +111,7 @@ public class CommandEX {
|
||||
ALLMusic.Side.SendMessage(sender, PlayMusic.getAllList());
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && !ALLMusic.Side.checkPermission(Name, "ALLMusic.vote")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && ALLMusic.Side.checkPermission(Name, "ALLMusic.vote")) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有权限切歌");
|
||||
return;
|
||||
}
|
||||
@@ -179,32 +177,32 @@ public class CommandEX {
|
||||
} else if (args[0].equalsIgnoreCase("addlist") && args.length == 2
|
||||
&& ALLMusic.Config.getAdmin().contains(Name)) {
|
||||
if (Function.isInteger(args[1])) {
|
||||
GetList.GetL(args[1]);
|
||||
ALLMusic.Music.SetList(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) {
|
||||
if (ALLMusic.Config.isNeedPermission() && !ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有权限搜歌");
|
||||
return;
|
||||
}
|
||||
ALLMusic.Side.RunTask(() -> {
|
||||
Search search = new Search(args);
|
||||
if (!search.isDone())
|
||||
SearchPage search = ALLMusic.Music.Search(args);
|
||||
if (search == null)
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c无法搜索歌曲:" + args[1]);
|
||||
else {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2搜索结果");
|
||||
ShowSearch(sender, search);
|
||||
PlayerSearch.SearchSave.put(Name, search);
|
||||
ALLMusic.SearchSave.put(Name, search);
|
||||
}
|
||||
});
|
||||
} else if (args[0].equalsIgnoreCase("select") && args.length == 2) {
|
||||
if (ALLMusic.Config.isNeedPermission() && !ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有权限搜歌");
|
||||
return;
|
||||
}
|
||||
Search obj = PlayerSearch.SearchSave.get(Name);
|
||||
SearchPage obj = ALLMusic.SearchSave.get(Name);
|
||||
if (obj == null) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有搜索音乐");
|
||||
} else if (!args[1].isEmpty() && Function.isInteger(args[1])) {
|
||||
@@ -217,16 +215,16 @@ public class CommandEX {
|
||||
ID[0] = obj.GetSong((obj.getPage() * 10) + (a - 1));
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§2你选择了序号" + a);
|
||||
AddMusic(sender, Name, ID);
|
||||
PlayerSearch.SearchSave.remove(Name);
|
||||
ALLMusic.SearchSave.remove(Name);
|
||||
} else {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c请输入正确的序号");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("nextpage")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && !ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有权限搜歌");
|
||||
return;
|
||||
}
|
||||
Search obj = PlayerSearch.SearchSave.get(Name);
|
||||
SearchPage obj = ALLMusic.SearchSave.get(Name);
|
||||
if (obj == null) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有搜索音乐");
|
||||
} else if (obj.nextPage()) {
|
||||
@@ -235,11 +233,11 @@ public class CommandEX {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c无法下一页");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("lastpage")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && !ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
if (ALLMusic.Config.isNeedPermission() && ALLMusic.Side.checkPermission(Name, "ALLMusic.search")) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有权限搜歌");
|
||||
return;
|
||||
}
|
||||
Search obj = PlayerSearch.SearchSave.get(Name);
|
||||
SearchPage obj = ALLMusic.SearchSave.get(Name);
|
||||
if (obj == null) {
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有搜索音乐");
|
||||
} else if (obj.lastPage()) {
|
||||
@@ -267,7 +265,7 @@ public class CommandEX {
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (ALLMusic.Config.isNeedPermission() && !ALLMusic.Side.checkPermission(Name, "ALLMusic.addmusic"))
|
||||
} else if (ALLMusic.Config.isNeedPermission() && ALLMusic.Side.checkPermission(Name, "ALLMusic.addmusic"))
|
||||
ALLMusic.Side.SendMessage(sender, "§d[ALLMusic]§c你没有权限点歌");
|
||||
else
|
||||
AddMusic(sender, Name, args);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package Color_yr.ALLMusic.Command;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.SongSearch.PlayerSearch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -15,7 +14,7 @@ public class TabCommand {
|
||||
arguments.add("vote");
|
||||
arguments.add("nomusic");
|
||||
arguments.add("search");
|
||||
if (PlayerSearch.SearchSave.get(name) != null) {
|
||||
if (ALLMusic.SearchSave.get(name) != null) {
|
||||
arguments.add("select");
|
||||
arguments.add("nextpage");
|
||||
arguments.add("lastpage");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Color_yr.ALLMusic;
|
||||
|
||||
import Color_yr.ALLMusic.VV.VVSaveOBJ;
|
||||
import Color_yr.ALLMusic.Side.SideBukkit.VV.VVSaveOBJ;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -8,7 +8,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigOBJ {
|
||||
private String Netease_Api;
|
||||
private String Music_Api1;
|
||||
private String Music_Api2;
|
||||
|
||||
private int Music_Api;
|
||||
|
||||
private int MaxList;
|
||||
private int MinVote;
|
||||
@@ -31,7 +34,9 @@ public class ConfigOBJ {
|
||||
private String Version;
|
||||
|
||||
public ConfigOBJ() {
|
||||
Netease_Api = "https://v1.itooi.cn/netease/";
|
||||
Music_Api1 = "https://v1.itooi.cn/netease/";
|
||||
Music_Api2 = "https://api.imjad.cn/cloudmusic/";
|
||||
Music_Api = 1;
|
||||
MaxList = 10;
|
||||
MinVote = 3;
|
||||
Delay = 0;
|
||||
@@ -50,6 +55,14 @@ public class ConfigOBJ {
|
||||
Version = ALLMusic.Version;
|
||||
}
|
||||
|
||||
public int getMusic_Api() {
|
||||
return Music_Api;
|
||||
}
|
||||
|
||||
public String getMusic_Api2() {
|
||||
return Music_Api2;
|
||||
}
|
||||
|
||||
public boolean isNeedPermission() {
|
||||
return NeedPermission;
|
||||
}
|
||||
@@ -58,8 +71,8 @@ public class ConfigOBJ {
|
||||
return SendLyric;
|
||||
}
|
||||
|
||||
public String getNetease_Api() {
|
||||
return Netease_Api;
|
||||
public String getMusic_Api1() {
|
||||
return Music_Api1;
|
||||
}
|
||||
|
||||
public VVSaveOBJ getVVSave(String player) {
|
||||
@@ -122,17 +135,17 @@ public class ConfigOBJ {
|
||||
public void addBanID(String ID) {
|
||||
if (!BanMusic.contains(ID))
|
||||
BanMusic.add(ID);
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
}
|
||||
|
||||
public void AddNoMusicPlayer(String ID) {
|
||||
if (!NoMusicPlayer.contains(ID))
|
||||
NoMusicPlayer.add(ID);
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
}
|
||||
|
||||
public void RemoveNoMusicPlayer(String ID) {
|
||||
NoMusicPlayer.remove(ID);
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package Color_yr.ALLMusic.MusicAPI;
|
||||
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
|
||||
public interface IMusic {
|
||||
SongInfo GetMusic(String ID, String player, boolean isList);
|
||||
|
||||
String GetPlayUrl(String ID);
|
||||
|
||||
void SetList(String ID);
|
||||
|
||||
LyricDo getLyric(String ID);
|
||||
|
||||
SearchPage Search(String[] name);
|
||||
|
||||
String GetListMusic();
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.HttpGet;
|
||||
import Color_yr.ALLMusic.Http.Res;
|
||||
import Color_yr.ALLMusic.MusicAPI.IMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicInfo.InfoOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicList.DataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicLyric.LyricCheck;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicSearch.SearchDataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicSearch.songs;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicInfo.PlayOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class API1 implements IMusic {
|
||||
|
||||
public int PlayNow = 0;
|
||||
public boolean isUpdata;
|
||||
|
||||
public API1() {
|
||||
ALLMusic.log.info("使用API1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SongInfo GetMusic(String ID, String player, boolean isList) {
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api1() + "song?id=", ID);
|
||||
SongInfo info = null;
|
||||
if (res != null && res.isOk()) {
|
||||
InfoOBJ temp = new Gson().fromJson(res.getData(), InfoOBJ.class);
|
||||
if (temp.isok()) {
|
||||
info = new SongInfo(temp.getAuthor(), temp.getName(),
|
||||
ID, temp.getAlia(), player, temp.getAl(), isList, temp.getLength());
|
||||
} else {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲信息获取为空");
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetPlayUrl(String ID) {
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api1() + "/url?quality=192&isRedirect=0&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
PlayOBJ obj = new Gson().fromJson(res.getData(), PlayOBJ.class);
|
||||
if (obj.getCode() == 200) {
|
||||
return obj.getData();
|
||||
} else
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c播放连接解析错误");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetList(String ID) {
|
||||
Thread thread = new Thread(() ->
|
||||
{
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api1() + "songList?id=", ID);
|
||||
if (res != null && res.isOk())
|
||||
try {
|
||||
isUpdata = true;
|
||||
DataOBJ obj = new Gson().fromJson(res.getData(), DataOBJ.class);
|
||||
ALLMusic.Config.getPlayList().addAll(obj.getPlaylist());
|
||||
ALLMusic.save();
|
||||
ALLMusic.log.info("§d[ALLMusic]§2歌曲列表" + obj.getName() + "获取成功");
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲列表获取错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
isUpdata = false;
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LyricDo getLyric(String ID) {
|
||||
;
|
||||
LyricDo Lyric = new LyricDo();
|
||||
Res res = HttpGet.realData("https://api.imjad.cn/cloudmusic/?type=lyric&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricCheck temp = new LyricCheck(res.getData());
|
||||
for(int times = 0 ; times <3;times++ ) {
|
||||
if (!temp.Check()) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误,正在进行第" + times + "重试");
|
||||
}
|
||||
else {
|
||||
if (!ALLMusic.Config.isSendLyric() && ALLMusic.VV == null) {
|
||||
Lyric.setHaveLyric(false);
|
||||
}
|
||||
Lyric.setLyric(temp.getTemp());
|
||||
return Lyric;
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析失败");
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Lyric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchPage Search(String[] name) {
|
||||
List<SearchOBJ> resData = new ArrayList<>();
|
||||
int maxpage;
|
||||
|
||||
StringBuilder name1 = new StringBuilder();
|
||||
for (int a = 1; a < name.length; a++) {
|
||||
name1.append(name[a]).append(" ");
|
||||
}
|
||||
String MusicName = name1.toString();
|
||||
MusicName = MusicName.substring(0, MusicName.length() - 1);
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api1() + "search?type=song&keyword=", MusicName);
|
||||
if (res != null && res.isOk()) {
|
||||
SearchDataOBJ obj = new Gson().fromJson(res.getData(), SearchDataOBJ.class);
|
||||
if (obj != null && obj.isok()) {
|
||||
List<songs> res1 = obj.getResult();
|
||||
SearchOBJ item;
|
||||
for (songs temp : res1) {
|
||||
item = new SearchOBJ(String.valueOf(temp.getId()), temp.getName(), temp.getArtists(), temp.getAlbum());
|
||||
resData.add(item);
|
||||
}
|
||||
maxpage = res1.size() / 10;
|
||||
return new SearchPage(resData, maxpage);
|
||||
} else {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲搜索出现错误");
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetListMusic() {
|
||||
if (!isUpdata && ALLMusic.Config.getPlayList().size() != 0) {
|
||||
String ID;
|
||||
if (ALLMusic.Config.isPlayListRandom()) {
|
||||
ID = ALLMusic.Config.getPlayList().get(new Random().nextInt(ALLMusic.Config.getPlayList().size()) - 1);
|
||||
} else {
|
||||
ID = ALLMusic.Config.getPlayList().get(PlayNow);
|
||||
PlayNow = PlayNow == ALLMusic.Config.getPlayList().size() ? 0 : +1;
|
||||
}
|
||||
return ID;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.SongInfo;
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.SongInfo;
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicInfo;
|
||||
|
||||
public class PlayOBJ {
|
||||
private String data;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.MusicList;
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
+9
-25
@@ -1,31 +1,22 @@
|
||||
package Color_yr.ALLMusic.SongLyric;
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicLyric;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LyricDo {
|
||||
public class LyricCheck {
|
||||
|
||||
private Map<Integer, ShowOBJ> Lyric = new HashMap<>();
|
||||
private Map<Integer, ShowOBJ> temp = new HashMap<>();
|
||||
private LyricOBJ obj;
|
||||
private boolean haveLyric = false;
|
||||
|
||||
public LyricDo() {
|
||||
Lyric = new HashMap<>();
|
||||
}
|
||||
|
||||
public LyricDo(String obj) {
|
||||
public LyricCheck(String obj) {
|
||||
this.obj = new Gson().fromJson(obj, LyricOBJ.class);
|
||||
}
|
||||
|
||||
public boolean isHaveLyric() {
|
||||
return haveLyric;
|
||||
}
|
||||
|
||||
public void setHaveLyric(boolean haveLyric) {
|
||||
this.haveLyric = haveLyric;
|
||||
public Map<Integer, ShowOBJ> getTemp() {
|
||||
return temp;
|
||||
}
|
||||
|
||||
public boolean Check() {
|
||||
@@ -44,25 +35,18 @@ public class LyricDo {
|
||||
if (haveT) {
|
||||
Map<Integer, String> temp1 = GetTime(Tlyric);
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
Lyric.put(item.getKey(), new ShowOBJ(haveT,
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), temp1.get(item.getKey())));
|
||||
}
|
||||
} else {
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
Lyric.put(item.getKey(), new ShowOBJ(haveT,
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), null));
|
||||
}
|
||||
}
|
||||
haveLyric = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShowOBJ checkTime(int playNow) {
|
||||
if (Lyric.containsKey(playNow))
|
||||
return Lyric.get(playNow);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map<Integer, String> GetTime(List<String> lyric) {
|
||||
Map<Integer, String> Lyric = new HashMap<>();
|
||||
String min;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.SongLyric;
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicLyric;
|
||||
|
||||
public class LyricOBJ {
|
||||
private boolean sgc;
|
||||
@@ -0,0 +1,41 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SearchDataOBJ {
|
||||
private data data;
|
||||
|
||||
public boolean isok() {
|
||||
return data != null;
|
||||
}
|
||||
|
||||
public List<songs> getResult() {
|
||||
return data.getSongs();
|
||||
}
|
||||
}
|
||||
|
||||
class data {
|
||||
private List<songs> songs;
|
||||
|
||||
public List<songs> getSongs() {
|
||||
return songs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class artists {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
class album {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI1.GetMusicSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class songs {
|
||||
private int id;
|
||||
private String name;
|
||||
private List<artists> ar;
|
||||
private album al;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getAlbum() {
|
||||
return al.getName();
|
||||
}
|
||||
|
||||
public String getArtists() {
|
||||
StringBuilder a = new StringBuilder();
|
||||
for (artists temp : ar) {
|
||||
a.append(temp.getName()).append(",");
|
||||
}
|
||||
return a.substring(0, a.length() - 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.HttpGet;
|
||||
import Color_yr.ALLMusic.Http.Res;
|
||||
import Color_yr.ALLMusic.MusicAPI.IMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicSearch.SearchDataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicInfo.InfoOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicInfo.PlayOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicList.DataOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicLyric.LyricCheck;
|
||||
import Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicSearch.songs;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class API2 implements IMusic {
|
||||
|
||||
public int PlayNow = 0;
|
||||
public boolean isUpdata;
|
||||
|
||||
public API2() {
|
||||
ALLMusic.log.info("使用API2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SongInfo GetMusic(String ID, String player, boolean isList) {
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api2() + "?type=detail&id=", ID);
|
||||
SongInfo info = null;
|
||||
if (res != null && res.isOk()) {
|
||||
InfoOBJ temp = new Gson().fromJson(res.getData(), InfoOBJ.class);
|
||||
if (temp.isok()) {
|
||||
info = new SongInfo(temp.getAuthor(), temp.getName(),
|
||||
ID, temp.getAlia(), player, temp.getAl(), isList, temp.getLength());
|
||||
} else {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲信息获取为空");
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetPlayUrl(String ID) {
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api2() + "?type=song&br=198000&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
PlayOBJ obj = new Gson().fromJson(res.getData(), PlayOBJ.class);
|
||||
if (obj.getCode() == 200) {
|
||||
return obj.getData();
|
||||
} else
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c播放连接解析错误");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetList(String ID) {
|
||||
Thread thread = new Thread(() ->
|
||||
{
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api2() + "?type=playlist&id=", ID);
|
||||
if (res != null && res.isOk())
|
||||
try {
|
||||
isUpdata = true;
|
||||
DataOBJ obj = new Gson().fromJson(res.getData(), DataOBJ.class);
|
||||
ALLMusic.Config.getPlayList().addAll(obj.getPlaylist());
|
||||
ALLMusic.save();
|
||||
ALLMusic.log.info("§d[ALLMusic]§2歌曲列表" + obj.getName() + "获取成功");
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲列表获取错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
isUpdata = false;
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LyricDo getLyric(String ID) {
|
||||
;
|
||||
LyricDo Lyric = new LyricDo();
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api2() + "?type=lyric&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricCheck temp = new LyricCheck(res.getData());
|
||||
for(int times = 0 ; times <3;times++ ) {
|
||||
if (!temp.Check()) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误,正在进行第" + times + "重试");
|
||||
}
|
||||
else {
|
||||
if (!ALLMusic.Config.isSendLyric() && ALLMusic.VV == null) {
|
||||
Lyric.setHaveLyric(false);
|
||||
}
|
||||
Lyric.setLyric(temp.getTemp());
|
||||
return Lyric;
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析失败");
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return Lyric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchPage Search(String[] name) {
|
||||
List<SearchOBJ> resData = new ArrayList<>();
|
||||
int maxpage;
|
||||
|
||||
StringBuilder name1 = new StringBuilder();
|
||||
for (int a = 1; a < name.length; a++) {
|
||||
name1.append(name[a]).append(" ");
|
||||
}
|
||||
String MusicName = name1.toString();
|
||||
MusicName = MusicName.substring(0, MusicName.length() - 1);
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getMusic_Api2() + "?type=search&s=", MusicName);
|
||||
if (res != null && res.isOk()) {
|
||||
SearchDataOBJ obj = new Gson().fromJson(res.getData(), SearchDataOBJ.class);
|
||||
if (obj != null && obj.isok()) {
|
||||
List<songs> res1 = obj.getResult();
|
||||
SearchOBJ item;
|
||||
for (songs temp : res1) {
|
||||
item = new SearchOBJ(String.valueOf(temp.getId()), temp.getName(), temp.getArtists(), temp.getAlbum());
|
||||
resData.add(item);
|
||||
}
|
||||
maxpage = res1.size() / 10;
|
||||
return new SearchPage(resData, maxpage);
|
||||
} else {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲搜索出现错误");
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetListMusic() {
|
||||
if (!isUpdata && ALLMusic.Config.getPlayList().size() != 0) {
|
||||
String ID;
|
||||
if (ALLMusic.Config.isPlayListRandom()) {
|
||||
ID = ALLMusic.Config.getPlayList().get(new Random().nextInt(ALLMusic.Config.getPlayList().size()) - 1);
|
||||
} else {
|
||||
ID = ALLMusic.Config.getPlayList().get(PlayNow);
|
||||
PlayNow = PlayNow == ALLMusic.Config.getPlayList().size() ? 0 : +1;
|
||||
}
|
||||
return ID;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InfoOBJ {
|
||||
private List<Songs> songs;
|
||||
|
||||
public boolean isok() {
|
||||
return songs != null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if(songs == null || songs.size() == 0)
|
||||
return null;
|
||||
return songs.get(0).getName();
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
StringBuilder Author = new StringBuilder();
|
||||
for (ar ar : songs.get(0).getAr()) {
|
||||
Author.append(ar.getName()).append(",");
|
||||
}
|
||||
if (Author.length() != 0) {
|
||||
Author = new StringBuilder(Author.substring(0, Author.length() - 1));
|
||||
}
|
||||
return Author.toString();
|
||||
}
|
||||
|
||||
public String getAlia() {
|
||||
StringBuilder Alia = new StringBuilder();
|
||||
for (String alia : songs.get(0).getAlia()) {
|
||||
Alia.append(alia).append(",");
|
||||
}
|
||||
if (Alia.length() != 0) {
|
||||
Alia = new StringBuilder(Alia.substring(0, Alia.length() - 1));
|
||||
}
|
||||
return Alia.toString();
|
||||
}
|
||||
|
||||
public String getAl() {
|
||||
return songs.get(0).getAl();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
if (songs == null)
|
||||
return 0;
|
||||
return songs.get(0).getLength();
|
||||
}
|
||||
}
|
||||
|
||||
class Songs {
|
||||
private String name;
|
||||
private List<ar> ar;
|
||||
private List<String> alia;
|
||||
private al al;
|
||||
private h l;
|
||||
private h m;
|
||||
private h h;
|
||||
|
||||
public int getLength() {
|
||||
if (l != null)
|
||||
return l.getLength();
|
||||
if (m != null)
|
||||
return m.getLength();
|
||||
if (h != null)
|
||||
return h.getLength();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<ar> getAr() {
|
||||
return ar;
|
||||
}
|
||||
|
||||
public List<String> getAlia() {
|
||||
return alia;
|
||||
}
|
||||
|
||||
public String getAl() {
|
||||
return al.getName();
|
||||
}
|
||||
}
|
||||
|
||||
class ar {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
class al {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
class h {
|
||||
private int br;
|
||||
private int size;
|
||||
|
||||
public int getLength() {
|
||||
return size / br * 8000;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayOBJ {
|
||||
private List<obj> data;
|
||||
private int code;
|
||||
|
||||
public String getData() {
|
||||
if (data == null)
|
||||
return null;
|
||||
if (data.size() == 0)
|
||||
return null;
|
||||
obj obj = data.get(0);
|
||||
return obj.getUrl();
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
class obj {
|
||||
private String url;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DataOBJ {
|
||||
private playlist playlist;
|
||||
|
||||
public List<String> getPlaylist() {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (track item : playlist.getTracks()) {
|
||||
list.add(item.getId());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return playlist.getName();
|
||||
}
|
||||
}
|
||||
|
||||
class track {
|
||||
private int id;
|
||||
|
||||
public String getId() {
|
||||
return String.valueOf(id);
|
||||
}
|
||||
}
|
||||
|
||||
class playlist {
|
||||
private List<track> tracks;
|
||||
private String name;
|
||||
|
||||
public List<track> getTracks() {
|
||||
return tracks;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicLyric;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LyricCheck {
|
||||
|
||||
private Map<Integer, ShowOBJ> temp = new HashMap<>();
|
||||
private LyricOBJ obj;
|
||||
public LyricCheck(String obj) {
|
||||
this.obj = new Gson().fromJson(obj, LyricOBJ.class);
|
||||
}
|
||||
|
||||
public Map<Integer, ShowOBJ> getTemp() {
|
||||
return temp;
|
||||
}
|
||||
|
||||
public boolean Check() {
|
||||
String[] lyric;
|
||||
|
||||
boolean haveT = false;
|
||||
if (!obj.isok())
|
||||
return false;
|
||||
lyric = obj.getLyric().split("\n");
|
||||
List<String> Tlyric = new ArrayList<>();
|
||||
if (obj.getTlyric() != null) {
|
||||
Tlyric = Arrays.asList(obj.getTlyric().split("\n"));
|
||||
haveT = true;
|
||||
}
|
||||
Map<Integer, String> temp = GetTime(Arrays.asList(lyric));
|
||||
if (haveT) {
|
||||
Map<Integer, String> temp1 = GetTime(Tlyric);
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), temp1.get(item.getKey())));
|
||||
}
|
||||
} else {
|
||||
for (Map.Entry<Integer, String> item : temp.entrySet()) {
|
||||
this.temp.put(item.getKey(), new ShowOBJ(haveT,
|
||||
item.getValue(), null));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Map<Integer, String> GetTime(List<String> lyric) {
|
||||
Map<Integer, String> Lyric = new HashMap<>();
|
||||
String min;
|
||||
String sec;
|
||||
String mil;
|
||||
int time;
|
||||
int milt;
|
||||
for (String s : lyric) {
|
||||
if (Function.countChar(Function.getString(s, "[", "]"), ':') > 1) {
|
||||
String[] a = s.split(":");
|
||||
min = a[0].substring(1);
|
||||
sec = a[1];
|
||||
mil = a[2];
|
||||
} else {
|
||||
min = Function.getString(s, "[", ":");
|
||||
sec = Function.getString(s, ":", ".");
|
||||
mil = Function.getString(s, ".", "]");
|
||||
}
|
||||
if (!Function.isInteger(min))
|
||||
continue;
|
||||
if (!Function.isInteger(sec))
|
||||
continue;
|
||||
if (!Function.isInteger(mil))
|
||||
continue;
|
||||
if (min.isEmpty() || sec.isEmpty() || mil.isEmpty())
|
||||
continue;
|
||||
milt = Integer.parseInt(mil);
|
||||
if (mil.length() == 3) {
|
||||
milt /= 10;
|
||||
}
|
||||
time = Integer.parseInt(min) * 60 * 1000 + Integer.parseInt(sec) * 1000 + milt * 10;
|
||||
if (time > 0 && time + ALLMusic.Config.getDelay() > 0)
|
||||
time += ALLMusic.Config.getDelay() * 10;
|
||||
Lyric.put(time, Function.getString(s, "]", null));
|
||||
}
|
||||
return Lyric;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicLyric;
|
||||
|
||||
public class LyricOBJ {
|
||||
private boolean sgc;
|
||||
private boolean sfy;
|
||||
private boolean qfy;
|
||||
private lrc lrc;
|
||||
private tlyric tlyric;
|
||||
|
||||
public boolean isok() {
|
||||
return lrc != null;
|
||||
}
|
||||
|
||||
public String getLyric() {
|
||||
return lrc.getLyric();
|
||||
}
|
||||
|
||||
public String getTlyric() {
|
||||
return tlyric.getLyric();
|
||||
}
|
||||
}
|
||||
|
||||
class lrc {
|
||||
private int version;
|
||||
private String lyric;
|
||||
|
||||
public String getLyric() {
|
||||
return lyric == null ? "" : lyric;
|
||||
}
|
||||
}
|
||||
|
||||
class tlyric {
|
||||
private int version;
|
||||
private String lyric;
|
||||
|
||||
public String getLyric() {
|
||||
return lyric;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SearchDataOBJ {
|
||||
private result result;
|
||||
|
||||
public boolean isok() {
|
||||
return result != null;
|
||||
}
|
||||
|
||||
public List<songs> getResult() {
|
||||
return result.getSongs();
|
||||
}
|
||||
}
|
||||
|
||||
class result {
|
||||
private List<songs> songs;
|
||||
|
||||
public List<songs> getSongs() {
|
||||
return songs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class artists {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
class album {
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.MusicAPI2.GetMusicSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class songs {
|
||||
private int id;
|
||||
private String name;
|
||||
private List<artists> ar;
|
||||
private album al;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getAlbum() {
|
||||
return al.getName();
|
||||
}
|
||||
|
||||
public String getArtists() {
|
||||
StringBuilder a = new StringBuilder();
|
||||
for (artists temp : ar) {
|
||||
a.append(temp.getName()).append(",");
|
||||
}
|
||||
return a.substring(0, a.length() - 1);
|
||||
}
|
||||
}
|
||||
+17
-17
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.SongInfo;
|
||||
package Color_yr.ALLMusic.MusicAPI.SongInfo;
|
||||
|
||||
public class SongInfo {
|
||||
private String Author;
|
||||
@@ -24,6 +24,22 @@ public class SongInfo {
|
||||
this.Length = Length;
|
||||
}
|
||||
|
||||
public String getAl() {
|
||||
return Al;
|
||||
}
|
||||
|
||||
public String getAlia() {
|
||||
return Alia;
|
||||
}
|
||||
|
||||
public String getCall() {
|
||||
return Call;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return Author;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return Length;
|
||||
}
|
||||
@@ -32,26 +48,10 @@ public class SongInfo {
|
||||
return isList;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return Author;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return Name;
|
||||
}
|
||||
|
||||
public String getCall() {
|
||||
return Call;
|
||||
}
|
||||
|
||||
public String getAlia() {
|
||||
return Alia;
|
||||
}
|
||||
|
||||
public String getAl() {
|
||||
return Al;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.SongLyric;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LyricDo {
|
||||
private Map<Integer, ShowOBJ> Lyric;
|
||||
private boolean haveLyric = false;
|
||||
|
||||
public LyricDo() {
|
||||
}
|
||||
|
||||
public void setLyric(Map<Integer, ShowOBJ> lyric) {
|
||||
Lyric = lyric;
|
||||
}
|
||||
|
||||
public void setHaveLyric(boolean haveLyric) {
|
||||
this.haveLyric = haveLyric;
|
||||
}
|
||||
|
||||
public boolean isHaveLyric() {
|
||||
return haveLyric;
|
||||
}
|
||||
|
||||
public ShowOBJ checkTime(int playNow) {
|
||||
if (Lyric == null)
|
||||
return null;
|
||||
if (Lyric.containsKey(playNow))
|
||||
return Lyric.get(playNow);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.SongLyric;
|
||||
package Color_yr.ALLMusic.MusicAPI.SongLyric;
|
||||
|
||||
public class ShowOBJ {
|
||||
private boolean haveT;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.SongSearch;
|
||||
package Color_yr.ALLMusic.MusicAPI.SongSearch;
|
||||
|
||||
public class SearchOBJ {
|
||||
private String ID;
|
||||
@@ -0,0 +1,53 @@
|
||||
package Color_yr.ALLMusic.MusicAPI.SongSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SearchPage {
|
||||
private List<SearchOBJ> resData;
|
||||
private int page = 0;
|
||||
private int maxpage = 0;
|
||||
|
||||
public SearchPage(List<SearchOBJ> resData,int maxpage) {
|
||||
this.resData = resData;
|
||||
this.maxpage = maxpage;
|
||||
}
|
||||
|
||||
public String GetSong(int index) {
|
||||
return resData.get(index).getID();
|
||||
}
|
||||
|
||||
public SearchOBJ getRes(int a) {
|
||||
return resData.get(a);
|
||||
}
|
||||
|
||||
public boolean nextPage() {
|
||||
if (page == maxpage)
|
||||
return false;
|
||||
page++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean lastPage() {
|
||||
if (page == 0)
|
||||
return false;
|
||||
page--;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
int a = resData.size() - page * 10;
|
||||
return Math.min(a, 10);
|
||||
}
|
||||
|
||||
public boolean haveNextPage() {
|
||||
return page < maxpage;
|
||||
}
|
||||
|
||||
public boolean haveLastPage() {
|
||||
return page != 0;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package Color_yr.ALLMusic.MusicList;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.HttpGet;
|
||||
import Color_yr.ALLMusic.Http.Res;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class GetList {
|
||||
public static int PlayNow = 0;
|
||||
public static boolean isUpdata;
|
||||
|
||||
public static void GetL(String ID) {
|
||||
Thread thread = new Thread(() ->
|
||||
{
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getNetease_Api() + "songList?id=", ID);
|
||||
if (res != null && res.isOk())
|
||||
try {
|
||||
isUpdata = true;
|
||||
DataOBJ obj = new Gson().fromJson(res.getData(), DataOBJ.class);
|
||||
ALLMusic.Config.getPlayList().addAll(obj.getPlaylist());
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.log.info("§d[ALLMusic]§2歌曲列表" + obj.getName() + "获取成功");
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲列表获取错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
isUpdata = false;
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public static String GetMusic() {
|
||||
if (!isUpdata && ALLMusic.Config.getPlayList().size() != 0) {
|
||||
String ID;
|
||||
if (ALLMusic.Config.isPlayListRandom()) {
|
||||
ID = ALLMusic.Config.getPlayList().get(new Random().nextInt(ALLMusic.Config.getPlayList().size()) - 1);
|
||||
} else {
|
||||
ID = ALLMusic.Config.getPlayList().get(PlayNow);
|
||||
PlayNow = PlayNow == ALLMusic.Config.getPlayList().size() ? 0 : +1;
|
||||
}
|
||||
return ID;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,7 @@ package Color_yr.ALLMusic.MusicPlay;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.ALLMusicBukkit;
|
||||
import Color_yr.ALLMusic.MusicList.GetList;
|
||||
import Color_yr.ALLMusic.SongInfo.GetMusicPlay;
|
||||
import Color_yr.ALLMusic.SongLyric.LyricGet;
|
||||
import Color_yr.ALLMusic.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -73,7 +70,7 @@ class PlayGo extends Thread {
|
||||
if (PlayMusic.getSize() == 0) {
|
||||
try {
|
||||
if (ALLMusic.Side.NeedPlay()) {
|
||||
String ID = GetList.GetMusic();
|
||||
String ID = ALLMusic.Music.GetListMusic();
|
||||
if (ID != null) {
|
||||
ALLMusic.Side.RunTask(() -> PlayMusic.addMusic(ID, "空闲列表", true));
|
||||
}
|
||||
@@ -87,13 +84,13 @@ class PlayGo extends Thread {
|
||||
PlayMusic.NowPlayMusic = PlayMusic.getMusic(0);
|
||||
PlayMusic.remove(0);
|
||||
|
||||
String url = GetMusicPlay.Get(PlayMusic.NowPlayMusic.getID());
|
||||
String url = ALLMusic.Music.GetPlayUrl(PlayMusic.NowPlayMusic.getID());
|
||||
if (url == null) {
|
||||
ALLMusic.Side.bqt("§d[ALLMusic]§c" + "无法播放歌曲" + PlayMusic.NowPlayMusic.getID() + "可能改歌曲为VIP歌曲");
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayMusic.Lyric = new LyricGet().Get(PlayMusic.NowPlayMusic.getID());
|
||||
PlayMusic.Lyric = ALLMusic.Music.getLyric(PlayMusic.NowPlayMusic.getID());
|
||||
|
||||
if (PlayMusic.NowPlayMusic.getLength() != 0) {
|
||||
PlayMusic.MusicAllTime = (PlayMusic.NowPlayMusic.getLength() / 1000) + 10;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package Color_yr.ALLMusic.MusicPlay;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.SongInfo.GetInfo;
|
||||
import Color_yr.ALLMusic.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.ALLMusic.Utils.logs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -44,7 +43,7 @@ public class PlayMusic {
|
||||
"点歌" + ID);
|
||||
logs.log_write("玩家:" + player + " 点歌:" + ID);
|
||||
try {
|
||||
SongInfo info = GetInfo.Get(ID, player, isList);
|
||||
SongInfo info = ALLMusic.Music.GetMusic(ID, player, isList);
|
||||
if (info != null) {
|
||||
PlayList.add(info);
|
||||
ALLMusic.Side.bq("§d[ALLMusic]§2音乐列表添加" + info.getName());
|
||||
|
||||
@@ -15,8 +15,6 @@ public interface ISide {
|
||||
|
||||
void bqt(String data);
|
||||
|
||||
void save();
|
||||
|
||||
boolean NeedPlay();
|
||||
|
||||
void SendMessage(Object obj, String Message);
|
||||
|
||||
+4
-8
@@ -1,8 +1,9 @@
|
||||
package Color_yr.ALLMusic.Side;
|
||||
package Color_yr.ALLMusic.Side.SideBC;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.ALLMusicBC;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.ALLMusic.Side.ISide;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@@ -75,11 +76,6 @@ public class SideBC implements ISide {
|
||||
ProxyServer.getInstance().broadcast(new TextComponent(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
ALLMusicBC.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean NeedPlay() {
|
||||
int online = GetAllPlayer();
|
||||
@@ -126,8 +122,8 @@ public class SideBC implements ISide {
|
||||
public boolean checkPermission(String player, String permission) {
|
||||
ProxiedPlayer player1 = ProxyServer.getInstance().getPlayer(player);
|
||||
if (player1 == null)
|
||||
return false;
|
||||
return player1.hasPermission(permission);
|
||||
return true;
|
||||
return !player1.hasPermission(permission);
|
||||
}
|
||||
|
||||
private void Send(ProxiedPlayer players, String data, Boolean isplay) {
|
||||
+4
-8
@@ -1,8 +1,9 @@
|
||||
package Color_yr.ALLMusic.Side;
|
||||
package Color_yr.ALLMusic.Side.SideBukkit;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.ALLMusicBukkit;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.ALLMusic.Side.ISide;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@@ -49,11 +50,6 @@ public class SideBukkit implements ISide {
|
||||
Bukkit.getScheduler().runTask(ALLMusicBukkit.ALLMusicP, () -> Bukkit.broadcastMessage(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
ALLMusicBukkit.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean NeedPlay() {
|
||||
int online = GetAllPlayer();
|
||||
@@ -93,8 +89,8 @@ public class SideBukkit implements ISide {
|
||||
public boolean checkPermission(String player, String permission) {
|
||||
Player player1 = Bukkit.getPlayer(player);
|
||||
if (player1 == null)
|
||||
return false;
|
||||
return player1.hasPermission(permission);
|
||||
return true;
|
||||
return !player1.hasPermission(permission);
|
||||
}
|
||||
|
||||
private void Send(Player players, String data, Boolean isplay) {
|
||||
+3
-4
@@ -1,19 +1,18 @@
|
||||
package Color_yr.ALLMusic.Side;
|
||||
package Color_yr.ALLMusic.Side.SideBukkit;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import net.minecraft.server.v1_12_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static Color_yr.ALLMusic.MusicPlay.PlayMusic.NowPlayPlayer;
|
||||
|
||||
public class SideBukkit1_12 extends SideBukkit {
|
||||
@Override
|
||||
public void SendLyric(String data) {
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
if (!ALLMusic.Config.getNoMusicPlayer().contains(players.getName())) {
|
||||
if (NowPlayPlayer.contains(players.getName())) {
|
||||
if (PlayMusic.NowPlayPlayer.contains(players.getName())) {
|
||||
if (ALLMusic.VV == null || !ALLMusic.Config.getVVSave(players.getName()).isEnable()) {
|
||||
ChatComponentText chat = new ChatComponentText(data);
|
||||
PacketPlayOutChat pack = new PacketPlayOutChat(chat, ChatMessageType.GAME_INFO);
|
||||
+3
-4
@@ -1,19 +1,18 @@
|
||||
package Color_yr.ALLMusic.Side;
|
||||
package Color_yr.ALLMusic.Side.SideBukkit;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static Color_yr.ALLMusic.MusicPlay.PlayMusic.NowPlayPlayer;
|
||||
|
||||
public class SideBukkit1_14 extends SideBukkit {
|
||||
@Override
|
||||
public void SendLyric(String data) {
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
if (!ALLMusic.Config.getNoMusicPlayer().contains(players.getName())) {
|
||||
if (NowPlayPlayer.contains(players.getName())) {
|
||||
if (PlayMusic.NowPlayPlayer.contains(players.getName())) {
|
||||
if (ALLMusic.VV == null || !ALLMusic.Config.getVVSave(players.getName()).isEnable()) {
|
||||
ChatComponentText chat = new ChatComponentText(data);
|
||||
PacketPlayOutChat pack = new PacketPlayOutChat(chat, ChatMessageType.GAME_INFO);
|
||||
+3
-4
@@ -1,19 +1,18 @@
|
||||
package Color_yr.ALLMusic.Side;
|
||||
package Color_yr.ALLMusic.Side.SideBukkit;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static Color_yr.ALLMusic.MusicPlay.PlayMusic.NowPlayPlayer;
|
||||
|
||||
public class SideBukkit1_15 extends SideBukkit {
|
||||
@Override
|
||||
public void SendLyric(String data) {
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
if (!ALLMusic.Config.getNoMusicPlayer().contains(players.getName())) {
|
||||
if (NowPlayPlayer.contains(players.getName())) {
|
||||
if (PlayMusic.NowPlayPlayer.contains(players.getName())) {
|
||||
if (ALLMusic.VV == null || !ALLMusic.Config.getVVSave(players.getName()).isEnable()) {
|
||||
ChatComponentText chat = new ChatComponentText(data);
|
||||
PacketPlayOutChat pack = new PacketPlayOutChat(chat, ChatMessageType.GAME_INFO);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.VV;
|
||||
package Color_yr.ALLMusic.Side.SideBukkit.VV;
|
||||
|
||||
public class PosOBJ {
|
||||
private int x;
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
package Color_yr.ALLMusic.VV;
|
||||
package Color_yr.ALLMusic.Side.SideBukkit.VV;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.ALLMusic.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.ALLMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import lk.vexview.api.VexViewAPI;
|
||||
import lk.vexview.hud.VexTextShow;
|
||||
@@ -63,7 +63,7 @@ public class VVGet {
|
||||
}
|
||||
|
||||
ALLMusic.Config.setVVSave(obj, player);
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class VVGet {
|
||||
VexViewAPI.sendHUD(player, show);
|
||||
}
|
||||
if (save) {
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class VVGet {
|
||||
VexViewAPI.sendHUD(player, show);
|
||||
}
|
||||
if (save) {
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class VVGet {
|
||||
VexViewAPI.sendHUD(player, show);
|
||||
}
|
||||
if (save) {
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public class VVGet {
|
||||
clear(Bukkit.getPlayer(player));
|
||||
}
|
||||
ALLMusic.Config.setVVSave(obj, player);
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.save();
|
||||
return obj.isEnable();
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.ALLMusic.VV;
|
||||
package Color_yr.ALLMusic.Side.SideBukkit.VV;
|
||||
|
||||
public class VVSaveOBJ {
|
||||
private PosOBJ List;
|
||||
@@ -1,23 +0,0 @@
|
||||
package Color_yr.ALLMusic.SongInfo;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.HttpGet;
|
||||
import Color_yr.ALLMusic.Http.Res;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class GetInfo {
|
||||
public static SongInfo Get(String ID, String player, boolean isList) {
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getNetease_Api() + "song?id=", ID);
|
||||
SongInfo info = null;
|
||||
if (res != null && res.isOk()) {
|
||||
InfoOBJ temp = new Gson().fromJson(res.getData(), InfoOBJ.class);
|
||||
if (temp.isok()) {
|
||||
info = new SongInfo(temp.getAuthor(), temp.getName(),
|
||||
ID, temp.getAlia(), player, temp.getAl(), isList, temp.getLength());
|
||||
} else {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲信息获取为空");
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package Color_yr.ALLMusic.SongInfo;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.HttpGet;
|
||||
import Color_yr.ALLMusic.Http.Res;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class GetMusicPlay {
|
||||
public static String Get(String ID) {
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getNetease_Api() + "/url?quality=192&isRedirect=0&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
PlayOBJ obj = new Gson().fromJson(res.getData(), PlayOBJ.class);
|
||||
if (obj.getCode() == 200) {
|
||||
return obj.getData();
|
||||
} else
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c播放连接解析错误");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package Color_yr.ALLMusic.SongLyric;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.HttpGet;
|
||||
import Color_yr.ALLMusic.Http.Res;
|
||||
|
||||
public class LyricGet {
|
||||
private int times = 0;
|
||||
|
||||
public LyricDo Get(String ID) {
|
||||
Res res = HttpGet.realData("https://api.imjad.cn/cloudmusic/?type=lyric&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricDo temp = new LyricDo(res.getData());
|
||||
if (!temp.Check()) {
|
||||
times++;
|
||||
if (times > 3) {
|
||||
return new LyricDo();
|
||||
}
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误,正在进行第" + times + "重试");
|
||||
temp = Get(ID);
|
||||
}
|
||||
if (!ALLMusic.Config.isSendLyric() && ALLMusic.VV == null)
|
||||
temp.setHaveLyric(false);
|
||||
return temp;
|
||||
} catch (Exception e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌词解析错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return new LyricDo();
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package Color_yr.ALLMusic.SongSearch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DataOBJ {
|
||||
private data data;
|
||||
|
||||
public boolean isok() {
|
||||
return data != null;
|
||||
}
|
||||
|
||||
public List<songs> getResult() {
|
||||
return data.getSongs();
|
||||
}
|
||||
}
|
||||
|
||||
class data {
|
||||
private List<songs> songs;
|
||||
|
||||
public List<songs> getSongs() {
|
||||
return songs;
|
||||
}
|
||||
}
|
||||
|
||||
class songs {
|
||||
private int id;
|
||||
private String name;
|
||||
private List<artists> ar;
|
||||
private album al;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getAlbum() {
|
||||
return al.getName();
|
||||
}
|
||||
|
||||
public String getArtists() {
|
||||
StringBuilder a = new StringBuilder();
|
||||
for (artists temp : ar) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package Color_yr.ALLMusic.SongSearch;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerSearch {
|
||||
public final static Map<String, Search> SearchSave = new HashMap<>();
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package Color_yr.ALLMusic.SongSearch;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.HttpGet;
|
||||
import Color_yr.ALLMusic.Http.Res;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Search {
|
||||
private List<SearchOBJ> resData = new ArrayList<>();
|
||||
private boolean done = false;
|
||||
private int page = 0;
|
||||
private int maxpage = 0;
|
||||
|
||||
public Search(String[] name) {
|
||||
StringBuilder name1 = new StringBuilder();
|
||||
for (int a = 1; a < name.length; a++) {
|
||||
name1.append(name[a]).append(" ");
|
||||
}
|
||||
String MusicName = name1.toString();
|
||||
MusicName = MusicName.substring(0, MusicName.length() - 1);
|
||||
Res res = HttpGet.realData(ALLMusic.Config.getNetease_Api() + "search?type=song&keyword=", MusicName);
|
||||
if (res != null && res.isOk()) {
|
||||
DataOBJ obj = new Gson().fromJson(res.getData(), DataOBJ.class);
|
||||
if (obj != null && obj.isok()) {
|
||||
List<songs> res1 = obj.getResult();
|
||||
SearchOBJ item;
|
||||
for (songs temp : res1) {
|
||||
item = new SearchOBJ(String.valueOf(temp.getId()), temp.getName(), temp.getArtists(), temp.getAlbum());
|
||||
resData.add(item);
|
||||
}
|
||||
maxpage = res1.size() / 10;
|
||||
done = true;
|
||||
} else {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲搜索出现错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String GetSong(int index) {
|
||||
return resData.get(index).getID();
|
||||
}
|
||||
|
||||
public SearchOBJ getRes(int a) {
|
||||
return resData.get(a);
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return done;
|
||||
}
|
||||
|
||||
public boolean nextPage() {
|
||||
if (page == maxpage)
|
||||
return false;
|
||||
page++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean lastPage() {
|
||||
if (page == 0)
|
||||
return false;
|
||||
page--;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
int a = resData.size() - page * 10;
|
||||
return Math.min(a, 10);
|
||||
}
|
||||
|
||||
public boolean haveNextPage() {
|
||||
return page < maxpage;
|
||||
}
|
||||
|
||||
public boolean haveLastPage() {
|
||||
return page != 0;
|
||||
}
|
||||
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
name: ALLMusic
|
||||
main: Color_yr.ALLMusic.ALLMusicBC
|
||||
author: Color_yr
|
||||
version: 1.9.0
|
||||
version: 1.10.0
|
||||
@@ -1,5 +1,7 @@
|
||||
{
|
||||
"Netease_Api": "https://v1.itooi.cn/netease/",
|
||||
"Music_Api1": "https://v1.itooi.cn/netease/",
|
||||
"Music_Api2": "https://api.imjad.cn/cloudmusic/",
|
||||
"Music_Api": 1,
|
||||
"MaxList": 10,
|
||||
"MinVote": 3,
|
||||
"Delay": 0,
|
||||
@@ -14,5 +16,5 @@
|
||||
"NeedPermission": false,
|
||||
"VexView": false,
|
||||
"VVSave": {},
|
||||
"Version": "1.9.0"
|
||||
"Version": "1.10.0"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
name: ALLMusic
|
||||
main: Color_yr.ALLMusic.ALLMusicBukkit
|
||||
author: Color_yr
|
||||
version: 1.9.0
|
||||
version: 1.10.0
|
||||
loadbefore:
|
||||
- vexview
|
||||
softdepend:
|
||||
|
||||
Reference in new issue
Block a user