1717 * Enum representing the operating system.
1818 */
1919public enum OS {
20- AIX ("aix" , "aix" ),
20+ AIX ("aix" ),
2121 /** @apiNote When working with Minecraft natives, this will be treated as {@link #LINUX}. */
2222 ALPINE ("apline_linux" , "alpine" ),
23- LINUX ("linux" , "linux" , " unix" ),
23+ LINUX ("linux" , "unix" ),
2424 /** @apiNote When working with Minecraft natives, this will be treated as {@link #LINUX}. */
2525 MUSL ("linux_musl" , "musl" ),
2626 /** @apiNote When working with Minecraft natives, this is primarily referred to as {@code osx}. */
2727 MACOS ("macos" , "mac" , "osx" , "darwin" ),
28- QNX ("qnx" , "qnx" ),
28+ QNX ("qnx" ),
2929 SOLARIS ("solaris" , "sunos" ),
3030 WINDOWS ("windows" , "win" ),
3131 UNKNOWN ("unknown" );
@@ -37,8 +37,8 @@ public enum OS {
3737 private final String key ;
3838 private final String [] names ;
3939
40- private OS (String key , String ... names ) {
41- this .key = key ;
40+ OS (String ... names ) {
41+ this .key = names [ 0 ] ;
4242 this .names = names ;
4343 }
4444
@@ -66,6 +66,17 @@ public String key() {
6666 return null ;
6767 }
6868
69+ public static @ Nullable OS byName (String name ) {
70+ for (OS value : $values ) {
71+ for (String n : value .names ) {
72+ if (n .equals (name ))
73+ return value ;
74+ }
75+ }
76+
77+ return null ;
78+ }
79+
6980 /**
7081 * Returns the mandatory file extension for executables on this OS.
7182 *
0 commit comments