diff --git a/.gitignore b/.gitignore index 463f0c19..584060d1 100644 --- a/.gitignore +++ b/.gitignore @@ -25,9 +25,16 @@ run forge*changelog.txt lib +**/allmusic/codec/ +**/allmusic/comm/ +**/allmusic/buffercodec/ **/allmusic/server/core/ -**/allmusic/server/codec/ **/allmusic/server/bstats/ **/allmusic/client/core/ **/allmusic/client/core/player/decoder/mp3/ .DS_Store +/onejar/**/src/main/java/com/coloryr/allmusic/client +/onejar/**/src/main/java/com/coloryr/allmusic/server +/onejar/**/src/main/java/com/coloryr/allmusic/comm +/onejar/**/src/main/java/com/coloryr/allmusic/codec +/onejar/**/src/main/java/com/coloryr/allmusic/buffercodec diff --git a/client b/client index 77d47807..e461cf8f 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 77d47807ffa078edba87cb9148e88453c2f23403 +Subproject commit e461cf8f3546ad0d8abac8267ec655e2ac5a4b44 diff --git a/codec/PacketCodec.java b/codec/PacketCodec.java deleted file mode 100644 index 4779c29e..00000000 --- a/codec/PacketCodec.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.coloryr.allmusic.server.codec; - -import com.coloryr.allmusic.server.core.objs.enums.ComType; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; - -import java.nio.charset.StandardCharsets; - -public class PacketCodec { - public static ByteBuf pack(ComType type, String data, int data1) { - ByteBuf buf = Unpooled.buffer(0); - buf.writeByte(type.ordinal()); - switch (type) { - case HUD: - case LYRIC: - case LIST: - case INFO: - case IMG: - case PLAY: - writeString(buf, data); - break; - case POS: - buf.writeInt(data1); - break; - } - return buf; - } - - public static void pack(ByteBuf buf, ComType type, String data, int data1) { - buf.writeByte(type.ordinal()); - switch (type) { - case HUD: - case LYRIC: - case LIST: - case INFO: - case IMG: - case PLAY: - writeString(buf, data); - break; - case POS: - buf.writeInt(data1); - break; - } - } - - private static void writeString(ByteBuf buf, String text) { - byte[] temp = text.getBytes(StandardCharsets.UTF_8); - buf.writeInt(temp.length); - buf.writeBytes(temp); - } -} diff --git a/core/AllMusic.java b/core/AllMusic.java index 6f0207c5..2a082b90 100644 --- a/core/AllMusic.java +++ b/core/AllMusic.java @@ -125,6 +125,7 @@ public class AllMusic { /** * 获取正在播放的玩家列表 + * * @return 列表 */ public static Set getNowPlayPlayer() { @@ -393,7 +394,8 @@ public class AllMusic { reader = new InputStreamReader(Files.newInputStream(cookieFile.toPath()), StandardCharsets.UTF_8); bf = new BufferedReader(reader); - Type listType = new TypeToken>(){}.getType(); + Type listType = new TypeToken>() { + }.getType(); cookie = new Gson().fromJson(bf, listType); bf.close(); reader.close(); diff --git a/core/AllMusicAPI.java b/core/AllMusicAPI.java index 553715b4..97ba556a 100644 --- a/core/AllMusicAPI.java +++ b/core/AllMusicAPI.java @@ -1,7 +1,7 @@ package com.coloryr.allmusic.server.core; -import com.coloryr.allmusic.server.core.objs.config.SaveObj; -import com.coloryr.allmusic.server.core.objs.enums.HudType; +import com.coloryr.allmusic.codec.HudPosObj; +import com.coloryr.allmusic.codec.HudType; import com.coloryr.allmusic.server.core.utils.HudUtils; public class AllMusicAPI { @@ -51,7 +51,7 @@ public class AllMusicAPI { * @param player 玩家 * @return Hud信息 */ - public static SaveObj getHud(String player) { + public static HudPosObj getHud(String player) { return HudUtils.get(player); } @@ -61,7 +61,7 @@ public class AllMusicAPI { * @param player 玩家 * @param hud Hud信息 */ - public static void setHud(String player, SaveObj hud) { + public static void setHud(String player, HudPosObj hud) { HudUtils.set(player, hud); } } diff --git a/core/command/AHudCommand.java b/core/command/AHudCommand.java index 07a7ed92..5a4a32e3 100644 --- a/core/command/AHudCommand.java +++ b/core/command/AHudCommand.java @@ -1,6 +1,6 @@ package com.coloryr.allmusic.server.core.command; -import com.coloryr.allmusic.server.core.objs.enums.HudType; +import com.coloryr.allmusic.codec.HudType; public abstract class AHudCommand extends ACommand { protected final HudType type; diff --git a/core/command/CommandEX.java b/core/command/CommandEX.java index 6697c7e2..0a1ca93a 100644 --- a/core/command/CommandEX.java +++ b/core/command/CommandEX.java @@ -18,6 +18,23 @@ public class CommandEX { public static final Map commandList = new HashMap<>(); public static final Map commandAdminList = new HashMap<>(); + private static final List normal = new ArrayList() {{ + this.addAll(commandList.keySet()); + }}; + /** + * 管理员的指令 + */ + private static final List admin = new ArrayList() {{ + this.addAll(commandAdminList.keySet()); + }}; + /** + * 搜歌的指令 + */ + private static final List search = new ArrayList() {{ + this.add("select"); + this.add("nextpage"); + this.add("lastpage"); + }}; static { commandList.put("stop", new CommandStop()); @@ -48,25 +65,6 @@ public class CommandEX { commandAdminList.put("test", new CommandTest()); } - private static final List normal = new ArrayList() {{ - this.addAll(commandList.keySet()); - }}; - - /** - * 管理员的指令 - */ - private static final List admin = new ArrayList() {{ - this.addAll(commandAdminList.keySet()); - }}; - /** - * 搜歌的指令 - */ - private static final List search = new ArrayList() {{ - this.add("select"); - this.add("nextpage"); - this.add("lastpage"); - }}; - /** * 搜索音乐 * @@ -298,8 +296,9 @@ public class CommandEX { /** * 检查是否为管理员 + * * @param sender 用户 - * @param name 用户名 + * @param name 用户名 * @return 是否为管理员 */ public static boolean checkAdmin(Object sender, String name) { diff --git a/core/command/sub/CommandBan.java b/core/command/sub/CommandBan.java index 83d8457a..419a7650 100644 --- a/core/command/sub/CommandBan.java +++ b/core/command/sub/CommandBan.java @@ -28,7 +28,7 @@ public class CommandBan extends ACommand { @Override public List tab(Object player, String name, String[] args, int index) { - if (args.length == index || (args.length == index + 1 )) { + if (args.length == index || (args.length == index + 1)) { List list = new ArrayList<>(); if (PlayMusic.nowPlayMusic != null) { list.add(PlayMusic.nowPlayMusic.getID()); diff --git a/core/command/sub/CommandHud.java b/core/command/sub/CommandHud.java index 4e7f568a..134e00eb 100644 --- a/core/command/sub/CommandHud.java +++ b/core/command/sub/CommandHud.java @@ -1,9 +1,9 @@ package com.coloryr.allmusic.server.core.command.sub; +import com.coloryr.allmusic.codec.HudType; import com.coloryr.allmusic.server.core.AllMusic; import com.coloryr.allmusic.server.core.command.ACommand; import com.coloryr.allmusic.server.core.command.ICommand; -import com.coloryr.allmusic.server.core.objs.enums.HudType; import com.coloryr.allmusic.server.core.objs.message.ARG; import com.coloryr.allmusic.server.core.utils.HudUtils; diff --git a/core/command/sub/CommandHudSet.java b/core/command/sub/CommandHudSet.java index f9cdac86..f5130cc1 100644 --- a/core/command/sub/CommandHudSet.java +++ b/core/command/sub/CommandHudSet.java @@ -1,12 +1,12 @@ package com.coloryr.allmusic.server.core.command.sub; +import com.coloryr.allmusic.codec.HudDirType; +import com.coloryr.allmusic.codec.HudItemPosObj; +import com.coloryr.allmusic.codec.HudType; import com.coloryr.allmusic.server.core.AllMusic; import com.coloryr.allmusic.server.core.command.ACommand; import com.coloryr.allmusic.server.core.command.AHudCommand; import com.coloryr.allmusic.server.core.command.ICommand; -import com.coloryr.allmusic.server.core.objs.enums.HudDirType; -import com.coloryr.allmusic.server.core.objs.enums.HudType; -import com.coloryr.allmusic.server.core.objs.hud.PosObj; import com.coloryr.allmusic.server.core.objs.message.ARG; import com.coloryr.allmusic.server.core.utils.HudUtils; @@ -140,7 +140,7 @@ public class CommandHudSet extends AHudCommand { AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.error); return; } - PosObj obj = HudUtils.setHudPos(name, type, args[3], args[4]); + HudItemPosObj obj = HudUtils.setHudPos(name, type, args[3], args[4]); if (obj == null) { AllMusic.side.sendMessageTask(sender, AllMusic.getMessage().command.error); return; diff --git a/core/command/sub/CommandMute.java b/core/command/sub/CommandMute.java index 121ace50..85e4d3b9 100644 --- a/core/command/sub/CommandMute.java +++ b/core/command/sub/CommandMute.java @@ -7,7 +7,6 @@ import com.coloryr.allmusic.server.core.music.play.PlayMusic; import com.coloryr.allmusic.server.core.sql.DataSql; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public class CommandMute extends ACommand { diff --git a/core/command/sub/CommandSelect.java b/core/command/sub/CommandSelect.java index 604ac837..a5e21cd2 100644 --- a/core/command/sub/CommandSelect.java +++ b/core/command/sub/CommandSelect.java @@ -43,12 +43,12 @@ public class CommandSelect extends ACommand { @Override public List tab(Object player, String name, String[] args, int index) { - if (args.length == 1 || (args.length == 2 )) { + if (args.length == 1 || (args.length == 2)) { List list = new ArrayList<>(); SearchPageObj obj = AllMusic.getSearch(name); if (obj != null) { for (int a = 0; a < obj.getIndex(); a++) { - list.add(String.valueOf(a+1)); + list.add(String.valueOf(a + 1)); } } return list; diff --git a/core/command/sub/CommandUnban.java b/core/command/sub/CommandUnban.java index 682e3f7c..8e665263 100644 --- a/core/command/sub/CommandUnban.java +++ b/core/command/sub/CommandUnban.java @@ -27,7 +27,7 @@ public class CommandUnban extends ACommand { @Override public List tab(Object player, String name, String[] args, int index) { - if (args.length == index || (args.length == index + 1 )) { + if (args.length == index || (args.length == index + 1)) { return new ArrayList<>(Cache.banMusic); } diff --git a/core/command/sub/CommandUnbanPlayer.java b/core/command/sub/CommandUnbanPlayer.java index 3021b70d..a427c669 100644 --- a/core/command/sub/CommandUnbanPlayer.java +++ b/core/command/sub/CommandUnbanPlayer.java @@ -22,7 +22,7 @@ public class CommandUnbanPlayer implements ICommand { @Override public List tab(Object player, String name, String[] args, int index) { - if (args.length == index || (args.length == index + 1 )) { + if (args.length == index || (args.length == index + 1)) { return new ArrayList<>(Cache.banPlayers); } diff --git a/core/music/api/APIMain.java b/core/music/api/APIMain.java index 7d63239b..38c68b72 100644 --- a/core/music/api/APIMain.java +++ b/core/music/api/APIMain.java @@ -43,6 +43,76 @@ public class APIMain { } } + private static int toUnsignedInt(byte x) { + return ((int) x) & 0xff;//将高24位全部变成0,低8位保持不变 + } + + private static MediaType testMediaType(BufferedInputStream stream) throws IOException { + stream.mark(10); + byte[] temp = new byte[4]; + int res = stream.read(temp); + if (res != 4) { + return MediaType.Unknow; + } + if (temp[0] == 'R' && temp[1] == 'I' && temp[2] == 'F' && temp[3] == 'F') { + return MediaType.Wav; + } else if (temp[0] == 'f' && temp[1] == 'L' && temp[2] == 'a' && temp[3] == 'C') { + return MediaType.Flac; + } else if (temp[0] == 'I' && temp[1] == 'D' && temp[2] == '3') { + return MediaType.Mp3; + } else if (toUnsignedInt(temp[0]) == 0xFF && toUnsignedInt(temp[1]) == 0xE0) { + return MediaType.Mp3; + } + + return MediaType.Unknow; + } + + public static SongInfoObj getUrlMusic(String url) { + try { + InputStream stream = HttpClientUtil.get(url); + if (stream == null) { + return null; + } + BufferedInputStream in = new BufferedInputStream(stream); + MediaType type = testMediaType(in); + in.reset(); + float le = 0; + if (type == MediaType.Mp3) { + Bitstream bt = new Bitstream(in); + bt.readFrame(); + bt.closeFrame(); + Header h; + for (; ; ) { + h = bt.readFrame(); + if (h == null) { + break; + } + bt.closeFrame(); + le += h.ms_per_frame(); + } + bt.close(); + return new SongInfoObj(null, url, (int) le, type); + } else if (type == MediaType.Flac) { + FlacDecoder flac = new FlacDecoder(in); + for (; ; ) { + Object temp = flac.readAndHandleMetadataBlock(); + if (temp instanceof StreamInfo) { + StreamInfo info = (StreamInfo) temp; + le = (float) info.numSamples / info.sampleRate; + flac.close(); + return new SongInfoObj(null, url, (int) le, type); + } + } + } + stream.close(); + } catch (Exception e) { + AllMusic.log.warning("§d[AllMusic3]§c歌曲长度解析错误"); + e.printStackTrace(); + } + + return null; + } + public boolean isUpdate() { return isUpdate; } @@ -251,74 +321,4 @@ public class APIMain { } return null; } - - private static int toUnsignedInt(byte x) { - return ((int) x) & 0xff;//将高24位全部变成0,低8位保持不变 - } - - private static MediaType testMediaType(BufferedInputStream stream) throws IOException { - stream.mark(10); - byte[] temp = new byte[4]; - int res = stream.read(temp); - if (res != 4) { - return MediaType.Unknow; - } - if (temp[0] == 'R' && temp[1] == 'I' && temp[2] == 'F' && temp[3] == 'F') { - return MediaType.Wav; - } else if (temp[0] == 'f' && temp[1] == 'L' && temp[2] == 'a' && temp[3] == 'C') { - return MediaType.Flac; - } else if (temp[0] == 'I' && temp[1] == 'D' && temp[2] == '3') { - return MediaType.Mp3; - } else if (toUnsignedInt(temp[0]) == 0xFF && toUnsignedInt(temp[1]) == 0xE0) { - return MediaType.Mp3; - } - - return MediaType.Unknow; - } - - public static SongInfoObj getUrlMusic(String url) { - try { - InputStream stream = HttpClientUtil.get(url); - if (stream == null) { - return null; - } - BufferedInputStream in = new BufferedInputStream(stream); - MediaType type = testMediaType(in); - in.reset(); - float le = 0; - if (type == MediaType.Mp3) { - Bitstream bt = new Bitstream(in); - bt.readFrame(); - bt.closeFrame(); - Header h; - for (; ; ) { - h = bt.readFrame(); - if (h == null) { - break; - } - bt.closeFrame(); - le += h.ms_per_frame(); - } - bt.close(); - return new SongInfoObj(null, url, (int) le, type); - } else if (type == MediaType.Flac) { - FlacDecoder flac = new FlacDecoder(in); - for (; ; ) { - Object temp = flac.readAndHandleMetadataBlock(); - if (temp instanceof StreamInfo) { - StreamInfo info = (StreamInfo) temp; - le = (float) info.numSamples / info.sampleRate; - flac.close(); - return new SongInfoObj(null, url, (int) le, type); - } - } - } - stream.close(); - } catch (Exception e) { - AllMusic.log.warning("§d[AllMusic3]§c歌曲长度解析错误"); - e.printStackTrace(); - } - - return null; - } } diff --git a/core/objs/config/ConfigObj.java b/core/objs/config/ConfigObj.java index ea164d20..2573a028 100644 --- a/core/objs/config/ConfigObj.java +++ b/core/objs/config/ConfigObj.java @@ -1,5 +1,6 @@ package com.coloryr.allmusic.server.core.objs.config; +import com.coloryr.allmusic.codec.HudPosObj; import com.coloryr.allmusic.server.core.AllMusic; import java.util.HashSet; @@ -96,7 +97,7 @@ public class ConfigObj { /** * 默认的Hud配置 */ - public SaveObj defaultHud; + public HudPosObj defaultHud; /** * 经济插件挂钩 */ @@ -133,7 +134,7 @@ public class ConfigObj { } if (defaultHud == null) { saveConfig = true; - defaultHud = SaveObj.make(); + defaultHud = HudPosObj.make(); } if (muteServer == null) { saveConfig = true; @@ -172,7 +173,7 @@ public class ConfigObj { playListEscapeDeep = 40; sendLyric = true; needPermission = false; - defaultHud = SaveObj.make(); + defaultHud = HudPosObj.make(); mutePlayMessage = false; muteAddMessage = false; showInBar = false; diff --git a/core/objs/config/EconomyObj.java b/core/objs/config/EconomyObj.java index ee4e98b4..98c0b7c6 100644 --- a/core/objs/config/EconomyObj.java +++ b/core/objs/config/EconomyObj.java @@ -1,7 +1,7 @@ package com.coloryr.allmusic.server.core.objs.config; public class EconomyObj { -// public String mysqlUrl; + // public String mysqlUrl; public String backend; public boolean vault; diff --git a/core/objs/config/SaveObj.java b/core/objs/config/SaveObj.java deleted file mode 100644 index 5f4bf6d0..00000000 --- a/core/objs/config/SaveObj.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.coloryr.allmusic.server.core.objs.config; - -import com.coloryr.allmusic.server.core.objs.enums.HudDirType; -import com.coloryr.allmusic.server.core.objs.hud.PosObj; - -public class SaveObj { - public PosObj list; - public PosObj lyric; - public PosObj info; - public PosObj pic; - public int picRotateSpeed; - - public static SaveObj make() { - SaveObj obj = new SaveObj(); - obj.init(); - - return obj; - } - - public SaveObj copy() { - SaveObj obj1 = new SaveObj(); - obj1.info = this.info.copy(); - obj1.list = this.list.copy(); - obj1.lyric = this.lyric.copy(); - obj1.pic = this.pic.copy(); - obj1.picRotateSpeed = this.picRotateSpeed; - return obj1; - } - - public boolean check() { - boolean save = false; - if (list == null) { - save = true; - list = new PosObj(2, 74, HudDirType.TOP_LEFT, 0xffffffff, true, true); - } - if (lyric == null) { - save = true; - lyric = new PosObj(74, 53, HudDirType.TOP_LEFT, 0xffffffff, true, true); - } - if (info == null) { - save = true; - info = new PosObj(74, 2, HudDirType.TOP_LEFT, 0xffffffff, true, true); - } - if (pic == null) { - save = true; - pic = new PosObj(2, 2, HudDirType.TOP_LEFT, 70, true, true); - } - return save; - } - - public void init() { - picRotateSpeed = 30; - list = new PosObj(2, 74, HudDirType.TOP_LEFT, 0xffffffff, true, true); - lyric = new PosObj(74, 53, HudDirType.TOP_LEFT, 0xffffffff, true, true); - info = new PosObj(74, 2, HudDirType.TOP_LEFT, 0xffffffff, true, true); - pic = new PosObj(2, 2, HudDirType.TOP_LEFT, 70, true, true); - } -} \ No newline at end of file diff --git a/core/objs/enums/ComType.java b/core/objs/enums/ComType.java deleted file mode 100644 index 23b7e5ca..00000000 --- a/core/objs/enums/ComType.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.coloryr.allmusic.server.core.objs.enums; - -public enum ComType { - LYRIC, INFO, LIST, PLAY, IMG, - STOP, CLEAR, POS, HUD -} diff --git a/core/objs/enums/HudDirType.java b/core/objs/enums/HudDirType.java deleted file mode 100644 index f3de59d7..00000000 --- a/core/objs/enums/HudDirType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.coloryr.allmusic.server.core.objs.enums; - -public enum HudDirType { - TOP_LEFT, TOP_CENTER, TOP_RIGHT, - LEFT, CENTER, RIGHT, - BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT -} diff --git a/core/objs/enums/HudType.java b/core/objs/enums/HudType.java deleted file mode 100644 index e178e4e8..00000000 --- a/core/objs/enums/HudType.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.coloryr.allmusic.server.core.objs.enums; - -public enum HudType { - INFO, LIST, LYRIC, PIC -} diff --git a/core/objs/hud/PosObj.java b/core/objs/hud/PosObj.java deleted file mode 100644 index a3883aa0..00000000 --- a/core/objs/hud/PosObj.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.coloryr.allmusic.server.core.objs.hud; - -import com.coloryr.allmusic.server.core.objs.enums.HudDirType; - -public class PosObj { - public int x; - public int y; - public HudDirType dir; - public int color; - public boolean shadow; - public boolean enable; - - public PosObj() { - - } - - public PosObj(int x, int y, HudDirType type, int color, boolean shadow, boolean enable) { - this.x = x; - this.y = y; - this.dir = type; - this.color = color; - this.shadow = shadow; - this.enable = enable; - } - - public PosObj copy() { - return new PosObj(this.x, this.y, this.dir, this.color, this.shadow, this.enable); - } -} diff --git a/core/objs/message/HudNameObj.java b/core/objs/message/HudNameObj.java index 601a99b5..b0d5bf86 100644 --- a/core/objs/message/HudNameObj.java +++ b/core/objs/message/HudNameObj.java @@ -1,7 +1,7 @@ package com.coloryr.allmusic.server.core.objs.message; -import com.coloryr.allmusic.server.core.objs.enums.HudDirType; -import com.coloryr.allmusic.server.core.objs.enums.HudType; +import com.coloryr.allmusic.codec.HudDirType; +import com.coloryr.allmusic.codec.HudType; public class HudNameObj { public String list; diff --git a/core/objs/music/SongInfoObj.java b/core/objs/music/SongInfoObj.java index b815efdc..6f8631ce 100644 --- a/core/objs/music/SongInfoObj.java +++ b/core/objs/music/SongInfoObj.java @@ -139,6 +139,10 @@ public class SongInfoObj { return name == null ? "" : name; } + public void setName(String info) { + name = info; + } + public String getID() { return id; } @@ -157,10 +161,6 @@ public class SongInfoObj { return name == null; } - public void setName(String info) { - name = info; - } - public MediaType getMediaType() { return mediaType; } diff --git a/core/side/BaseSide.java b/core/side/BaseSide.java index 9ec6914e..3fc75735 100644 --- a/core/side/BaseSide.java +++ b/core/side/BaseSide.java @@ -1,9 +1,9 @@ package com.coloryr.allmusic.server.core.side; +import com.coloryr.allmusic.codec.CommandType; +import com.coloryr.allmusic.codec.HudPosObj; +import com.coloryr.allmusic.codec.HudType; import com.coloryr.allmusic.server.core.AllMusic; -import com.coloryr.allmusic.server.core.objs.config.SaveObj; -import com.coloryr.allmusic.server.core.objs.enums.ComType; -import com.coloryr.allmusic.server.core.objs.enums.HudType; import com.coloryr.allmusic.server.core.objs.music.MusicObj; import com.coloryr.allmusic.server.core.objs.music.SongInfoObj; import com.coloryr.allmusic.server.core.utils.HudUtils; @@ -91,7 +91,7 @@ public abstract class BaseSide { * @param data 数据 * @param data1 数据 */ - public abstract void send(Object player, ComType type, String data, int data1); + public abstract void send(Object player, CommandType type, String data, int data1); /** * 根据名字获取玩家 @@ -197,7 +197,7 @@ public abstract class BaseSide { if (AllMusic.isSkip(player, getPlayerServer(player), true)) return; try { - send(player1, ComType.POS, null, pos); + send(player1, CommandType.POS, null, pos); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c清空Hud发生出错"); e.printStackTrace(); @@ -215,7 +215,7 @@ public abstract class BaseSide { if (player == null) return; try { - send(player, ComType.STOP, null, 0); + send(player, CommandType.STOP, null, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c停止指令发送出错"); e.printStackTrace(); @@ -229,7 +229,7 @@ public abstract class BaseSide { AllMusic.clearNowPlayer(); try { for (Object player : getPlayers()) { - send(player, ComType.STOP, null, 0); + send(player, CommandType.STOP, null, 0); } } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c停止指令发送出错"); @@ -251,7 +251,7 @@ public abstract class BaseSide { try { if (AllMusic.isSkip(player, getPlayerServer(player), false)) return; - send(player1, ComType.PLAY, url, 0); + send(player1, CommandType.PLAY, url, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c歌曲指令发送出错"); e.printStackTrace(); @@ -272,10 +272,10 @@ public abstract class BaseSide { if (AllMusic.isSkip(name, getPlayerServer(player), true)) continue; try { - SaveObj obj = HudUtils.get(name); + HudPosObj obj = HudUtils.get(name); if (!obj.lyric.enable) continue; - send(player, ComType.LYRIC, data, 0); + send(player, CommandType.LYRIC, data, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c歌词发送出错"); e.printStackTrace(); @@ -297,10 +297,10 @@ public abstract class BaseSide { if (AllMusic.isSkip(name, getPlayerServer(player), true)) continue; try { - SaveObj obj = HudUtils.get(name); + HudPosObj obj = HudUtils.get(name); if (!obj.lyric.enable) continue; - send(player, ComType.INFO, data, 0); + send(player, CommandType.INFO, data, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c歌词信息发送出错"); e.printStackTrace(); @@ -320,9 +320,9 @@ public abstract class BaseSide { if (AllMusic.isSkip(name, null, false)) return; try { - SaveObj obj = HudUtils.get(name); + HudPosObj obj = HudUtils.get(name); String data = AllMusic.gson.toJson(obj); - send(player, ComType.HUD, data, 0); + send(player, CommandType.HUD_DATA, data, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c界面位置发送出错"); e.printStackTrace(); @@ -348,13 +348,13 @@ public abstract class BaseSide { return; switch (pos) { case INFO: - send(player, ComType.INFO, data, 0); + send(player, CommandType.INFO, data, 0); break; case LIST: - send(player, ComType.LIST, data, 0); + send(player, CommandType.LIST, data, 0); break; case LYRIC: - send(player, ComType.LYRIC, data, 0); + send(player, CommandType.LYRIC, data, 0); break; } } catch (Exception e) { @@ -377,10 +377,10 @@ public abstract class BaseSide { if (AllMusic.isSkip(name, getPlayerServer(player), true)) continue; try { - SaveObj obj = HudUtils.get(name); + HudPosObj obj = HudUtils.get(name); if (!obj.list.enable) continue; - send(player, ComType.LIST, data, 0); + send(player, CommandType.LIST, data, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c歌曲列表发送出错"); e.printStackTrace(); @@ -398,9 +398,9 @@ public abstract class BaseSide { continue; name = name.toLowerCase(Locale.ROOT); try { - SaveObj obj = HudUtils.get(name); + HudPosObj obj = HudUtils.get(name); String data = AllMusic.gson.toJson(obj); - send(player, ComType.HUD, data, 0); + send(player, CommandType.HUD_DATA, data, 0); } catch (Exception e1) { AllMusic.log.warning("§d[AllMusic]§c数据发送发生错误"); e1.printStackTrace(); @@ -444,7 +444,7 @@ public abstract class BaseSide { if (AllMusic.isSkip(name, getPlayerServer(player), false)) continue; try { - send(player, ComType.PLAY, url, 0); + send(player, CommandType.PLAY, url, 0); AllMusic.addNowPlayPlayer(name); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c歌曲指令发送出错"); @@ -466,11 +466,11 @@ public abstract class BaseSide { name = name.toLowerCase(Locale.ROOT); if (AllMusic.isSkip(name, getPlayerServer(player), true)) continue; - SaveObj obj = HudUtils.get(name); + HudPosObj obj = HudUtils.get(name); if (!obj.pic.enable) continue; try { - send(player, ComType.IMG, url, 0); + send(player, CommandType.IMG, url, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c图片指令发送出错"); e.printStackTrace(); @@ -491,7 +491,7 @@ public abstract class BaseSide { if (AllMusic.isSkip(player, getPlayerServer(player), true)) return; try { - send(player1, ComType.IMG, url, 0); + send(player1, CommandType.IMG, url, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c图片指令发送出错"); e.printStackTrace(); @@ -508,7 +508,7 @@ public abstract class BaseSide { if (player == null) return; try { - send(player, ComType.CLEAR, null, 0); + send(player, CommandType.CLEAR, null, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c清空Hud发生出错"); e.printStackTrace(); @@ -521,7 +521,7 @@ public abstract class BaseSide { public final void clearHud() { for (Object player : getPlayers()) { try { - send(player, ComType.CLEAR, null, 0); + send(player, CommandType.CLEAR, null, 0); } catch (Exception e) { AllMusic.log.warning("§d[AllMusic]§c清空Hud发生出错"); e.printStackTrace(); diff --git a/core/sql/DataSql.java b/core/sql/DataSql.java index f2a71a7b..af0ab259 100644 --- a/core/sql/DataSql.java +++ b/core/sql/DataSql.java @@ -1,9 +1,9 @@ package com.coloryr.allmusic.server.core.sql; +import com.coloryr.allmusic.codec.HudDirType; +import com.coloryr.allmusic.codec.HudItemPosObj; +import com.coloryr.allmusic.codec.HudPosObj; import com.coloryr.allmusic.server.core.AllMusic; -import com.coloryr.allmusic.server.core.objs.config.SaveObj; -import com.coloryr.allmusic.server.core.objs.enums.HudDirType; -import com.coloryr.allmusic.server.core.objs.hud.PosObj; import java.io.File; import java.sql.*; @@ -142,7 +142,7 @@ public class DataSql { * @param name 用户名 * @param hud Hud数据 */ - private static void update(String name, SaveObj hud) { + private static void update(String name, HudPosObj hud) { name = name.toLowerCase(Locale.ROOT); String sql = ""; try { @@ -190,7 +190,7 @@ public class DataSql { * @param name 用户名 * @param hud 数据 */ - public static void addUser(String name, SaveObj hud) { + public static void addUser(String name, HudPosObj hud) { name = name.toLowerCase(Locale.ROOT); String sql = ""; try { @@ -245,7 +245,7 @@ public class DataSql { /** * 读取所有数据 */ - public static SaveObj readHud(String name) { + public static HudPosObj readHud(String name) { try { AllMusic.log.info("正在读取玩家数据:" + name); if (connection.isReadOnly() || connection.isClosed()) { @@ -257,25 +257,25 @@ public class DataSql { "pic_rotate,pic_rotate_speed,info_color,info_dir,info_shadow,lyric_color," + "lyric_dir,lyric_shadow,list_color,list_dir,list_shadow,pic_dir FROM allmusic WHERE name='" + name + "'"); HudDirType[] vas = HudDirType.values(); - SaveObj obj = null; + HudPosObj obj = null; if (set.next()) { - obj = new SaveObj(); - PosObj pos1 = new PosObj(); + obj = new HudPosObj(); + HudItemPosObj pos1 = new HudItemPosObj(); pos1.x = set.getInt(1); pos1.y = set.getInt(2); obj.info = pos1; obj.info.enable = set.getInt(3) == 1; - PosObj pos2 = new PosObj(); + HudItemPosObj pos2 = new HudItemPosObj(); pos2.x = set.getInt(4); pos2.y = set.getInt(5); obj.lyric = pos2; obj.lyric.enable = set.getInt(6) == 1; - PosObj pos3 = new PosObj(); + HudItemPosObj pos3 = new HudItemPosObj(); pos3.x = set.getInt(7); pos3.y = set.getInt(8); obj.list = pos3; obj.list.enable = set.getInt(9) == 1; - PosObj pos4 = new PosObj(); + HudItemPosObj pos4 = new HudItemPosObj(); pos4.x = set.getInt(10); pos4.y = set.getInt(11); obj.pic = pos4; diff --git a/core/utils/HudUtils.java b/core/utils/HudUtils.java index fe0ea29a..bdef2c68 100644 --- a/core/utils/HudUtils.java +++ b/core/utils/HudUtils.java @@ -1,13 +1,13 @@ package com.coloryr.allmusic.server.core.utils; +import com.coloryr.allmusic.codec.HudDirType; +import com.coloryr.allmusic.codec.HudItemPosObj; +import com.coloryr.allmusic.codec.HudPosObj; +import com.coloryr.allmusic.codec.HudType; import com.coloryr.allmusic.server.core.AllMusic; import com.coloryr.allmusic.server.core.music.play.LyricSave; import com.coloryr.allmusic.server.core.music.play.PlayMusic; import com.coloryr.allmusic.server.core.objs.config.LimitObj; -import com.coloryr.allmusic.server.core.objs.config.SaveObj; -import com.coloryr.allmusic.server.core.objs.enums.HudDirType; -import com.coloryr.allmusic.server.core.objs.enums.HudType; -import com.coloryr.allmusic.server.core.objs.hud.PosObj; import com.coloryr.allmusic.server.core.objs.message.ARG; import com.coloryr.allmusic.server.core.objs.music.SongInfoObj; import com.coloryr.allmusic.server.core.sql.DataSql; @@ -17,7 +17,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class HudUtils { - private static final Map HudList = new ConcurrentHashMap<>(); + private static final Map HudList = new ConcurrentHashMap<>(); /** * 获取玩家的Hud储存 @@ -25,12 +25,12 @@ public class HudUtils { * @param name 玩家名 * @return Hud储存 */ - public static SaveObj get(String name) { + public static HudPosObj get(String name) { name = name.toLowerCase(Locale.ROOT); if (!HudList.containsKey(name)) { - SaveObj obj1 = DataSql.readHud(name); + HudPosObj obj1 = DataSql.readHud(name); if (obj1 == null) { - SaveObj obj = AllMusic.getConfig().defaultHud.copy(); + HudPosObj obj = AllMusic.getConfig().defaultHud.copy(); HudList.put(name, obj); String finalName = name; DataSql.task(() -> DataSql.addUser(finalName, obj)); @@ -43,7 +43,7 @@ public class HudUtils { return HudList.get(name); } - public static void addAndSave(String name, SaveObj hud) { + public static void addAndSave(String name, HudPosObj hud) { name = name.toLowerCase(Locale.ROOT); HudList.put(name, hud); String finalName = name; @@ -59,11 +59,11 @@ public class HudUtils { * @param y y * @return 位置数据 */ - public static PosObj setHudPos(String player, HudType pos, String x, String y) { - SaveObj obj = get(player); + public static HudItemPosObj setHudPos(String player, HudType pos, String x, String y) { + HudPosObj obj = get(player); if (obj == null) obj = AllMusic.getConfig().defaultHud.copy(); - PosObj posOBJ = new PosObj(0, 0, HudDirType.TOP_LEFT, 0xffffff, false, true); + HudItemPosObj posOBJ = new HudItemPosObj(0, 0, HudDirType.TOP_LEFT, 0xffffff, false, true); if (!Function.isInteger(x) && !Function.isInteger(y)) return null; int x1 = Integer.parseInt(x); @@ -188,7 +188,7 @@ public class HudUtils { * @return 设置结果 */ public static boolean setHudEnable(String player, HudType pos, String arg) { - SaveObj obj = get(player); + HudPosObj obj = get(player); boolean res = false; boolean value = false; boolean have = false; @@ -264,7 +264,7 @@ public class HudUtils { public static void sendHudPos(String player) { AllMusic.side.runTask(() -> { try { - SaveObj obj = get(player); + HudPosObj obj = get(player); if (obj == null) { obj = AllMusic.getConfig().defaultHud.copy(); addAndSave(player, obj); @@ -283,14 +283,14 @@ public class HudUtils { * @param player 用户名 */ public static void reset(String player) { - SaveObj obj = AllMusic.getConfig().defaultHud.copy(); + HudPosObj obj = AllMusic.getConfig().defaultHud.copy(); addAndSave(player, obj); HudUtils.sendHudPos(player); } public static void reset(String player, HudType type) { - SaveObj obj = AllMusic.getConfig().defaultHud.copy(); - SaveObj obj1 = get(player); + HudPosObj obj = AllMusic.getConfig().defaultHud.copy(); + HudPosObj obj1 = get(player); switch (type) { case INFO: obj1.info = obj.info; @@ -319,7 +319,7 @@ public class HudUtils { * @return 结果 */ public static boolean setPicSize(String player, String size) { - SaveObj obj = get(player); + HudPosObj obj = get(player); if (obj == null) obj = AllMusic.getConfig().defaultHud.copy(); if (!Function.isInteger(size)) @@ -340,7 +340,7 @@ public class HudUtils { * @return 结果 */ public static boolean setPicRotate(String player, String open) { - SaveObj obj = get(player); + HudPosObj obj = get(player); if (obj == null) obj = AllMusic.getConfig().defaultHud.copy(); @@ -363,7 +363,7 @@ public class HudUtils { * @return 结果 */ public static boolean setPicRotateSpeed(String player, String size) { - SaveObj obj = get(player); + HudPosObj obj = get(player); if (obj == null) obj = AllMusic.getConfig().defaultHud.copy(); if (!Function.isInteger(size)) @@ -392,7 +392,7 @@ public class HudUtils { return null; } - SaveObj obj = get(player); + HudPosObj obj = get(player); if (obj == null) obj = AllMusic.getConfig().defaultHud.copy(); @@ -431,7 +431,7 @@ public class HudUtils { return false; } - SaveObj obj = get(player); + HudPosObj obj = get(player); if (obj == null) obj = AllMusic.getConfig().defaultHud.copy(); @@ -457,7 +457,7 @@ public class HudUtils { } public static boolean setShadow(String name, HudType pos, String arg) { - SaveObj obj = get(name); + HudPosObj obj = get(name); boolean res = false; boolean value = false; boolean have = false; @@ -509,7 +509,7 @@ public class HudUtils { return res; } - public static void set(String name, SaveObj obj) { + public static void set(String name, HudPosObj obj) { addAndSave(name, obj); HudUtils.sendHudPos(name); } diff --git a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java similarity index 88% rename from fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java rename to fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java index c8f4f852..9f4c37f8 100644 --- a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java +++ b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java @@ -1,7 +1,7 @@ package com.coloryr.allmusic.server; import com.coloryr.allmusic.server.core.AllMusic; -import net.fabricmc.api.ModInitializer; +import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.minecraft.server.MinecraftServer; @@ -11,7 +11,7 @@ import org.apache.logging.log4j.Logger; import java.io.File; -public class AllMusicFabric implements ModInitializer { +public class AllMusicServer implements DedicatedServerModInitializer { public static final Logger LOGGER = LogManager.getLogger("AllMusic Server"); public static final Identifier ID = new Identifier("allmusic", "channel"); public static MinecraftServer server; @@ -19,7 +19,7 @@ public class AllMusicFabric implements ModInitializer { public static final String dir = "allmusic_server/"; @Override - public void onInitialize() { + public void onInitializeServer() { AllMusic.log = new LogFabric(); AllMusic.side = new SideFabric(); diff --git a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/FabricApi.java b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/FabricApi.java index 0d46f250..a8ae3577 100644 --- a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/FabricApi.java +++ b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/FabricApi.java @@ -44,7 +44,7 @@ public class FabricApi { LiteralText endText = new LiteralText(end); endText.setStyle(endText.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command))); send.append(endText); - for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (ServerPlayerEntity player : AllMusicServer.server.getPlayerManager().getPlayerList()) { player.sendMessage(send, false); } } diff --git a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/LogFabric.java b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/LogFabric.java index b1a201ff..df6c69ed 100644 --- a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/LogFabric.java +++ b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/LogFabric.java @@ -5,11 +5,11 @@ import com.coloryr.allmusic.server.core.side.IMyLogger; public class LogFabric implements IMyLogger { @Override public void warning(String data) { - AllMusicFabric.LOGGER.warn(data); + AllMusicServer.LOGGER.warn(data); } @Override public void info(String data) { - AllMusicFabric.LOGGER.info(data); + AllMusicServer.LOGGER.info(data); } } diff --git a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/SideFabric.java b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/SideFabric.java index 68667071..174447dc 100644 --- a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/SideFabric.java +++ b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/SideFabric.java @@ -1,8 +1,8 @@ package com.coloryr.allmusic.server; -import com.coloryr.allmusic.server.codec.PacketCodec; +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.enums.ComType; import com.coloryr.allmusic.server.core.objs.music.MusicObj; import com.coloryr.allmusic.server.core.objs.music.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; @@ -25,7 +25,7 @@ public class SideFabric extends BaseSide { @Override public void runTask(Runnable run) { - AllMusicFabric.server.execute(run); + AllMusicServer.server.execute(run); } @Override @@ -55,7 +55,7 @@ public class SideFabric extends BaseSide { @Override public Collection getPlayers() { - return AllMusicFabric.server.getPlayerManager().getPlayerList(); + return AllMusicServer.server.getPlayerManager().getPlayerList(); } @Override @@ -74,10 +74,10 @@ public class SideFabric extends BaseSide { } @Override - public void send(Object player, ComType type, String data, int data1) { + public void send(Object player, CommandType type, String data, int data1) { if (player instanceof ServerPlayerEntity) { ServerPlayerEntity player1 = (ServerPlayerEntity) player; - send(player1, PacketCodec.pack(type, data, data1)); + send(player1, MusicPacketCodec.pack(type, data, data1)); } } @@ -96,12 +96,12 @@ public class SideFabric extends BaseSide { @Override public File getFolder() { - return new File(AllMusicFabric.dir); + return new File(AllMusicServer.dir); } @Override public boolean needPlay(boolean islist) { - for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (ServerPlayerEntity player : AllMusicServer.server.getPlayerManager().getPlayerList()) { if (!AllMusic.isSkip(player.getName().getString(), null, false, islist)) { return true; } @@ -114,7 +114,7 @@ public class SideFabric extends BaseSide { if (message == null || message.isEmpty()) { return; } - for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (ServerPlayerEntity player : AllMusicServer.server.getPlayerManager().getPlayerList()) { player.sendMessage(Text.of(message), false); } } @@ -173,7 +173,7 @@ public class SideFabric extends BaseSide { if (players == null) return; try { - runTask(() -> ServerPlayNetworking.send(players, AllMusicFabric.ID, new PacketByteBuf(data))); + runTask(() -> ServerPlayNetworking.send(players, AllMusicServer.ID, new PacketByteBuf(data))); } catch (Exception e) { AllMusic.log.warning("§c数据发送发生错误"); e.printStackTrace(); diff --git a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/Tasks.java b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/Tasks.java index 36312372..1eb5acf5 100644 --- a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/Tasks.java +++ b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/Tasks.java @@ -8,7 +8,7 @@ public class Tasks { private static final List taskItems = new CopyOnWriteArrayList<>(); public static void init() { - AllMusicFabric.server.addServerGuiTickable(Tasks::tick); + AllMusicServer.server.addServerGuiTickable(Tasks::tick); } public static void tick() { diff --git a/fabric_1_16_5/src/main/resources/fabric.mod.json b/fabric_1_16_5/src/main/resources/fabric.mod.json index 61649bc9..035dfc4f 100644 --- a/fabric_1_16_5/src/main/resources/fabric.mod.json +++ b/fabric_1_16_5/src/main/resources/fabric.mod.json @@ -18,8 +18,8 @@ "environment": "*", "entrypoints": { - "main": [ - "com.coloryr.allmusic.server.AllMusicFabric" + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" ] }, "mixins": [ diff --git a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java similarity index 88% rename from fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java rename to fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java index 4c938f74..f814c8da 100644 --- a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java +++ b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java @@ -1,6 +1,7 @@ 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; @@ -11,7 +12,7 @@ import org.slf4j.LoggerFactory; import java.io.File; -public class AllMusicFabric implements ModInitializer { +public class AllMusicServer implements DedicatedServerModInitializer { public static MinecraftServer server; public static final Logger LOGGER = LoggerFactory.getLogger("AllMusic Server"); @@ -20,7 +21,7 @@ public class AllMusicFabric implements ModInitializer { public static final String dir = "allmusic_server/"; @Override - public void onInitialize() { + public void onInitializeServer() { AllMusic.log = new LogFabric(); AllMusic.side = new SideFabric(); diff --git a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/FabricApi.java b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/FabricApi.java index 35d3024c..c06f920d 100644 --- a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/FabricApi.java +++ b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/FabricApi.java @@ -35,7 +35,7 @@ public class FabricApi { MutableText endText = Text.literal(end); endText.setStyle(endText.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command))); send.append(endText); - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { player.sendMessage(send, false); } } diff --git a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/LogFabric.java b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/LogFabric.java index b1a201ff..df6c69ed 100644 --- a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/LogFabric.java +++ b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/LogFabric.java @@ -5,11 +5,11 @@ import com.coloryr.allmusic.server.core.side.IMyLogger; public class LogFabric implements IMyLogger { @Override public void warning(String data) { - AllMusicFabric.LOGGER.warn(data); + AllMusicServer.LOGGER.warn(data); } @Override public void info(String data) { - AllMusicFabric.LOGGER.info(data); + AllMusicServer.LOGGER.info(data); } } diff --git a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/SideFabric.java b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/SideFabric.java index 25cc0704..e0eb300a 100644 --- a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/SideFabric.java +++ b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/SideFabric.java @@ -1,8 +1,8 @@ package com.coloryr.allmusic.server; -import com.coloryr.allmusic.server.codec.PacketCodec; +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.enums.ComType; import com.coloryr.allmusic.server.core.objs.music.MusicObj; import com.coloryr.allmusic.server.core.objs.music.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; @@ -22,7 +22,7 @@ import java.util.Collection; public class SideFabric extends BaseSide { @Override public void runTask(Runnable run) { - AllMusicFabric.server.execute(run); + AllMusicServer.server.execute(run); } @Override @@ -52,7 +52,7 @@ public class SideFabric extends BaseSide { @Override public boolean needPlay(boolean islist) { - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { if (!AllMusic.isSkip(player.getName().getString(), null, false, islist)) { return true; } @@ -62,7 +62,7 @@ public class SideFabric extends BaseSide { @Override public Collection getPlayers() { - return AllMusicFabric.server.getPlayerManager().getPlayerList(); + return AllMusicServer.server.getPlayerManager().getPlayerList(); } @Override @@ -80,15 +80,15 @@ public class SideFabric extends BaseSide { } @Override - public void send(Object player, ComType type, String data, int data1) { + public void send(Object player, CommandType type, String data, int data1) { if (player instanceof ServerPlayerEntity player1) { - send(player1, PacketCodec.pack(type, data, data1)); + send(player1, MusicPacketCodec.pack(type, data, data1)); } } @Override public Object getPlayer(String player) { - return AllMusicFabric.server.getPlayerManager().getPlayer(player); + return AllMusicServer.server.getPlayerManager().getPlayer(player); } @Override @@ -100,7 +100,7 @@ public class SideFabric extends BaseSide { @Override public File getFolder() { - return new File(AllMusicFabric.dir); + return new File(AllMusicServer.dir); } @Override @@ -108,7 +108,7 @@ public class SideFabric extends BaseSide { if (message == null || message.isEmpty()) { return; } - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(message), false); } @@ -163,7 +163,7 @@ public class SideFabric extends BaseSide { if (players == null) return; try { - runTask(() -> ServerPlayNetworking.send(players, AllMusicFabric.ID, new PacketByteBuf(data))); + runTask(() -> ServerPlayNetworking.send(players, AllMusicServer.ID, new PacketByteBuf(data))); } catch (Exception e) { AllMusic.log.warning("§c数据发送发生错误"); e.printStackTrace(); diff --git a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/Tasks.java b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/Tasks.java index c70e7f5e..a68ab552 100644 --- a/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/Tasks.java +++ b/fabric_1_20_1/src/main/java/com/coloryr/allmusic/server/Tasks.java @@ -8,7 +8,7 @@ public class Tasks { private static final List taskItems = new CopyOnWriteArrayList<>(); public static void init() { - AllMusicFabric.server.addServerGuiTickable(Tasks::tick); + AllMusicServer.server.addServerGuiTickable(Tasks::tick); } public static void tick() { diff --git a/fabric_1_20_1/src/main/resources/fabric.mod.json b/fabric_1_20_1/src/main/resources/fabric.mod.json index ca45d4e8..e046d5c4 100644 --- a/fabric_1_20_1/src/main/resources/fabric.mod.json +++ b/fabric_1_20_1/src/main/resources/fabric.mod.json @@ -18,8 +18,8 @@ "environment": "*", "entrypoints": { - "main": [ - "com.coloryr.allmusic.server.AllMusicFabric" + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" ] }, "mixins": [ diff --git a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java similarity index 80% rename from fabric_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java rename to fabric_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java index 40cb911f..d706bcc3 100644 --- a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java +++ b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java @@ -1,7 +1,7 @@ package com.coloryr.allmusic.server; import com.coloryr.allmusic.server.core.AllMusic; -import net.fabricmc.api.ModInitializer; +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; @@ -12,15 +12,14 @@ import org.slf4j.LoggerFactory; import java.io.File; -public class AllMusicFabric implements ModInitializer { +public class AllMusicServer implements DedicatedServerModInitializer { public static final Logger LOGGER = LoggerFactory.getLogger("AllMusic Server"); - public static final Identifier ID = Identifier.of("allmusic", "channel"); public static MinecraftServer server; public static final String dir = "allmusic_server/"; @Override - public void onInitialize() { + public void onInitializeServer() { AllMusic.log = new LogFabric(); AllMusic.side = new SideFabric(); @@ -29,7 +28,6 @@ public class AllMusicFabric implements ModInitializer { CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> CommandFabric.instance.register(dispatcher)); - PayloadTypeRegistry.playS2C().register(PackPayload.ID, PackPayload.CODEC); ServerLifecycleEvents.SERVER_STARTED.register((a) -> { server = a; diff --git a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/FabricApi.java b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/FabricApi.java index 35d3024c..c06f920d 100644 --- a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/FabricApi.java +++ b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/FabricApi.java @@ -35,7 +35,7 @@ public class FabricApi { MutableText endText = Text.literal(end); endText.setStyle(endText.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command))); send.append(endText); - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { player.sendMessage(send, false); } } diff --git a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/LogFabric.java b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/LogFabric.java index b1a201ff..df6c69ed 100644 --- a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/LogFabric.java +++ b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/LogFabric.java @@ -5,11 +5,11 @@ import com.coloryr.allmusic.server.core.side.IMyLogger; public class LogFabric implements IMyLogger { @Override public void warning(String data) { - AllMusicFabric.LOGGER.warn(data); + AllMusicServer.LOGGER.warn(data); } @Override public void info(String data) { - AllMusicFabric.LOGGER.info(data); + AllMusicServer.LOGGER.info(data); } } diff --git a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/PackPayload.java b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/PackPayload.java deleted file mode 100644 index 6623f5de..00000000 --- a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/PackPayload.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.coloryr.allmusic.server; - -import com.coloryr.allmusic.server.core.objs.enums.ComType; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.packet.CustomPayload; - -public record PackPayload(ComType type, String data, int data1) implements CustomPayload { - public static final Id ID = new CustomPayload.Id<>(AllMusicFabric.ID); - public static final PacketCodec CODEC = - PacketCodec.of((value, buf) -> com.coloryr.allmusic.server.codec.PacketCodec.pack(buf, value.type, value.data, value.data1), - buffer -> new PackPayload(ComType.CLEAR, null, 0)); - - @Override - public Id getId() { - return ID; - } -} diff --git a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/SideFabric.java b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/SideFabric.java index 0e98ab77..7a2a1051 100644 --- a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/SideFabric.java +++ b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/SideFabric.java @@ -1,7 +1,9 @@ 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.AllMusic; -import com.coloryr.allmusic.server.core.objs.enums.ComType; import com.coloryr.allmusic.server.core.objs.music.MusicObj; import com.coloryr.allmusic.server.core.objs.music.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; @@ -20,7 +22,7 @@ public class SideFabric extends BaseSide { @Override public void runTask(Runnable run) { - AllMusicFabric.server.execute(run); + AllMusicServer.server.execute(run); } @Override @@ -50,7 +52,7 @@ public class SideFabric extends BaseSide { @Override public boolean needPlay(boolean islist) { - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { if (!AllMusic.isSkip(player.getName().getString(), null, false, islist)) { return true; } @@ -60,7 +62,7 @@ public class SideFabric extends BaseSide { @Override public Collection getPlayers() { - return AllMusicFabric.server.getPlayerManager().getPlayerList(); + return AllMusicServer.server.getPlayerManager().getPlayerList(); } @Override @@ -78,15 +80,15 @@ public class SideFabric extends BaseSide { } @Override - public void send(Object player, ComType type, String data, int data1) { + public void send(Object player, CommandType type, String data, int data1) { if (player instanceof ServerPlayerEntity player1) { - send(player1, new PackPayload(type, data, data1)); + send(player1, new MusicPack(type, data, data1)); } } @Override public Object getPlayer(String player) { - return AllMusicFabric.server.getPlayerManager().getPlayer(player); + return AllMusicServer.server.getPlayerManager().getPlayer(player); } @Override @@ -98,7 +100,7 @@ public class SideFabric extends BaseSide { @Override public File getFolder() { - return new File(AllMusicFabric.dir); + return new File(AllMusicServer.dir); } @Override @@ -106,7 +108,7 @@ public class SideFabric extends BaseSide { if (message == null || message.isEmpty()) { return; } - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(message), false); } @@ -157,11 +159,11 @@ public class SideFabric extends BaseSide { return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != ActionResult.PASS; } - private void send(ServerPlayerEntity players, PackPayload data) { + private void send(ServerPlayerEntity players, MusicPack data) { if (players == null) return; try { - runTask(() -> ServerPlayNetworking.send(players, data)); + runTask(() -> ServerPlayNetworking.send(players, new MusicCodec(data))); } catch (Exception e) { AllMusic.log.warning("§c数据发送发生错误"); e.printStackTrace(); diff --git a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/Tasks.java b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/Tasks.java index c70e7f5e..a68ab552 100644 --- a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/Tasks.java +++ b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/Tasks.java @@ -8,7 +8,7 @@ public class Tasks { private static final List taskItems = new CopyOnWriteArrayList<>(); public static void init() { - AllMusicFabric.server.addServerGuiTickable(Tasks::tick); + AllMusicServer.server.addServerGuiTickable(Tasks::tick); } public static void tick() { diff --git a/fabric_1_21/src/main/resources/fabric.mod.json b/fabric_1_21/src/main/resources/fabric.mod.json index da205be5..338a869c 100644 --- a/fabric_1_21/src/main/resources/fabric.mod.json +++ b/fabric_1_21/src/main/resources/fabric.mod.json @@ -19,7 +19,10 @@ "environment": "*", "entrypoints": { "main": [ - "com.coloryr.allmusic.server.AllMusicFabric" + "com.coloryr.allmusic.comm.AllMusicInit" + ], + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" ] }, "mixins": [ diff --git a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java similarity index 66% rename from fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java rename to fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java index 4d08d9bd..3da617a8 100644 --- a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java +++ b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java @@ -1,10 +1,8 @@ package com.coloryr.allmusic.server; -import com.coloryr.allmusic.server.core.AllMusic; -import net.fabricmc.api.ModInitializer; +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.resources.Identifier; import net.minecraft.server.MinecraftServer; import org.slf4j.Logger; @@ -12,35 +10,32 @@ import org.slf4j.LoggerFactory; import java.io.File; -public class AllMusicFabric implements ModInitializer { - public static MinecraftServer server; +public class AllMusicServer implements DedicatedServerModInitializer { public static final Logger LOGGER = LoggerFactory.getLogger("AllMusic Server"); - public static final Identifier ID = Identifier.fromNamespaceAndPath("allmusic", "channel"); - public static final String dir = "allmusic_server/"; + public static MinecraftServer server; @Override - public void onInitialize() { - AllMusic.log = new LogFabric(); - AllMusic.side = new SideFabric(); + public void onInitializeServer() { + com.coloryr.allmusic.server.core.AllMusic.log = new LogFabric(); + com.coloryr.allmusic.server.core.AllMusic.side = new SideFabric(); - new AllMusic().init(new File(dir)); + new com.coloryr.allmusic.server.core.AllMusic().init(new File(dir)); CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> CommandFabric.instance.register(dispatcher)); - PayloadTypeRegistry.playS2C().register(PackPayload.ID, PackPayload.CODEC); ServerLifecycleEvents.SERVER_STARTED.register((a) -> { server = a; - AllMusic.start(); + com.coloryr.allmusic.server.core.AllMusic.start(); Tasks.init(); }); ServerLifecycleEvents.SERVER_STOPPING.register((a) -> { - AllMusic.stop(); + com.coloryr.allmusic.server.core.AllMusic.stop(); }); } } diff --git a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/CommandFabric.java b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/CommandFabric.java index 2f9ef462..5bf02199 100644 --- a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/CommandFabric.java +++ b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/CommandFabric.java @@ -59,7 +59,7 @@ public class CommandFabric implements Command, Predicate ID = new CustomPacketPayload.Type<>(AllMusicFabric.ID); - public static final StreamCodec CODEC = - StreamCodec.of((value, buf) -> PacketCodec.pack(value, buf.type1, buf.data, buf.data1), - buffer -> new PackPayload(ComType.CLEAR, null, 0)); - - @Override - public CustomPacketPayload.Type type() { - return ID; - } -} diff --git a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/SideFabric.java b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/SideFabric.java index 8d4f5b96..f4544914 100644 --- a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/SideFabric.java +++ b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/SideFabric.java @@ -1,7 +1,8 @@ package com.coloryr.allmusic.server; -import com.coloryr.allmusic.server.core.AllMusic; -import com.coloryr.allmusic.server.core.objs.enums.ComType; +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.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; @@ -20,7 +21,7 @@ import java.util.Collection; public class SideFabric extends BaseSide { @Override public void runTask(Runnable run) { - AllMusicFabric.server.execute(run); + AllMusicServer.server.execute(run); } @Override @@ -50,8 +51,8 @@ public class SideFabric extends BaseSide { @Override public boolean needPlay(boolean islist) { - for (var player : AllMusicFabric.server.getPlayerList().getPlayers()) { - if (!AllMusic.isSkip(player.getName().getString(), null, false, islist)) { + for (var player : AllMusicServer.server.getPlayerList().getPlayers()) { + if (!com.coloryr.allmusic.server.core.AllMusic.isSkip(player.getName().getString(), null, false, islist)) { return true; } } @@ -60,7 +61,7 @@ public class SideFabric extends BaseSide { @Override public Collection getPlayers() { - return AllMusicFabric.server.getPlayerList().getPlayers(); + return AllMusicServer.server.getPlayerList().getPlayers(); } @Override @@ -78,15 +79,15 @@ public class SideFabric extends BaseSide { } @Override - public void send(Object player, ComType type, String data, int data1) { + public void send(Object player, CommandType type, String data, int data1) { if (player instanceof ServerPlayer player1) { - send(player1, new PackPayload(type, data, data1)); + send(player1, new MusicPack(type, data, data1)); } } @Override public Object getPlayer(String player) { - return AllMusicFabric.server.getPlayerList().getPlayer(player); + return AllMusicServer.server.getPlayerList().getPlayer(player); } @Override @@ -98,7 +99,7 @@ public class SideFabric extends BaseSide { @Override public File getFolder() { - return new File(AllMusicFabric.dir); + return new File(AllMusicServer.dir); } @Override @@ -106,8 +107,8 @@ public class SideFabric extends BaseSide { if (message == null || message.isEmpty()) { return; } - for (var player : AllMusicFabric.server.getPlayerList().getPlayers()) { - if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + for (var player : AllMusicServer.server.getPlayerList().getPlayers()) { + if (!com.coloryr.allmusic.server.core.AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendSystemMessage(Component.literal(message), false); } } @@ -157,13 +158,13 @@ public class SideFabric extends BaseSide { return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != InteractionResult.PASS; } - private void send(ServerPlayer players, PackPayload data) { + private void send(ServerPlayer players, MusicPack data) { if (players == null) return; try { - runTask(() -> ServerPlayNetworking.send(players, data)); + runTask(() -> ServerPlayNetworking.send(players, new MusicCodec(data))); } catch (Exception e) { - AllMusic.log.warning("§c数据发送发生错误"); + com.coloryr.allmusic.server.core.AllMusic.log.warning("§c数据发送发生错误"); e.printStackTrace(); } } diff --git a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/Tasks.java b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/Tasks.java index 57e1f3e3..d4e72d39 100644 --- a/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/Tasks.java +++ b/fabric_1_21_11/src/main/java/com/coloryr/allmusic/server/Tasks.java @@ -8,7 +8,7 @@ public class Tasks { private static final List taskItems = new CopyOnWriteArrayList<>(); public static void init() { - AllMusicFabric.server.addTickable(Tasks::tick); + AllMusicServer.server.addTickable(Tasks::tick); } public static void tick() { diff --git a/fabric_1_21_11/src/main/resources/fabric.mod.json b/fabric_1_21_11/src/main/resources/fabric.mod.json index f8f83600..813de075 100644 --- a/fabric_1_21_11/src/main/resources/fabric.mod.json +++ b/fabric_1_21_11/src/main/resources/fabric.mod.json @@ -19,7 +19,10 @@ "environment": "*", "entrypoints": { "main": [ - "com.coloryr.allmusic.server.AllMusicFabric" + "com.coloryr.allmusic.comm.AllMusicInit" + ], + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" ] }, "mixins": [ diff --git a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java similarity index 58% rename from fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java rename to fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java index e39cfaf2..64d92d4d 100644 --- a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java +++ b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicServer.java @@ -1,46 +1,37 @@ package com.coloryr.allmusic.server; -import com.coloryr.allmusic.server.core.AllMusic; -import net.fabricmc.api.ModInitializer; +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; import java.io.File; -public class AllMusicFabric implements ModInitializer { - public static MinecraftServer server; +public class AllMusicServer implements DedicatedServerModInitializer { public static final Logger LOGGER = LoggerFactory.getLogger("AllMusic Server"); - - public static final Identifier ID = Identifier.of("allmusic", "channel"); - public static final String dir = "allmusic_server/"; + public static MinecraftServer server; @Override - public void onInitialize() { - AllMusic.log = new LogFabric(); - AllMusic.side = new SideFabric(); + public void onInitializeServer() { + com.coloryr.allmusic.server.core.AllMusic.log = new LogFabric(); + com.coloryr.allmusic.server.core.AllMusic.side = new SideFabric(); - new AllMusic().init(new File(dir)); + new com.coloryr.allmusic.server.core.AllMusic().init(new File(dir)); CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> CommandFabric.instance.register(dispatcher)); - PayloadTypeRegistry.playS2C().register(PackPayload.ID, PackPayload.CODEC); ServerLifecycleEvents.SERVER_STARTED.register((a) -> { server = a; - - AllMusic.start(); - + com.coloryr.allmusic.server.core.AllMusic.start(); Tasks.init(); }); ServerLifecycleEvents.SERVER_STOPPING.register((a) -> { - AllMusic.stop(); + com.coloryr.allmusic.server.core.AllMusic.stop(); }); } } diff --git a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java index 32e8f46b..ad3c8d44 100644 --- a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java +++ b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java @@ -59,7 +59,7 @@ public class CommandFabric implements Command, Predicate ID = new CustomPayload.Id<>(AllMusicFabric.ID); - public static final PacketCodec CODEC = - PacketCodec.of((value, buf) -> com.coloryr.allmusic.server.codec.PacketCodec.pack(buf, value.type, value.data, value.data1), - buffer -> new PackPayload(ComType.CLEAR, null, 0)); - - @Override - public Id getId() { - return ID; - } -} diff --git a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java index 335f09f4..4914a870 100644 --- a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java +++ b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java @@ -1,7 +1,8 @@ package com.coloryr.allmusic.server; -import com.coloryr.allmusic.server.core.AllMusic; -import com.coloryr.allmusic.server.core.objs.enums.ComType; +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.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; @@ -19,7 +20,7 @@ import java.util.Collection; public class SideFabric extends BaseSide { @Override public void runTask(Runnable run) { - AllMusicFabric.server.execute(run); + AllMusicServer.server.execute(run); } @Override @@ -49,8 +50,8 @@ public class SideFabric extends BaseSide { @Override public boolean needPlay(boolean islist) { - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.isSkip(player.getName().getString(), null, false, islist)) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { + if (!com.coloryr.allmusic.server.core.AllMusic.isSkip(player.getName().getString(), null, false, islist)) { return true; } } @@ -59,7 +60,7 @@ public class SideFabric extends BaseSide { @Override public Collection getPlayers() { - return AllMusicFabric.server.getPlayerManager().getPlayerList(); + return AllMusicServer.server.getPlayerManager().getPlayerList(); } @Override @@ -77,15 +78,15 @@ public class SideFabric extends BaseSide { } @Override - public void send(Object player, ComType type, String data, int data1) { + public void send(Object player, CommandType type, String data, int data1) { if (player instanceof ServerPlayerEntity player1) { - send(player1, new PackPayload(type, data, data1)); + send(player1, new MusicPack(type, data, data1)); } } @Override public Object getPlayer(String player) { - return AllMusicFabric.server.getPlayerManager().getPlayer(player); + return AllMusicServer.server.getPlayerManager().getPlayer(player); } @Override @@ -97,7 +98,7 @@ public class SideFabric extends BaseSide { @Override public File getFolder() { - return new File(AllMusicFabric.dir); + return new File(AllMusicServer.dir); } @Override @@ -105,8 +106,8 @@ public class SideFabric extends BaseSide { if (message == null || message.isEmpty()) { return; } - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { + if (!com.coloryr.allmusic.server.core.AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(message), false); } } @@ -156,13 +157,13 @@ public class SideFabric extends BaseSide { return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != ActionResult.PASS; } - private void send(ServerPlayerEntity players, PackPayload data) { + private void send(ServerPlayerEntity players, MusicPack data) { if (players == null) return; try { - runTask(() -> ServerPlayNetworking.send(players, data)); + runTask(() -> ServerPlayNetworking.send(players, new MusicCodec(data))); } catch (Exception e) { - AllMusic.log.warning("§c数据发送发生错误"); + com.coloryr.allmusic.server.core.AllMusic.log.warning("§c数据发送发生错误"); e.printStackTrace(); } } diff --git a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java index c70e7f5e..a68ab552 100644 --- a/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java +++ b/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java @@ -8,7 +8,7 @@ public class Tasks { private static final List taskItems = new CopyOnWriteArrayList<>(); public static void init() { - AllMusicFabric.server.addServerGuiTickable(Tasks::tick); + AllMusicServer.server.addServerGuiTickable(Tasks::tick); } public static void tick() { diff --git a/fabric_1_21_6/src/main/resources/fabric.mod.json b/fabric_1_21_6/src/main/resources/fabric.mod.json index 7a709e84..005d1ba5 100644 --- a/fabric_1_21_6/src/main/resources/fabric.mod.json +++ b/fabric_1_21_6/src/main/resources/fabric.mod.json @@ -19,7 +19,10 @@ "environment": "*", "entrypoints": { "main": [ - "com.coloryr.allmusic.server.AllMusicFabric" + "com.coloryr.allmusic.comm.AllMusicInit" + ], + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" ] }, "mixins": [ diff --git a/link.cmd b/link.cmd index ea1b4166..f31a94a0 100644 --- a/link.cmd +++ b/link.cmd @@ -20,7 +20,8 @@ forge_1_7_10 forge_1_12_2 forge_1_16_5 forge_1_20_1 ^ neoforge_1_21 neoforge_1_21_6 neoforge_1_21_11 for %%i in (%array1%) do ( - if not exist "%%i\src\main\java\com\coloryr\allmusic\server\codec" mklink /j "%%i\src\main\java\com\coloryr\allmusic\server\codec" "codec" + if not exist "%%i\src\main\java\com\coloryr\allmusic\codec" mklink /j "%%i\src\main\java\com\coloryr\allmusic\codec" "client\codec" + if not exist "%%i\src\main\java\com\coloryr\allmusic\buffercodec" mklink /j "%%i\src\main\java\com\coloryr\allmusic\buffercodec" "client\buffercodec" ) set array2=folia server_top server @@ -29,7 +30,9 @@ for %%i in (%array2%) do ( if not exist "%%i\src\main\java\com\coloryr\allmusic\server\bstats" mklink /j "%%i\src\main\java\com\coloryr\allmusic\server\bstats" "bstats" ) -set array3=neoforge_1_21_6 fabric_1_21_6 forge_1_20_1 fabric_1_20_1 +set array3=fabric_1_16_5 fabric_1_20_1 fabric_1_21 fabric_1_21_6 fabric_1_21_11 ^ +neoforge_1_21_6 ^ +forge_1_20_1 for %%i in (%array3%) do ( @@ -39,8 +42,18 @@ for %%i in (%array3%) do ( if not exist "onejar\%%i\build\libs" mklink /j "onejar\%%i\build\libs" "build\libs" if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\server" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\server" "%%i\src\main\java\com\coloryr\allmusic\server" if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\client" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\client" "client\%%i\src\main\java\com\coloryr\allmusic\client" + + if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\codec" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\codec" "client\%%i\src\main\java\com\coloryr\allmusic\codec" + if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\buffercodec" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\buffercodec" "client\%%i\src\main\java\com\coloryr\allmusic\buffercodec" + if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\server\core" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\server\core" "core" - if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\server\codec" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\server\codec" "codec" if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\client\core" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\client\core" "client\core" if not exist "onejar\%%i\src\main\resources\com\coloryr\allmusic\client\core\player\decoder\mp3" mklink /j "onejar\%%i\src\main\resources\com\coloryr\allmusic\client\core\player\decoder\mp3" "client\mp3" +) + +set array4=fabric_1_21 fabric_1_21_6 fabric_1_21_11 + +for %%i in (%array4%) do ( + if not exist "%%i\src\main\java\com\coloryr\allmusic\comm" mklink /j "%%i\src\main\java\com\coloryr\allmusic\comm" "client\%%i\src\main\java\com\coloryr\allmusic\comm" + if not exist "onejar\%%i\src\main\java\com\coloryr\allmusic\comm" mklink /j "onejar\%%i\src\main\java\com\coloryr\allmusic\comm" "client\%%i\src\main\java\com\coloryr\allmusic\comm" ) \ No newline at end of file diff --git a/onejar/fabric_1_16_5/.gitignore b/onejar/fabric_1_16_5/.gitignore new file mode 100644 index 00000000..c476faf2 --- /dev/null +++ b/onejar/fabric_1_16_5/.gitignore @@ -0,0 +1,40 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/onejar/fabric_1_16_5/build.gradle b/onejar/fabric_1_16_5/build.gradle new file mode 100644 index 00000000..31902765 --- /dev/null +++ b/onejar/fabric_1_16_5/build.gradle @@ -0,0 +1,103 @@ +plugins { + id 'fabric-loom' version '1.10-SNAPSHOT' + id 'maven-publish' +// id "org.jetbrains.kotlin.jvm" version "1.9.23" +} + +def getVersionFromFile() { + def versionFile = file('../../version') + if (versionFile.exists()) { + return versionFile.text.trim() + } else { + throw new GradleException("Version file not found: ${versionFile.absolutePath}") + } +} + +version = getVersionFromFile() + +group = project.maven_group + +base { + archivesName = project.archives_base_name +} + +repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" + + include modImplementation('org.apache.httpcomponents.client5:httpclient5:5.6') + include modImplementation('org.apache.httpcomponents.core5:httpcore5:5.4') + include modImplementation('org.apache.httpcomponents.core5:httpcore5-h2:5.4') + include modImplementation('org.xerial:sqlite-jdbc:3.51.1.0') + + // Uncomment the following line to enable the deprecated Fabric API modules. + // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time. + + // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}" +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 8 +} + +//tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { +// kotlinOptions { +// jvmTarget = 1.8 +// } +//} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}"} + } +} + +// configure the maven publication +publishing { + publications { + create("mavenJava", MavenPublication) { + artifactId = project.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} \ No newline at end of file diff --git a/onejar/fabric_1_16_5/gradle.properties b/onejar/fabric_1_16_5/gradle.properties new file mode 100644 index 00000000..d6ee1e16 --- /dev/null +++ b/onejar/fabric_1_16_5/gradle.properties @@ -0,0 +1,17 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.16.5 +yarn_mappings=1.16.5+build.10 +loader_version=0.15.11 +fabric_kotlin_version=1.10.19+kotlin.1.9.23 + +# Mod Properties +maven_group = com.coloryr.allmusic.onejar +archives_base_name =[fabric-1.16.5]AllMusic_OneJar + +# Dependencies +fabric_version=0.42.0+1.16 \ No newline at end of file diff --git a/onejar/fabric_1_16_5/gradle/wrapper/gradle-wrapper.jar b/onejar/fabric_1_16_5/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..943f0cbf Binary files /dev/null and b/onejar/fabric_1_16_5/gradle/wrapper/gradle-wrapper.jar differ diff --git a/onejar/fabric_1_16_5/gradle/wrapper/gradle-wrapper.properties b/onejar/fabric_1_16_5/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..cea7a793 --- /dev/null +++ b/onejar/fabric_1_16_5/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/onejar/fabric_1_16_5/gradlew b/onejar/fabric_1_16_5/gradlew new file mode 100644 index 00000000..65dcd68d --- /dev/null +++ b/onejar/fabric_1_16_5/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/onejar/fabric_1_16_5/gradlew.bat b/onejar/fabric_1_16_5/gradlew.bat new file mode 100644 index 00000000..93e3f59f --- /dev/null +++ b/onejar/fabric_1_16_5/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/onejar/fabric_1_16_5/settings.gradle b/onejar/fabric_1_16_5/settings.gradle new file mode 100644 index 00000000..100d736f --- /dev/null +++ b/onejar/fabric_1_16_5/settings.gradle @@ -0,0 +1,12 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} + +rootProject.name = 'AllMusic' \ No newline at end of file diff --git a/onejar/fabric_1_16_5/src/main/resources/allmusic_client.mixins.json b/onejar/fabric_1_16_5/src/main/resources/allmusic_client.mixins.json new file mode 100644 index 00000000..480fc775 --- /dev/null +++ b/onejar/fabric_1_16_5/src/main/resources/allmusic_client.mixins.json @@ -0,0 +1,18 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.coloryr.allmusic.client.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "GuiShow", + "QuitServer", + "SoundEvent", + "Tick" + ], + "injectors": { + "defaultRequire": 1 + }, + "mixins": [ + + ] +} diff --git a/onejar/fabric_1_16_5/src/main/resources/allmusic_server.mixins.json b/onejar/fabric_1_16_5/src/main/resources/allmusic_server.mixins.json new file mode 100644 index 00000000..97c5516c --- /dev/null +++ b/onejar/fabric_1_16_5/src/main/resources/allmusic_server.mixins.json @@ -0,0 +1,16 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.coloryr.allmusic.server.mixin", + "compatibilityLevel": "JAVA_8", + "server": [ + + ], + "mixins": [ + "IGetCommandOutput", + "ServerPlayerMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/onejar/fabric_1_16_5/src/main/resources/assets/allmusic_server/icon.png b/onejar/fabric_1_16_5/src/main/resources/assets/allmusic_server/icon.png new file mode 100644 index 00000000..b2b5fa79 Binary files /dev/null and b/onejar/fabric_1_16_5/src/main/resources/assets/allmusic_server/icon.png differ diff --git a/onejar/fabric_1_16_5/src/main/resources/fabric.mod.json b/onejar/fabric_1_16_5/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..8a6d9d87 --- /dev/null +++ b/onejar/fabric_1_16_5/src/main/resources/fabric.mod.json @@ -0,0 +1,40 @@ +{ + "schemaVersion": 1, + "id": "allmusic_server", + "version": "${version}", + + "name": "AllMusic Server", + "description": "AllMusic Server Mod", + "authors": [ + "Color_yr" + ], + "contact": { + "homepage": "https://github.com/Coloryr/AllMusic_Server", + "sources": "https://github.com/Coloryr/AllMusic_Server" + }, + + "license": "GPL-3.0", + "icon": "assets/allmusic_server/icon.png", + + "environment": "*", + "entrypoints": { + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" + ], + "client": [ + "com.coloryr.allmusic.client.AllMusicClient" + ] + }, + "mixins": [ + "allmusic_client.mixins.json", + "allmusic_server.mixins.json" + ], + "depends": { + "fabricloader": ">=0.15.11", + "fabric": "*", + "minecraft": ">=1.16" + }, + "suggests": { + + } +} \ No newline at end of file diff --git a/onejar/fabric_1_20_1/gradle.properties b/onejar/fabric_1_20_1/gradle.properties index c4d108b6..949c3ec1 100644 --- a/onejar/fabric_1_20_1/gradle.properties +++ b/onejar/fabric_1_20_1/gradle.properties @@ -10,8 +10,8 @@ loader_version=0.17.2 fabric_kotlin_version=1.10.19+kotlin.1.9.23 # Mod Properties -maven_group = com.coloryr.allmusic -archives_base_name =[fabric-1.20.1]AllMusic +maven_group = com.coloryr.allmusic.onejar +archives_base_name =[fabric-1.20.1]AllMusic_OneJar # Dependencies fabric_version=0.92.6+1.20.1 diff --git a/onejar/fabric_1_20_1/settings.gradle b/onejar/fabric_1_20_1/settings.gradle index 100d736f..ddc7928c 100644 --- a/onejar/fabric_1_20_1/settings.gradle +++ b/onejar/fabric_1_20_1/settings.gradle @@ -9,4 +9,4 @@ pluginManagement { } } -rootProject.name = 'AllMusic' \ No newline at end of file +rootProject.name = 'AllMusic_OneJar' \ No newline at end of file diff --git a/onejar/fabric_1_20_1/src/main/resources/fabric.mod.json b/onejar/fabric_1_20_1/src/main/resources/fabric.mod.json index 25b643bf..dc0191be 100644 --- a/onejar/fabric_1_20_1/src/main/resources/fabric.mod.json +++ b/onejar/fabric_1_20_1/src/main/resources/fabric.mod.json @@ -18,11 +18,11 @@ "environment": "*", "entrypoints": { - "main": [ - "com.coloryr.allmusic.server.AllMusicFabric" + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" ], "client": [ - "com.coloryr.allmusic.client.AllMusic" + "com.coloryr.allmusic.client.AllMusicClient" ] }, "mixins": [ diff --git a/onejar/fabric_1_21/.gitignore b/onejar/fabric_1_21/.gitignore new file mode 100644 index 00000000..c476faf2 --- /dev/null +++ b/onejar/fabric_1_21/.gitignore @@ -0,0 +1,40 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/onejar/fabric_1_21/build.gradle b/onejar/fabric_1_21/build.gradle new file mode 100644 index 00000000..ddddd19d --- /dev/null +++ b/onejar/fabric_1_21/build.gradle @@ -0,0 +1,98 @@ +plugins { + id 'fabric-loom' version '1.10-SNAPSHOT' + id 'maven-publish' +// id "org.jetbrains.kotlin.jvm" version "2.0.0" +} + +def getVersionFromFile() { + def versionFile = file('../../version') + if (versionFile.exists()) { + return versionFile.text.trim() + } else { + throw new GradleException("Version file not found: ${versionFile.absolutePath}") + } +} + +version = getVersionFromFile() + +group = project.maven_group + +base { + archivesName = project.archives_base_name +} + +repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" + + include modImplementation('org.apache.httpcomponents.client5:httpclient5:5.6') + include modImplementation('org.apache.httpcomponents.core5:httpcore5:5.4') + include modImplementation('org.apache.httpcomponents.core5:httpcore5-h2:5.4') + include modImplementation('org.xerial:sqlite-jdbc:3.51.1.0') +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 21 +} + +//tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { +// kotlinOptions { +// jvmTarget = 21 +// } +//} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}"} + } +} + +// configure the maven publication +publishing { + publications { + create("mavenJava", MavenPublication) { + artifactId = project.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} \ No newline at end of file diff --git a/onejar/fabric_1_21/gradle.properties b/onejar/fabric_1_21/gradle.properties new file mode 100644 index 00000000..b1021b42 --- /dev/null +++ b/onejar/fabric_1_21/gradle.properties @@ -0,0 +1,17 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.21 +yarn_mappings=1.21+build.1 +loader_version=0.16.10 +fabric_kotlin_version=1.11.0+kotlin.2.0.0 + +# Mod Properties +maven_group = com.coloryr.allmusic.onejar +archives_base_name =[fabric-1.21]AllMusic_OneJar + +# Dependencies +fabric_version=0.100.1+1.21 diff --git a/onejar/fabric_1_21/gradle/wrapper/gradle-wrapper.jar b/onejar/fabric_1_21/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..ccebba77 Binary files /dev/null and b/onejar/fabric_1_21/gradle/wrapper/gradle-wrapper.jar differ diff --git a/onejar/fabric_1_21/gradle/wrapper/gradle-wrapper.properties b/onejar/fabric_1_21/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..cea7a793 --- /dev/null +++ b/onejar/fabric_1_21/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/onejar/fabric_1_21/gradlew b/onejar/fabric_1_21/gradlew new file mode 100644 index 00000000..79a61d42 --- /dev/null +++ b/onejar/fabric_1_21/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/onejar/fabric_1_21/gradlew.bat b/onejar/fabric_1_21/gradlew.bat new file mode 100644 index 00000000..93e3f59f --- /dev/null +++ b/onejar/fabric_1_21/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/onejar/fabric_1_21/settings.gradle b/onejar/fabric_1_21/settings.gradle new file mode 100644 index 00000000..ddc7928c --- /dev/null +++ b/onejar/fabric_1_21/settings.gradle @@ -0,0 +1,12 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} + +rootProject.name = 'AllMusic_OneJar' \ No newline at end of file diff --git a/onejar/fabric_1_21/src/main/resources/allmusic_client.mixins.json b/onejar/fabric_1_21/src/main/resources/allmusic_client.mixins.json new file mode 100644 index 00000000..f3433807 --- /dev/null +++ b/onejar/fabric_1_21/src/main/resources/allmusic_client.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "com.coloryr.allmusic.client.mixin", + "compatibilityLevel": "JAVA_21", + "client": [ + "GuiShow", + "QuitServer", + "SoundEvent", + "Tick" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/onejar/fabric_1_21/src/main/resources/allmusic_server.mixins.json b/onejar/fabric_1_21/src/main/resources/allmusic_server.mixins.json new file mode 100644 index 00000000..5ae7a802 --- /dev/null +++ b/onejar/fabric_1_21/src/main/resources/allmusic_server.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.coloryr.allmusic.server.mixin", + "compatibilityLevel": "JAVA_17", + "server": [ + + ], + "mixins": [ + "ServerPlayerMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/onejar/fabric_1_21/src/main/resources/assets/allmusic_server/icon.png b/onejar/fabric_1_21/src/main/resources/assets/allmusic_server/icon.png new file mode 100644 index 00000000..b2b5fa79 Binary files /dev/null and b/onejar/fabric_1_21/src/main/resources/assets/allmusic_server/icon.png differ diff --git a/onejar/fabric_1_21/src/main/resources/fabric.mod.json b/onejar/fabric_1_21/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..dfe6f55e --- /dev/null +++ b/onejar/fabric_1_21/src/main/resources/fabric.mod.json @@ -0,0 +1,43 @@ +{ + "schemaVersion": 1, + "id": "allmusic_server", + "version": "${version}", + + "name": "AllMusic Server", + "description": "AllMusic Server Mod", + "authors": [ + "Color_yr" + ], + "contact": { + "homepage": "https://github.com/Coloryr/AllMusic_Server", + "sources": "https://github.com/Coloryr/AllMusic_Server" + }, + + "license": "GPL-3.0", + "icon": "assets/allmusic_server/icon.png", + + "environment": "*", + "entrypoints": { + "main": [ + "com.coloryr.allmusic.comm.AllMusicInit" + ], + "client": [ + "com.coloryr.allmusic.client.AllMusicClient" + ], + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" + ] + }, + "mixins": [ + "allmusic_server.mixins.json" + ], + "depends": { + "fabricloader": ">=0.15.11", + "minecraft": "~1.21", + "java": ">=21", + "fabric-api": "*" + }, + "suggests": { + + } +} diff --git a/onejar/fabric_1_21_11/.gitignore b/onejar/fabric_1_21_11/.gitignore new file mode 100644 index 00000000..c476faf2 --- /dev/null +++ b/onejar/fabric_1_21_11/.gitignore @@ -0,0 +1,40 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/onejar/fabric_1_21_11/build.gradle b/onejar/fabric_1_21_11/build.gradle new file mode 100644 index 00000000..b7f6c03e --- /dev/null +++ b/onejar/fabric_1_21_11/build.gradle @@ -0,0 +1,96 @@ +plugins { + id 'net.fabricmc.fabric-loom-remap' version "${loom_version}" + id 'maven-publish' +} + +def getVersionFromFile() { + def versionFile = file('../../version') + if (versionFile.exists()) { + return versionFile.text.trim() + } else { + throw new GradleException("Version file not found: ${versionFile.absolutePath}") + } +} + +version = getVersionFromFile() + +group = project.maven_group + +base { + archivesName = project.archives_base_name +} + +repositories { + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html + // for more information about repositories. +} + +dependencies { + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings loom.officialMojangMappings() + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + include modImplementation('org.apache.httpcomponents.client5:httpclient5:5.6') + include modImplementation('org.apache.httpcomponents.core5:httpcore5:5.4') + include modImplementation('org.apache.httpcomponents.core5:httpcore5-h2:5.4') + include implementation('org.xerial:sqlite-jdbc:3.51.1.0') +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 21 +} + +//tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { +// kotlinOptions { +// jvmTarget = 21 +// } +//} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}"} + } +} + +// configure the maven publication +publishing { + publications { + create("mavenJava", MavenPublication) { + artifactId = project.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} \ No newline at end of file diff --git a/onejar/fabric_1_21_11/gradle.properties b/onejar/fabric_1_21_11/gradle.properties new file mode 100644 index 00000000..19246b3c --- /dev/null +++ b/onejar/fabric_1_21_11/gradle.properties @@ -0,0 +1,16 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.21.11 +loader_version=0.18.4 +loom_version=1.14-SNAPSHOT + +# Mod Properties +maven_group = com.coloryr.allmusic.server +archives_base_name =[fabric-1.21.11]AllMusic_Server_OneJar + +# Dependencies +fabric_version=0.140.2+1.21.11 diff --git a/onejar/fabric_1_21_11/gradle/wrapper/gradle-wrapper.jar b/onejar/fabric_1_21_11/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..ccebba77 Binary files /dev/null and b/onejar/fabric_1_21_11/gradle/wrapper/gradle-wrapper.jar differ diff --git a/onejar/fabric_1_21_11/gradle/wrapper/gradle-wrapper.properties b/onejar/fabric_1_21_11/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..23449a2b --- /dev/null +++ b/onejar/fabric_1_21_11/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/onejar/fabric_1_21_11/gradlew b/onejar/fabric_1_21_11/gradlew new file mode 100644 index 00000000..79a61d42 --- /dev/null +++ b/onejar/fabric_1_21_11/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/onejar/fabric_1_21_11/gradlew.bat b/onejar/fabric_1_21_11/gradlew.bat new file mode 100644 index 00000000..93e3f59f --- /dev/null +++ b/onejar/fabric_1_21_11/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/onejar/fabric_1_21_11/settings.gradle b/onejar/fabric_1_21_11/settings.gradle new file mode 100644 index 00000000..100d736f --- /dev/null +++ b/onejar/fabric_1_21_11/settings.gradle @@ -0,0 +1,12 @@ +pluginManagement { + repositories { + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + mavenCentral() + gradlePluginPortal() + } +} + +rootProject.name = 'AllMusic' \ No newline at end of file diff --git a/onejar/fabric_1_21_11/src/main/resources/allmusic_client.mixins.json b/onejar/fabric_1_21_11/src/main/resources/allmusic_client.mixins.json new file mode 100644 index 00000000..0e4a718e --- /dev/null +++ b/onejar/fabric_1_21_11/src/main/resources/allmusic_client.mixins.json @@ -0,0 +1,22 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.coloryr.allmusic.client.mixin", + "compatibilityLevel": "JAVA_21", + "client": [ + "GuiShow", + "QuitServer", + "Register", + "SoundEvent", + "Tick" + ], + "mixins": [ + + ], + "injectors": { + "defaultRequire": 1 + }, + "overwrites": { + "requireAnnotations": true + } +} diff --git a/onejar/fabric_1_21_11/src/main/resources/allmusic_server.mixins.json b/onejar/fabric_1_21_11/src/main/resources/allmusic_server.mixins.json new file mode 100644 index 00000000..2d123b5a --- /dev/null +++ b/onejar/fabric_1_21_11/src/main/resources/allmusic_server.mixins.json @@ -0,0 +1,18 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.coloryr.allmusic.server.mixin", + "compatibilityLevel": "JAVA_21", + "server": [ + "ServerPlayerMixin" + ], + "mixins": [ + + ], + "injectors": { + "defaultRequire": 1 + }, + "overwrites": { + "requireAnnotations": true + } +} diff --git a/onejar/fabric_1_21_11/src/main/resources/assets/allmusic_server/icon.png b/onejar/fabric_1_21_11/src/main/resources/assets/allmusic_server/icon.png new file mode 100644 index 00000000..b2b5fa79 Binary files /dev/null and b/onejar/fabric_1_21_11/src/main/resources/assets/allmusic_server/icon.png differ diff --git a/onejar/fabric_1_21_11/src/main/resources/fabric.mod.json b/onejar/fabric_1_21_11/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..572c7929 --- /dev/null +++ b/onejar/fabric_1_21_11/src/main/resources/fabric.mod.json @@ -0,0 +1,49 @@ +{ + "schemaVersion": 1, + "id": "allmusic", + "version": "${version}", + "name": "AllMusic", + "description": "AllMusic Mod", + "authors": [ + "Color_yr" + ], + "contact": { + "homepage": "https://github.com/Coloryr/AllMusic_Server", + "sources": "https://github.com/Coloryr/AllMusic_Server" + }, + + "license": "GPL-3.0", + "icon": "assets/allmusic_server/icon.png", + + "environment": "*", + "entrypoints": { + "main": [ + "com.coloryr.allmusic.comm.AllMusicInit" + ], + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" + ], + "client": [ + "com.coloryr.allmusic.client.AllMusicClient" + ] + }, + "mixins": [ + { + "config": "allmusic_server.mixins.json", + "environment": "server" + }, + { + "config": "allmusic_client.mixins.json", + "environment": "client" + } + ], + "depends": { + "fabricloader": ">=0.16.14", + "minecraft": "~1.21.6", + "java": ">=21", + "fabric-api": "*" + }, + "suggests": { + + } +} diff --git a/onejar/fabric_1_21_6/build.gradle b/onejar/fabric_1_21_6/build.gradle index 32cc455f..49b2927d 100644 --- a/onejar/fabric_1_21_6/build.gradle +++ b/onejar/fabric_1_21_6/build.gradle @@ -39,8 +39,9 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" - include modImplementation('com.squareup.okio:okio-jvm:3.16.4') - include modImplementation('com.squareup.okhttp3:okhttp:5.3.2') + include modImplementation('org.apache.httpcomponents.client5:httpclient5:5.6') + include modImplementation('org.apache.httpcomponents.core5:httpcore5:5.4') + include modImplementation('org.apache.httpcomponents.core5:httpcore5-h2:5.4') include modImplementation('org.xerial:sqlite-jdbc:3.51.1.0') } diff --git a/onejar/fabric_1_21_6/gradle.properties b/onejar/fabric_1_21_6/gradle.properties index e69f8ea2..fc8bd313 100644 --- a/onejar/fabric_1_21_6/gradle.properties +++ b/onejar/fabric_1_21_6/gradle.properties @@ -10,8 +10,8 @@ loader_version=0.17.2 fabric_kotlin_version=1.13.4+kotlin.2.2.0 # Mod Properties -maven_group = com.coloryr.allmusic -archives_base_name =[fabric-1.21.6]AllMusic +maven_group = com.coloryr.allmusic.onejar +archives_base_name =[fabric-1.21.6]AllMusic_OneJar # Dependencies fabric_version=0.128.2+1.21.6 diff --git a/onejar/fabric_1_21_6/settings.gradle b/onejar/fabric_1_21_6/settings.gradle index 100d736f..ddc7928c 100644 --- a/onejar/fabric_1_21_6/settings.gradle +++ b/onejar/fabric_1_21_6/settings.gradle @@ -9,4 +9,4 @@ pluginManagement { } } -rootProject.name = 'AllMusic' \ No newline at end of file +rootProject.name = 'AllMusic_OneJar' \ No newline at end of file diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/AllMusic.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/AllMusic.java deleted file mode 100644 index 2c5c3d5a..00000000 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/AllMusic.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.coloryr.allmusic.client; - -import com.coloryr.allmusic.client.core.AllMusicBridge; -import com.coloryr.allmusic.client.core.AllMusicCore; -import com.coloryr.allmusic.server.AllMusicFabric; -import com.coloryr.allmusic.server.PackPayload; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.textures.FilterMode; -import com.mojang.blaze3d.textures.GpuTexture; -import com.mojang.blaze3d.textures.GpuTextureView; -import com.mojang.blaze3d.textures.TextureFormat; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gl.RenderPipelines; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.*; -import net.minecraft.client.texture.AbstractTexture; -import net.minecraft.client.texture.GlTexture; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.sound.SoundCategory; -import net.minecraft.text.Text; -import net.minecraft.util.Identifier; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.joml.Matrix3x2fStack; - -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; - -public class AllMusic implements ClientModInitializer, AllMusicBridge { - private static DrawContext context; - - public static class Tex extends AbstractTexture { - public Tex(GpuTexture tex, GpuTextureView view) { - this.glTexture = tex; - this.glTextureView = view; - } - } - - public Object genTexture(int size) { - var device = RenderSystem.getDevice(); - var tex = device.createTexture("allmusic:gui_textured", 5, TextureFormat.RGBA8, size, size, 1, 1); - tex.setTextureFilter(FilterMode.NEAREST, false); - - var view = device.createTextureView(tex); - - Tex tex1 = new Tex(tex, view); - - MinecraftClient.getInstance().getTextureManager().registerTexture(AllMusicFabric.ID, tex1); - - return tex; - } - - public void updateTexture(Object tex, int size, ByteBuffer byteBuffer) { - if (tex instanceof GlTexture tex1) { - AllMusicCore.updateGLTexture(tex1.getGlId(), size, byteBuffer); - } - } - - public int getScreenWidth() { - return MinecraftClient.getInstance().getWindow().getScaledWidth(); - } - - public int getScreenHeight() { - return MinecraftClient.getInstance().getWindow().getScaledHeight(); - } - - public int getTextWidth(String item) { - return MinecraftClient.getInstance().textRenderer.getWidth(item); - } - - public int getFontHeight() { - return MinecraftClient.getInstance().textRenderer.fontHeight; - } - - public void drawText(String item, int x, int y, int color, boolean shadow) { - var hud = MinecraftClient.getInstance().textRenderer; - context.drawText(hud, item, x, y, color, shadow); - } - - public void drawPic(Object texture, int size, int x, int y, int ang) { - Matrix3x2fStack stack = context.getMatrices(); - Matrix3x2fStack matrix = stack.pushMatrix(); - - int a = size / 2; - - if (ang > 0) { - matrix.translation(x + a, y + a); - matrix.pushMatrix().rotate((float) Math.toRadians(ang)); - } else { - matrix.translation(x + a, y + a); - } - - context.drawTexture(RenderPipelines.GUI_TEXTURED, AllMusicFabric.ID, -a, -a, 0, 0, size, size, size, size, size, size); - stack.popMatrix(); - if (ang > 0) { - stack.popMatrix(); - } - } - - public void sendMessage(String data) { - data = "[AllMusic Client]" + data; - AllMusicFabric.LOGGER.warn(data); - String finalData = data; - MinecraftClient.getInstance().execute(() -> { - if (MinecraftClient.getInstance().player == null) - return; - MinecraftClient.getInstance().player.sendMessage(Text.of(finalData), false); - }); - } - - public float getVolume() { - return MinecraftClient.getInstance().options.getSoundVolume(SoundCategory.RECORDS); - } - - @Override - public void stopPlayMusic() { - MinecraftClient.getInstance().getSoundManager().stopSounds(null, SoundCategory.MUSIC); - MinecraftClient.getInstance().getSoundManager().stopSounds(null, SoundCategory.RECORDS); - } - - public static void update(DrawContext draw) { - context = draw; - AllMusicCore.hudUpdate(); - } - - @Override - public void onInitializeClient() { - ClientPlayNetworking.registerGlobalReceiver(PackPayload.ID, (pack, handler) -> { - if (pack != null) { - AllMusicCore.packDo(AllMusicCore.types[pack.type().ordinal()], pack.data(), pack.data1()); - } - }); - - AllMusicCore.init(FabricLoader.getInstance().getConfigDir(), this); - } -} diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/GuiShow.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/GuiShow.java index 443cb850..ccf447be 100644 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/GuiShow.java +++ b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/GuiShow.java @@ -1,10 +1,9 @@ package com.coloryr.allmusic.client.mixin; -import com.coloryr.allmusic.client.AllMusic; +import com.coloryr.allmusic.client.AllMusicClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.render.RenderTickCounter; -import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -14,6 +13,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class GuiShow { @Inject(method = {"renderMiscOverlays"}, at = {@At(value = "RETURN")}) public void guiShow(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { - AllMusic.update(context); + AllMusicClient.update(context); } } diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/Register.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/Register.java index cf7cee6f..82d76c5b 100644 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/Register.java +++ b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/Register.java @@ -1,7 +1,6 @@ package com.coloryr.allmusic.client.mixin; import com.coloryr.allmusic.client.core.AllMusicCore; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/SoundEvent.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/SoundEvent.java index 00a2a83b..faff2608 100644 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/SoundEvent.java +++ b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/client/mixin/SoundEvent.java @@ -17,8 +17,7 @@ public class SoundEvent { if (AllMusicCore.isPlay()) { SoundCategory data = sound.getCategory(); switch (data) { - case RECORDS, MUSIC: - { + case RECORDS, MUSIC: { cir.cancel(); cir.setReturnValue(SoundSystem.PlayResult.NOT_STARTED); } @@ -37,7 +36,7 @@ public class SoundEvent { } @Inject(method = "reloadSounds", at = @At("RETURN")) - public void reload(CallbackInfo info){ + public void reload(CallbackInfo info) { AllMusicCore.reload(); } } diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java deleted file mode 100644 index a107fb72..00000000 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/AllMusicFabric.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.coloryr.allmusic.server; - -import com.coloryr.allmusic.server.core.AllMusic; -import net.fabricmc.api.ModInitializer; -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; - -import java.io.File; - -public class AllMusicFabric implements ModInitializer { - public static MinecraftServer server; - public static final Logger LOGGER = LoggerFactory.getLogger("AllMusic"); - - public static final Identifier ID = Identifier.of("allmusic", "channel"); - - public static final String dir = "allmusic_server/"; - - @Override - public void onInitialize() { - AllMusic.log = new LogFabric(); - AllMusic.side = new SideFabric(); - - new AllMusic().init(new File(dir)); - - CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) - -> CommandFabric.instance.register(dispatcher)); - - PayloadTypeRegistry.playS2C().register(PackPayload.ID, PackPayload.CODEC); - - ServerLifecycleEvents.SERVER_STARTED.register((a) -> { - server = a; - AllMusic.start(); - Tasks.init(); - }); - - ServerLifecycleEvents.SERVER_STOPPING.register((a) -> { - AllMusic.stop(); - }); - } -} diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java index 32e8f46b..ad3c8d44 100644 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java +++ b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/CommandFabric.java @@ -59,7 +59,7 @@ public class CommandFabric implements Command, Predicate ID = new CustomPayload.Id<>(AllMusicFabric.ID); - public static final PacketCodec CODEC = - PacketCodec.of((value, buf) -> com.coloryr.allmusic.server.codec.PacketCodec.pack(buf, value.type, value.data, value.data1), - buffer -> { - byte type = buffer.readByte(); - if (type >= types.length || type < 0) { - return null; - } - ComType type1 = types[type]; - String data = null; - int data1 = 0; - switch (type1) { - case LYRIC: - case INFO: - case LIST: - case PLAY: - case IMG: - case HUD: - data = readString(buffer); - break; - case POS: - data1 = buffer.readInt(); - break; - } - return new PackPayload(type1, data, data1); - }); - - private static String readString(ByteBuf buf) { - int size = buf.readInt(); - byte[] temp = new byte[size]; - buf.readBytes(temp); - - return new String(temp, StandardCharsets.UTF_8); - } - - @Override - public Id getId() { - return ID; - } -} diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java index 335f09f4..4914a870 100644 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java +++ b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/SideFabric.java @@ -1,7 +1,8 @@ package com.coloryr.allmusic.server; -import com.coloryr.allmusic.server.core.AllMusic; -import com.coloryr.allmusic.server.core.objs.enums.ComType; +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.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; @@ -19,7 +20,7 @@ import java.util.Collection; public class SideFabric extends BaseSide { @Override public void runTask(Runnable run) { - AllMusicFabric.server.execute(run); + AllMusicServer.server.execute(run); } @Override @@ -49,8 +50,8 @@ public class SideFabric extends BaseSide { @Override public boolean needPlay(boolean islist) { - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.isSkip(player.getName().getString(), null, false, islist)) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { + if (!com.coloryr.allmusic.server.core.AllMusic.isSkip(player.getName().getString(), null, false, islist)) { return true; } } @@ -59,7 +60,7 @@ public class SideFabric extends BaseSide { @Override public Collection getPlayers() { - return AllMusicFabric.server.getPlayerManager().getPlayerList(); + return AllMusicServer.server.getPlayerManager().getPlayerList(); } @Override @@ -77,15 +78,15 @@ public class SideFabric extends BaseSide { } @Override - public void send(Object player, ComType type, String data, int data1) { + public void send(Object player, CommandType type, String data, int data1) { if (player instanceof ServerPlayerEntity player1) { - send(player1, new PackPayload(type, data, data1)); + send(player1, new MusicPack(type, data, data1)); } } @Override public Object getPlayer(String player) { - return AllMusicFabric.server.getPlayerManager().getPlayer(player); + return AllMusicServer.server.getPlayerManager().getPlayer(player); } @Override @@ -97,7 +98,7 @@ public class SideFabric extends BaseSide { @Override public File getFolder() { - return new File(AllMusicFabric.dir); + return new File(AllMusicServer.dir); } @Override @@ -105,8 +106,8 @@ public class SideFabric extends BaseSide { if (message == null || message.isEmpty()) { return; } - for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + for (var player : AllMusicServer.server.getPlayerManager().getPlayerList()) { + if (!com.coloryr.allmusic.server.core.AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(message), false); } } @@ -156,13 +157,13 @@ public class SideFabric extends BaseSide { return MusicAddEvent.EVENT.invoker().interact(source.getPlayer(), music) != ActionResult.PASS; } - private void send(ServerPlayerEntity players, PackPayload data) { + private void send(ServerPlayerEntity players, MusicPack data) { if (players == null) return; try { - runTask(() -> ServerPlayNetworking.send(players, data)); + runTask(() -> ServerPlayNetworking.send(players, new MusicCodec(data))); } catch (Exception e) { - AllMusic.log.warning("§c数据发送发生错误"); + com.coloryr.allmusic.server.core.AllMusic.log.warning("§c数据发送发生错误"); e.printStackTrace(); } } diff --git a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java index c70e7f5e..a68ab552 100644 --- a/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java +++ b/onejar/fabric_1_21_6/src/main/java/com/coloryr/allmusic/server/Tasks.java @@ -8,7 +8,7 @@ public class Tasks { private static final List taskItems = new CopyOnWriteArrayList<>(); public static void init() { - AllMusicFabric.server.addServerGuiTickable(Tasks::tick); + AllMusicServer.server.addServerGuiTickable(Tasks::tick); } public static void tick() { diff --git a/onejar/fabric_1_21_6/src/main/resources/fabric.mod.json b/onejar/fabric_1_21_6/src/main/resources/fabric.mod.json index 97fcaa95..572c7929 100644 --- a/onejar/fabric_1_21_6/src/main/resources/fabric.mod.json +++ b/onejar/fabric_1_21_6/src/main/resources/fabric.mod.json @@ -18,10 +18,13 @@ "environment": "*", "entrypoints": { "main": [ - "com.coloryr.allmusic.server.AllMusicFabric" + "com.coloryr.allmusic.comm.AllMusicInit" + ], + "server": [ + "com.coloryr.allmusic.server.AllMusicServer" ], "client": [ - "com.coloryr.allmusic.client.AllMusic" + "com.coloryr.allmusic.client.AllMusicClient" ] }, "mixins": [ @@ -38,8 +41,7 @@ "fabricloader": ">=0.16.14", "minecraft": "~1.21.6", "java": ">=21", - "fabric-api": "*", - "fabric-language-kotlin": "*" + "fabric-api": "*" }, "suggests": { diff --git a/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java b/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java index c9099688..71f8e0a3 100644 --- a/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java +++ b/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java @@ -2,13 +2,9 @@ package com.coloryr.allmusic.server.side.bukkit; import com.coloryr.allmusic.server.AllMusicBukkit; import com.coloryr.allmusic.server.core.AllMusic; -import com.coloryr.allmusic.server.core.objs.config.SaveObj; -import com.coloryr.allmusic.server.core.objs.enums.ComType; -import com.coloryr.allmusic.server.core.objs.enums.HudType; import com.coloryr.allmusic.server.core.objs.music.MusicObj; import com.coloryr.allmusic.server.core.objs.music.SongInfoObj; import com.coloryr.allmusic.server.core.side.BaseSide; -import com.coloryr.allmusic.server.core.utils.HudUtils; import com.coloryr.allmusic.server.side.bukkit.event.MusicAddEvent; import com.coloryr.allmusic.server.side.bukkit.event.MusicPlayEvent; import com.coloryr.allmusic.server.side.bukkit.hooks.CitizensNPC; @@ -25,7 +21,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.util.Collection; -import java.util.Collections; public class SideBukkit extends BaseSide { private static Class ByteBufC;