mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
parent
464f5e09ae
commit
f2aa9dccd1
@ -61,14 +61,18 @@ import lombok.NonNull;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -76,6 +80,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -1602,6 +1607,18 @@ import java.util.zip.ZipInputStream;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Settings.load(configFile);
|
Settings.load(configFile);
|
||||||
|
//Sets the version information for the settings.yml file
|
||||||
|
try (InputStream stream = getClass().getResourceAsStream("/plugin.properties")) {
|
||||||
|
try (BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
|
||||||
|
String versionString = br.readLine();
|
||||||
|
String commitString = br.readLine();
|
||||||
|
String dateString = br.readLine();
|
||||||
|
this.version = PlotVersion.tryParse(versionString, commitString, dateString);
|
||||||
|
System.out.println("Version is " + this.version);
|
||||||
|
}
|
||||||
|
} catch (IOException throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
Settings.save(configFile);
|
Settings.save(configFile);
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,14 @@ package com.github.intellectualsites.plotsquared.plot;
|
|||||||
public class PlotVersion {
|
public class PlotVersion {
|
||||||
public final int year, month, day, hash, build;
|
public final int year, month, day, hash, build;
|
||||||
|
|
||||||
|
public PlotVersion(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 PlotVersion(String version, String commit, String date) {
|
public PlotVersion(String version, String commit, String date) {
|
||||||
String[] split = version.substring(version.indexOf('=') + 1).split("\\.");
|
String[] split = version.substring(version.indexOf('=') + 1).split("\\.");
|
||||||
this.build = Integer.parseInt(split[1]);
|
this.build = Integer.parseInt(split[1]);
|
||||||
@ -13,8 +21,23 @@ public class PlotVersion {
|
|||||||
this.day = Integer.parseInt(split1[2]);
|
this.day = Integer.parseInt(split1[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static PlotVersion tryParse(String version, String commit, String date) {
|
||||||
public String toString() {
|
try {
|
||||||
|
return new PlotVersion(version, commit, date);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new PlotVersion(0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String versionString() {
|
||||||
|
if (hash == 0 && build == 0) {
|
||||||
|
return "NoVer-SNAPSHOT";
|
||||||
|
} else {
|
||||||
|
return "5." + build;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override public String toString() {
|
||||||
if (hash == 0 && build == 0) {
|
if (hash == 0 && build == 0) {
|
||||||
return "PlotSquared-NoVer-SNAPSHOT";
|
return "PlotSquared-NoVer-SNAPSHOT";
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user