From 9e324762b6df6e735e42e72a47f77a7960f48567 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 29 Apr 2019 15:18:38 -0400 Subject: [PATCH] Move the update utility setup to it's own method --- .../plotsquared/plot/PlotSquared.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java index 6252274d7..8823118b1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java @@ -1611,6 +1611,30 @@ import java.util.zip.ZipInputStream; } } Settings.load(configFile); + setupUpdateUtility(); + //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); + 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 + .toHexString(version.hash); + System.out.println("Version is " + this.version); + } + } catch (IOException throwable) { + throwable.printStackTrace(); + } + Settings.save(configFile); + config = YamlConfiguration.loadConfiguration(configFile); + } + + private void setupUpdateUtility() { try { copyFile("updater.properties", "config"); try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( @@ -1630,24 +1654,6 @@ import java.util.zip.ZipInputStream; } catch (final Throwable throwable) { throwable.printStackTrace(); } - try (InputStream stream = getClass().getResourceAsStream("/plugin.properties"); - 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(); - 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 - .toHexString(version.hash); - System.out.println("Version is " + this.version); - } catch (IOException throwable) { - throwable.printStackTrace(); - } - Settings.save(configFile); - config = YamlConfiguration.loadConfiguration(configFile); } /**