更新1.1.0

新增指令delete ban
新增管理名单
新增不点歌服务器
This commit is contained in:
Color_yr committed 2019-08-22 23:20:11 +08:00
1 parent bf1f9b94a9
commit 27fa878d43
5 files changed
+99 -48

No files matched your search

@@ -10,7 +10,9 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
@@ -18,7 +20,7 @@ import static Color_yr.ALLmusic.PlayMusic.PlayMusic_Start;
public class ALLmusic_BC extends Plugin {
public static String Version = "1.0.0";
public static final String Version = "1.1.0";
public static int Maxlist = 0;
public static int min_vote = 0;
@@ -30,9 +32,12 @@ public class ALLmusic_BC extends Plugin {
public static Configuration Banconfig;
public static File BanFileName;
public static List<String> Admin = new ArrayList<String>();
public static List<String> server = new ArrayList<String>();
public static Logger log = ProxyServer.getInstance().getLogger();
public void loadconfig() {
private void loadconfig() {
ProxyServer.getInstance().getLogger().info("§d[ALLmusic]§e当前插件版本为:" + Version
+ ",你的配置文件版本为:" + config.getString("Version"));
@@ -40,6 +45,9 @@ public class ALLmusic_BC extends Plugin {
min_vote = config.getInt("min_vote", 3);
Music_Api1 = config.getString("Music_Api1", "http://music.163.com/song/media/outer/url?id=");
Admin = config.getStringList("Admin");
server = config.getStringList("nomusic_server");
Configuration a = config.getSection("nomusic");
Collection<String> b = a.getKeys();
for (String c : b) {
@@ -49,42 +57,31 @@ public class ALLmusic_BC extends Plugin {
}
}
private void reloadConfig() {
public void setConfig() {
try {
if(FileName == null) {
FileName = new File(getDataFolder(), "config.yml");
BanFileName = new File(getDataFolder(), "banlist.yml");
logs.file = new File(getDataFolder(), "logs.log");
if (!getDataFolder().exists())
getDataFolder().mkdir();
if (!FileName.exists()) {
InputStream in = getResourceAsStream("config.yml");
Files.copy(in, FileName.toPath());
in = getResourceAsStream("banlist.yml");
Files.copy(in, BanFileName.toPath());
}
if (!logs.file.exists()) {
logs.file.createNewFile();
}
}
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(FileName);
Banconfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(BanFileName);
loadconfig();
} catch (Exception arg0) {
log.warning("§d[ALLmusic_BC]§c配置文件读取失败:" + arg0);
}
}
public void setConfig() {
FileName = new File(getDataFolder(), "config.yml");
BanFileName = new File(getDataFolder(), "banlist.yml");
logs.file = new File(getDataFolder(), "logs.log");
if (!getDataFolder().exists())
getDataFolder().mkdir();
if (!FileName.exists()) {
try (InputStream in = getResourceAsStream("config.yml")) {
Files.copy(in, FileName.toPath());
} catch (IOException e) {
log.warning("§d[ALLmusic]§c配置文件创建失败:" + e);
}
try (InputStream in = getResourceAsStream("banlist.yml")) {
Files.copy(in, BanFileName.toPath());
} catch (IOException e) {
log.warning("§d[ALLmusic]§c禁用列表创建失败:" + e);
}
}
try {
if (!logs.file.exists()) {
logs.file.createNewFile();
}
} catch (IOException e) {
log.warning("§d[ALLmusic]§c日志文件错误:" + e);
}
reloadConfig();
}
@Override
@@ -39,11 +39,13 @@ public class PlayMusic {
Iterator<ProxiedPlayer> iterator = values.iterator();
while (iterator.hasNext()) {
ProxiedPlayer players = iterator.next();
if (stop.containsKey(players.getName())) {
if (!stop.get(players.getName()).equalsIgnoreCase("true"))
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());
} else
players.sendData("AudioBuffer", data.getBytes());
} else
players.sendData("AudioBuffer", data.getBytes());
}
}
}
+60 -12
View File
@@ -7,7 +7,6 @@ import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.util.Iterator;
import java.util.Map;
import java.util.regex.Pattern;
@@ -71,6 +70,7 @@ public class command extends Command {
}
public void execute(CommandSender sender, String[] args) {
String name = sender.getName();
if (args.length == 0) {
sender.sendMessage(new TextComponent("§d[ALLmusic]§c错误,请使用/music help 获取帮助"));
return;
@@ -83,8 +83,8 @@ public class command extends Command {
sender.sendMessage(new TextComponent("§d[ALLmusic]§2使用/music nomusic 不再参与点歌"));
return;
} else if (args[0].equalsIgnoreCase("stop")) {
PlayMusic.SendToOnePlayer("[Stop]", sender.getName());
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已停止" + sender.getName() + "的音乐播放"));
PlayMusic.SendToOnePlayer("[Stop]", name);
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已停止" + name + "的音乐播放"));
} else if (args[0].equalsIgnoreCase("list")) {
if (PlayMusic.now_music == null) {
sender.sendMessage(new TextComponent("§d[ALLmusic]§2无正在播放的歌曲"));
@@ -105,28 +105,28 @@ public class command extends Command {
} else if (PlayMusic.Vote_time == 0) {
PlayMusic.Vote_time = 30;
PlayMusic.Vote.clear();
PlayMusic.Vote.add(sender.getName());
PlayMusic.Vote.add(name);
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已发起切歌投票"));
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + sender.getName() +
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + name +
"发起了切歌投票,30秒后结束,输入/music vote 同意切歌。"));
} else if (PlayMusic.Vote_time > 0) {
if (!PlayMusic.Vote.contains(sender.getName())) {
PlayMusic.Vote.add(sender.getName());
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + sender.getName() + "同意切歌,共有" +
if (!PlayMusic.Vote.contains(name)) {
PlayMusic.Vote.add(name);
ProxyServer.getInstance().broadcast(new TextComponent("§d[ALLmusic]§2" + name + "同意切歌,共有" +
PlayMusic.Vote.size() + "名玩家同意切歌。"));
}
}
} else if (args[0].equalsIgnoreCase("reload")) {
ALLmusic_BC music = new ALLmusic_BC();
music.loadconfig();
music.setConfig();
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已重读配置文件"));
} else if (args[0].equalsIgnoreCase("next") && sender.hasPermission("ALLmusic.admin")) {
} else if (args[0].equalsIgnoreCase("next") && ALLmusic_BC.Admin.contains(name)) {
PlayMusic.Music_time = 1;
PlayMusic.SendToPlayer("[Stop]");
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已强制切歌"));
} else if (args[0].equalsIgnoreCase("nomusic")) {
PlayMusic.stop.put(sender.getName(), "true");
PlayMusic.SendToOnePlayer("[Stop]", sender.getName());
PlayMusic.stop.put(name, "true");
PlayMusic.SendToOnePlayer("[Stop]", name);
sender.sendMessage(new TextComponent("§d[ALLmusic]§2你不会再收到点歌了!想要再次参与点歌就点一首歌吧!"));
ALLmusic_BC.config.set("nomusic", PlayMusic.stop);
try {
@@ -135,7 +135,55 @@ public class command extends Command {
logs log = new logs();
log.log_write(e.getMessage());
}
} else if (args[0].equalsIgnoreCase("ban") && args.length == 2
&& ALLmusic_BC.Admin.contains(name)) {
if (isInteger(args[1])) {
ALLmusic_BC.Banconfig.set(args[1], "true");
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(ALLmusic_BC.Banconfig, ALLmusic_BC.BanFileName);
sender.sendMessage(new TextComponent("§d[ALLmusic]§2已禁止" + args[1]));
} catch (Exception e) {
logs log = new logs();
log.log_write(e.getMessage());
}
} else {
sender.sendMessage(new TextComponent("§d[ALLmusic]§2请输入有效的ID"));
return;
}
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2
&& ALLmusic_BC.Admin.contains(name)) {
if (isInteger(args[1])) {
String music = args[1];
if (PlayMusic.playlist.containsValue(music)) {
String a;
if (PlayMusic.playlist.size() == 1) {
PlayMusic.playlist.remove(1);
} else if (PlayMusic.playlist.size() > 1) {
int i = 0;
for (Map.Entry<Integer, String> b : PlayMusic.playlist.entrySet()) {
if (b.getValue().equalsIgnoreCase(music))
break;
else
i++;
}
for (; PlayMusic.playlist.size() - 1 > i; i++) {
a = PlayMusic.playlist.get(i + 1);
PlayMusic.playlist.put(i, a);
}
PlayMusic.playlist.remove(i);
}
PlayMusic.All_music = PlayMusic.playlist.size();
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);
}
}