This commit is contained in:
KingRainbow44 2022-06-26 13:00:23 -04:00
parent 269149bb1f
commit f86b4bec11

View File

@ -146,22 +146,12 @@ public final class Utils {
Files.copy(stream, new File(destination).toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(stream, new File(destination).toPath(), StandardCopyOption.REPLACE_EXISTING);
return true; return true;
} catch (Exception e) { } catch (Exception exception) {
Grasscutter.getLogger().warn("Unable to copy resource " + resource + " to " + destination, e); Grasscutter.getLogger().warn("Unable to copy resource " + resource + " to " + destination, exception);
return false; return false;
} }
} }
/**
* Get object with null fallback.
* @param nonNull The object to return if not null.
* @param fallback The object to return if null.
* @return One of the two provided objects.
*/
public static <T> T requireNonNullElseGet(T nonNull, T fallback) {
return nonNull != null ? nonNull : fallback;
}
/** /**
* Logs an object to the console. * Logs an object to the console.
* @param object The object to log. * @param object The object to log.
@ -276,7 +266,7 @@ public final class Utils {
/** /**
* Performs a linear interpolation using a table of fixed points to create an effective piecewise f(x) = y function. * Performs a linear interpolation using a table of fixed points to create an effective piecewise f(x) = y function.
* @param x * @param x The x value.
* @param xyArray Array of points in [[x0,y0], ... [xN, yN]] format * @param xyArray Array of points in [[x0,y0], ... [xN, yN]] format
* @return f(x) = y * @return f(x) = y
*/ */