Migrate old TNT height nerf settings to falling block height nerf

This commit is contained in:
Byteflux 2015-06-04 03:57:23 -07:00
parent 5866cac361
commit 7d15ab73ad
7 changed files with 65 additions and 9 deletions

View File

@ -78,3 +78,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
} }
-- --
1.9.5.msysgit.1

View File

@ -58,3 +58,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
} }
-- --
1.9.5.msysgit.1

View File

@ -47,3 +47,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
} }
-- --
1.9.5.msysgit.1

View File

@ -39,6 +39,48 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public int fallingBlockHeightNerf; + public int fallingBlockHeightNerf;
+ private void fallingBlockheightNerf() + private void fallingBlockheightNerf()
+ { + {
+ // TODO: Remove migrations after most users have upgraded.
+ if ( PaperSpigotConfig.version < 8 )
+ {
+ // Migrate default value
+
+ int heightNerf = config.getInt( "world-settings.default.falling-block-height-nerf", 0 );
+ if ( heightNerf == 0 ) heightNerf = config.getInt( "world-settings.default.tnt-entity-height-nerf", 0 );
+ if ( heightNerf == 0 ) heightNerf = config.getInt( "world-settings.default.tnt-gameplay.tnt-entity-height-limit", 0 );
+ if ( heightNerf != 0 ) config.set( "world-settings.default.falling-block-height-nerf", heightNerf );
+
+ if ( config.contains( "world-settings.default.tnt-entity-height-nerf" ) )
+ {
+ config.getDefaults().set( "world-settings.default.tnt-entity-height-nerf", null );
+ config.set( "world-settings.default.tnt-entity-height-nerf", null );
+ }
+
+ if ( config.contains( "world-settings.default.tnt-gameplay.tnt-entity-height-limit" ) )
+ {
+ config.getDefaults().set( "world-settings.default.tnt-gameplay.tnt-entity-height-limit", null );
+ config.set( "world-settings.default.tnt-gameplay.tnt-entity-height-limit", null );
+ }
+
+ // Migrate world setting
+
+ heightNerf = config.getInt( "world-settings." + worldName + ".falling-block-height-nerf" );
+ if ( heightNerf == 0 ) heightNerf = config.getInt( "world-settings." + worldName + ".tnt-entity-height-nerf", 0 );
+ if ( heightNerf == 0 ) heightNerf = config.getInt( "world-settings." + worldName + ".tnt-gameplay.tnt-entity-height-limit", 0 );
+ if ( heightNerf != 0 ) config.set( "world-settings." + worldName + ".falling-block-height-nerf", heightNerf );
+
+ if ( config.contains( "world-settings." + worldName + ".tnt-entity-height-nerf" ) )
+ {
+ config.getDefaults().set( "world-settings." + worldName + ".tnt-entity-height-nerf", null );
+ config.set( "world-settings." + worldName + ".tnt-entity-height-nerf", null);
+ }
+
+ if ( config.contains( "world-settings." + worldName + ".tnt-gameplay.tnt-entity-height-limit" ) )
+ {
+ config.getDefaults().set( "world-settings." + worldName + ".tnt-gameplay.tnt-entity-height-limit", null );
+ config.set( "world-settings." + worldName + ".tnt-gameplay.tnt-entity-height-limit", null );
+ }
+ }
+
+ fallingBlockHeightNerf = getInt( "falling-block-height-nerf", 0 ); + fallingBlockHeightNerf = getInt( "falling-block-height-nerf", 0 );
+ if ( fallingBlockHeightNerf != 0 ) + if ( fallingBlockHeightNerf != 0 )
+ { + {
@ -47,3 +89,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
} }
-- --
1.9.5.msysgit.1

View File

@ -147,8 +147,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ commands = new HashMap<String, Command>(); + commands = new HashMap<String, Command>();
+ +
+ version = getInt( "config-version", 7 ); + version = getInt( "config-version", 8 );
+ set( "config-version", 7 ); + set( "config-version", 8 );
+ readConfig( PaperSpigotConfig.class, null ); + readConfig( PaperSpigotConfig.class, null );
+ } + }
+ +
@ -317,3 +317,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+} +}
-- --
1.9.5.msysgit.1

View File

@ -116,3 +116,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
} }
-- --
1.9.5.msysgit.1

View File

@ -37,3 +37,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
} }
-- --
1.9.5.msysgit.1