
de.adrodoc55.commons.CommonDirectories Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mpl-ide Show documentation
Show all versions of mpl-ide Show documentation
MPL is a language that makes it easier to write applications for Minecraft 1.9 or higher. The final result of compiling an MPL application are command blocks that can be imported into your world in various ways. MPL comes with it's own editor that supports syntax- and error-highlighting and has a built in compiler.
The newest version!
package de.adrodoc55.commons;
import java.io.File;
import javax.annotation.Nullable;
import org.apache.commons.lang.SystemUtils;
public interface CommonDirectories {
public static @Nullable File getFurthestExistingSubDir(@Nullable File parentDirectory,
String relativePath) {
if (parentDirectory == null || !parentDirectory.isDirectory()) {
return null;
}
File file = new File(parentDirectory, relativePath);
while (!file.isDirectory()) {
file = file.getParentFile();
}
return file;
}
public static File getMCEditDir() {
if (SystemUtils.IS_OS_WINDOWS) {
return new File(SystemUtils.getUserHome(), "Documents/MCEdit");
} else {
return new File("/.mcedit");
}
}
public static @Nullable File getMinecraftDir() {
String path = getDirInAppData("minecraft");
if (path != null) {
return new File(path);
}
return null;
}
public static @Nullable String getDirInAppData(String dir) {
if (SystemUtils.IS_OS_WINDOWS) {
return System.getenv("APPDATA") + "/." + dir;
} else if (SystemUtils.IS_OS_MAC) {
return SystemUtils.USER_HOME + "/Library/Application Support/" + dir;
} else if (SystemUtils.IS_OS_UNIX) {
return SystemUtils.USER_HOME + "/." + dir;
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy