-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the natives/classifier concepts in Minecraft version …
…manifests (#45) These were used in 1.18 and below to reference natives instead of rules.
- Loading branch information
Showing
5 changed files
with
89 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/net/neoforged/neoform/runtime/utils/OsType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.neoforged.neoform.runtime.utils; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
public enum OsType { | ||
@SerializedName("windows") | ||
WINDOWS, | ||
@SerializedName("linux") | ||
LINUX, | ||
@SerializedName("osx") | ||
MAC, | ||
UNKNOWN; | ||
|
||
private static final OsType CURRENT; | ||
|
||
static { | ||
var osName = System.getProperty("os.name"); | ||
// The following matches the logic in Apache Commons Lang 3 SystemUtils | ||
if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { | ||
CURRENT = OsType.LINUX; | ||
} else if (osName.startsWith("Mac OS X")) { | ||
CURRENT = OsType.MAC; | ||
} else if (osName.startsWith("Windows")) { | ||
CURRENT = OsType.WINDOWS; | ||
} else { | ||
CURRENT = OsType.UNKNOWN; | ||
} | ||
} | ||
|
||
public static OsType current() { | ||
return CURRENT; | ||
} | ||
} |
29 changes: 3 additions & 26 deletions
29
src/main/java/net/neoforged/neoform/runtime/utils/OsUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,18 @@ | ||
package net.neoforged.neoform.runtime.utils; | ||
|
||
public final class OsUtil { | ||
private static OsType TYPE; | ||
|
||
static { | ||
var osName = System.getProperty("os.name"); | ||
// The following matches the logic in Apache Commons Lang 3 SystemUtils | ||
if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { | ||
TYPE = OsType.LINUX; | ||
} else if (osName.startsWith("Mac OS X")) { | ||
TYPE = OsType.MAC; | ||
} else if (osName.startsWith("Windows")) { | ||
TYPE = OsType.WINDOWS; | ||
} else { | ||
TYPE = OsType.UNKNOWN; | ||
} | ||
} | ||
|
||
private OsUtil() { | ||
} | ||
|
||
public static boolean isWindows() { | ||
return TYPE == OsType.WINDOWS; | ||
return OsType.current() == OsType.WINDOWS; | ||
} | ||
|
||
public static boolean isLinux() { | ||
return TYPE == OsType.LINUX; | ||
return OsType.current() == OsType.LINUX; | ||
} | ||
|
||
public static boolean isMac() { | ||
return TYPE == OsType.MAC; | ||
} | ||
|
||
enum OsType { | ||
WINDOWS, | ||
LINUX, | ||
MAC, | ||
UNKNOWN | ||
return OsType.current() == OsType.MAC; | ||
} | ||
} |