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