From 70b61aaa00c025728d3882faf7ce0e5c0531b9b5 Mon Sep 17 00:00:00 2001 From: kyrptonaught Date: Thu, 20 Jun 2024 01:18:53 -0400 Subject: [PATCH] Add support for new custom nbs player --- build.gradle | 2 +- .../net/kyrptonaught/serverutils/ServerUtilsMod.java | 2 -- .../customMapLoader/CustomMapLoaderMod.java | 10 +++++----- .../NoteBlockMusic.java} | 5 ++--- 4 files changed, 8 insertions(+), 11 deletions(-) rename src/main/java/net/kyrptonaught/serverutils/{noteblockMusic/NoteblockMusicMod.java => switchableresourcepacks/NoteBlockMusic.java} (85%) diff --git a/build.gradle b/build.gradle index da19047..71129ff 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,7 @@ shadowJar { relocate 'okio' , 'net.dv8tion.shaded.okio' //Exclude META-INF entries of shaded deps - exclude('META-INF/**', '**/*.pdn','**/*.bbmodel') + exclude('META-INF/**') // include() upsets shadow, so use from() instead from('LICENSE.md', 'NOTICE.txt') from('licenses') { diff --git a/src/main/java/net/kyrptonaught/serverutils/ServerUtilsMod.java b/src/main/java/net/kyrptonaught/serverutils/ServerUtilsMod.java index 7347471..e4f585f 100644 --- a/src/main/java/net/kyrptonaught/serverutils/ServerUtilsMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/ServerUtilsMod.java @@ -23,7 +23,6 @@ import net.kyrptonaught.serverutils.dropevent.DropEventMod; import net.kyrptonaught.serverutils.healthcmd.HealthCMDMod; import net.kyrptonaught.serverutils.knockback.KnockbackMod; -import net.kyrptonaught.serverutils.noteblockMusic.NoteblockMusicMod; import net.kyrptonaught.serverutils.panoramaViewer.PanoramaViewer; import net.kyrptonaught.serverutils.personatus.PersonatusModule; import net.kyrptonaught.serverutils.playerJoinLocation.PlayerJoinLocationMod; @@ -90,7 +89,6 @@ public class ServerUtilsMod implements ModInitializer { public static WhitelistSyncMod whitelistSyncMod = (WhitelistSyncMod) registerModule("whitelistsync", new WhitelistSyncMod()); public static SnowballKnockbackMod snowballKnockback = (SnowballKnockbackMod) registerModule("snowballknockback", new SnowballKnockbackMod()); public static Module armorHudModule = registerModule("armorhud", new ArmorHudMod()); - public static Module noteblockMusic = registerModule("noteblockmusic", new NoteblockMusicMod()); public static PlayerJoinLocationMod playerJoinLocationMod = (PlayerJoinLocationMod) registerModule("playerjoinlocation", new PlayerJoinLocationMod()); public static Module knockbackModule = registerModule("knockback", new KnockbackMod()); public static CustomMapLoaderMod CustomMapLoaderModule = (CustomMapLoaderMod) registerModule("custommaploader", new CustomMapLoaderMod()); diff --git a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/CustomMapLoaderMod.java b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/CustomMapLoaderMod.java index 74c9659..4a33588 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/CustomMapLoaderMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/CustomMapLoaderMod.java @@ -16,9 +16,9 @@ import net.kyrptonaught.serverutils.dimensionLoader.CustomDimHolder; import net.kyrptonaught.serverutils.dimensionLoader.DimensionLoaderMod; import net.kyrptonaught.serverutils.discordBridge.MessageSender; -import net.kyrptonaught.serverutils.noteblockMusic.NoteblockMusicMod; import net.kyrptonaught.serverutils.playerJoinLocation.PlayerJoinLocationMod; import net.kyrptonaught.serverutils.playerlockdown.PlayerLockdownMod; +import net.kyrptonaught.serverutils.switchableresourcepacks.NoteBlockMusic; import net.kyrptonaught.serverutils.switchableresourcepacks.ResourcePack; import net.kyrptonaught.serverutils.switchableresourcepacks.SwitchableResourcepacksMod; import net.minecraft.registry.CombinedDynamicRegistries; @@ -145,7 +145,7 @@ public static void battleLoad(MinecraftServer server, Identifier addon, Identifi return true; }); - NoteblockMusicMod.cacheAll(path.resolve("nbs")); + NoteBlockMusic.cacheAll(path.resolve("nbs")); ADDON_DATAPACK_PROVIDER.loadAddon(addon, path); tryEnableDatapack(server, config); @@ -245,7 +245,7 @@ public static void prepareLobby(MinecraftServer server, Identifier addon, Identi teleportToLobby(dimID, players, null); - NoteblockMusicMod.cacheAll(path.resolve("nbs")); + NoteBlockMusic.cacheAll(path.resolve("nbs")); ADDON_DATAPACK_PROVIDER.loadAddon(addon, path); tryEnableDatapack(server, config); @@ -350,7 +350,7 @@ public static void unloadLobbyMap(MinecraftServer server, Identifier dimID, Coll if (LOADED_LOBBIES.containsKey(dimID)) { tryDisableDatapack(server, LOADED_LOBBIES.get(dimID)); ADDON_DATAPACK_PROVIDER.unloadAddon(LOADED_LOBBIES.get(dimID).addon_id); - NoteblockMusicMod.clearCache(); + NoteBlockMusic.clearCache(); } LOADED_LOBBIES.remove(dimID); @@ -363,7 +363,7 @@ public static void unloadBattleMap(MinecraftServer server, Identifier dimID, Col LOADED_BATTLE_MAPS.get(dimID).scheduleToRemove = true; tryDisableDatapack(server, LOADED_BATTLE_MAPS.get(dimID).getAddon()); ADDON_DATAPACK_PROVIDER.unloadAddon(LOADED_BATTLE_MAPS.get(dimID).getAddon().addon_id); - NoteblockMusicMod.clearCache(); + NoteBlockMusic.clearCache(); } DimensionLoaderMod.unLoadDimension(server, dimID, functions); diff --git a/src/main/java/net/kyrptonaught/serverutils/noteblockMusic/NoteblockMusicMod.java b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/NoteBlockMusic.java similarity index 85% rename from src/main/java/net/kyrptonaught/serverutils/noteblockMusic/NoteblockMusicMod.java rename to src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/NoteBlockMusic.java index cbf80a7..4479911 100644 --- a/src/main/java/net/kyrptonaught/serverutils/noteblockMusic/NoteblockMusicMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/NoteBlockMusic.java @@ -1,14 +1,13 @@ -package net.kyrptonaught.serverutils.noteblockMusic; +package net.kyrptonaught.serverutils.switchableresourcepacks; import net.kyrptonaught.noteblockplayer.Commands; -import net.kyrptonaught.serverutils.Module; import net.raphimc.noteblocklib.format.nbs.NbsSong; import java.nio.file.Files; import java.nio.file.Path; import java.util.stream.Stream; -public class NoteblockMusicMod extends Module { +public class NoteBlockMusic { public static void cacheSong(String id, Path songPath) { NbsSong song = Commands.loadSong(songPath);