mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-19 17:39:34 +00:00
删除无用代码
This commit is contained in:
1 parent
6ea391cc9d
commit
ca8127acdd
23 files changed
+95
-317
No files matched your search
+3
-3
@@ -3,7 +3,7 @@ plugins {
|
||||
id 'maven-publish'
|
||||
id 'com.github.johnrengelman.shadow' version '6.1.0'
|
||||
}
|
||||
version = "2.10.4"
|
||||
version = "2.10.5"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
@@ -28,14 +28,14 @@ dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||
compileOnly 'net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT'
|
||||
compileOnly "com.github.MilkBowl:VaultAPI:1.7"
|
||||
compileOnly 'com.velocitypowered:velocity-api:1.1.3'
|
||||
compileOnly 'com.velocitypowered:velocity-api:1.1.4'
|
||||
dependencies { compile fileTree(dir:'lib',include:['*.jar'])}
|
||||
compileOnly 'me.clip:placeholderapi:2.10.6'
|
||||
|
||||
compile 'org.apache.ant:ant:1.9.4'
|
||||
compile 'org.apache.httpcomponents:httpclient:4.5.11'
|
||||
|
||||
annotationProcessor 'com.velocitypowered:velocity-api:1.1.3'
|
||||
annotationProcessor 'com.velocitypowered:velocity-api:1.1.4'
|
||||
}
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Color_yr.AllMusic.API;
|
||||
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.AllMusic.MusicAPI.SongSearch.SearchPage;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.AllMusic;
|
||||
package Color_yr.AllMusic.API;
|
||||
|
||||
public interface IMyLogger {
|
||||
void warning(String data);
|
||||
@@ -1,15 +1,15 @@
|
||||
package Color_yr.AllMusic;
|
||||
|
||||
import Color_yr.AllMusic.API.IMusicAPI;
|
||||
import Color_yr.AllMusic.API.IMyLogger;
|
||||
import Color_yr.AllMusic.API.ISide;
|
||||
import Color_yr.AllMusic.Message.*;
|
||||
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.MusicPlay.PlayMusic;
|
||||
import Color_yr.AllMusic.MusicPlay.SendHud.SaveOBJ;
|
||||
import Color_yr.AllMusic.MusicPlay.MusicSearch;
|
||||
import Color_yr.AllMusic.Side.SideBukkit.VaultHook;
|
||||
import Color_yr.AllMusic.Utils.RunApi;
|
||||
import Color_yr.AllMusic.Utils.logs;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -21,11 +21,10 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class AllMusic {
|
||||
public static final String channel = "allmusic:channel";
|
||||
public static final String Version = "2.10.4";
|
||||
public static final String Version = "2.10.5";
|
||||
|
||||
private static final Map<String, SearchPage> SearchSave = new HashMap<>();
|
||||
private static final List<String> VotePlayer = new ArrayList<>();
|
||||
@@ -141,7 +140,7 @@ public class AllMusic {
|
||||
|
||||
public static void start() {
|
||||
PlayMusic.start();
|
||||
SearchTask.start();
|
||||
MusicSearch.start();
|
||||
log.info("§d[AllMusic]§2§e已启动-" + Version);
|
||||
}
|
||||
|
||||
@@ -150,11 +149,8 @@ public class AllMusic {
|
||||
clearVote();
|
||||
logs.stop();
|
||||
Side.Send("[Stop]", false);
|
||||
SearchTask.stop();
|
||||
MusicSearch.stop();
|
||||
PlayMusic.stop();
|
||||
// if (AllMusic.Config.AutoApi) {
|
||||
// RunApi.stop();
|
||||
// }
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -169,11 +165,6 @@ public class AllMusic {
|
||||
}
|
||||
|
||||
private static void initAPI() {
|
||||
// if (AllMusic.Config.AutoApi) {
|
||||
// if (!RunApi.runAPI(DataFolder)) {
|
||||
// log.warning("§d[AllMusic]§c外置API启动失败");
|
||||
// }
|
||||
// }
|
||||
switch (AllMusic.Config.getMusic_Api()) {
|
||||
case 2: {
|
||||
AllMusic.Music = new API1();
|
||||
|
||||
@@ -1,29 +1,23 @@
|
||||
package Color_yr.AllMusic.Command;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import Color_yr.AllMusic.Http.HttpRequest;
|
||||
import Color_yr.AllMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
import Color_yr.AllMusic.MusicAPI.SongSearch.SearchPage;
|
||||
import Color_yr.AllMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.AllMusic.MusicPlay.SendHud.Hud;
|
||||
import Color_yr.AllMusic.MusicPlay.SendHud.HudUtils;
|
||||
import Color_yr.AllMusic.MusicPlay.SendHud.PosOBJ;
|
||||
import Color_yr.AllMusic.SearchTask;
|
||||
import Color_yr.AllMusic.TaskObj;
|
||||
import Color_yr.AllMusic.MusicPlay.MusicSearch;
|
||||
import Color_yr.AllMusic.MusicPlay.MusicObj;
|
||||
import Color_yr.AllMusic.Utils.Function;
|
||||
import Color_yr.AllMusic.Utils.UnZip;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CommandEX {
|
||||
private static boolean init = false;
|
||||
|
||||
private static void SearchMusic(Object sender, String Name, String[] args, boolean isDefault) {
|
||||
TaskObj obj = new TaskObj();
|
||||
MusicObj obj = new MusicObj();
|
||||
obj.sender = sender;
|
||||
obj.Name = Name;
|
||||
obj.args = args;
|
||||
obj.isDefault = isDefault;
|
||||
SearchTask.addSearch(obj);
|
||||
MusicSearch.addSearch(obj);
|
||||
}
|
||||
|
||||
private static void AddMusic(Object sender, String Name, String[] args) {
|
||||
@@ -56,7 +50,7 @@ public class CommandEX {
|
||||
}
|
||||
AllMusic.getConfig().RemoveNoMusicPlayer(Name);
|
||||
if (AllMusic.Side.NeedPlay()) {
|
||||
TaskObj obj = new TaskObj();
|
||||
MusicObj obj = new MusicObj();
|
||||
obj.sender = MusicID;
|
||||
obj.Name = Name;
|
||||
obj.isDefault = false;
|
||||
@@ -100,28 +94,6 @@ public class CommandEX {
|
||||
AllMusic.Side.SendMessage(sender, "");
|
||||
}
|
||||
|
||||
private static void initApi() {
|
||||
try {
|
||||
AllMusic.log.info("§d[AllMusic]§2开始下载");
|
||||
File file = HttpRequest.downloadNet("http://save.s-yh-china.com/", "MusicApi.zip", AllMusic.getDataFolder());
|
||||
if (HttpRequest.isCancel) {
|
||||
init = false;
|
||||
return;
|
||||
}
|
||||
AllMusic.log.info("§d[AllMusic]§2下载完成,开始解压");
|
||||
UnZip.unZip(file, AllMusic.getDataFolder() + "\\");
|
||||
AllMusic.getConfig().setMusic_Api(2);
|
||||
AllMusic.getConfig().setAutoApi(true);
|
||||
AllMusic.save();
|
||||
AllMusic.log.info("§d[AllMusic]§2外置Api下载完成");
|
||||
AllMusic.Side.reload();
|
||||
init = false;
|
||||
} catch (Exception e) {
|
||||
AllMusic.log.warning("§d[AllMusic]§c安装失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void EX(Object sender, String Name, String[] args) {
|
||||
if (args.length == 0) {
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getCommand().getError());
|
||||
@@ -148,7 +120,7 @@ public class CommandEX {
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
AllMusic.Side.ClearHud(Name);
|
||||
AllMusic.Side.Send("[Stop]", Name, false);
|
||||
Hud.clearHud(Name);
|
||||
HudUtils.clearHud(Name);
|
||||
AllMusic.removeNowPlayPlayer(Name);
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getMusicPlay().getStopPlay());
|
||||
} else if (args[0].equalsIgnoreCase("list")) {
|
||||
@@ -218,7 +190,10 @@ public class CommandEX {
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("url") && args.length == 2
|
||||
&& AllMusic.getConfig().getAdmin().contains(Name)) {
|
||||
PlayMusic.addUrl(args[1]);
|
||||
MusicObj obj = new MusicObj();
|
||||
obj.isUrl = true;
|
||||
obj.url = args[1];
|
||||
PlayMusic.addTask(obj);
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getAddMusic().getSuccess());
|
||||
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2
|
||||
&& AllMusic.getConfig().getAdmin().contains(Name)) {
|
||||
@@ -321,7 +296,7 @@ public class CommandEX {
|
||||
if (args[1].equalsIgnoreCase("enable")) {
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
boolean temp = Hud.SetHudEnable(Name, args[2]);
|
||||
boolean temp = HudUtils.SetHudEnable(Name, args[2]);
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getHud().getState()
|
||||
.replace("%State%", temp ? "启用" : "关闭")
|
||||
.replace("%Hud%", AllMusic.getMessage().getHudList().Get(args[2])));
|
||||
@@ -329,19 +304,19 @@ public class CommandEX {
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getCommand().getError());
|
||||
}
|
||||
} else {
|
||||
boolean temp = Hud.SetHudEnable(Name, null);
|
||||
boolean temp = HudUtils.SetHudEnable(Name, null);
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getHud().getState()
|
||||
.replace("%State%", temp ? "启用" : "关闭")
|
||||
.replace("%Hud%", AllMusic.getMessage().getHudList().getAll()));
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("reset")) {
|
||||
Hud.Reset(Name);
|
||||
HudUtils.Reset(Name);
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getHud().getReset());
|
||||
} else if (args.length != 4) {
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getCommand().getError());
|
||||
} else {
|
||||
try {
|
||||
PosOBJ obj = Hud.SetHudPos(Name, args[1], args[2], args[3]);
|
||||
PosOBJ obj = HudUtils.SetHudPos(Name, args[1], args[2], args[3]);
|
||||
if (obj == null) {
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getCommand().getError());
|
||||
} else {
|
||||
@@ -356,33 +331,6 @@ public class CommandEX {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("initApi") && AllMusic.getConfig().getAdmin().contains(Name)) {
|
||||
if (AllMusic.getConfig().isAutoApi() || AllMusic.getConfig().getMusic_Api() == 2) {
|
||||
AllMusic.log.info("§d[AllMusic]§2你已经在使用外置api了,不需要安装哦");
|
||||
} else {
|
||||
if (init) {
|
||||
AllMusic.log.info("§d[AllMusic]§2Api正在安装");
|
||||
} else {
|
||||
init = true;
|
||||
try {
|
||||
new Thread(CommandEX::initApi).start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("cancelApi") && AllMusic.getConfig().getAdmin().contains(Name)) {
|
||||
if (AllMusic.getConfig().isAutoApi() || AllMusic.getConfig().getMusic_Api() == 2) {
|
||||
AllMusic.log.info("§d[AllMusic]§2你已经在使用外置api了,不需要安装哦");
|
||||
} else {
|
||||
if (!init) {
|
||||
AllMusic.log.info("§d[AllMusic]§2Api没有在下载");
|
||||
} else {
|
||||
AllMusic.log.info("§d[AllMusic]§2已取消下载");
|
||||
HttpRequest.isCancel = true;
|
||||
}
|
||||
}
|
||||
} else if (AllMusic.getConfig().isNeedPermission() && AllMusic.Side.checkPermission(Name, "AllMusic.addmusic"))
|
||||
AllMusic.Side.SendMessage(sender, AllMusic.getMessage().getCommand().getNoPer());
|
||||
else {
|
||||
|
||||
@@ -8,7 +8,6 @@ public class CommandVelocity implements SimpleCommand {
|
||||
@Override
|
||||
public void execute(final Invocation invocation) {
|
||||
CommandSource source = invocation.source();
|
||||
// Get the arguments after the command alias
|
||||
String[] args = invocation.arguments();
|
||||
String name = "CONSOLE";
|
||||
if (invocation.source() instanceof Player) {
|
||||
|
||||
+6
-5
@@ -5,6 +5,7 @@ import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.config.CookieSpecs;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.config.Registry;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
@@ -25,15 +26,15 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
public class HttpGet {
|
||||
public class HttpClientUtil {
|
||||
private static HttpClient client;
|
||||
private static RequestConfig defaultConfig;
|
||||
|
||||
static {
|
||||
try {
|
||||
defaultConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD)
|
||||
.setConnectTimeout(2000).setSocketTimeout(2000)
|
||||
.setConnectionRequestTimeout(2000).build();
|
||||
.setConnectTimeout(5000).setSocketTimeout(5000)
|
||||
.setConnectionRequestTimeout(5000).build();
|
||||
class AnyTrustStrategy implements TrustStrategy {
|
||||
@Override
|
||||
public boolean isTrusted(X509Certificate[] chain, String authType) {
|
||||
@@ -60,7 +61,7 @@ public class HttpGet {
|
||||
public static Res realData(String path, String data) {
|
||||
try {
|
||||
data = URLEncoder.encode(data, "UTF-8");
|
||||
org.apache.http.client.methods.HttpGet get = new org.apache.http.client.methods.HttpGet(path + data);
|
||||
HttpGet get = new HttpGet(path + data);
|
||||
get.setConfig(defaultConfig);
|
||||
get.setHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36");
|
||||
@@ -68,7 +69,7 @@ public class HttpGet {
|
||||
InputStream inputStream = response.getEntity().getContent();
|
||||
boolean ok = response.getStatusLine().getStatusCode() == 200;
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
byte[] buffer = new byte[4096];
|
||||
int length;
|
||||
while ((length = inputStream.read(buffer)) != -1) {
|
||||
result.write(buffer, 0, length);
|
||||
@@ -1,57 +0,0 @@
|
||||
package Color_yr.AllMusic.Http;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class HttpRequest {
|
||||
|
||||
public static boolean isCancel;
|
||||
|
||||
public static File downloadNet(String urlStr, String fileName, String savePath) throws MalformedURLException {
|
||||
// 下载网络文件
|
||||
int bytesum = 0;
|
||||
int byteread = 0;
|
||||
|
||||
URL url = new URL(urlStr + fileName);
|
||||
isCancel = false;
|
||||
try {
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream inStream = conn.getInputStream();
|
||||
FileOutputStream fs = new FileOutputStream(savePath + "\\" + fileName);
|
||||
int all = conn.getContentLength();
|
||||
int index = 0;
|
||||
byte[] buffer = new byte[8196];
|
||||
while ((byteread = inStream.read(buffer)) != -1) {
|
||||
bytesum += byteread;
|
||||
if (index >= 1000) {
|
||||
AllMusic.log.info("已经下载了 " + bytesum + " byte,共" + all + " byte");
|
||||
index = 0;
|
||||
}
|
||||
fs.write(buffer, 0, byteread);
|
||||
index++;
|
||||
if (isCancel) {
|
||||
inStream.close();
|
||||
fs.close();
|
||||
new File(savePath + "\\" + fileName).delete();
|
||||
}
|
||||
}
|
||||
|
||||
inStream.close();
|
||||
fs.close();
|
||||
} catch (IOException e) {
|
||||
if (!isCancel) {
|
||||
AllMusic.log.warning("§d[AllMusic]§c文件下载失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
new File(savePath + "\\" + fileName).delete();
|
||||
}
|
||||
return new File(savePath + "\\" + fileName);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package Color_yr.AllMusic.MusicAPI.MusicAPI1;
|
||||
|
||||
import Color_yr.AllMusic.API.IMusicAPI;
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import Color_yr.AllMusic.Http.HttpGet;
|
||||
import Color_yr.AllMusic.Http.HttpClientUtil;
|
||||
import Color_yr.AllMusic.Http.Res;
|
||||
import Color_yr.AllMusic.MusicAPI.MusicAPI1.GetMusicInfo.InfoOBJ;
|
||||
import Color_yr.AllMusic.MusicAPI.MusicAPI1.GetMusicInfo.PlayOBJ;
|
||||
@@ -11,7 +11,7 @@ import Color_yr.AllMusic.MusicAPI.MusicAPI1.GetMusicLyric.LyricOBJ;
|
||||
import Color_yr.AllMusic.MusicAPI.MusicAPI1.GetMusicSearch.SearchDataOBJ;
|
||||
import Color_yr.AllMusic.MusicAPI.MusicAPI1.GetMusicSearch.songs;
|
||||
import Color_yr.AllMusic.MusicAPI.MusicAPI1.GetProgramInfo.PrInfoOBJ;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.AllMusic.MusicAPI.SongSearch.SearchOBJ;
|
||||
@@ -32,13 +32,13 @@ public class API1 implements IMusicAPI {
|
||||
AllMusic.log.info("§d[AllMusic]§e使用外置本地爬虫");
|
||||
if (!AllMusic.getConfig().getLoginPass().isEmpty() && !AllMusic.getConfig().getLoginUser().isEmpty()) {
|
||||
if (!AllMusic.getConfig().getLoginUser().contains("@"))
|
||||
HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/login/cellphone?phone="
|
||||
HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/login/cellphone?phone="
|
||||
+ AllMusic.getConfig().getLoginUser() + "&password=", AllMusic.getConfig().getLoginPass());
|
||||
else
|
||||
HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/login?email="
|
||||
HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/login?email="
|
||||
+ AllMusic.getConfig().getLoginUser() + "&password=", AllMusic.getConfig().getLoginPass());
|
||||
}
|
||||
Res res = HttpGet.realData(AllMusic.getConfig().getMusic_Url(), "");
|
||||
Res res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url(), "");
|
||||
if (res == null || !res.isOk()) {
|
||||
AllMusic.log.info("§d[AllMusic]§c使用外置本地爬虫连接失败");
|
||||
AllMusic.getConfig().setMusic_Api(1);
|
||||
@@ -48,7 +48,7 @@ public class API1 implements IMusicAPI {
|
||||
}
|
||||
|
||||
private SongInfo GetMusicDetail(String ID, String player, boolean isList) {
|
||||
Res res = HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/song/detail?ids=", ID);
|
||||
Res res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/song/detail?ids=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
InfoOBJ temp = new Gson().fromJson(res.getData(), InfoOBJ.class);
|
||||
if (temp.isok()) {
|
||||
@@ -64,7 +64,7 @@ public class API1 implements IMusicAPI {
|
||||
SongInfo info = GetMusicDetail(ID, player, isList);
|
||||
if (info != null)
|
||||
return info;
|
||||
Res res = HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/dj/program/detail?id=", ID);
|
||||
Res res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/dj/program/detail?id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
PrInfoOBJ temp = new Gson().fromJson(res.getData(), PrInfoOBJ.class);
|
||||
if (temp.isOK()) {
|
||||
@@ -79,8 +79,8 @@ public class API1 implements IMusicAPI {
|
||||
|
||||
@Override
|
||||
public String GetPlayUrl(String ID) {
|
||||
HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/check/music?id=", ID);
|
||||
Res res = HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/song/url?br=320000&id=", ID);
|
||||
HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/check/music?id=", ID);
|
||||
Res res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/song/url?br=320000&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
PlayOBJ obj = new Gson().fromJson(res.getData(), PlayOBJ.class);
|
||||
@@ -93,7 +93,7 @@ public class API1 implements IMusicAPI {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
res = HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/song/url?id=", ID);
|
||||
res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/song/url?id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
PlayOBJ obj = new Gson().fromJson(res.getData(), PlayOBJ.class);
|
||||
@@ -115,7 +115,7 @@ public class API1 implements IMusicAPI {
|
||||
public void SetList(String ID, Object sender) {
|
||||
Thread thread = new Thread(() ->
|
||||
{
|
||||
Res res = HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/playlist/detail?id=", ID);
|
||||
Res res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/playlist/detail?id=", ID);
|
||||
if (res != null && res.isOk())
|
||||
try {
|
||||
isUpdata = true;
|
||||
@@ -135,7 +135,7 @@ public class API1 implements IMusicAPI {
|
||||
@Override
|
||||
public LyricSave getLyric(String ID) {
|
||||
LyricSave Lyric = new LyricSave();
|
||||
Res res = HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/lyric?id=", ID);
|
||||
Res res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/lyric?id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricOBJ obj = new Gson().fromJson(res.getData(), LyricOBJ.class);
|
||||
@@ -172,7 +172,7 @@ public class API1 implements IMusicAPI {
|
||||
}
|
||||
String MusicName = name1.toString();
|
||||
MusicName = MusicName.substring(0, MusicName.length() - 1);
|
||||
Res res = HttpGet.realData(AllMusic.getConfig().getMusic_Url() + "/search?keywords=", MusicName);
|
||||
Res res = HttpClientUtil.realData(AllMusic.getConfig().getMusic_Url() + "/search?keywords=", MusicName);
|
||||
if (res != null && res.isOk()) {
|
||||
SearchDataOBJ obj = new Gson().fromJson(res.getData(), SearchDataOBJ.class);
|
||||
if (obj != null && obj.isok()) {
|
||||
|
||||
@@ -2,11 +2,11 @@ package Color_yr.AllMusic.MusicAPI.MusicAPI2;
|
||||
|
||||
import Color_yr.AllMusic.API.IMusicAPI;
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import Color_yr.AllMusic.Http.HttpGet;
|
||||
import Color_yr.AllMusic.Http.HttpClientUtil;
|
||||
import Color_yr.AllMusic.Http.Res;
|
||||
import Color_yr.AllMusic.MusicAPI.MusicAPI2.GetMusicInfo.InfoOBJ;
|
||||
import Color_yr.AllMusic.MusicAPI.MusicAPI2.GetMusicLyric.LyricOBJ;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.LyricDo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.AllMusic.MusicAPI.SongSearch.SearchPage;
|
||||
@@ -19,13 +19,9 @@ public class API2 implements IMusicAPI {
|
||||
public int PlayNow = 0;
|
||||
public boolean isUpdata;
|
||||
|
||||
public API2() {
|
||||
AllMusic.log.info("§d[AllMusic]§e使用内置爬虫,你可以输入/music initApi来尝试自动搭建外置爬虫");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SongInfo GetMusic(String ID, String player, boolean isList) {
|
||||
Res res = HttpGet.realData("https://music.163.com/api/song/detail/?ids=%5B", ID + "]");
|
||||
Res res = HttpClientUtil.realData("https://music.163.com/api/song/detail/?ids=%5B", ID + "]");
|
||||
SongInfo info = null;
|
||||
if (res != null && res.isOk()) {
|
||||
InfoOBJ temp = new Gson().fromJson(res.getData(), InfoOBJ.class);
|
||||
@@ -52,7 +48,7 @@ public class API2 implements IMusicAPI {
|
||||
@Override
|
||||
public LyricSave getLyric(String ID) {
|
||||
LyricSave Lyric = new LyricSave();
|
||||
Res res = HttpGet.realData("https://music.163.com/api/song/lyric?os=pc&lv=-1&kv=-1&tv=-1&id=", ID);
|
||||
Res res = HttpClientUtil.realData("https://music.163.com/api/song/lyric?os=pc&lv=-1&kv=-1&tv=-1&id=", ID);
|
||||
if (res != null && res.isOk()) {
|
||||
try {
|
||||
LyricOBJ obj = new Gson().fromJson(res.getData(), LyricOBJ.class);
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package Color_yr.AllMusic.MusicAPI.SongInfo;
|
||||
package Color_yr.AllMusic.MusicAPI;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package Color_yr.AllMusic.MusicPlay;
|
||||
|
||||
public class MusicObj {
|
||||
public Object sender;
|
||||
public String Name;
|
||||
public String[] args;
|
||||
public boolean isDefault;
|
||||
public boolean isUrl;
|
||||
public String url;
|
||||
}
|
||||
+6
-5
@@ -1,21 +1,22 @@
|
||||
package Color_yr.AllMusic;
|
||||
package Color_yr.AllMusic.MusicPlay;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import Color_yr.AllMusic.Command.CommandEX;
|
||||
import Color_yr.AllMusic.MusicAPI.SongSearch.SearchPage;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class SearchTask {
|
||||
public class MusicSearch {
|
||||
private static Thread taskT;
|
||||
private static boolean isRun;
|
||||
private static List<TaskObj> tasks = new CopyOnWriteArrayList<>();
|
||||
private static List<MusicObj> tasks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private static final Runnable Do = () -> {
|
||||
while (isRun) {
|
||||
try {
|
||||
if (!tasks.isEmpty()) {
|
||||
TaskObj obj = tasks.remove(0);
|
||||
MusicObj obj = tasks.remove(0);
|
||||
SearchPage search = AllMusic.getMusic().Search(obj.args, obj.isDefault);
|
||||
if (search == null)
|
||||
AllMusic.Side.SendMessaget(obj.sender, AllMusic.getMessage().getSearch()
|
||||
@@ -44,7 +45,7 @@ public class SearchTask {
|
||||
isRun = false;
|
||||
}
|
||||
|
||||
public static void addSearch(TaskObj obj) {
|
||||
public static void addSearch(MusicObj obj) {
|
||||
tasks.add(obj);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,7 @@ package Color_yr.AllMusic.MusicPlay;
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.AllMusic.MusicPlay.SendHud.Hud;
|
||||
import Color_yr.AllMusic.TaskObj;
|
||||
import Color_yr.AllMusic.MusicPlay.SendHud.HudUtils;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -29,12 +28,12 @@ class PlayGo {
|
||||
if (show != null) {
|
||||
PlayMusic.nowLyric = show;
|
||||
times = 0;
|
||||
Hud.SendHudLyricData(show);
|
||||
HudUtils.SendHudLyricData(show);
|
||||
} else {
|
||||
times++;
|
||||
if (times == 500 && PlayMusic.nowLyric != null) {
|
||||
times = 0;
|
||||
Hud.SendHudLyricData(PlayMusic.nowLyric);
|
||||
HudUtils.SendHudLyricData(PlayMusic.nowLyric);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -81,20 +80,20 @@ class PlayGo {
|
||||
PlayMusic.nowLyric = null;
|
||||
PlayMusic.NowPlayMusic = null;
|
||||
closeTimer();
|
||||
Hud.clearHud();
|
||||
HudUtils.clearHud();
|
||||
}
|
||||
|
||||
private static final Runnable Do = () -> {
|
||||
while (isRun) {
|
||||
if (PlayMusic.getSize() == 0) {
|
||||
try {
|
||||
Hud.SendHudNowData();
|
||||
Hud.SendHudLyricData(null);
|
||||
Hud.SendHudListData();
|
||||
HudUtils.SendHudNowData();
|
||||
HudUtils.SendHudLyricData(null);
|
||||
HudUtils.SendHudListData();
|
||||
if (AllMusic.Side.NeedPlay()) {
|
||||
String ID = AllMusic.getMusic().GetListMusic();
|
||||
if (ID != null) {
|
||||
TaskObj obj = new TaskObj();
|
||||
MusicObj obj = new MusicObj();
|
||||
obj.sender = ID;
|
||||
obj.Name = "空闲列表";
|
||||
obj.isDefault = true;
|
||||
@@ -137,8 +136,8 @@ class PlayGo {
|
||||
AllMusic.Side.Send("[Play]" + url, true);
|
||||
try {
|
||||
while (PlayMusic.MusicLessTime > 0) {
|
||||
Hud.SendHudNowData();
|
||||
Hud.SendHudListData();
|
||||
HudUtils.SendHudNowData();
|
||||
HudUtils.SendHudListData();
|
||||
if (!AllMusic.Side.NeedPlay()) {
|
||||
PlayMusic.MusicLessTime = 1;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package Color_yr.AllMusic.MusicPlay;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.LyricSave;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.AllMusic.TaskObj;
|
||||
import Color_yr.AllMusic.Utils.logs;
|
||||
import Color_yr.AllMusic.decoder.Bitstream;
|
||||
import Color_yr.AllMusic.decoder.Header;
|
||||
@@ -30,13 +29,17 @@ public class PlayMusic {
|
||||
|
||||
private static boolean isRun;
|
||||
private static Thread addT;
|
||||
private static final List<TaskObj> tasks = new CopyOnWriteArrayList<>();
|
||||
private static final List<MusicObj> tasks = new CopyOnWriteArrayList<>();
|
||||
private static final Runnable Do = () -> {
|
||||
while (isRun) {
|
||||
try {
|
||||
if (!tasks.isEmpty()) {
|
||||
TaskObj obj = tasks.remove(0);
|
||||
addMusic((String) obj.sender, obj.Name, obj.isDefault);
|
||||
MusicObj obj = tasks.remove(0);
|
||||
if (obj.isUrl) {
|
||||
addUrl(obj.url);
|
||||
} else {
|
||||
addMusic((String) obj.sender, obj.Name, obj.isDefault);
|
||||
}
|
||||
}
|
||||
Thread.sleep(10);
|
||||
} catch (Exception e) {
|
||||
@@ -59,7 +62,7 @@ public class PlayMusic {
|
||||
addT.start();
|
||||
}
|
||||
|
||||
public static void addTask(TaskObj obj) {
|
||||
public static void addTask(MusicObj obj) {
|
||||
tasks.add(obj);
|
||||
}
|
||||
|
||||
@@ -153,7 +156,7 @@ public class PlayMusic {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addUrl(String arg) {
|
||||
private static void addUrl(String arg) {
|
||||
synchronized (PlayList) {
|
||||
try {
|
||||
URL urlfile = new URL(arg);
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
package Color_yr.AllMusic.MusicPlay.SendHud;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongInfo;
|
||||
import Color_yr.AllMusic.MusicAPI.SongLyric.ShowOBJ;
|
||||
import Color_yr.AllMusic.MusicPlay.PlayMusic;
|
||||
import Color_yr.AllMusic.Utils.Function;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class Hud {
|
||||
public class HudUtils {
|
||||
public static PosOBJ SetHudPos(String player, String pos, String x, String y) {
|
||||
SaveOBJ obj = AllMusic.getConfig().getInfoSave(player);
|
||||
if (obj == null)
|
||||
@@ -46,7 +46,7 @@ public class Hud {
|
||||
|
||||
AllMusic.getConfig().setInfoSave(obj, player);
|
||||
AllMusic.save();
|
||||
Hud.SendHudSave(player);
|
||||
HudUtils.SendHudSave(player);
|
||||
return posOBJ;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class Hud {
|
||||
clearHud(player);
|
||||
AllMusic.getConfig().setInfoSave(obj, player);
|
||||
AllMusic.save();
|
||||
Hud.SendHudSave(player);
|
||||
HudUtils.SendHudSave(player);
|
||||
if (pos == null) {
|
||||
return a;
|
||||
} else {
|
||||
@@ -197,6 +197,6 @@ public class Hud {
|
||||
clearHud(name);
|
||||
AllMusic.getConfig().setInfoSave(obj, name);
|
||||
AllMusic.save();
|
||||
Hud.SendHudSave(name);
|
||||
HudUtils.SendHudSave(name);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package Color_yr.AllMusic.Side.SideBC;
|
||||
|
||||
import Color_yr.AllMusic.IMyLogger;
|
||||
import Color_yr.AllMusic.API.IMyLogger;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Color_yr.AllMusic.Side.SideBukkit;
|
||||
|
||||
import Color_yr.AllMusic.IMyLogger;
|
||||
import Color_yr.AllMusic.API.IMyLogger;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package Color_yr.AllMusic.Side.SideVelocity;
|
||||
|
||||
import Color_yr.AllMusic.IMyLogger;
|
||||
import Color_yr.AllMusic.API.IMyLogger;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class VelocityLog implements IMyLogger {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package Color_yr.AllMusic;
|
||||
|
||||
public class TaskObj {
|
||||
public Object sender;
|
||||
public String Name;
|
||||
public String[] args;
|
||||
public boolean isDefault;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package Color_yr.AllMusic.Utils;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
public class RunApi {
|
||||
private static Process Process;
|
||||
|
||||
public static boolean runAPI(File DataFolder) {
|
||||
try {
|
||||
if (isPortUsing()) {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
||||
Process = Runtime.getRuntime().exec("cmd /c start " + System.getProperty("user.dir") + "\\" + DataFolder + "\\NeteaseCloudMusicApi\\start.cmd");
|
||||
} else {
|
||||
Process = Runtime.getRuntime().exec("bash " + System.getProperty("user.dir") + "\\" + DataFolder + "\\NeteaseCloudMusicApi\\start.sh");
|
||||
}
|
||||
Thread.sleep(500);
|
||||
return true;
|
||||
} else {
|
||||
AllMusic.log.info("§d[AllMusic]§cApi开始失败,端口已被占用,可能是已经启动");
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPortUsing() {
|
||||
try {
|
||||
Socket socket = new Socket();
|
||||
socket.bind(new InetSocketAddress(4000));
|
||||
socket.close();
|
||||
return true;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
if (Process != null && Process.isAlive()) {
|
||||
Process.destroyForcibly();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package Color_yr.AllMusic.Utils;
|
||||
|
||||
import Color_yr.AllMusic.AllMusic;
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class UnZip {
|
||||
|
||||
public static void unZip(File zipFile, String outDir) {
|
||||
ZipFile zip = null;
|
||||
try {
|
||||
File outFileDir = new File(outDir);
|
||||
if (!outFileDir.exists()) {
|
||||
outFileDir.mkdirs();
|
||||
}
|
||||
|
||||
zip = new ZipFile(zipFile);
|
||||
for (Enumeration enumeration = zip.getEntries(); enumeration.hasMoreElements(); ) {
|
||||
ZipEntry entry = (ZipEntry) enumeration.nextElement();
|
||||
String zipEntryName = entry.getName();
|
||||
InputStream in = zip.getInputStream(entry);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
File fileDir = new File(outDir + zipEntryName);
|
||||
fileDir.mkdir();
|
||||
continue;
|
||||
}
|
||||
|
||||
File file = new File(outDir, zipEntryName);
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
byte[] buff = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buff)) > 0) {
|
||||
out.write(buff, 0, len);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
AllMusic.log.warning("§d[AllMusic]§c解压失败");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (zip != null) {
|
||||
try {
|
||||
zip.close();
|
||||
zipFile.delete();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,8 +203,7 @@ public final class Bitstream implements BitstreamErrors {
|
||||
public InputStream getRawID3v2() {
|
||||
if (rawid3v2 == null) return null;
|
||||
else {
|
||||
ByteArrayInputStream bain = new ByteArrayInputStream(rawid3v2);
|
||||
return bain;
|
||||
return new ByteArrayInputStream(rawid3v2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +354,7 @@ public final class Bitstream implements BitstreamErrors {
|
||||
|
||||
if (bytesRead != 3) throw newBitstreamException(STREAM_EOF, null);
|
||||
|
||||
headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2] << 0) & 0x000000FF);
|
||||
headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2]) & 0x000000FF);
|
||||
|
||||
do {
|
||||
headerstring <<= 8;
|
||||
|
||||
Reference in new issue
Block a user