WorldEdit version is now printed on load.

This commit is contained in:
sk89q 2010-11-03 17:05:05 -07:00
parent 28f76f869c
commit 4d06bc5df1
2 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Class-Path: jnbt.jar truezip.jar ant.jar Class-Path: jnbt.jar truezip.jar ant.jar
WorldEdit-Version: 1.1

View File

@ -20,7 +20,12 @@
import com.sk89q.worldedit.snapshots.SnapshotRepository; import com.sk89q.worldedit.snapshots.SnapshotRepository;
import java.util.Map; import java.util.Map;
import java.util.HashSet; import java.util.HashSet;
import com.sk89q.worldedit.ServerInterface; import java.util.jar.Manifest;
import java.util.jar.Attributes;
import java.net.URL;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Entry point for the plugin for hey0's mod. * Entry point for the plugin for hey0's mod.
@ -28,6 +33,10 @@ import com.sk89q.worldedit.ServerInterface;
* @author sk89q * @author sk89q
*/ */
public class WorldEdit extends Plugin { public class WorldEdit extends Plugin {
/**
* Logger.
*/
private static final Logger logger = Logger.getLogger("Minecraft");
/** /**
* WorldEditLibrary's properties file. * WorldEditLibrary's properties file.
*/ */
@ -60,6 +69,8 @@ public class WorldEdit extends Plugin {
PluginListener.Priority.MEDIUM); PluginListener.Priority.MEDIUM);
loader.addListener(PluginLoader.Hook.LOGIN, listener, this, loader.addListener(PluginLoader.Hook.LOGIN, listener, this,
PluginListener.Priority.MEDIUM); PluginListener.Priority.MEDIUM);
logger.log(Level.INFO, "WorldEdit version " + getWorldEditVersion() + " loaded.");
} }
/** /**
@ -111,4 +122,23 @@ public class WorldEdit extends Plugin {
worldEdit.clearSessions(); worldEdit.clearSessions();
} }
/**
* Get the WorldEdit version.
*
* @return
*/
private String getWorldEditVersion() {
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)";
}
}
} }