66import com .denizenscript .denizen .nms .abstracts .BiomeNMS ;
77import com .denizenscript .denizen .utilities .BukkitImplDeprecations ;
88import com .denizenscript .denizen .utilities .flags .WorldFlagHandler ;
9+ import com .denizenscript .denizen .utilities .world .GameRuleReflect ;
910import com .denizenscript .denizencore .flags .AbstractFlagTracker ;
1011import com .denizenscript .denizencore .flags .FlaggableObject ;
1112import com .denizenscript .denizencore .objects .Adjustable ;
@@ -177,7 +178,7 @@ public <T> T getGameRuleOrDefault(GameRule<T> gameRule) {
177178 if (value == null ) {
178179 value = world .getGameRuleDefault (gameRule );
179180 if (value == null ) {
180- throw new IllegalStateException ("World " + world_name + " contains no GameRule " + gameRule .getName ());
181+ throw new IllegalStateException ("World " + world_name + " contains no GameRule " + GameRuleReflect .getName (gameRule ));
181182 }
182183 }
183184 return value ;
@@ -852,16 +853,19 @@ else if (time >= 12500) {
852853 // @returns ElementTag
853854 // @description
854855 // Returns the current value of the specified gamerule in the world.
855- // Note that the name is case-sensitive... so "doFireTick" is correct, but "dofiretick" is not.
856856 // -->
857857 registerTag (ElementTag .class , "gamerule" , (attribute , object ) -> {
858858 if (!attribute .hasParam ()) {
859859 attribute .echoError ("The tag 'worldtag.gamerule[...]' must have an input value." );
860860 return null ;
861861 }
862- GameRule rule = GameRule .getByName (attribute .getParam ());
863- Object result = object .getWorld ().getGameRuleValue (rule );
864- return new ElementTag (result == null ? "null" : result .toString ());
862+ GameRule <?> rule = GameRuleReflect .getByName (attribute .getParam ());
863+ if (rule == null ) {
864+ attribute .echoError ("Invalid game rule specified: " + attribute .getParam () + '.' );
865+ return null ;
866+ }
867+ Object result = GameRuleReflect .getValue (object .getWorld (), rule );
868+ return new ElementTag (String .valueOf (result ), true );
865869 });
866870
867871 // <--[tag]
@@ -872,10 +876,10 @@ else if (time >= 12500) {
872876 // -->
873877 registerTag (MapTag .class , "gamerule_map" , (attribute , object ) -> {
874878 MapTag map = new MapTag ();
875- for (GameRule rule : GameRule .values ()) {
876- Object result = object .getWorld (). getGameRuleValue ( rule );
879+ for (GameRule <?> rule : GameRuleReflect .values ()) {
880+ Object result = GameRuleReflect . getValue ( object .getWorld (), rule );
877881 if (result != null ) {
878- map .putObject (rule .getName (), new ElementTag (result .toString ()));
882+ map .putObject (GameRuleReflect .getName (rule ), new ElementTag (result .toString (), true ));
879883 }
880884 }
881885 return map ;
@@ -987,7 +991,7 @@ else if (time >= 12500) {
987991 // @description
988992 // Returns whether enough players are sleeping to prepare for the night to advance.
989993 // Typically used before checking <@link tag WorldTag.enough_deep_sleeping>
990- // By default, automatically checks the playersSleepingPercentage gamerule,
994+ // By default, automatically checks the players_sleeping_percentage gamerule,
991995 // but this can optionally be overridden by specifying a percentage integer.
992996 // Any integer above 100 will always yield 'false'. Requires at least one player to be sleeping to return 'true'.
993997 // -->
@@ -1008,7 +1012,7 @@ else if (time >= 12500) {
10081012 // @description
10091013 // Returns whether enough players have been in bed long enough for the night to advance (generally 100 ticks).
10101014 // Loops through all online players, so is typically used after checking <@link tag WorldTag.enough_sleeping>
1011- // By default, automatically checks the playersSleepingPercentage gamerule,
1015+ // By default, automatically checks the players_sleeping_percentage gamerule,
10121016 // but this can optionally be overridden by specifying a percentage integer.
10131017 // Any integer above 100 will always yield 'false'. Requires at least one player to be sleeping to return 'true'.
10141018 // -->
@@ -1509,7 +1513,7 @@ else if (time >= 12500) {
15091513 // @input None
15101514 // @description
15111515 // Skips to the next day as if enough players slept through the night.
1512- // NOTE: This ignores the doDaylightCycle gamerule!
1516+ // NOTE: This ignores the advance_time gamerule!
15131517 // -->
15141518 tagProcessor .registerMechanism ("skip_night" , false , (object , mechanism ) -> {
15151519 // general logic from NMS world tick
@@ -1525,7 +1529,7 @@ else if (time >= 12500) {
15251529 NMSHandler .worldHelper .wakeUpAllPlayers (world );
15261530 }
15271531 // minor change: prior to 1.18, hasStorm/isRaining was not checked
1528- if (object .getGameRuleOrDefault (GameRule . DO_WEATHER_CYCLE ) && world .hasStorm ()) {
1532+ if (object .getGameRuleOrDefault (GameRuleReflect . WEATHER_CYCLE_GAMERULE ) && world .hasStorm ()) {
15291533 NMSHandler .worldHelper .clearWeather (world );
15301534 }
15311535 });
0 commit comments