mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-20 06:29:36 +00:00
1.5.0
This commit is contained in:
1 parent
43e2563c4a
commit
31acd02b22
21 files changed
+320
-143
No files matched your search
@@ -6,12 +6,10 @@ import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ALLMusic {
|
||||
public static final String channel = "allmusic:channel";
|
||||
public static final String Version = "1.5.0";
|
||||
public static ConfigOBJ Config;
|
||||
public static Logger log;
|
||||
public static File ConfigFile;
|
||||
|
||||
public static ISide Side;
|
||||
public static final String channel = "allmusic:channel";
|
||||
|
||||
public static final String Version = "1.4.0";
|
||||
}
|
||||
@@ -15,6 +15,7 @@ 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);
|
||||
@@ -55,9 +56,9 @@ public class ALLMusicBC extends Plugin {
|
||||
try {
|
||||
if (ALLMusic.ConfigFile == null) {
|
||||
ALLMusic.ConfigFile = new File(ALLMusicP.getDataFolder(), "config.json");
|
||||
logs.file = new File(ALLMusicP.getDataFolder(), "logs.log");
|
||||
if (!ALLMusicP.getDataFolder().exists())
|
||||
ALLMusicP.getDataFolder().mkdir();
|
||||
new logs().Init(ALLMusicP.getDataFolder());
|
||||
if (!ALLMusic.ConfigFile.exists()) {
|
||||
InputStream in = ALLMusicP.getResourceAsStream("config_BC.json");
|
||||
Files.copy(in, ALLMusic.ConfigFile.toPath());
|
||||
@@ -66,7 +67,6 @@ public class ALLMusicBC extends Plugin {
|
||||
logs.file.createNewFile();
|
||||
}
|
||||
}
|
||||
|
||||
LoadConfig();
|
||||
} catch (IOException e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c配置文件错误");
|
||||
|
||||
@@ -58,18 +58,14 @@ public class ALLMusicBukkit extends JavaPlugin {
|
||||
try {
|
||||
if (ALLMusic.ConfigFile == null) {
|
||||
ALLMusic.ConfigFile = new File(ALLMusicP.getDataFolder(), "config.json");
|
||||
logs.file = new File(ALLMusicP.getDataFolder(), "logs.log");
|
||||
if (!ALLMusicP.getDataFolder().exists())
|
||||
ALLMusicP.getDataFolder().mkdir();
|
||||
new logs().Init(ALLMusicP.getDataFolder());
|
||||
if (!ALLMusic.ConfigFile.exists()) {
|
||||
InputStream in = ALLMusicP.getResource("config_BC.json");
|
||||
Files.copy(in, ALLMusic.ConfigFile.toPath());
|
||||
}
|
||||
if (!logs.file.exists()) {
|
||||
logs.file.createNewFile();
|
||||
}
|
||||
}
|
||||
|
||||
LoadConfig();
|
||||
} catch (IOException e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c配置文件错误");
|
||||
|
||||
@@ -3,6 +3,7 @@ package Color_yr.ALLMusic.Command;
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.ALLMusicBC;
|
||||
import Color_yr.ALLMusic.Play.PlayMusic;
|
||||
import Color_yr.ALLMusic.PlayList.GetList;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@@ -10,9 +11,6 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBC extends Command implements TabExecutor {
|
||||
|
||||
public CommandBC() {
|
||||
@@ -20,7 +18,6 @@ public class CommandBC extends Command implements TabExecutor {
|
||||
}
|
||||
|
||||
private void AddMusic(CommandSender sender, String[] args) {
|
||||
|
||||
String MusicID;
|
||||
if (args[0].contains("id=")) {
|
||||
if (args[0].contains("&user"))
|
||||
@@ -37,14 +34,21 @@ public class CommandBC extends Command implements TabExecutor {
|
||||
if (Function.isInteger(MusicID)) {
|
||||
if (PlayMusic.PlayList.size() == ALLMusic.Config.getMaxList()) {
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§c错误,队列已满"));
|
||||
return;
|
||||
} else if (ALLMusic.Config.getBanMusic().contains(MusicID)) {
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§c错误,这首歌被禁点了"));
|
||||
} else {
|
||||
PlayMusic.AddMusic(MusicID, sender.getName());
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§2点歌成功"));
|
||||
ALLMusic.Config.RemoveNoMusicPlayer(sender.getName());
|
||||
if (ALLMusic.Side.NeedPlay()) {
|
||||
PlayMusic.AddMusic(MusicID, sender.getName());
|
||||
if (PlayMusic.isList && ALLMusic.Config.isPlayListSwitch()) {
|
||||
PlayMusic.MusicAllTime = 1;
|
||||
PlayMusic.isList = false;
|
||||
}
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§2点歌成功"));
|
||||
}
|
||||
else
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§c没有播放的玩家"));
|
||||
}
|
||||
ALLMusic.Config.RemoveNoMusicPlayer(sender.getName());
|
||||
} else
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请输入歌曲数字ID"));
|
||||
}
|
||||
@@ -127,24 +131,19 @@ public class CommandBC extends Command implements TabExecutor {
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§2请输入有效的序列ID"));
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("addlist") && args.length == 2
|
||||
&& ALLMusic.Config.getAdmin().contains(name)) {
|
||||
if (Function.isInteger(args[1])) {
|
||||
GetList.GetL(args[1]);
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§2添加音乐列表" + args[1]));
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("§d[ALLMusic]§2请输入有效的音乐列表ID"));
|
||||
}
|
||||
} else
|
||||
AddMusic(sender, args);
|
||||
}
|
||||
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
List<String> arguments = new ArrayList<>();
|
||||
if (args.length == 0) {
|
||||
arguments.add("stop");
|
||||
arguments.add("list");
|
||||
arguments.add("vote");
|
||||
arguments.add("nomusic");
|
||||
if (ALLMusic.Config.getAdmin().contains(sender.getName())) {
|
||||
arguments.add("reload");
|
||||
arguments.add("next");
|
||||
arguments.add("ban");
|
||||
arguments.add("delete");
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
return TabCommand.GetTabList(sender.getName());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package Color_yr.ALLMusic.Command;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.ALLMusicBC;
|
||||
import Color_yr.ALLMusic.ALLMusicBukkit;
|
||||
import Color_yr.ALLMusic.Play.PlayMusic;
|
||||
import Color_yr.ALLMusic.PlayList.GetList;
|
||||
import Color_yr.ALLMusic.Utils.Function;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -11,7 +11,6 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBukkit implements CommandExecutor, TabExecutor {
|
||||
@@ -34,21 +33,28 @@ public class CommandBukkit implements CommandExecutor, TabExecutor {
|
||||
if (Function.isInteger(MusicID)) {
|
||||
if (PlayMusic.PlayList.size() == ALLMusic.Config.getMaxList()) {
|
||||
sender.sendMessage("§d[ALLMusic]§c错误,队列已满");
|
||||
return;
|
||||
} else if (ALLMusic.Config.getBanMusic().contains(MusicID)) {
|
||||
sender.sendMessage("§d[ALLMusic]§c错误,这首歌被禁点了");
|
||||
} else {
|
||||
PlayMusic.AddMusic(MusicID, sender.getName());
|
||||
sender.sendMessage("§d[ALLMusic]§2点歌成功");
|
||||
ALLMusic.Config.RemoveNoMusicPlayer(sender.getName());
|
||||
if (ALLMusic.Side.NeedPlay()) {
|
||||
PlayMusic.AddMusic(MusicID, sender.getName());
|
||||
if (PlayMusic.isList && ALLMusic.Config.isPlayListSwitch()) {
|
||||
PlayMusic.MusicAllTime = 1;
|
||||
PlayMusic.isList = false;
|
||||
}
|
||||
sender.sendMessage("§d[ALLMusic]§2点歌成功");
|
||||
}
|
||||
else
|
||||
sender.sendMessage("§d[ALLMusic]§c没有播放的玩家");
|
||||
}
|
||||
ALLMusic.Config.RemoveNoMusicPlayer(sender.getName());
|
||||
} else
|
||||
sender.sendMessage("§d[ALLmusic]§c错误,请输入歌曲数字ID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(command.getName().equalsIgnoreCase("music")) {
|
||||
if (command.getName().equalsIgnoreCase("music")) {
|
||||
String name = sender.getName();
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("§d[ALLMusic]§c错误,请使用/music help 获取帮助");
|
||||
@@ -126,6 +132,14 @@ public class CommandBukkit implements CommandExecutor, TabExecutor {
|
||||
} else {
|
||||
sender.sendMessage("§d[ALLMusic]§2请输入有效的序列ID");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("addlist") && args.length == 2
|
||||
&& ALLMusic.Config.getAdmin().contains(name)) {
|
||||
if (Function.isInteger(args[1])) {
|
||||
GetList.GetL(args[1]);
|
||||
sender.sendMessage("§d[ALLMusic]§2添加音乐列表" + args[1]);
|
||||
} else {
|
||||
sender.sendMessage("§d[ALLMusic]§2请输入有效的音乐列表ID");
|
||||
}
|
||||
} else
|
||||
AddMusic(sender, args);
|
||||
return true;
|
||||
@@ -135,21 +149,8 @@ public class CommandBukkit implements CommandExecutor, TabExecutor {
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if(command.getName().equalsIgnoreCase("music")) {
|
||||
List<String> arguments = new ArrayList<>();
|
||||
if (args.length == 0) {
|
||||
arguments.add("stop");
|
||||
arguments.add("list");
|
||||
arguments.add("vote");
|
||||
arguments.add("nomusic");
|
||||
if (ALLMusic.Config.getAdmin().contains(sender.getName())) {
|
||||
arguments.add("reload");
|
||||
arguments.add("next");
|
||||
arguments.add("ban");
|
||||
arguments.add("delete");
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
if (command.getName().equalsIgnoreCase("music")) {
|
||||
return TabCommand.GetTabList(sender.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package Color_yr.ALLMusic.Command;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TabCommand {
|
||||
public static List<String> GetTabList(String name) {
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("stop");
|
||||
arguments.add("list");
|
||||
arguments.add("vote");
|
||||
arguments.add("nomusic");
|
||||
if (ALLMusic.Config.getAdmin().contains(name)) {
|
||||
arguments.add("reload");
|
||||
arguments.add("next");
|
||||
arguments.add("ban");
|
||||
arguments.add("delete");
|
||||
arguments.add("addlist");
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ public class ConfigOBJ {
|
||||
private String Music_Api1;
|
||||
private String Lyric_Api1;
|
||||
private String Info_Api1;
|
||||
private String List_Api1;
|
||||
|
||||
private int MaxList;
|
||||
private int MinVote;
|
||||
@@ -16,6 +17,10 @@ public class ConfigOBJ {
|
||||
private List<String> NoMusicServer;
|
||||
private List<String> NoMusicPlayer;
|
||||
private List<String> BanMusic;
|
||||
private List<String> PlayList;
|
||||
|
||||
private boolean PlayListSwitch;
|
||||
private boolean PlayListRandom;
|
||||
|
||||
private String Version;
|
||||
|
||||
@@ -23,6 +28,7 @@ public class ConfigOBJ {
|
||||
Music_Api1 = "http://music.163.com/song/media/outer/url?id=";
|
||||
Lyric_Api1 = "https://api.imjad.cn/cloudmusic/?type=lyric&id=";
|
||||
Info_Api1 = "https://api.imjad.cn/cloudmusic/?type=detail&id=";
|
||||
List_Api1 = "https://api.imjad.cn/cloudmusic/?type=playlist&id=";
|
||||
MaxList = 10;
|
||||
MinVote = 3;
|
||||
Delay = 2;
|
||||
@@ -30,14 +36,33 @@ public class ConfigOBJ {
|
||||
NoMusicServer = new ArrayList<>();
|
||||
NoMusicPlayer = new ArrayList<>();
|
||||
BanMusic = new ArrayList<>();
|
||||
PlayList = new ArrayList<>();
|
||||
PlayListSwitch = true;
|
||||
PlayListRandom = true;
|
||||
|
||||
Version = ALLMusic.Version;
|
||||
}
|
||||
|
||||
public boolean isPlayListRandom() {
|
||||
return PlayListRandom;
|
||||
}
|
||||
|
||||
public List<String> getPlayList() {
|
||||
return PlayList;
|
||||
}
|
||||
|
||||
public boolean isPlayListSwitch() {
|
||||
return PlayListSwitch;
|
||||
}
|
||||
|
||||
public String getInfo_Api1() {
|
||||
return Info_Api1;
|
||||
}
|
||||
|
||||
public String getList_Api1() {
|
||||
return List_Api1;
|
||||
}
|
||||
|
||||
public String getLyric_Api1() {
|
||||
return Lyric_Api1;
|
||||
}
|
||||
@@ -89,6 +114,7 @@ public class ConfigOBJ {
|
||||
NoMusicPlayer.add(ID);
|
||||
ALLMusic.Side.save();
|
||||
}
|
||||
|
||||
public void RemoveNoMusicPlayer(String ID) {
|
||||
NoMusicPlayer.remove(ID);
|
||||
ALLMusic.Side.save();
|
||||
|
||||
@@ -15,6 +15,12 @@ public class LyricDo {
|
||||
this.obj = new Gson().fromJson(obj, LyricOBJ.class);
|
||||
}
|
||||
|
||||
public LyricDo(Map<Integer, ShowOBJ> Lyric) {
|
||||
if (Lyric == null)
|
||||
return;
|
||||
this.Lyric = Lyric;
|
||||
}
|
||||
|
||||
public void Check() {
|
||||
String[] lyric;
|
||||
|
||||
@@ -22,17 +28,41 @@ public class LyricDo {
|
||||
if (obj.getLyric() == null)
|
||||
return;
|
||||
lyric = obj.getLyric().split("\n");
|
||||
List<String> tlyric = new ArrayList<>();
|
||||
List<String> Tlyric = new ArrayList<>();
|
||||
if (obj.getTlyric() != null) {
|
||||
tlyric = Arrays.asList(obj.getTlyric().split("\n"));
|
||||
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()) {
|
||||
Lyric.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,
|
||||
item.getValue(), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ShowOBJ checkTime(int playNow) {
|
||||
if (Lyric.containsKey(playNow))
|
||||
return Lyric.get(playNow);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<Integer, ShowOBJ> getLyric() {
|
||||
return Lyric;
|
||||
}
|
||||
|
||||
private Map<Integer, String> GetTime(List<String> lyric) {
|
||||
Map<Integer, String> Lyric = new HashMap<>();
|
||||
String min;
|
||||
String sec;
|
||||
String mil;
|
||||
String Tlyric = null;
|
||||
String temp;
|
||||
String temp2;
|
||||
int time;
|
||||
int milt;
|
||||
for (String s : lyric) {
|
||||
@@ -55,31 +85,14 @@ public class LyricDo {
|
||||
if (min.isEmpty() || sec.isEmpty() || mil.isEmpty())
|
||||
continue;
|
||||
milt = Integer.parseInt(mil);
|
||||
if(mil.length() == 3) {
|
||||
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();
|
||||
if (haveT) {
|
||||
temp = Function.getString(s, "[", "]");
|
||||
for (String item : tlyric) {
|
||||
temp2 = Function.getString(item, "[", "]");
|
||||
if (temp.startsWith(temp2) || temp2.startsWith(temp)) {
|
||||
Tlyric = Function.getString(item, "]", null);
|
||||
break;
|
||||
} else
|
||||
Tlyric = null;
|
||||
}
|
||||
}
|
||||
Lyric.put(time, new ShowOBJ(time, haveT,
|
||||
Function.getString(s, "]", null), Tlyric));
|
||||
time += ALLMusic.Config.getDelay() * 10;
|
||||
Lyric.put(time, Function.getString(s, "]", null));
|
||||
}
|
||||
}
|
||||
|
||||
public ShowOBJ checkTime(int playNow) {
|
||||
if (Lyric.containsKey(playNow))
|
||||
return Lyric.get(playNow);
|
||||
return null;
|
||||
return Lyric;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ public class LyricOBJ {
|
||||
return tlyric.getLyric();
|
||||
}
|
||||
}
|
||||
|
||||
class lrc {
|
||||
private int version;
|
||||
private String lyric;
|
||||
@@ -23,6 +24,7 @@ class lrc {
|
||||
return lyric == null ? "" : lyric;
|
||||
}
|
||||
}
|
||||
|
||||
class tlyric {
|
||||
private int version;
|
||||
private String lyric;
|
||||
|
||||
@@ -1,41 +1,23 @@
|
||||
package Color_yr.ALLMusic.Lyric;
|
||||
|
||||
public class ShowOBJ {
|
||||
private int time;
|
||||
private boolean haveT;
|
||||
private String lyric;
|
||||
private String tlyric;
|
||||
|
||||
public ShowOBJ(int time, boolean haveT, String lyric, String tlyric) {
|
||||
this.time = time;
|
||||
public ShowOBJ(boolean haveT, String lyric, String tlyric) {
|
||||
this.haveT = haveT;
|
||||
this.lyric = lyric;
|
||||
this.tlyric = tlyric;
|
||||
}
|
||||
|
||||
public String getLyric() {
|
||||
return lyric;
|
||||
}
|
||||
|
||||
public boolean isHaveT() {
|
||||
return haveT;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getTlyric() {
|
||||
return tlyric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (lyric == null || lyric.isEmpty())
|
||||
return null;
|
||||
if (haveT) {
|
||||
if (tlyric == null || !tlyric.isEmpty())
|
||||
return lyric + (haveT ? "(" + tlyric + ")" : null);
|
||||
if (tlyric != null && !tlyric.isEmpty())
|
||||
return lyric + "(" + tlyric + ")";
|
||||
}
|
||||
return lyric;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.Get;
|
||||
import Color_yr.ALLMusic.Lyric.LyricDo;
|
||||
import Color_yr.ALLMusic.Lyric.ShowOBJ;
|
||||
import Color_yr.ALLMusic.PlayList.GetList;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -11,6 +12,19 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
class PlayGo extends Thread {
|
||||
|
||||
//创建 run 方法
|
||||
Runnable runnable = () -> PlayMusic.MusicNowTime += 10;
|
||||
Runnable runnable1 = () -> {
|
||||
ShowOBJ show = PlayMusic.Lyric.checkTime(PlayMusic.MusicNowTime);
|
||||
if (show != null) {
|
||||
String now = show.toString();
|
||||
PlayMusic.nowLyric = now != null ? now : PlayMusic.nowLyric;
|
||||
}
|
||||
ALLMusic.Side.SendLyric(PlayMusic.nowLyric);
|
||||
};
|
||||
private ScheduledExecutorService service;
|
||||
private ScheduledExecutorService service1;
|
||||
|
||||
public void close() {
|
||||
if (service != null) {
|
||||
service.shutdown();
|
||||
@@ -22,19 +36,6 @@ class PlayGo extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
private ScheduledExecutorService service;
|
||||
private ScheduledExecutorService service1;
|
||||
//创建 run 方法
|
||||
Runnable runnable = () -> PlayMusic.MusicNowTime += 10;
|
||||
Runnable runnable1 = () -> {
|
||||
ShowOBJ show = PlayMusic.Lyric.checkTime(PlayMusic.MusicNowTime);
|
||||
if (show != null) {
|
||||
String now = show.toString();
|
||||
PlayMusic.nowLyric = now != null ? now : PlayMusic.nowLyric;
|
||||
}
|
||||
ALLMusic.Side.SendLyric(PlayMusic.nowLyric);
|
||||
};
|
||||
|
||||
private void startTime() {
|
||||
service = Executors.newSingleThreadScheduledExecutor();
|
||||
service.scheduleAtFixedRate(runnable, 0, 10, TimeUnit.MILLISECONDS);
|
||||
@@ -48,18 +49,25 @@ class PlayGo extends Thread {
|
||||
if (PlayMusic.PlayList.size() == 0) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.getMessage();
|
||||
if (ALLMusic.Side.NeedPlay()) {
|
||||
String obj = GetList.GetMusic();
|
||||
if (obj != null) {
|
||||
PlayMusic.isList = true;
|
||||
PlayMusic.AddMusic(obj, "空闲列表");
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
}
|
||||
} else {
|
||||
PlayMusic.NowPlayMusic = PlayMusic.PlayList.get(0);
|
||||
PlayMusic.PlayList.remove(0);
|
||||
PlayMusic.nowLyric = "";
|
||||
PlayMusic.haveLyric = false;
|
||||
PlayMusic.Lyric = null;
|
||||
PlayMusic.MusicNowTime = 0;
|
||||
PlayMusic.MusicAllTime = 0;
|
||||
close();
|
||||
PlayMusic.Lyric = null;
|
||||
PlayMusic.nowLyric = "";
|
||||
PlayMusic.haveLyric = false;
|
||||
ALLMusic.Side.SendLyric("");
|
||||
String songURL = Get.realURL(ALLMusic.Config.getMusic_Api1() + PlayMusic.NowPlayMusic.getID());
|
||||
String Lyric = Get.realData(ALLMusic.Config.getLyric_Api1() + PlayMusic.NowPlayMusic.getID());
|
||||
@@ -81,14 +89,18 @@ class PlayGo extends Thread {
|
||||
ALLMusic.Side.Send("[Play]" + songURL, true);
|
||||
try {
|
||||
while (PlayMusic.MusicAllTime > 0) {
|
||||
if (!ALLMusic.Side.NeedPlay()) {
|
||||
PlayMusic.MusicAllTime = 1;
|
||||
}
|
||||
if (PlayMusic.Vote_time > 0) {
|
||||
PlayMusic.Vote_time --;
|
||||
PlayMusic.Vote_time--;
|
||||
if (PlayMusic.Vote_time == 0) {
|
||||
PlayMusic.Vote.clear();
|
||||
ALLMusic.Side.bq("§d[ALLMusic]§2" + "切歌时间结束");
|
||||
} else {
|
||||
int players = ALLMusic.Side.GetAllPlayer();
|
||||
if (PlayMusic.Vote.size() >= ALLMusic.Config.getMinVote() || (players <= ALLMusic.Config.getMinVote() && players <= PlayMusic.Vote.size())) {
|
||||
if (PlayMusic.Vote.size() >= ALLMusic.Config.getMinVote() ||
|
||||
(players <= ALLMusic.Config.getMinVote() && players <= PlayMusic.Vote.size())) {
|
||||
ALLMusic.Side.bq("§d[ALLMusic]§2" + "已切歌");
|
||||
ALLMusic.Side.Send("[Stop]", false);
|
||||
PlayMusic.Vote.clear();
|
||||
@@ -102,10 +114,10 @@ class PlayGo extends Thread {
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
PlayMusic.MusicAllTime --;
|
||||
PlayMusic.MusicAllTime--;
|
||||
}
|
||||
close();
|
||||
} catch (InterruptedException e) {
|
||||
ALLMusic.log.warning("§d[ALLMusic]§c歌曲播放出现错误");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -5,16 +5,9 @@ import Color_yr.ALLMusic.Lyric.LyricDo;
|
||||
import Color_yr.ALLMusic.Song.GetInfo;
|
||||
import Color_yr.ALLMusic.Song.Info;
|
||||
import Color_yr.ALLMusic.Utils.logs;
|
||||
import javazoom.jl.decoder.Bitstream;
|
||||
import javazoom.jl.decoder.Header;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayMusic {
|
||||
|
||||
@@ -33,6 +26,8 @@ public class PlayMusic {
|
||||
|
||||
private static PlayGo PlayGo;
|
||||
|
||||
public static boolean isList = false;
|
||||
|
||||
public static void stop() {
|
||||
if (PlayGo != null && PlayGo.isAlive()) {
|
||||
PlayGo.close();
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package Color_yr.ALLMusic.PlayList;
|
||||
|
||||
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.getTrackIds()) {
|
||||
list.add(item.getId());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
class PlayList {
|
||||
private List<track> trackIds;
|
||||
|
||||
public List<track> getTrackIds() {
|
||||
return trackIds;
|
||||
}
|
||||
}
|
||||
|
||||
class track {
|
||||
private int id;
|
||||
|
||||
public String getId() {
|
||||
return String.valueOf(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package Color_yr.ALLMusic.PlayList;
|
||||
|
||||
import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.Http.Get;
|
||||
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(() ->
|
||||
{
|
||||
String data = Get.realData(ALLMusic.Config.getList_Api1() + ID);
|
||||
if (data != null)
|
||||
try {
|
||||
isUpdata = true;
|
||||
DataOBJ obj = new Gson().fromJson(data, DataOBJ.class);
|
||||
ALLMusic.Config.getPlayList().addAll(obj.getPlaylist());
|
||||
ALLMusic.Side.save();
|
||||
ALLMusic.log.info("§d[ALLMusic]§c歌曲列表" + ID + "获取成功");
|
||||
} 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 obj = null;
|
||||
if (ALLMusic.Config.isPlayListRandom()) {
|
||||
obj = ALLMusic.Config.getPlayList().get(new Random().nextInt(ALLMusic.Config.getPlayList().size() - 1));
|
||||
} else {
|
||||
obj = ALLMusic.Config.getPlayList().get(PlayNow);
|
||||
PlayNow = PlayNow == ALLMusic.Config.getPlayList().size() ? 0 : +1;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,19 @@
|
||||
package Color_yr.ALLMusic.Side;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISide {
|
||||
void Send(String player, String data, Boolean isplay);
|
||||
|
||||
void Send(String data, Boolean isplay);
|
||||
|
||||
int GetAllPlayer();
|
||||
|
||||
void SendLyric(String data);
|
||||
|
||||
void bq(String data);
|
||||
|
||||
void save();
|
||||
|
||||
boolean NeedPlay();
|
||||
}
|
||||
@@ -6,21 +6,24 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.Title;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static Color_yr.ALLMusic.Play.PlayMusic.NowPlay;
|
||||
import static Color_yr.ALLMusic.Play.PlayMusic.PlayList;
|
||||
|
||||
public class SideBC implements ISide {
|
||||
@Override
|
||||
public void Send(String data, String player, Boolean isplay) {
|
||||
Send(ProxyServer.getInstance().getPlayer(player), data, isplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Send(String data, Boolean isplay) {
|
||||
try {
|
||||
@@ -74,7 +77,23 @@ public class SideBC implements ISide {
|
||||
ALLMusicBC.save();
|
||||
}
|
||||
|
||||
private void Send(ProxiedPlayer players, String data,Boolean isplay) {
|
||||
@Override
|
||||
public boolean NeedPlay() {
|
||||
int online = GetAllPlayer();
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
if (ALLMusic.Config.getNoMusicPlayer().contains(player.getName())) {
|
||||
online--;
|
||||
} else {
|
||||
ServerInfo server = player.getServer().getInfo();
|
||||
if (server != null && ALLMusic.Config.getNoMusicServer().contains(server.getName())) {
|
||||
online--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return online > 0;
|
||||
}
|
||||
|
||||
private void Send(ProxiedPlayer players, String data, Boolean isplay) {
|
||||
try {
|
||||
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
|
||||
ByteBuf buf = Unpooled.buffer(bytes.length + 1);
|
||||
|
||||
@@ -4,13 +4,15 @@ import Color_yr.ALLMusic.ALLMusic;
|
||||
import Color_yr.ALLMusic.ALLMusicBukkit;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.server.v1_12_R1.*;
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static Color_yr.ALLMusic.ALLMusicBukkit.ALLMusicP;
|
||||
import static Color_yr.ALLMusic.Play.PlayMusic.NowPlay;
|
||||
@@ -64,6 +66,17 @@ public class SideBukkit implements ISide {
|
||||
ALLMusicBukkit.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean NeedPlay() {
|
||||
int online = GetAllPlayer();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (ALLMusic.Config.getNoMusicPlayer().contains(player.getName())) {
|
||||
online--;
|
||||
}
|
||||
}
|
||||
return online > 0;
|
||||
}
|
||||
|
||||
private void Send(Player players, String data, Boolean isplay) {
|
||||
try {
|
||||
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
@@ -10,12 +10,11 @@ import java.util.Date;
|
||||
|
||||
public class logs {
|
||||
public static File file;
|
||||
private static FileWriter fw;
|
||||
private static Date date = new Date();
|
||||
|
||||
public static void log_write(String text) {
|
||||
try {
|
||||
fw = new FileWriter(file, true);
|
||||
FileWriter fw = new FileWriter(file, true);
|
||||
String year = String.format("%tF", date);
|
||||
String time = String.format("%tT", date);
|
||||
String write = "[" + year + "]" + "[" + time + "]" + text;
|
||||
@@ -30,4 +29,11 @@ public class logs {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void Init(File Dir) throws IOException {
|
||||
file = new File(Dir, "logs.log");
|
||||
if (!logs.file.exists()) {
|
||||
logs.file.createNewFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
name: ALLMusic
|
||||
main: Color_yr.ALLMusic.ALLMusicBC
|
||||
author: Color_yr
|
||||
version: 1.4.0
|
||||
version: 1.5.0
|
||||
@@ -2,6 +2,7 @@
|
||||
"Music_Api1": "http://music.163.com/song/media/outer/url?id=",
|
||||
"Lyric_Api1": "https://api.imjad.cn/cloudmusic/?type=lyric&id=",
|
||||
"Info_Api1": "https://api.imjad.cn/cloudmusic/?type=detail&id=",
|
||||
"List_Api1": "https://api.imjad.cn/cloudmusic/?type=playlist&id=",
|
||||
"MaxList": 10,
|
||||
"MinVote": 3,
|
||||
"Delay": 2,
|
||||
@@ -9,5 +10,8 @@
|
||||
"NoMusicServer": [],
|
||||
"NoMusicPlayer": [],
|
||||
"BanMusic": [],
|
||||
"Version": "1.4.0"
|
||||
"PlayList": [],
|
||||
"PlayListSwitch": true,
|
||||
"PlayListRandom": true,
|
||||
"Version": "1.5.0"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
name: ALLMusic
|
||||
main: Color_yr.ALLMusic.ALLMusicBukkit
|
||||
author: Color_yr
|
||||
version: 1.4.0
|
||||
version: 1.5.0
|
||||
|
||||
commands:
|
||||
music:
|
||||
|
||||
Reference in new issue
Block a user