From 520bac05da774e972b1be56a7235b7b23d967e79 Mon Sep 17 00:00:00 2001 From: taoneill Date: Tue, 19 Jun 2012 00:37:18 -0400 Subject: [PATCH] Less complicated file numbering system Closes gh-486. There will still be duplicate numbers when old versions are deleted, as the version only takes into account the number of old versions in the /temp/oldversion/warzone-x/ folder. --- .../war/command/SaveZoneCommand.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/war/src/main/java/com/tommytony/war/command/SaveZoneCommand.java b/war/src/main/java/com/tommytony/war/command/SaveZoneCommand.java index 9c6d063..ea400ca 100644 --- a/war/src/main/java/com/tommytony/war/command/SaveZoneCommand.java +++ b/war/src/main/java/com/tommytony/war/command/SaveZoneCommand.java @@ -77,23 +77,8 @@ public class SaveZoneCommand extends AbstractZoneMakerCommand { oldVersionsFolder.mkdirs(); File[] versionFolders = oldVersionsFolder.listFiles(); - File last = null; - if (versionFolders.length > 0) { - last = versionFolders[versionFolders.length - 1]; - } - - int oldVersion = 0; - if (last != null) { - // at least one version - try { - String numVersion = last.getName().split("-")[1]; // get rid of datetime prefix - oldVersion = Integer.parseInt(numVersion); - } catch (NumberFormatException badname) { - War.war.log("Failed to read old version of warzone " + zone.getName(), Level.WARNING); - } - } - - int newVersion = oldVersion + 1; + int newVersion = versionFolders.length + 1; + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); String newVersionString = format.format(new Date()) + "-" + newVersion; String newVersionPath = War.war.getDataFolder().getPath() + "/temp/oldversions/warzone-" + zone.getName() + "/" + newVersionString;