2021-07-01 20:16:25 +00:00
|
|
|
package com.fastasyncworldedit.core;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2021-07-24 15:34:05 +00:00
|
|
|
/**
|
|
|
|
* An internal FAWE class not meant for public use.
|
|
|
|
**/
|
2018-08-12 14:03:07 +00:00
|
|
|
public class FaweVersion {
|
2021-07-24 15:34:05 +00:00
|
|
|
|
2020-10-05 17:41:41 +00:00
|
|
|
public final int year;
|
|
|
|
public final int month;
|
|
|
|
public final int day;
|
|
|
|
public final int hash;
|
|
|
|
public final int build;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2019-04-16 22:35:39 +00:00
|
|
|
public FaweVersion(int year, int month, int day, int hash, int build) {
|
|
|
|
this.year = year;
|
|
|
|
this.month = month;
|
|
|
|
this.day = day;
|
|
|
|
this.hash = hash;
|
|
|
|
this.build = build;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FaweVersion(String version, String commit, String date) {
|
2019-08-29 13:52:08 +00:00
|
|
|
String[] split = version.substring(version.indexOf('=') + 1).split("-");
|
2021-07-01 20:16:25 +00:00
|
|
|
int build = 0;
|
|
|
|
try {
|
|
|
|
build = Integer.parseInt(split[1]);
|
|
|
|
} catch (NumberFormatException ignored) {
|
|
|
|
}
|
|
|
|
this.build = build;
|
2019-04-16 22:35:39 +00:00
|
|
|
this.hash = Integer.parseInt(commit.substring(commit.indexOf('=') + 1), 16);
|
|
|
|
String[] split1 = date.substring(date.indexOf('=') + 1).split("\\.");
|
|
|
|
this.year = Integer.parseInt(split1[0]);
|
|
|
|
this.month = Integer.parseInt(split1[1]);
|
|
|
|
this.day = Integer.parseInt(split1[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FaweVersion tryParse(String version, String commit, String date) {
|
|
|
|
try {
|
|
|
|
return new FaweVersion(version, commit, date);
|
2019-07-22 02:49:08 +00:00
|
|
|
} catch (Exception exception) {
|
|
|
|
exception.printStackTrace();
|
2019-04-16 22:35:39 +00:00
|
|
|
return new FaweVersion(0, 0, 0, 0, 0);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-24 15:34:05 +00:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2019-05-05 08:37:11 +00:00
|
|
|
if (hash == 0 && build == 0) {
|
2021-07-01 20:16:25 +00:00
|
|
|
return "FastAsyncWorldEdit-1.17-NoVer-SNAPSHOT";
|
2019-05-05 08:37:11 +00:00
|
|
|
} else {
|
2021-07-01 20:16:25 +00:00
|
|
|
return "FastAsyncWorldEdit-1.17" + build;
|
2019-05-05 08:37:11 +00:00
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isNewer(FaweVersion other) {
|
2019-04-16 22:35:39 +00:00
|
|
|
return other.build < this.build;
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2021-07-24 15:34:05 +00:00
|
|
|
|
2019-07-22 02:49:08 +00:00
|
|
|
}
|