@@ -355,9 +355,9 @@ public List<String> dirs(String namespace, final String directory, boolean inclu
355355 boolean hasRoot = directory .startsWith ("/" );
356356 // Clear the folder, so it is in proper format.
357357 final String dir = (
358- includeRoot ?
359- (!hasRoot ? "/" + directory : directory ) :
360- (hasRoot ? directory .substring (1 ) : directory )
358+ includeRoot ?
359+ (!hasRoot ? "/" + directory : directory ) :
360+ (hasRoot ? directory .substring (1 ) : directory )
361361 ) + (!directory .endsWith ("/" ) ? "/" : "" );
362362 return dirs (namespace , 64 , includeRoot ).stream ().filter (sub -> sub .startsWith (dir ) && (sub .length () != dir .length () || includeRoot )).toList ();
363363 }
@@ -379,7 +379,7 @@ public List<String> groups() {
379379 * @return The recipes contained in the group.
380380 */
381381 public List <CustomRecipe <?>> getGroup (String group ) {
382- return BY_GROUP .computeIfAbsent (group , s -> values ().stream ().filter (r -> r .getGroup ().equals (s )).collect ( Collectors . toList () ));
382+ return BY_GROUP .computeIfAbsent (group , s -> values ().stream ().filter (r -> r .getGroup ().equals (s )).toList ());
383383 }
384384
385385 /**
@@ -396,10 +396,10 @@ public List<CustomRecipe<?>> getFromDir(String namespace, String dir) {
396396 get (s ).forEach (recipe -> {
397397 String key = recipe .getNamespacedKey ().getKey ();
398398 String recipeFolder = "/" + (key .contains ("/" ) ? key .substring (0 , key .lastIndexOf ("/" ) + 1 ) : "" );
399- folderIndex .computeIfAbsent (recipeFolder , s1 -> new LinkedList <>()).add (recipe );
399+ folderIndex .computeIfAbsent (recipeFolder , s1 -> new ArrayList <>()).add (recipe );
400400 });
401401 return folderIndex ;
402- }).getOrDefault (dir , new LinkedList <>());
402+ }).getOrDefault (dir , new ArrayList <>());
403403 }
404404
405405 private String cleanDir (String dir ) {
@@ -425,28 +425,38 @@ public List<CustomRecipe<?>> get(String namespace, String folder) {
425425 * @return The recipes contained in the namespace.
426426 */
427427 public List <CustomRecipe <?>> get (String namespace ) {
428- return BY_NAMESPACE .computeIfAbsent (namespace , s -> entrySet ().stream ().filter (entry -> entry .getKey ().getNamespace ().equalsIgnoreCase (s )).map (Map .Entry ::getValue ).collect (Collectors .toList ()));
428+ return BY_NAMESPACE .computeIfAbsent (namespace , s -> entrySet ().stream ()
429+ .filter (entry -> entry .getKey ().getNamespace ().equalsIgnoreCase (s ))
430+ .map (Map .Entry ::getValue ).collect (Collectors .toUnmodifiableList ()));
429431 }
430432
431433 /**
432434 * @deprecated Not used anywhere and fundamentally flawed. Do not use!
433435 */
434436 @ Deprecated (forRemoval = true )
435437 public List <CustomRecipe <?>> get (CustomItem result ) {
436- return get (result .hasNamespacedKey () ? new StackReference (WolfyUtilCore .getInstance (), new WolfyUtilsStackIdentifier (result .getNamespacedKey ()), result .getWeight (), result .getAmount (), result .getItemStack ()) : result .stackReference ());
438+ return get (result .hasNamespacedKey () ?
439+ new StackReference (
440+ WolfyUtilCore .getInstance (),
441+ new WolfyUtilsStackIdentifier (result .getNamespacedKey ()), result .getWeight (), result .getAmount (), result .getItemStack ()
442+ ) : result .stackReference ()
443+ );
437444 }
438445
439446 /**
440447 * @deprecated Not used anywhere and fundamentally flawed. Do not use!
441448 */
442449 @ Deprecated (forRemoval = true )
443450 public List <CustomRecipe <?>> get (StackReference reference ) {
444- return values ().stream ().filter (recipe -> recipe .getResult ().choices ().contains (reference )).collect ( Collectors . toList () );
451+ return values ().stream ().filter (recipe -> recipe .getResult ().choices ().contains (reference )).toList ();
445452 }
446453
447454 @ SuppressWarnings ("unchecked" )
448455 public <T extends CustomRecipe <?>> List <T > get (Class <T > type ) {
449- return (List <T >) BY_CLASS_TYPE .computeIfAbsent (type , aClass -> values ().stream ().filter (aClass ::isInstance ).map (recipe -> ((Class <T >) aClass ).cast (recipe )).collect (Collectors .toList ()));
456+ return (List <T >) BY_CLASS_TYPE .computeIfAbsent (type , aClass -> values ().stream ()
457+ .filter (aClass ::isInstance )
458+ .map (recipe -> ((Class <T >) aClass ).cast (recipe ))
459+ .collect (Collectors .toUnmodifiableList ()));
450460 }
451461
452462 /**
0 commit comments