@@ -111,6 +111,48 @@ void yamlLoadersPopulateRegistriesAndOfferMissingLookups() throws Exception {
111111 assertTrue (new ConversionLoader ().load (missing ).isEmpty ());
112112 }
113113
114+ @ Test
115+ void nullYamlIconsUseDefaultAndDoNotPreventLaterTemplatesLoading () throws Exception {
116+ String content =
117+ """
118+ explicit-null:
119+ name: Explicit null
120+ icon: null
121+ tilde-null:
122+ name: Tilde null
123+ icon: ~
124+ empty-null:
125+ name: Empty null
126+ icon:
127+ omitted:
128+ name: Omitted icon
129+ later-template:
130+ name: Later template
131+ icon: v.iron_sword
132+ """ ;
133+ // Use Bukkit's actual YAML parser and ConfigurationSection, not a mocked null getter.
134+ var parsed = yaml (content );
135+ for (String id : List .of ("explicit-null" , "tilde-null" , "empty-null" , "omitted" )) {
136+ var section = parsed .getConfigurationSection (id );
137+ assertNotNull (section );
138+ assertNull (section .getString ("icon" ));
139+ assertEquals ("v.paper" , section .getString ("icon" , "v.paper" ));
140+ }
141+ new StatTemplateLoader ().load (config ("nullable-icons.yml" , content ));
142+ assertEquals (
143+ List .of ("explicit-null" , "tilde-null" , "empty-null" , "omitted" , "later-template" ),
144+ StatTemplateLoader .getAll ().stream ().map (template -> template .getId ()).toList ());
145+ for (String id : List .of ("explicit-null" , "tilde-null" , "empty-null" , "omitted" )) {
146+ assertEquals (
147+ org .bukkit .Material .PAPER , StatTemplateLoader .getByString (id ).getIcon ().getType ());
148+ }
149+ assertEquals (
150+ org .bukkit .Material .IRON_SWORD ,
151+ StatTemplateLoader .getByString ("later-template" ).getIcon ().getType ());
152+ verify (items .getCreator (), times (4 )).getItemFromPath ("v.paper" );
153+ verify (items .getCreator ()).getItemFromPath ("v.iron_sword" );
154+ }
155+
114156 @ Test
115157 void configurationClampsPercentagesAndParsesOffsetsCombinationsAndPermissions () throws Exception {
116158 var loader = new ConfigLoader ();
0 commit comments