Fixed broken migration for old storage versions.

This commit is contained in:
Tobias Ottenweller 2014-01-06 17:28:59 +01:00
parent a613b1933a
commit 2bd8b0ff03

View File

@ -31,27 +31,14 @@ public class MigrationUtil
{ {
public static boolean performMigration(int storageVersion, int currentVersion, List<Gate> gates) public static boolean performMigration(int storageVersion, int currentVersion, List<Gate> gates)
{ {
if (storageVersion == 0 && currentVersion >= 1) { if (storageVersion == 0 && currentVersion >= 2) {
removePortalBlocks(gates);
for (Gate g : gates) { updateAllowVehicles(gates);
for (Location l : g.getGateBlockLocations()) {
Block b = l.getBlock();
if (b.getType() == Material.PORTAL) {
b.setType(Material.AIR);
}
}
}
return true; return true;
} }
else if (storageVersion == 1 && currentVersion >= 2) { else if (storageVersion == 1 && currentVersion >= 2) {
updateAllowVehicles(gates);
for (Gate g : gates) {
g.setAllowsVehicles(true);
}
return true; return true;
} }
@ -60,4 +47,28 @@ public class MigrationUtil
return false; return false;
} }
} }
protected static void removePortalBlocks(List<Gate> 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<Gate> gates)
{
for (Gate g : gates) {
g.setAllowsVehicles(true);
}
}
} }