forked from xjboss/KCauldronX
Finally fix #67
This commit is contained in:
@ -9,96 +9,96 @@ import java.util.Properties;
|
||||
import org.spigotmc.RestartCommand;
|
||||
|
||||
public class KCauldron {
|
||||
private static boolean sManifestParsed = false;
|
||||
private static boolean sManifestParsed = false;
|
||||
|
||||
private static void parseManifest() {
|
||||
if (sManifestParsed)
|
||||
return;
|
||||
sManifestParsed = true;
|
||||
private static void parseManifest() {
|
||||
if (sManifestParsed)
|
||||
return;
|
||||
sManifestParsed = true;
|
||||
|
||||
try {
|
||||
Enumeration<URL> resources = KCauldron.class.getClassLoader()
|
||||
.getResources("META-INF/MANIFEST.MF");
|
||||
Properties manifest = new Properties();
|
||||
while (resources.hasMoreElements()) {
|
||||
URL url = resources.nextElement();
|
||||
manifest.load(url.openStream());
|
||||
String version = manifest.getProperty("KCauldron-Version");
|
||||
if (version != null) {
|
||||
String path = url.getPath();
|
||||
String jarFilePath = path.substring(path.indexOf(":") + 1,
|
||||
path.indexOf("!"));
|
||||
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8");
|
||||
sServerLocation = new File(jarFilePath);
|
||||
try {
|
||||
Enumeration<URL> resources = KCauldron.class.getClassLoader()
|
||||
.getResources("META-INF/MANIFEST.MF");
|
||||
Properties manifest = new Properties();
|
||||
while (resources.hasMoreElements()) {
|
||||
URL url = resources.nextElement();
|
||||
manifest.load(url.openStream());
|
||||
String version = manifest.getProperty("KCauldron-Version");
|
||||
if (version != null) {
|
||||
String path = url.getPath();
|
||||
String jarFilePath = path.substring(path.indexOf(":") + 1,
|
||||
path.indexOf("!"));
|
||||
jarFilePath = URLDecoder.decode(jarFilePath, "UTF-8");
|
||||
sServerLocation = new File(jarFilePath);
|
||||
|
||||
sCurrentVersion = version;
|
||||
sGroup = manifest.getProperty("KCauldron-Group");
|
||||
sBranch = manifest.getProperty("KCauldron-Branch");
|
||||
sChannel = manifest.getProperty("KCauldron-Channel");
|
||||
break;
|
||||
}
|
||||
manifest.clear();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
sCurrentVersion = version;
|
||||
sGroup = manifest.getProperty("KCauldron-Group");
|
||||
sBranch = manifest.getProperty("KCauldron-Branch");
|
||||
sChannel = manifest.getProperty("KCauldron-Channel");
|
||||
break;
|
||||
}
|
||||
manifest.clear();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String sCurrentVersion;
|
||||
private static String sCurrentVersion;
|
||||
|
||||
public static String getCurrentVersion() {
|
||||
parseManifest();
|
||||
return sCurrentVersion;
|
||||
}
|
||||
public static String getCurrentVersion() {
|
||||
parseManifest();
|
||||
return sCurrentVersion;
|
||||
}
|
||||
|
||||
private static File sServerLocation;
|
||||
private static File sServerLocation;
|
||||
|
||||
public static File getServerLocation() {
|
||||
parseManifest();
|
||||
return sServerLocation;
|
||||
}
|
||||
|
||||
private static File sServerHome;
|
||||
|
||||
public static File getServerHome() {
|
||||
if (sServerHome == null) {
|
||||
String home = System.getenv("KCAULDRON_HOME");
|
||||
if (home != null) {
|
||||
sServerHome = new File(home);
|
||||
} else {
|
||||
parseManifest();
|
||||
sServerHome = sServerLocation.getParentFile();
|
||||
}
|
||||
}
|
||||
return sServerHome;
|
||||
}
|
||||
public static File getServerLocation() {
|
||||
parseManifest();
|
||||
return sServerLocation;
|
||||
}
|
||||
|
||||
private static File sServerHome;
|
||||
|
||||
public static File getServerHome() {
|
||||
if (sServerHome == null) {
|
||||
String home = System.getenv("KCAULDRON_HOME");
|
||||
if (home != null) {
|
||||
sServerHome = new File(home);
|
||||
} else {
|
||||
parseManifest();
|
||||
sServerHome = sServerLocation.getParentFile();
|
||||
}
|
||||
}
|
||||
return sServerHome;
|
||||
}
|
||||
|
||||
private static String sGroup;
|
||||
private static String sGroup;
|
||||
|
||||
public static String getGroup() {
|
||||
parseManifest();
|
||||
return sGroup;
|
||||
}
|
||||
public static String getGroup() {
|
||||
parseManifest();
|
||||
return sGroup;
|
||||
}
|
||||
|
||||
private static String sBranch;
|
||||
private static String sBranch;
|
||||
|
||||
public static String getBranch() {
|
||||
parseManifest();
|
||||
return sBranch;
|
||||
}
|
||||
public static String getBranch() {
|
||||
parseManifest();
|
||||
return sBranch;
|
||||
}
|
||||
|
||||
private static String sChannel;
|
||||
private static String sChannel;
|
||||
|
||||
public static String getChannel() {
|
||||
parseManifest();
|
||||
return sChannel;
|
||||
}
|
||||
public static String getChannel() {
|
||||
parseManifest();
|
||||
return sChannel;
|
||||
}
|
||||
|
||||
public static File sNewServerLocation;
|
||||
public static String sNewServerVersion;
|
||||
public static boolean sUpdateInProgress;
|
||||
public static File sNewServerLocation;
|
||||
public static String sNewServerVersion;
|
||||
public static boolean sUpdateInProgress;
|
||||
|
||||
public static void restart() {
|
||||
RestartCommand.restart(true);
|
||||
}
|
||||
public static void restart() {
|
||||
RestartCommand.restart(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user