mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-21 09:12:16 +00:00
脱离子服
This commit is contained in:
1 parent
6079a3302a
commit
363276e715
4 files changed
+21
-56
No files matched your search
@@ -68,8 +68,6 @@ public class ALLmusic_BC extends Plugin {
|
||||
setConfig();
|
||||
reloadConfig();
|
||||
PlayMusic_Start();
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(this, new ChannelListener());
|
||||
ProxyServer.getInstance().registerChannel("ALLmusic_BC");
|
||||
ProxyServer.getInstance().getPluginManager().registerCommand(this, new command());
|
||||
log.info("§d[ALLmusic_BC]§e已启动-" + Version);;
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package Color_yr.ALLmusic;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChannelListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent e) {
|
||||
if (e.getTag().equalsIgnoreCase("ALLmusic")) {
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(e.getData()));
|
||||
try {
|
||||
String channel = in.readUTF(); // channel we delivered
|
||||
if (channel.equals("get")) {
|
||||
ServerInfo server = ProxyServer.getInstance().getPlayer(e.getReceiver().toString()).getServer().getInfo();
|
||||
String input = in.readUTF(); // the inputstring
|
||||
if (input.equals("test")) {
|
||||
}
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendToBukkit(String channel, String message) {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(stream);
|
||||
try {
|
||||
out.writeUTF(channel);
|
||||
out.writeUTF(message);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, ServerInfo> Server = ProxyServer.getInstance().getServers();
|
||||
Collection<ServerInfo> values = Server.values();
|
||||
Iterator<ServerInfo> iterator = values.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ServerInfo server = iterator.next();
|
||||
server.sendData("ALLmusic", stream.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package Color_yr.ALLmusic;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -12,7 +13,10 @@ import javazoom.jl.decoder.Bitstream;
|
||||
import javazoom.jl.decoder.BitstreamException;
|
||||
import javazoom.jl.decoder.Header;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
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 java.util.Map;
|
||||
|
||||
@@ -28,6 +32,20 @@ public class PlayMusic {
|
||||
playgo.start();
|
||||
}
|
||||
|
||||
public static void SendToPlayer(String data)
|
||||
{
|
||||
Collection<ProxiedPlayer> values = ProxyServer.getInstance().getPlayers();
|
||||
Iterator<ProxiedPlayer> iterator = values.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ProxiedPlayer players = iterator.next();
|
||||
players.sendData("AudioBuffer", data.getBytes());
|
||||
}
|
||||
}
|
||||
public static void SendToOnePlayer(String data, String Player)
|
||||
{
|
||||
ProxiedPlayer players = ProxyServer.getInstance().getPlayer(Player);
|
||||
players.sendData("AudioBuffer", data.getBytes());
|
||||
}
|
||||
public static int Music_Time(String music) {
|
||||
try {
|
||||
URL urlfile = new URL(music);
|
||||
@@ -100,8 +118,8 @@ class playgo extends Thread {
|
||||
String song = PlayMusic.realURL("http://music.163.com/song/media/outer/url?id=" + playsong);
|
||||
if(song!=null) {
|
||||
int Music_time = PlayMusic.Music_Time(song);
|
||||
ChannelListener.sendToBukkit("play", playsong);
|
||||
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "正在播放歌曲" + playsong));
|
||||
PlayMusic.SendToPlayer("[Net]" +song);
|
||||
PlayMusic.playlist.remove("0");
|
||||
music_list();
|
||||
try {
|
||||
@@ -112,7 +130,7 @@ class playgo extends Thread {
|
||||
PlayMusic.Vote_time--;
|
||||
if (PlayMusic.Vote.size() >= ProxyServer.getInstance().getOnlineCount()) {
|
||||
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "已切歌"));
|
||||
ChannelListener.sendToBukkit("stopALL", "");
|
||||
PlayMusic.SendToPlayer("[Stop]");
|
||||
Music_time = 0;
|
||||
if (PlayMusic.All_music == 0) {
|
||||
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic_BC]§2" + "队列中无歌曲"));
|
||||
|
||||
@@ -46,7 +46,7 @@ public class command extends Command {
|
||||
return;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
ChannelListener.sendToBukkit("stop", sender.getName());
|
||||
PlayMusic.SendToOnePlayer("[Stop]",sender.getName());
|
||||
sender.sendMessage(new TextComponent("§d[ALLmusic_BC]§2已停止" + sender.getName() + "的音乐播放"));
|
||||
} else if (args[0].equalsIgnoreCase("now")) {
|
||||
if (PlayMusic.playlist.size() == 0) {
|
||||
|
||||
Reference in new issue
Block a user