mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-30 22:24:06 +01:00
Add mod version check code
This commit is contained in:
parent
d396046249
commit
d8ccc26109
@ -108,6 +108,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||||||
private Metrics metrics;
|
private Metrics metrics;
|
||||||
private BukkitEnableCoreCallback enabCoreCB = new BukkitEnableCoreCallback();
|
private BukkitEnableCoreCallback enabCoreCB = new BukkitEnableCoreCallback();
|
||||||
private Method ismodloaded;
|
private Method ismodloaded;
|
||||||
|
private Method instance;
|
||||||
|
private Method getindexedmodlist;
|
||||||
|
private Method getversion;
|
||||||
private HashMap<String, BukkitWorld> world_by_name = new HashMap<String, BukkitWorld>();
|
private HashMap<String, BukkitWorld> world_by_name = new HashMap<String, BukkitWorld>();
|
||||||
private HashSet<String> modsused = new HashSet<String>();
|
private HashSet<String> modsused = new HashSet<String>();
|
||||||
// TPS calculator
|
// TPS calculator
|
||||||
@ -199,6 +202,10 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||||||
try {
|
try {
|
||||||
Class<?> c = Class.forName("cpw.mods.fml.common.Loader");
|
Class<?> c = Class.forName("cpw.mods.fml.common.Loader");
|
||||||
ismodloaded = c.getMethod("isModLoaded", String.class);
|
ismodloaded = c.getMethod("isModLoaded", String.class);
|
||||||
|
instance = c.getMethod("instance");
|
||||||
|
getindexedmodlist = c.getMethod("getIndexedModList");
|
||||||
|
c = Class.forName("cpw.mods.fml.common.ModContainer");
|
||||||
|
getversion = c.getMethod("getVersion");
|
||||||
} catch (NoSuchMethodException nsmx) {
|
} catch (NoSuchMethodException nsmx) {
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
}
|
}
|
||||||
@ -521,6 +528,24 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public String getModVersion(String name) {
|
||||||
|
if((instance != null) && (getindexedmodlist != null) && (getversion != null)) {
|
||||||
|
try {
|
||||||
|
Object inst = instance.invoke(null);
|
||||||
|
Map<?,?> modmap = (Map<?,?>) getindexedmodlist.invoke(inst);
|
||||||
|
Object mod = modmap.get(name);
|
||||||
|
if (mod != null) {
|
||||||
|
return (String) getversion.invoke(mod);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException iax) {
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getServerTPS() {
|
public double getServerTPS() {
|
||||||
|
Loading…
Reference in New Issue
Block a user