changed how we check versions so we don't display update to people

running development versions.
This commit is contained in:
Sleaker 2012-02-18 11:16:13 -08:00
parent 0afb78399a
commit 264f769aad
2 changed files with 14 additions and 19 deletions

View File

@ -86,8 +86,8 @@ public class Vault extends JavaPlugin {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private Permission perms; private Permission perms;
private String newVersion; private int newVersion;
private String currentVersion; private int currentVersion;
private ServicesManager sm; private ServicesManager sm;
private Metrics metrics; private Metrics metrics;
@ -101,7 +101,7 @@ public class Vault extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
currentVersion = getDescription().getVersion().substring(0, 5); currentVersion = Integer.valueOf(getDescription().getVersion().substring(0, 5).replace(".", ""));
sm = getServer().getServicesManager(); sm = getServer().getServicesManager();
// Load Vault Addons // Load Vault Addons
loadEconomy(); loadEconomy();
@ -120,8 +120,8 @@ public class Vault extends JavaPlugin {
public void run() { public void run() {
try { try {
newVersion = updateCheck(currentVersion); newVersion = updateCheck(currentVersion);
if (!newVersion.contains(currentVersion)) { if (newVersion > currentVersion) {
log.warning(newVersion + " is out! You are running " + currentVersion); log.warning("Vault " + newVersion + " is out! You are running: Vault " + currentVersion);
log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault"); log.warning("Update Vault at: http://dev.bukkit.org/server-mods/vault");
} }
} catch (Exception e) { } catch (Exception e) {
@ -424,7 +424,7 @@ public class Vault extends JavaPlugin {
} }
} }
public synchronized void setVersion(String newVersion) { public synchronized void setVersion(int newVersion) {
this.newVersion = newVersion; this.newVersion = newVersion;
} }
@ -447,7 +447,7 @@ public class Vault extends JavaPlugin {
} }
} }
public String updateCheck(String currentVersion) throws Exception { public int updateCheck(int currentVersion) throws Exception {
String pluginUrlString = "http://dev.bukkit.org/server-mods/vault/files.rss"; String pluginUrlString = "http://dev.bukkit.org/server-mods/vault/files.rss";
try { try {
URL url = new URL(pluginUrlString); URL url = new URL(pluginUrlString);
@ -460,7 +460,7 @@ public class Vault extends JavaPlugin {
NodeList firstElementTagName = firstElement.getElementsByTagName("title"); NodeList firstElementTagName = firstElement.getElementsByTagName("title");
Element firstNameElement = (Element) firstElementTagName.item(0); Element firstNameElement = (Element) firstElementTagName.item(0);
NodeList firstNodes = firstNameElement.getChildNodes(); NodeList firstNodes = firstNameElement.getChildNodes();
return firstNodes.item(0).getNodeValue(); return Integer.valueOf(firstNodes.item(0).getNodeValue().replace("Vault", "").replace(".", "").trim());
} }
} }
catch (Exception localException) { catch (Exception localException) {
@ -476,7 +476,7 @@ public class Vault extends JavaPlugin {
if (perms.has(player, "vault.admin")) { if (perms.has(player, "vault.admin")) {
try { try {
String oldVersion = getDescription().getVersion().substring(0, 5); String oldVersion = getDescription().getVersion().substring(0, 5);
if (!newVersion.contains(oldVersion)) { if (newVersion > currentVersion) {
player.sendMessage(newVersion + " is out! You are running " + oldVersion); player.sendMessage(newVersion + " is out! You are running " + oldVersion);
player.sendMessage("Update Vault at: http://dev.bukkit.org/server-mods/vault"); player.sendMessage("Update Vault at: http://dev.bukkit.org/server-mods/vault");
} }

View File

@ -211,8 +211,7 @@ public class Permission_GroupManager extends Permission {
AnjoPermissionsHandler handler; AnjoPermissionsHandler handler;
if (worldName == null) { if (worldName == null) {
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName); handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
} } else {
else {
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName); handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
} }
if (handler == null) { if (handler == null) {
@ -226,8 +225,7 @@ public class Permission_GroupManager extends Permission {
OverloadedWorldHolder owh; OverloadedWorldHolder owh;
if (worldName == null) { if (worldName == null) {
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName); owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
} } else {
else {
owh = groupManager.getWorldsHolder().getWorldData(worldName); owh = groupManager.getWorldsHolder().getWorldData(worldName);
} }
if (owh == null) { if (owh == null) {
@ -256,8 +254,7 @@ public class Permission_GroupManager extends Permission {
OverloadedWorldHolder owh; OverloadedWorldHolder owh;
if (worldName == null) { if (worldName == null) {
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName); owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
} } else {
else {
owh = groupManager.getWorldsHolder().getWorldData(worldName); owh = groupManager.getWorldsHolder().getWorldData(worldName);
} }
if (owh == null) { if (owh == null) {
@ -284,8 +281,7 @@ public class Permission_GroupManager extends Permission {
AnjoPermissionsHandler handler; AnjoPermissionsHandler handler;
if (worldName == null) { if (worldName == null) {
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName); handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
} } else {
else {
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName); handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
} }
return handler.getGroups(playerName); return handler.getGroups(playerName);
@ -296,8 +292,7 @@ public class Permission_GroupManager extends Permission {
AnjoPermissionsHandler handler; AnjoPermissionsHandler handler;
if (worldName == null) { if (worldName == null) {
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName); handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
} } else {
else {
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName); handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
} }
return handler.getGroup(playerName); return handler.getGroup(playerName);