17
17
* Enum representing the operating system.
18
18
*/
19
19
public enum OS {
20
- AIX ("aix" , "aix" ),
20
+ AIX ("aix" ),
21
21
/** @apiNote When working with Minecraft natives, this will be treated as {@link #LINUX}. */
22
22
ALPINE ("apline_linux" , "alpine" ),
23
- LINUX ("linux" , "linux" , " unix" ),
23
+ LINUX ("linux" , "unix" ),
24
24
/** @apiNote When working with Minecraft natives, this will be treated as {@link #LINUX}. */
25
25
MUSL ("linux_musl" , "musl" ),
26
26
/** @apiNote When working with Minecraft natives, this is primarily referred to as {@code osx}. */
27
27
MACOS ("macos" , "mac" , "osx" , "darwin" ),
28
- QNX ("qnx" , "qnx" ),
28
+ QNX ("qnx" ),
29
29
SOLARIS ("solaris" , "sunos" ),
30
30
WINDOWS ("windows" , "win" ),
31
31
UNKNOWN ("unknown" );
@@ -37,8 +37,8 @@ public enum OS {
37
37
private final String key ;
38
38
private final String [] names ;
39
39
40
- private OS (String key , String ... names ) {
41
- this .key = key ;
40
+ OS (String ... names ) {
41
+ this .key = names [ 0 ] ;
42
42
this .names = names ;
43
43
}
44
44
@@ -66,6 +66,17 @@ public String key() {
66
66
return null ;
67
67
}
68
68
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
+
69
80
/**
70
81
* Returns the mandatory file extension for executables on this OS.
71
82
*
0 commit comments