From 2bd8b0ff0338b179504602c674eb317801248d6e Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Mon, 6 Jan 2014 17:28:59 +0100 Subject: [PATCH] Fixed broken migration for old storage versions. --- .../gates/persistence/MigrationUtil.java | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/de/craftinc/gates/persistence/MigrationUtil.java b/src/de/craftinc/gates/persistence/MigrationUtil.java index 9b07408..bcd9cc4 100644 --- a/src/de/craftinc/gates/persistence/MigrationUtil.java +++ b/src/de/craftinc/gates/persistence/MigrationUtil.java @@ -31,27 +31,14 @@ public class MigrationUtil { public static boolean performMigration(int storageVersion, int currentVersion, List gates) { - if (storageVersion == 0 && currentVersion >= 1) { - - for (Gate g : gates) { - - for (Location l : g.getGateBlockLocations()) { - Block b = l.getBlock(); - - if (b.getType() == Material.PORTAL) { - b.setType(Material.AIR); - } - } - } + if (storageVersion == 0 && currentVersion >= 2) { + removePortalBlocks(gates); + updateAllowVehicles(gates); return true; } else if (storageVersion == 1 && currentVersion >= 2) { - - for (Gate g : gates) { - - g.setAllowsVehicles(true); - } + updateAllowVehicles(gates); return true; } @@ -60,4 +47,28 @@ public class MigrationUtil return false; } } + + + protected static void removePortalBlocks(List gates) + { + for (Gate g : gates) { + + for (Location l : g.getGateBlockLocations()) { + Block b = l.getBlock(); + + if (b.getType() == Material.PORTAL) { + b.setType(Material.AIR); + } + } + } + } + + + protected static void updateAllowVehicles(List gates) + { + for (Gate g : gates) { + + g.setAllowsVehicles(true); + } + } }