|
|
@ -6,13 +6,16 @@ import java.net.URLDecoder; |
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.Enumeration; |
|
|
|
import java.util.Properties; |
|
|
|
import java.util.Properties; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.spigotmc.RestartCommand; |
|
|
|
|
|
|
|
|
|
|
|
public class KCauldron { |
|
|
|
public class KCauldron { |
|
|
|
private static boolean sManifestParsed = false; |
|
|
|
private static boolean sManifestParsed = false; |
|
|
|
|
|
|
|
|
|
|
|
private static void parseManifest() { |
|
|
|
private static void parseManifest() { |
|
|
|
if (sManifestParsed) return; |
|
|
|
if (sManifestParsed) |
|
|
|
|
|
|
|
return; |
|
|
|
sManifestParsed = true; |
|
|
|
sManifestParsed = true; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Enumeration<URL> resources = KCauldron.class.getClassLoader() |
|
|
|
Enumeration<URL> resources = KCauldron.class.getClassLoader() |
|
|
|
.getResources("META-INF/MANIFEST.MF"); |
|
|
|
.getResources("META-INF/MANIFEST.MF"); |
|
|
@ -23,10 +26,11 @@ public class KCauldron { |
|
|
|
String version = manifest.getProperty("KCauldron-Version"); |
|
|
|
String version = manifest.getProperty("KCauldron-Version"); |
|
|
|
if (version != null) { |
|
|
|
if (version != null) { |
|
|
|
String path = url.getPath(); |
|
|
|
String path = url.getPath(); |
|
|
|
String jarFilePath = path.substring(path.indexOf(":") + 1, path.indexOf("!")); |
|
|
|
String jarFilePath = path.substring(path.indexOf(":") + 1, |
|
|
|
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8"); |
|
|
|
path.indexOf("!")); |
|
|
|
sServerLocation = new File(jarFilePath); |
|
|
|
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8"); |
|
|
|
|
|
|
|
sServerLocation = new File(jarFilePath); |
|
|
|
|
|
|
|
|
|
|
|
sCurrentVersion = version; |
|
|
|
sCurrentVersion = version; |
|
|
|
sBranch = manifest.getProperty("KCauldron-Branch"); |
|
|
|
sBranch = manifest.getProperty("KCauldron-Branch"); |
|
|
|
sChannel = manifest.getProperty("KCauldron-Channel"); |
|
|
|
sChannel = manifest.getProperty("KCauldron-Channel"); |
|
|
@ -38,7 +42,7 @@ public class KCauldron { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String sCurrentVersion; |
|
|
|
private static String sCurrentVersion; |
|
|
|
|
|
|
|
|
|
|
|
public static String getCurrentVersion() { |
|
|
|
public static String getCurrentVersion() { |
|
|
@ -52,22 +56,26 @@ public class KCauldron { |
|
|
|
parseManifest(); |
|
|
|
parseManifest(); |
|
|
|
return sServerLocation; |
|
|
|
return sServerLocation; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String sBranch; |
|
|
|
private static String sBranch; |
|
|
|
|
|
|
|
|
|
|
|
public static String getBranch() { |
|
|
|
public static String getBranch() { |
|
|
|
parseManifest(); |
|
|
|
parseManifest(); |
|
|
|
return sBranch; |
|
|
|
return sBranch; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String sChannel; |
|
|
|
private static String sChannel; |
|
|
|
|
|
|
|
|
|
|
|
public static String getChannel() { |
|
|
|
public static String getChannel() { |
|
|
|
parseManifest(); |
|
|
|
parseManifest(); |
|
|
|
return sChannel; |
|
|
|
return sChannel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static File sNewServerLocation; |
|
|
|
public static File sNewServerLocation; |
|
|
|
public static String sNewServerVersion; |
|
|
|
public static String sNewServerVersion; |
|
|
|
public static boolean sUpdateInProgress; |
|
|
|
public static boolean sUpdateInProgress; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void restart() { |
|
|
|
|
|
|
|
RestartCommand.restart(true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|