3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Improved version detection to be more reliable.

Dieser Commit ist enthalten in:
sk89q 2010-12-25 20:52:56 -08:00
Ursprung d94fe00e3e
Commit e67d01cbb9

Datei anzeigen

@ -39,6 +39,12 @@ public class WorldEdit extends Plugin {
*/
private static final WorldEditListener listener = new WorldEditListener();
/**
* WorldEdit version, fetched from the .jar's manifest. Used to print the
* WorldEdit version in various places.
*/
private String version;
/**
* Initializes the plugin.
*/
@ -81,22 +87,32 @@ public class WorldEdit extends Plugin {
}
/**
* Get the WorldEdit version.
* Get the CraftBook version.
*
* @return
*/
private String getVersion() {
try {
String classContainer = WorldEdit.class.getProtectionDomain()
.getCodeSource().getLocation().toString();
URL manifestUrl = new URL("jar:" + classContainer + "!/META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(manifestUrl.openStream());
Attributes attrib = manifest.getMainAttributes();
String ver = (String)attrib.getValue("WorldEdit-Version");
return ver != null ? ver : "(unavailable)";
} catch (IOException e) {
return "(unknown)";
public String getVersion() {
if (version != null) {
return version;
}
Package p = WorldEdit.class.getPackage();
if (p == null) {
p = Package.getPackage("com.sk89q.worldedit");
}
if (p == null) {
version = "(unknown)";
} else {
version = p.getImplementationVersion();
if (version == null) {
version = "(unknown)";
}
}
return version;
}
/**