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); + } + } }