mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Fix NPE with plot version (update to new versioning within code)
Also add date and commit to plugin.properties file.
This commit is contained in:
parent
ae9e52f093
commit
77ddeabca2
@ -1,3 +1,5 @@
|
|||||||
|
import org.ajoberstar.grgit.Grgit
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'org.yaml:snakeyaml:1.23'
|
compile 'org.yaml:snakeyaml:1.23'
|
||||||
@ -7,13 +9,14 @@ dependencies {
|
|||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
from('src/main/resources') {
|
from('src/main/resources') {
|
||||||
include 'plugin.properties'
|
include 'plugin.properties'
|
||||||
expand(
|
expand(
|
||||||
version: "${project.parent.version}",
|
version: "${project.parent.version}",
|
||||||
name: project.parent.name,
|
name: project.parent.name,
|
||||||
|
commit: "${git.head().abbreviatedId}",
|
||||||
|
date: "${git.head().getDate().format("yy.MM.dd")}",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for updates
|
/* // Check for updates
|
||||||
if (Settings.Enabled_Components.UPDATER) {
|
if (Settings.Enabled_Components.UPDATER) {
|
||||||
updater = new Updater();
|
updater = new Updater();
|
||||||
TaskManager.IMP.taskAsync(new Runnable() {
|
TaskManager.IMP.taskAsync(new Runnable() {
|
||||||
@ -236,7 +236,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
updater.update(getPlatform(), getVersion());
|
updater.update(getPlatform(), getVersion());
|
||||||
}
|
}
|
||||||
}, 36000);
|
}, 36000);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// World generators:
|
// World generators:
|
||||||
final ConfigurationSection section = this.worlds.getConfigurationSection("worlds");
|
final ConfigurationSection section = this.worlds.getConfigurationSection("worlds");
|
||||||
@ -1699,10 +1699,14 @@ import java.util.zip.ZipInputStream;
|
|||||||
Settings.load(configFile);
|
Settings.load(configFile);
|
||||||
try {
|
try {
|
||||||
InputStream stream = getClass().getResourceAsStream("/plugin.properties");
|
InputStream stream = getClass().getResourceAsStream("/plugin.properties");
|
||||||
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
|
||||||
String versionString = scanner.next().trim();
|
//java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||||
scanner.close();
|
String versionString = br.readLine();
|
||||||
this.version = PlotVersion.tryParse(versionString);
|
String commitString = br.readLine();
|
||||||
|
String dateString = br.readLine();
|
||||||
|
//scanner.close();
|
||||||
|
br.close();
|
||||||
|
this.version = PlotVersion.tryParse(versionString, commitString, dateString);
|
||||||
Settings.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
Settings.DATE = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||||
Settings.BUILD = "https://ci.athion.net/job/PlotSquared/" + version.build;
|
Settings.BUILD = "https://ci.athion.net/job/PlotSquared/" + version.build;
|
||||||
Settings.COMMIT = "https://github.com/IntellectualSites/PlotSquared/commit/" + Integer
|
Settings.COMMIT = "https://github.com/IntellectualSites/PlotSquared/commit/" + Integer
|
||||||
|
@ -11,28 +11,19 @@ public class PlotVersion {
|
|||||||
this.build = build;
|
this.build = build;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotVersion(String version) {
|
public PlotVersion(String version, String commit, String date) {
|
||||||
String[] split = version.substring(version.indexOf('=') + 1).split("-");
|
String[] split = version.substring(version.indexOf('=') + 1).split("\\.");
|
||||||
if (split[0].equals("unknown")) {
|
this.build = Integer.parseInt(split[1]);
|
||||||
this.year = month = day = hash = build = 0;
|
this.hash = Integer.parseInt(commit.substring(commit.indexOf('=') + 1), 16);
|
||||||
return;
|
String[] split1 = date.substring(date.indexOf('=') + 1).split("\\.");
|
||||||
}
|
this.year = Integer.parseInt(split1[0]);
|
||||||
String[] date = split[0].split("\\.");
|
this.month = Integer.parseInt(split1[1]);
|
||||||
this.year = Integer.parseInt(date[0]);
|
this.day = Integer.parseInt(split1[2]);
|
||||||
this.month = Integer.parseInt(date[1]);
|
|
||||||
this.day = Integer.parseInt(date[2]);
|
|
||||||
if (split[1].equals("SNAPSHOT")) { // fallback when compiling with Maven
|
|
||||||
this.hash = 0;
|
|
||||||
this.build = 0;
|
|
||||||
} else {
|
|
||||||
this.hash = Integer.parseInt(split[1], 16);
|
|
||||||
this.build = Integer.parseInt(split[2]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlotVersion tryParse(String version) {
|
public static PlotVersion tryParse(String version, String commit, String date) {
|
||||||
try {
|
try {
|
||||||
return new PlotVersion(version);
|
return new PlotVersion(version, commit, date);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
ignore.printStackTrace();
|
ignore.printStackTrace();
|
||||||
return new PlotVersion(0, 0, 0, 0, 0);
|
return new PlotVersion(0, 0, 0, 0, 0);
|
||||||
|
@ -32,7 +32,7 @@ public class Updater {
|
|||||||
return newVersion != null;
|
return newVersion != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(String platform, PlotVersion currentVersion) {
|
/*public void update(String platform, PlotVersion currentVersion) {
|
||||||
if (currentVersion == null || platform == null) {
|
if (currentVersion == null || platform == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,5 +78,5 @@ public class Updater {
|
|||||||
}
|
}
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignore) {
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@ -1 +1,3 @@
|
|||||||
version=${version}
|
version=${version}
|
||||||
|
commit=${commit}
|
||||||
|
date=${date}
|
||||||
|
@ -43,9 +43,6 @@ ext {
|
|||||||
version = String.format("%s.%s", rootVersion, buildNumber)
|
version = String.format("%s.%s", rootVersion, buildNumber)
|
||||||
|
|
||||||
description = rootProject.name
|
description = rootProject.name
|
||||||
if (project.hasProperty("lzNoVersion")) { // gradle build -PlzNoVersion
|
|
||||||
version = "unknown"
|
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
Loading…
Reference in New Issue
Block a user