44import  org .vivecraft .ViveMain ;
55import  org .vivecraft .config .enums .ClimbeyBlockmode ;
66import  org .vivecraft .config .enums .HeadshotIndicator ;
7+ import  org .vivecraft .config .enums .UpdateType ;
78import  org .vivecraft .network .NetworkHandler ;
89import  org .vivecraft .network .PacketUtils ;
910import  org .vivecraft .network .packet .s2c .AttackWhileBlockingPayloadS2C ;
1011import  org .vivecraft .network .packet .s2c .CrawlPayloadS2C ;
1112import  org .vivecraft .network .packet .s2c .DualWieldingPayloadS2C ;
1213import  org .vivecraft .network .packet .s2c .TeleportPayloadS2C ;
1314import  org .vivecraft .util .MCVersion ;
15+ import  org .vivecraft .util .UpdateChecker ;
1416
1517import  java .io .*;
1618import  java .util .*;
@@ -30,6 +32,7 @@ public class Config {
3032
3133    // general 
3234    public  final  ConfigBuilder .BooleanValue  checkForUpdates ;
35+     public  final  ConfigBuilder .EnumValue <UpdateType > updateType ;
3336    public  final  ConfigBuilder .BooleanValue  vrOnly ;
3437    public  final  ConfigBuilder .BooleanValue  viveOnly ;
3538    public  final  ConfigBuilder .BooleanValue  allowOp ;
@@ -151,19 +154,32 @@ public Config(Plugin plugin, boolean inMemory) {
151154            .push ("general" );
152155        this .checkForUpdates  = this .builder 
153156            .push ("checkForUpdate" )
154-             .define (true );
157+             .define (true )
158+             .setOnUpdate ((oV , nV , notifier ) -> {
159+                 if  (nV ) {
160+                     UpdateChecker .scheduleUpdateCheck (notifier );
161+                 }
162+             });
163+         this .updateType  = this .builder 
164+             .push ("checkForUpdateType" )
165+             .defineEnum (UpdateType .RELEASE , UpdateType .class )
166+             .setOnUpdate ((oV , nV , notifier ) -> {
167+                 if  (this .checkForUpdates .get () && oV  != nV ) {
168+                     UpdateChecker .scheduleUpdateCheck (notifier );
169+                 }
170+             });
155171        this .vrOnly  = this .builder 
156172            .push ("vr_only" )
157173            .define (false )
158-             .setOnUpdate ((oV ,  nV )  -> NetworkHandler .updateViveVROnly ());
174+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> NetworkHandler .updateViveVROnly ());
159175        this .viveOnly  = this .builder 
160176            .push ("vive_only" )
161177            .define (false )
162-             .setOnUpdate ((oV ,  nV )  -> NetworkHandler .updateViveVROnly ());
178+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> NetworkHandler .updateViveVROnly ());
163179        this .allowOp  = this .builder 
164180            .push ("allow_op" )
165181            .define (true )
166-             .setOnUpdate ((oV ,  nV )  -> NetworkHandler .updateViveVROnly ());
182+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> NetworkHandler .updateViveVROnly ());
167183        this .messageKickDelay  = this .builder 
168184            .push ("messageAndKickDelay" )
169185            .defineInRange (200 , 100 , 1000 );
@@ -173,15 +189,15 @@ public Config(Plugin plugin, boolean inMemory) {
173189        this .viveCrafting  = this .builder 
174190            .push ("viveCrafting" )
175191            .define (true )
176-             .setOnUpdate ((oV ,  nV )  -> ViveMain .INSTANCE .updateRecipes ());
192+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> ViveMain .INSTANCE .updateRecipes ());
177193        this .requestData  = this .builder 
178194            .push ("requestData" )
179195            .define (true )
180196            .setNeedsReload (true );
181197        this .sendData  = this .builder 
182198            .push ("sendData" )
183199            .define (true )
184-             .setOnUpdate ((oV ,  nV )  -> ViveMain .INSTANCE .toggleDataTask (nV ));
200+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> ViveMain .INSTANCE .toggleDataTask (nV ));
185201        this .sendDataToOwner  = this .builder 
186202            .push ("sendDataToOwner" )
187203            .define (false );
@@ -372,7 +388,7 @@ public Config(Plugin plugin, boolean inMemory) {
372388            .push ("enabled" )
373389            .define (false )
374390            .setPacketFunction ((v , p ) -> PacketUtils .getClimbeyServerPayload (p ))
375-             .setOnUpdate ((oV ,  nV )  -> ViveMain .INSTANCE .updateRecipes ());
391+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> ViveMain .INSTANCE .updateRecipes ());
376392        this .climbeyBlockmode  = this .builder 
377393            .push ("blockmode" )
378394            .defineEnum (ClimbeyBlockmode .DISABLED , ClimbeyBlockmode .class )
@@ -391,7 +407,7 @@ public Config(Plugin plugin, boolean inMemory) {
391407        this .crawlingEnabled  = this .builder 
392408            .push ("enabled" )
393409            .define (true )
394-             .setOnUpdate ((oV ,  nV )  -> {
410+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> {
395411                if  (!nV ) {
396412                    // disable crawling for everyone 
397413                    ViveMain .VIVE_PLAYERS .values ().forEach (vp  -> vp .crawling  = false );
@@ -478,7 +494,7 @@ public Config(Plugin plugin, boolean inMemory) {
478494        this .debugParticlesEnabled  = this .builder 
479495            .push ("enabled" )
480496            .define (false )
481-             .setOnUpdate ((oV ,  nV )  -> ViveMain .INSTANCE .toggleParticleTask (nV ));
497+             .setOnUpdate ((ConfigBuilder . SimpleUpdateNotifier < Boolean >)  nV  -> ViveMain .INSTANCE .toggleParticleTask (nV ));
482498        this .debugParticlesOpOnly  = this .builder 
483499            .push ("opOnly" )
484500            .define (true );
0 commit comments