mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-21 20:52:31 +00:00
up mod
This commit is contained in:
1 parent
2fc536e7de
commit
1aa446f93f
47 files changed
+101
-528
No files matched your search
@@ -195,10 +195,12 @@ Forge/Fabric/NeoForge类服务器
|
||||
- addMusicCost 点歌花费
|
||||
- useCost 启用花费
|
||||
- sendDelay Hud信息更新延迟
|
||||
- defaultApi 默认音乐API
|
||||
|
||||
## 指令说明
|
||||
普通玩家指令
|
||||
- /music [音乐ID/网易云分享链接] 点歌
|
||||
- /music [音乐API] [音乐ID] 点歌
|
||||
- /music stop 停止播放歌曲
|
||||
- /music list 查看歌曲队列
|
||||
- /music cancel [序号] 取消你的点歌
|
||||
@@ -209,6 +211,7 @@ Forge/Fabric/NeoForge类服务器
|
||||
- /music mute 不再参与点歌,再输入一次恢复
|
||||
- /music mute list 不接收空闲列表点歌,再输入一次恢复
|
||||
- /music search [歌名] 搜索歌曲
|
||||
- /music search [音乐API] [歌名] 搜索歌曲
|
||||
- /music select [序列] 选择歌曲
|
||||
- /music nextpage 切换下一页歌曲搜索结果
|
||||
- /music lastpage 切换上一页歌曲搜索结果
|
||||
@@ -233,16 +236,18 @@ Forge/Fabric/NeoForge类服务器
|
||||
- /music reload 重读配置文件
|
||||
- /music next 强制切歌
|
||||
- /music ban [ID] 禁止点这首歌
|
||||
- /music ban [音乐API] [ID] 禁止点这首歌
|
||||
- /music unban [ID] 解禁点这首歌
|
||||
- /music unban [音乐API] [ID] 解禁点这首歌
|
||||
- /music banplayer [ID] 禁止某位玩家点歌
|
||||
- /music unbanplayer [ID] 解禁某位玩家点歌
|
||||
- /music url [url] 播放一首自定义歌曲
|
||||
- /music delete [序号] 删除队列中的歌曲
|
||||
- /music addlist [歌单ID] 添加歌单到空闲列表
|
||||
- /music clearlist 清空空闲歌单
|
||||
- /music clearban 清空禁止点歌列表
|
||||
- /music clearbanplayer 清空禁止点歌玩家列表
|
||||
- /music test [ID] 测试歌曲内容解析
|
||||
- /music test [音乐API] [ID] 测试歌曲内容解析
|
||||
|
||||
若开启权限后
|
||||
- 点歌需要权限`allmusic.addmusic`
|
||||
|
||||
+1
-1
Submodule client updated: f418e3a1f6...eb707c18ea.
@@ -27,6 +27,6 @@ public class CommandSearchApi extends ACommand {
|
||||
}
|
||||
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().search.startSearch);
|
||||
CommandEX.searchMusicApi(sender, name, args,false);
|
||||
CommandEX.searchMusicApi(sender, name, args, false);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class MusicSearch {
|
||||
IMusicApi api = AllMusic.MUSIC_APIS.get(obj.api);
|
||||
if (api == null) {
|
||||
AllMusic.side.sendMessageTask(obj.sender, AllMusic.getMessage().musicPlay.error2);
|
||||
return;
|
||||
}
|
||||
SearchPageObj search = api.search(obj.args, obj.isDefault);
|
||||
if (search == null)
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CommandFabric implements Command<ServerCommandSource>, Predicate<Se
|
||||
String remaining = builder.getRemaining().trim();
|
||||
|
||||
for (String s : results) {
|
||||
if (s.startsWith(remaining)){
|
||||
if (s.startsWith(remaining)) {
|
||||
builder.suggest(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.coloryr.allmusic.server;
|
||||
import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.mixin.IGetCommandOutput;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
import com.coloryr.allmusic.server.event.MusicPlayEvent;
|
||||
import com.coloryr.allmusic.server.mixin.IGetCommandOutput;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
@@ -160,7 +160,7 @@ public class SideFabric extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
ServerCommandSource sender = (ServerCommandSource) obj;
|
||||
ServerPlayerEntity entity = null;
|
||||
if (sender.getEntity() instanceof ServerPlayerEntity) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -20,5 +20,5 @@ public interface MusicAddEvent {
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
ActionResult interact(ServerPlayerEntity player, MusicObj music);
|
||||
ActionResult interact(ServerPlayerEntity player, PlayerAddMusicObj music);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
public interface IGetCommandOutput {
|
||||
@Accessor(value = "output")
|
||||
CommandOutput getOutput();
|
||||
|
||||
@Accessor(value = "silent")
|
||||
boolean getSilent();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.coloryr.allmusic.server;
|
||||
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CommandFabric implements Command<ServerCommandSource>, Predicate<Se
|
||||
String remaining = builder.getRemaining().trim();
|
||||
|
||||
for (String s : results) {
|
||||
if (s.startsWith(remaining)){
|
||||
if (s.startsWith(remaining)) {
|
||||
builder.suggest(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.coloryr.allmusic.server;
|
||||
import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -154,7 +154,7 @@ public class SideFabric extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
ServerCommandSource source = (ServerCommandSource) obj;
|
||||
return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != ActionResult.PASS;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -20,5 +20,5 @@ public interface MusicAddEvent {
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
ActionResult interact(ServerPlayerEntity player, MusicObj music);
|
||||
ActionResult interact(ServerPlayerEntity player, PlayerAddMusicObj music);
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.codec.MusicPack;
|
||||
import com.coloryr.allmusic.comm.MusicCodec;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -154,7 +154,7 @@ public class SideFabric extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
ServerCommandSource source = (ServerCommandSource) obj;
|
||||
return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != ActionResult.PASS;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -20,5 +20,5 @@ public interface MusicAddEvent {
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
ActionResult interact(ServerPlayerEntity player, MusicObj music);
|
||||
ActionResult interact(ServerPlayerEntity player, PlayerAddMusicObj music);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.coloryr.allmusic.server;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.codec.MusicPack;
|
||||
import com.coloryr.allmusic.comm.MusicCodec;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -153,7 +153,7 @@ public class SideFabric extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
CommandSourceStack source = (CommandSourceStack) obj;
|
||||
return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -20,5 +20,5 @@ public interface MusicAddEvent {
|
||||
return InteractionResult.PASS;
|
||||
});
|
||||
|
||||
InteractionResult interact(ServerPlayer player, MusicObj music);
|
||||
InteractionResult interact(ServerPlayer player, PlayerAddMusicObj music);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.coloryr.allmusic.server;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.codec.MusicPack;
|
||||
import com.coloryr.allmusic.comm.MusicCodec;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -152,7 +152,7 @@ public class SideFabric extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
ServerCommandSource source = (ServerCommandSource) obj;
|
||||
return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != ActionResult.PASS;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -20,5 +20,5 @@ public interface MusicAddEvent {
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
ActionResult interact(PlayerEntity player, MusicObj music);
|
||||
ActionResult interact(PlayerEntity player, PlayerAddMusicObj music);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.coloryr.allmusic.server;
|
||||
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.music.play.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.music.play.TopLyricSave;
|
||||
import com.coloryr.allmusic.server.core.music.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.music.TopLyricSave;
|
||||
import com.coloryr.allmusic.server.core.objs.music.TopSongInfoObj;
|
||||
import com.coloryr.allmusic.server.hooks.AllMusicPAPI;
|
||||
import com.coloryr.allmusic.server.hooks.VaultHook;
|
||||
@@ -16,7 +16,6 @@ public class AllMusicFolia extends JavaPlugin {
|
||||
public static AllMusicPAPI PAPI;
|
||||
public static boolean spigotSet;
|
||||
private static PluginMessage pluginMessage;
|
||||
private static MetricsFolia metricsFolia;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -85,14 +84,11 @@ public class AllMusicFolia extends JavaPlugin {
|
||||
Bukkit.getPluginManager().registerEvents(new ListenerFolia(), this);
|
||||
AllMusic.start();
|
||||
}
|
||||
|
||||
metricsFolia = new MetricsFolia(this, 6720);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
AllMusic.isRun = false;
|
||||
metricsFolia.shutdown();
|
||||
if (AllMusic.getConfig().topPAPI)
|
||||
pluginMessage.stop();
|
||||
else
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.coloryr.allmusic.server;
|
||||
|
||||
import com.coloryr.allmusic.server.bstats.MetricsBase;
|
||||
import com.coloryr.allmusic.server.bstats.charts.CustomChart;
|
||||
import com.coloryr.allmusic.server.bstats.json.JsonObjectBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MetricsFolia {
|
||||
|
||||
private final Plugin plugin;
|
||||
private final MetricsBase metricsBase;
|
||||
|
||||
/**
|
||||
* Creates a new Metrics instance.
|
||||
*
|
||||
* @param plugin Your plugin instance.
|
||||
* @param serviceId The id of the service.
|
||||
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||
*/
|
||||
public MetricsFolia(JavaPlugin plugin, int serviceId) {
|
||||
this.plugin = plugin;
|
||||
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
if (!config.isSet("serverUuid")) {
|
||||
config.addDefault("enabled", true);
|
||||
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
config.addDefault("logFailedRequests", false);
|
||||
config.addDefault("logSentData", false);
|
||||
config.addDefault("logResponseStatusText", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options().header(
|
||||
"bStats (https://bStats.org) collects some basic information for plugin authors, like how\n" +
|
||||
"many people use their plugin and their total player count. It's recommended to keep bStats\n" +
|
||||
"enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n" +
|
||||
"performance penalty associated with having metrics enabled, and data sent to bStats is fully\n" +
|
||||
"anonymous."
|
||||
).copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
// Load the data
|
||||
boolean enabled = config.getBoolean("enabled", true);
|
||||
String serverUUID = config.getString("serverUuid");
|
||||
boolean logErrors = config.getBoolean("logFailedRequests", false);
|
||||
boolean logSentData = config.getBoolean("logSentData", false);
|
||||
boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false);
|
||||
|
||||
metricsBase = new MetricsBase(
|
||||
"bukkit",
|
||||
serverUUID,
|
||||
serviceId,
|
||||
enabled,
|
||||
this::appendPlatformData,
|
||||
this::appendServiceData,
|
||||
submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
|
||||
plugin::isEnabled,
|
||||
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
|
||||
(message) -> this.plugin.getLogger().log(Level.INFO, message),
|
||||
logErrors,
|
||||
logSentData,
|
||||
logResponseStatusText
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the underlying scheduler service.
|
||||
*/
|
||||
public void shutdown() {
|
||||
metricsBase.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
metricsBase.addCustomChart(chart);
|
||||
}
|
||||
|
||||
private void appendPlatformData(JsonObjectBuilder builder) {
|
||||
builder.appendField("playerAmount", getPlayerAmount());
|
||||
builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0);
|
||||
builder.appendField("bukkitVersion", Bukkit.getVersion());
|
||||
builder.appendField("bukkitName", Bukkit.getName());
|
||||
|
||||
builder.appendField("javaVersion", System.getProperty("java.version"));
|
||||
builder.appendField("osName", System.getProperty("os.name"));
|
||||
builder.appendField("osArch", System.getProperty("os.arch"));
|
||||
builder.appendField("osVersion", System.getProperty("os.version"));
|
||||
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
private void appendServiceData(JsonObjectBuilder builder) {
|
||||
builder.appendField("pluginVersion", plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
private int getPlayerAmount() {
|
||||
try {
|
||||
// Around MC 1.8 the return type was changed from an array to a collection,
|
||||
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
return onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
return Bukkit.getOnlinePlayers().size(); // Just use the new method if the reflection failed
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.coloryr.allmusic.server;
|
||||
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.music.play.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.music.play.TopLyricSave;
|
||||
import com.coloryr.allmusic.server.core.music.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.music.TopLyricSave;
|
||||
import com.coloryr.allmusic.server.core.objs.music.TopSongInfoObj;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -178,7 +179,7 @@ public class SideFolia extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
//不要改这个,有事件在其他线程触发
|
||||
MusicAddEvent event = new MusicAddEvent(music, (CommandSender) obj);
|
||||
Bukkit.getGlobalRegionScheduler().execute(AllMusicFolia.plugin, ()->{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
@@ -15,7 +16,7 @@ public class MusicAddEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
@@ -25,38 +26,16 @@ public class MusicAddEvent extends Event implements Cancellable {
|
||||
*/
|
||||
private boolean cancel = false;
|
||||
|
||||
public MusicAddEvent(MusicObj id, CommandSender player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, CommandSender player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件是否被取消
|
||||
*
|
||||
* @return 是否被取消
|
||||
* @deprecated 请使用 {@link #isCancelled()}
|
||||
*/
|
||||
@Deprecated(since = "3.3.1")
|
||||
public boolean isCancel() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置事件是否被取消
|
||||
*
|
||||
* @param cancel 是否取消事件
|
||||
* @deprecated 请使用 {@link #setCancelled(boolean)}
|
||||
*/
|
||||
@Deprecated(since = "3.3.1")
|
||||
public void setCancel(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
public CommandSender getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.coloryr.allmusic.server.hooks;
|
||||
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.music.play.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.music.PlayMusic;
|
||||
import com.coloryr.allmusic.server.PluginMessage;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -165,7 +166,7 @@ public class SideForge extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
MusicAddEvent event = new MusicAddEvent(music, (ICommandSender) obj);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
@@ -10,13 +11,13 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
private final ICommandSender player;
|
||||
|
||||
public MusicAddEvent(MusicObj id, ICommandSender player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, ICommandSender player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -25,7 +26,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.coloryr.allmusic.server;
|
||||
import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -161,7 +161,7 @@ public class SideForge extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
MusicAddEvent event = new MusicAddEvent(music, (CommandSource) obj);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -10,13 +10,13 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
private final CommandSource player;
|
||||
|
||||
public MusicAddEvent(MusicObj id, CommandSource player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, CommandSource player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.coloryr.allmusic.server;
|
||||
import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -157,7 +157,7 @@ public class SideForge extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
CommandSourceStack sender = (CommandSourceStack) obj;
|
||||
ServerPlayer serverPlayer = null;
|
||||
if (sender.getEntity() instanceof ServerPlayer player) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -10,13 +10,13 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
private final ServerPlayer player;
|
||||
|
||||
public MusicAddEvent(MusicObj id, ServerPlayer player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, ServerPlayer player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.coloryr.allmusic.server;
|
||||
import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -167,7 +167,7 @@ public class SideForge extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
MusicAddEvent event = new MusicAddEvent(music, (ICommandSender) obj);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
@@ -10,13 +10,13 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
private final ICommandSender player;
|
||||
|
||||
public MusicAddEvent(MusicObj id, ICommandSender player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, ICommandSender player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.codec.MusicPack;
|
||||
import com.coloryr.allmusic.comm.MusicCodec;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -155,7 +155,7 @@ public class SideNeoForge extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
CommandSourceStack source = (CommandSourceStack) obj;
|
||||
MusicAddEvent event = new MusicAddEvent(music, source.getPlayer());
|
||||
NeoForge.EVENT_BUS.post(event);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.bus.api.Event;
|
||||
|
||||
@@ -8,7 +8,7 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
@@ -16,7 +16,7 @@ public class MusicAddEvent extends Event {
|
||||
|
||||
private boolean cancel;
|
||||
|
||||
public MusicAddEvent(MusicObj id, ServerPlayer player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, ServerPlayer player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.codec.MusicPack;
|
||||
import com.coloryr.allmusic.comm.MusicCodec;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -156,7 +156,7 @@ public class SideNeoForge extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
CommandSourceStack source = (CommandSourceStack) obj;
|
||||
MusicAddEvent event = new MusicAddEvent(music, source.getPlayer());
|
||||
NeoForge.EVENT_BUS.post(event);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.bus.api.Event;
|
||||
|
||||
@@ -8,7 +8,7 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
@@ -16,7 +16,7 @@ public class MusicAddEvent extends Event {
|
||||
|
||||
private boolean cancel;
|
||||
|
||||
public MusicAddEvent(MusicObj id, ServerPlayer player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, ServerPlayer player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.codec.MusicPack;
|
||||
import com.coloryr.allmusic.comm.MusicCodec;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.event.MusicAddEvent;
|
||||
@@ -155,7 +155,7 @@ public class SideNeoForge extends BaseSide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
CommandSourceStack source = (CommandSourceStack) obj;
|
||||
MusicAddEvent event = new MusicAddEvent(music, source.getPlayer());
|
||||
NeoForge.EVENT_BUS.post(event);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.bus.api.Event;
|
||||
|
||||
@@ -8,7 +8,7 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
@@ -16,7 +16,7 @@ public class MusicAddEvent extends Event {
|
||||
|
||||
private boolean cancel;
|
||||
|
||||
public MusicAddEvent(MusicObj id, ServerPlayer player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, ServerPlayer player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
public class AllMusicBC extends Plugin {
|
||||
|
||||
public static Plugin plugin;
|
||||
private static MetricsBC metricsBC;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -23,14 +22,12 @@ public class AllMusicBC extends Plugin {
|
||||
ProxyServer.getInstance().registerChannel(AllMusic.channelBC);
|
||||
ProxyServer.getInstance().getPluginManager().registerCommand(this, new CommandBC());
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(this, new ListenerBC());
|
||||
metricsBC = new MetricsBC(this, 6720);
|
||||
|
||||
AllMusic.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
metricsBC.shutdown();
|
||||
AllMusic.stop();
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,12 @@ public class AllMusicVelocity {
|
||||
public final ProxyServer server;
|
||||
public final Path dataDirectory;
|
||||
private final Logger logger;
|
||||
private final MetricsVelocity.Factory metricsFactory;
|
||||
private MetricsVelocity metricsVelocity;
|
||||
|
||||
@Inject
|
||||
public AllMusicVelocity(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory, MetricsVelocity.Factory metricsFactory) {
|
||||
public AllMusicVelocity(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
this.metricsFactory = metricsFactory;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -52,14 +49,12 @@ public class AllMusicVelocity {
|
||||
server.getChannelRegistrar().register(channelBC);
|
||||
server.getCommandManager().register(meta, new CommandVelocity());
|
||||
server.getEventManager().register(this, new ListenerVelocity());
|
||||
metricsVelocity = metricsFactory.make(this, 6720);
|
||||
|
||||
AllMusic.start();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStop(ProxyShutdownEvent event) {
|
||||
metricsVelocity.shutdown();
|
||||
AllMusic.stop();
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
package com.coloryr.allmusic.server.side.bc;
|
||||
|
||||
import com.coloryr.allmusic.server.bstats.MetricsBase;
|
||||
import com.coloryr.allmusic.server.bstats.charts.CustomChart;
|
||||
import com.coloryr.allmusic.server.bstats.json.JsonObjectBuilder;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MetricsBC {
|
||||
|
||||
private final Plugin plugin;
|
||||
private final MetricsBase metricsBase;
|
||||
|
||||
private boolean enabled;
|
||||
private String serverUUID;
|
||||
private boolean logErrors = false;
|
||||
private boolean logSentData;
|
||||
private boolean logResponseStatusText;
|
||||
|
||||
/**
|
||||
* Creates a new Metrics instance.
|
||||
*
|
||||
* @param plugin Your plugin instance.
|
||||
* @param serviceId The id of the service.
|
||||
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||
*/
|
||||
public MetricsBC(Plugin plugin, int serviceId) {
|
||||
this.plugin = plugin;
|
||||
|
||||
try {
|
||||
loadConfig();
|
||||
} catch (IOException e) {
|
||||
// Failed to load configuration
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to load bStats config!", e);
|
||||
metricsBase = null;
|
||||
return;
|
||||
}
|
||||
|
||||
metricsBase = new MetricsBase(
|
||||
"bungeecord",
|
||||
serverUUID,
|
||||
serviceId,
|
||||
enabled,
|
||||
this::appendPlatformData,
|
||||
this::appendServiceData,
|
||||
null,
|
||||
() -> true,
|
||||
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
|
||||
(message) -> this.plugin.getLogger().log(Level.INFO, message),
|
||||
logErrors,
|
||||
logSentData,
|
||||
logResponseStatusText
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the bStats configuration.
|
||||
*/
|
||||
private void loadConfig() throws IOException {
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
bStatsFolder.mkdirs();
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
writeFile(configFile,
|
||||
"# bStats (https://bStats.org) collects some basic information for plugin authors, like how",
|
||||
"# many people use their plugin and their total player count. It's recommended to keep bStats",
|
||||
"# enabled, but if you're not comfortable with this, you can turn this setting off. There is no",
|
||||
"# performance penalty associated with having metrics enabled, and data sent to bStats is fully",
|
||||
"# anonymous.",
|
||||
"enabled: true",
|
||||
"serverUuid: \"" + UUID.randomUUID() + "\"",
|
||||
"logFailedRequests: false",
|
||||
"logSentData: false",
|
||||
"logResponseStatusText: false");
|
||||
}
|
||||
|
||||
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
|
||||
// Load configuration
|
||||
enabled = configuration.getBoolean("enabled", true);
|
||||
serverUUID = configuration.getString("serverUuid");
|
||||
logErrors = configuration.getBoolean("logFailedRequests", false);
|
||||
logSentData = configuration.getBoolean("logSentData", false);
|
||||
logResponseStatusText = configuration.getBoolean("logResponseStatusText", false);
|
||||
}
|
||||
|
||||
private void writeFile(File file, String... lines) throws IOException {
|
||||
try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file))) {
|
||||
for (String line : lines) {
|
||||
bufferedWriter.write(line);
|
||||
bufferedWriter.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the underlying scheduler service.
|
||||
*/
|
||||
public void shutdown() {
|
||||
metricsBase.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
metricsBase.addCustomChart(chart);
|
||||
}
|
||||
|
||||
private void appendPlatformData(JsonObjectBuilder builder) {
|
||||
builder.appendField("playerAmount", plugin.getProxy().getOnlineCount());
|
||||
builder.appendField("managedServers", plugin.getProxy().getServers().size());
|
||||
builder.appendField("onlineMode", plugin.getProxy().getConfig().isOnlineMode() ? 1 : 0);
|
||||
builder.appendField("bungeecordVersion", plugin.getProxy().getVersion());
|
||||
builder.appendField("bungeecordName", plugin.getProxy().getName());
|
||||
|
||||
builder.appendField("javaVersion", System.getProperty("java.version"));
|
||||
builder.appendField("osName", System.getProperty("os.name"));
|
||||
builder.appendField("osArch", System.getProperty("os.arch"));
|
||||
builder.appendField("osVersion", System.getProperty("os.version"));
|
||||
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
private void appendServiceData(JsonObjectBuilder builder) {
|
||||
builder.appendField("pluginVersion", plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,8 +4,9 @@ import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.AllMusicBC;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.music.play.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.music.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.core.sql.IEconomy;
|
||||
@@ -321,7 +322,7 @@ public class SideBC extends BaseSide implements IEconomy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
MusicAddEvent event = new MusicAddEvent(music, (CommandSender) obj);
|
||||
ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
return event.isCancel();
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.side.bc.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class MusicAddEvent extends Event {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
@@ -21,7 +21,7 @@ public class MusicAddEvent extends Event {
|
||||
*/
|
||||
private boolean cancel = false;
|
||||
|
||||
public MusicAddEvent(MusicObj id, CommandSender player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, CommandSender player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class MusicAddEvent extends Event {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
package com.coloryr.allmusic.server.side.velocity;
|
||||
|
||||
import com.coloryr.allmusic.server.bstats.MetricsBase;
|
||||
import com.coloryr.allmusic.server.bstats.charts.CustomChart;
|
||||
import com.coloryr.allmusic.server.bstats.config.MetricsConfig;
|
||||
import com.coloryr.allmusic.server.bstats.json.JsonObjectBuilder;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.plugin.PluginDescription;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MetricsVelocity {
|
||||
|
||||
private final PluginContainer pluginContainer;
|
||||
private final ProxyServer server;
|
||||
private MetricsBase metricsBase;
|
||||
private MetricsVelocity(Object plugin, ProxyServer server, Logger logger, Path dataDirectory, int serviceId) {
|
||||
pluginContainer = server.getPluginManager().fromInstance(plugin)
|
||||
.orElseThrow(() -> new IllegalArgumentException("The provided instance is not a plugin"));
|
||||
this.server = server;
|
||||
|
||||
File configFile = dataDirectory.getParent().resolve("bStats").resolve("config.txt").toFile();
|
||||
MetricsConfig config;
|
||||
try {
|
||||
config = new MetricsConfig(configFile, true);
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to create bStats config", e);
|
||||
return;
|
||||
}
|
||||
|
||||
metricsBase = new MetricsBase(
|
||||
"velocity",
|
||||
config.getServerUUID(),
|
||||
serviceId,
|
||||
config.isEnabled(),
|
||||
this::appendPlatformData,
|
||||
this::appendServiceData,
|
||||
task -> server.getScheduler().buildTask(plugin, task).schedule(),
|
||||
() -> true,
|
||||
logger::warn,
|
||||
logger::info,
|
||||
config.isLogErrorsEnabled(),
|
||||
config.isLogSentDataEnabled(),
|
||||
config.isLogResponseStatusTextEnabled()
|
||||
);
|
||||
|
||||
if (!config.didExistBefore()) {
|
||||
// Send an info message when the bStats config file gets created for the first time
|
||||
logger.info("Velocity and some of its plugins collect metrics and send them to bStats (https://bStats.org).");
|
||||
logger.info("bStats collects some basic information for plugin authors, like how many people use");
|
||||
logger.info("their plugin and their total player count. It's recommend to keep bStats enabled, but");
|
||||
logger.info("if you're not comfortable with this, you can opt-out by editing the config.txt file in");
|
||||
logger.info("the '/plugins/bStats/' folder and setting enabled to false.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the underlying scheduler service.
|
||||
*/
|
||||
public void shutdown() {
|
||||
metricsBase.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (metricsBase != null) {
|
||||
metricsBase.addCustomChart(chart);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendPlatformData(JsonObjectBuilder builder) {
|
||||
builder.appendField("playerAmount", server.getPlayerCount());
|
||||
builder.appendField("managedServers", server.getAllServers().size());
|
||||
builder.appendField("onlineMode", server.getConfiguration().isOnlineMode() ? 1 : 0);
|
||||
builder.appendField("velocityVersionVersion", server.getVersion().getVersion());
|
||||
builder.appendField("velocityVersionName", server.getVersion().getName());
|
||||
builder.appendField("velocityVersionVendor", server.getVersion().getVendor());
|
||||
|
||||
builder.appendField("javaVersion", System.getProperty("java.version"));
|
||||
builder.appendField("osName", System.getProperty("os.name"));
|
||||
builder.appendField("osArch", System.getProperty("os.arch"));
|
||||
builder.appendField("osVersion", System.getProperty("os.version"));
|
||||
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
private void appendServiceData(JsonObjectBuilder builder) {
|
||||
builder.appendField("pluginVersion", pluginContainer.getDescription().getVersion().orElse("unknown"));
|
||||
}
|
||||
|
||||
/**
|
||||
* A factory to create new Metrics classes.
|
||||
*/
|
||||
public static class Factory {
|
||||
|
||||
private final ProxyServer server;
|
||||
private final Logger logger;
|
||||
private final Path dataDirectory;
|
||||
|
||||
// The constructor is not meant to be called by the user.
|
||||
// The instance is created using Dependency Injection
|
||||
@Inject
|
||||
private Factory(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Metrics class.
|
||||
*
|
||||
* @param plugin The plugin instance.
|
||||
* @param serviceId The id of the service.
|
||||
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||
* <p>Not to be confused with Velocity's {@link PluginDescription#getId()} method!
|
||||
* @return A Metrics instance that can be used to register custom charts.
|
||||
* <p>The return value can be ignored, when you do not want to register custom charts.
|
||||
*/
|
||||
public MetricsVelocity make(Object plugin, int serviceId) {
|
||||
return new MetricsVelocity(plugin, server, logger, dataDirectory, serviceId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -4,8 +4,8 @@ import com.coloryr.allmusic.buffercodec.MusicPacketCodec;
|
||||
import com.coloryr.allmusic.codec.CommandType;
|
||||
import com.coloryr.allmusic.server.AllMusicVelocity;
|
||||
import com.coloryr.allmusic.server.core.AllMusic;
|
||||
import com.coloryr.allmusic.server.core.music.play.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.music.PlayMusic;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.SongInfoObj;
|
||||
import com.coloryr.allmusic.server.core.side.BaseSide;
|
||||
import com.coloryr.allmusic.server.core.sql.IEconomy;
|
||||
@@ -314,7 +314,7 @@ public class SideVelocity extends BaseSide implements IEconomy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMusicAdd(Object obj, MusicObj music) {
|
||||
public boolean onMusicAdd(Object obj, PlayerAddMusicObj music) {
|
||||
MusicAddEvent event = new MusicAddEvent(music, (CommandSource) obj);
|
||||
AllMusicVelocity.plugin.server.getEventManager().fire(event).join();
|
||||
return event.isCancel();
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.coloryr.allmusic.server.side.velocity.event;
|
||||
|
||||
import com.coloryr.allmusic.server.core.objs.music.MusicObj;
|
||||
import com.coloryr.allmusic.server.core.objs.music.PlayerAddMusicObj;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
|
||||
/**
|
||||
@@ -10,7 +10,7 @@ public class MusicAddEvent {
|
||||
/**
|
||||
* 添加的音乐
|
||||
*/
|
||||
private final MusicObj music;
|
||||
private final PlayerAddMusicObj music;
|
||||
/**
|
||||
* 添加者
|
||||
*/
|
||||
@@ -20,7 +20,7 @@ public class MusicAddEvent {
|
||||
*/
|
||||
private boolean cancel = false;
|
||||
|
||||
public MusicAddEvent(MusicObj id, CommandSource player) {
|
||||
public MusicAddEvent(PlayerAddMusicObj id, CommandSource player) {
|
||||
this.music = id;
|
||||
this.player = player;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class MusicAddEvent {
|
||||
return player;
|
||||
}
|
||||
|
||||
public MusicObj getMusic() {
|
||||
public PlayerAddMusicObj getMusic() {
|
||||
return music;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user