Initial replay writing support.
- Added Replay.save() method to save replays to a file. - Separated Replay loading from the constructor into a load() method. - Added OsuWriter class to write replays. - Parse replay seeds (what do they do?). - Added Updater.getBuildDate() method to retrieve the current build date (for the replay 'version' field). - Added osu! mode constants in OsuFile. - Added methods to retrieve raw ReplayFrame coordinates. - Added replay fields/methods to GameData and Game state. - Added jponge/lzma-java dependency for LZMA compression, since it isn't implemented in Apache commons-compress... Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -28,6 +28,10 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.net.URL;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
@@ -93,6 +97,9 @@ public class Updater {
|
||||
/** The current and latest versions. */
|
||||
private DefaultArtifactVersion currentVersion, latestVersion;
|
||||
|
||||
/** The build date. */
|
||||
private int buildDate = -1;
|
||||
|
||||
/** The download object. */
|
||||
private Download download;
|
||||
|
||||
@@ -115,6 +122,32 @@ public class Updater {
|
||||
return (status == Status.UPDATE_AVAILABLE || status == Status.UPDATE_DOWNLOADED || status == Status.UPDATE_DOWNLOADING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build date, or the current date if not available.
|
||||
*/
|
||||
public int getBuildDate() {
|
||||
if (buildDate == -1) {
|
||||
Date date = null;
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
props.load(ResourceLoader.getResourceAsStream(Options.VERSION_FILE));
|
||||
String build = props.getProperty("build.date");
|
||||
if (build == null || build.equals("${timestamp}") || build.equals("${maven.build.timestamp}"))
|
||||
date = new Date();
|
||||
else {
|
||||
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH);
|
||||
date = format.parse(build);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
date = new Date();
|
||||
} finally {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
buildDate = Integer.parseInt(dateFormat.format(date));
|
||||
}
|
||||
}
|
||||
return buildDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version from a set of properties.
|
||||
* @param props the set of properties
|
||||
|
||||
Reference in New Issue
Block a user