1818import me .shedaniel .autoconfig .serializer .Toml4jConfigSerializer ;
1919
2020public class IamMusicPlayer {
21- public static final IMPConfig CONFIG = AutoConfig .register (IMPConfig .class , Toml4jConfigSerializer ::new ).getConfig ();
21+
22+ public static final IMPConfig CONFIG = AutoConfig .register (
23+ IMPConfig .class ,
24+ Toml4jConfigSerializer ::new
25+ ).getConfig ();
2226 public static final String MODID = "iammusicplayer" ;
23- private static final Supplier <String > MODNAME = Suppliers .memoize (() -> Platform .getMod (MODID ).getName ());
27+ public static final String CONFIG_VERSION = "1" ;
28+ private static final Supplier <String > MODNAME = Suppliers .memoize (() ->
29+ Platform .getMod (MODID ).getName ()
30+ );
2431
2532 public static void init () {
2633 IMPPackets .init ();
@@ -36,6 +43,39 @@ public static void init() {
3643 CommonHandler .init ();
3744 }
3845
46+ private static void checkAndResetConfig () {
47+ if (
48+ CONFIG .configVersion == null ||
49+ CONFIG .configVersion .isEmpty () ||
50+ !CONFIG .configVersion .equals (CONFIG_VERSION )
51+ ) {
52+ // Reset all config values to defaults
53+ CONFIG .volume = 1f ;
54+ CONFIG .maxPlayCont = 8 ;
55+ CONFIG .spatial = true ;
56+ CONFIG .sampleRate = 44100 ;
57+ CONFIG .useYoutubeDownloader = true ;
58+ CONFIG .relayServerURL =
59+ "https://raw.githubusercontent.com/TeamFelnull/IamMusicPlayer/master/relay_server.json" ;
60+ CONFIG .lavaPlayerNativesURL =
61+ "https://raw.githubusercontent.com/Mod-Sauce/test_lavaplayer_IMP/refs/heads/main/lavaplayer/natives_link.json" ;
62+ CONFIG .hideDisplaySprite = false ;
63+ CONFIG .hideDecorativeAntenna = false ;
64+ CONFIG .maxWaitTime = 1000 * 10 ;
65+ CONFIG .retryTime = 1000 * 3 ;
66+ CONFIG .dropItemRing = true ;
67+ CONFIG .soundPhysicsRemasteredIntegration = true ;
68+ CONFIG .showMusicLines = false ;
69+ CONFIG .showSpeakerRange = false ;
70+
71+ // Update config version
72+ CONFIG .configVersion = CONFIG_VERSION ;
73+
74+ // Save the config
75+ AutoConfig .getConfigHolder (IMPConfig .class ).save ();
76+ }
77+ }
78+
3979 public static void setup () {
4080 IMPVillagerProfessions .setup ();
4181 }
0 commit comments