mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13: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 {
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'org.yaml:snakeyaml:1.23'
|
||||
@ -7,13 +9,14 @@ dependencies {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
|
||||
processResources {
|
||||
from('src/main/resources') {
|
||||
include 'plugin.properties'
|
||||
expand(
|
||||
version: "${project.parent.version}",
|
||||
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) {
|
||||
updater = new Updater();
|
||||
TaskManager.IMP.taskAsync(new Runnable() {
|
||||
@ -236,7 +236,7 @@ import java.util.zip.ZipInputStream;
|
||||
updater.update(getPlatform(), getVersion());
|
||||
}
|
||||
}, 36000);
|
||||
}
|
||||
}*/
|
||||
|
||||
// World generators:
|
||||
final ConfigurationSection section = this.worlds.getConfigurationSection("worlds");
|
||||
@ -1699,10 +1699,14 @@ import java.util.zip.ZipInputStream;
|
||||
Settings.load(configFile);
|
||||
try {
|
||||
InputStream stream = getClass().getResourceAsStream("/plugin.properties");
|
||||
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = scanner.next().trim();
|
||||
scanner.close();
|
||||
this.version = PlotVersion.tryParse(versionString);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
|
||||
//java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
|
||||
String versionString = br.readLine();
|
||||
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.BUILD = "https://ci.athion.net/job/PlotSquared/" + version.build;
|
||||
Settings.COMMIT = "https://github.com/IntellectualSites/PlotSquared/commit/" + Integer
|
||||
|
@ -11,28 +11,19 @@ public class PlotVersion {
|
||||
this.build = build;
|
||||
}
|
||||
|
||||
public PlotVersion(String version) {
|
||||
String[] split = version.substring(version.indexOf('=') + 1).split("-");
|
||||
if (split[0].equals("unknown")) {
|
||||
this.year = month = day = hash = build = 0;
|
||||
return;
|
||||
}
|
||||
String[] date = split[0].split("\\.");
|
||||
this.year = Integer.parseInt(date[0]);
|
||||
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 PlotVersion(String version, String commit, String date) {
|
||||
String[] split = version.substring(version.indexOf('=') + 1).split("\\.");
|
||||
this.build = Integer.parseInt(split[1]);
|
||||
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 PlotVersion tryParse(String version) {
|
||||
public static PlotVersion tryParse(String version, String commit, String date) {
|
||||
try {
|
||||
return new PlotVersion(version);
|
||||
return new PlotVersion(version, commit, date);
|
||||
} catch (Exception ignore) {
|
||||
ignore.printStackTrace();
|
||||
return new PlotVersion(0, 0, 0, 0, 0);
|
||||
|
@ -32,7 +32,7 @@ public class Updater {
|
||||
return newVersion != null;
|
||||
}
|
||||
|
||||
public void update(String platform, PlotVersion currentVersion) {
|
||||
/*public void update(String platform, PlotVersion currentVersion) {
|
||||
if (currentVersion == null || platform == null) {
|
||||
return;
|
||||
}
|
||||
@ -78,5 +78,5 @@ public class Updater {
|
||||
}
|
||||
} 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)
|
||||
|
||||
description = rootProject.name
|
||||
if (project.hasProperty("lzNoVersion")) { // gradle build -PlzNoVersion
|
||||
version = "unknown"
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java'
|
||||
|
Loading…
Reference in New Issue
Block a user