mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-20 22:42:14 +00:00
change
增加手机版链接支持
This commit is contained in:
1 parent
f5c2d2d2e5
commit
db426dcace
4 files changed
+29
-33
No files matched your search
@@ -20,7 +20,7 @@ import static Color_yr.ALLmusic.PlayMusic.PlayMusic_Start;
|
||||
|
||||
public class ALLmusic_BC extends Plugin {
|
||||
|
||||
public static final String Version = "1.1.0";
|
||||
private static final String Version = "1.1.0";
|
||||
|
||||
public static int Maxlist = 0;
|
||||
public static int min_vote = 0;
|
||||
@@ -57,7 +57,7 @@ public class ALLmusic_BC extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfig() {
|
||||
void setConfig() {
|
||||
try {
|
||||
if(FileName == null) {
|
||||
FileName = new File(getDataFolder(), "config.yml");
|
||||
|
||||
@@ -30,16 +30,14 @@ public class PlayMusic {
|
||||
|
||||
private static Thread playgo = new playgo();
|
||||
|
||||
public static void PlayMusic_Start() {
|
||||
static void PlayMusic_Start() {
|
||||
playgo.start();
|
||||
}
|
||||
|
||||
public static void SendToPlayer(String data) {
|
||||
static void SendToPlayer(String data) {
|
||||
Collection<ProxiedPlayer> values = ProxyServer.getInstance().getPlayers();
|
||||
Iterator<ProxiedPlayer> iterator = values.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ProxiedPlayer players = iterator.next();
|
||||
if(!ALLmusic_BC.server.contains(players.getServer().getInfo().getName())) {
|
||||
for (ProxiedPlayer players : values) {
|
||||
if (!ALLmusic_BC.server.contains(players.getServer().getInfo().getName())) {
|
||||
if (stop.containsKey(players.getName())) {
|
||||
if (!stop.get(players.getName()).equalsIgnoreCase("true"))
|
||||
players.sendData("AudioBuffer", data.getBytes());
|
||||
@@ -49,16 +47,16 @@ public class PlayMusic {
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendToOnePlayer(String data, String Player) {
|
||||
static void SendToOnePlayer(String data, String Player) {
|
||||
try {
|
||||
ProxiedPlayer players = ProxyServer.getInstance().getPlayer(Player);
|
||||
players.sendData("AudioBuffer", data.getBytes());
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int Music_Time(String music) {
|
||||
static int Music_Time(String music) {
|
||||
try {
|
||||
URL urlfile = new URL(music);
|
||||
URLConnection con = urlfile.openConnection();
|
||||
@@ -68,13 +66,13 @@ public class PlayMusic {
|
||||
Header h = bt.readFrame();
|
||||
int time = (int) h.total_ms(b);
|
||||
return time / 1000;
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
} catch (Exception ignored) {
|
||||
ignored.getMessage();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String realURL(String path) {
|
||||
static String realURL(String path) {
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
try {
|
||||
@@ -101,7 +99,7 @@ public class PlayMusic {
|
||||
|
||||
class playgo extends Thread {
|
||||
|
||||
public static void music_list() {
|
||||
private static void music_list() {
|
||||
String a;
|
||||
if (PlayMusic.playlist.size() == 1) {
|
||||
a = PlayMusic.playlist.get(1);
|
||||
|
||||
@@ -12,16 +12,16 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class command extends Command {
|
||||
|
||||
public command() {
|
||||
command() {
|
||||
super("music");
|
||||
}
|
||||
|
||||
public boolean isInteger(String str) {
|
||||
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
|
||||
private boolean isInteger(String str) {
|
||||
Pattern pattern = Pattern.compile("^[-+]?[\\d]*$");
|
||||
return pattern.matcher(str).matches();
|
||||
}
|
||||
|
||||
public String get_string(String a, String b, String c) {
|
||||
private String get_string(String a, String b, String c) {
|
||||
int x = a.indexOf(b) + b.length();
|
||||
int y;
|
||||
if (c != null)
|
||||
@@ -30,21 +30,26 @@ public class command extends Command {
|
||||
return a.substring(x, y);
|
||||
}
|
||||
|
||||
public void add_music(CommandSender sender, String[] args) {
|
||||
private void add_music(CommandSender sender, String[] args) {
|
||||
|
||||
String music_id;
|
||||
if (args[0].indexOf("id=") != -1) {
|
||||
if (args[0].indexOf("&user") != -1)
|
||||
if (args[0].contains("id=")) {
|
||||
if (args[0].contains("&user"))
|
||||
music_id = get_string(args[0], "id=", "&user");
|
||||
else
|
||||
music_id = get_string(args[0], "id=", null);
|
||||
} else if (args[0].contains("song/")) {
|
||||
if (args[0].contains("/?userid"))
|
||||
music_id = get_string(args[0], "song/", "/?userid");
|
||||
else
|
||||
music_id = get_string(args[0], "song/", null);
|
||||
} else
|
||||
music_id = args[0];
|
||||
if (isInteger(music_id)) {
|
||||
if (PlayMusic.playlist.size() == ALLmusic_BC.Maxlist) {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,队列已满"));
|
||||
return;
|
||||
} else if (ALLmusic_BC.Banconfig.getBoolean(music_id, false) == true) {
|
||||
} else if (ALLmusic_BC.Banconfig.getBoolean(music_id, false)) {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,这首歌被禁点了"));
|
||||
} else if (PlayMusic.playlist.containsValue(music_id)) {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,这首歌已经在队列了"));
|
||||
@@ -73,7 +78,6 @@ public class command extends Command {
|
||||
String name = sender.getName();
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请使用/music help 获取帮助"));
|
||||
return;
|
||||
} else if (args[0].equalsIgnoreCase("help")) {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2帮助手册"));
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music [音乐ID] 来点歌"));
|
||||
@@ -81,7 +85,6 @@ public class command extends Command {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music list 查看歌曲队列"));
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music vote 投票切歌"));
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music nomusic 不再参与点歌"));
|
||||
return;
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
PlayMusic.SendToOnePlayer("[Stop]", name);
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已停止" + name + "的音乐播放"));
|
||||
@@ -148,7 +151,6 @@ public class command extends Command {
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2请输入有效的ID"));
|
||||
return;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2
|
||||
&& ALLmusic_BC.Admin.contains(name)) {
|
||||
@@ -176,11 +178,9 @@ public class command extends Command {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已删除" + music));
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2找不到" + music));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic]§2请输入有效的ID"));
|
||||
return;
|
||||
}
|
||||
} else
|
||||
add_music(sender, args);
|
||||
|
||||
@@ -7,10 +7,10 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Date;
|
||||
|
||||
public class logs {
|
||||
public static File file;
|
||||
class logs {
|
||||
static File file;
|
||||
|
||||
public void log_write(String text) {
|
||||
void log_write(String text) {
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
fw = new FileWriter(file, true);
|
||||
@@ -24,8 +24,6 @@ public class logs {
|
||||
fw.flush();
|
||||
pw.close();
|
||||
fw.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
ALLmusic_BC.log.warning("§d[ALLmusic_BC]§c日志文件写入失败" + e);
|
||||
} catch (IOException e) {
|
||||
ALLmusic_BC.log.warning("§d[ALLmusic_BC]§c日志文件写入失败" + e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user