Skip to content

Commit

Permalink
Fix corrupted data when upgrading from 1.13 to 1.14 with capital lett…
Browse files Browse the repository at this point in the history
…ers in world names. (#35)
  • Loading branch information
BuildTools committed Jun 20, 2019
1 parent e548de0 commit e5507f7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/java/world/bentobox/biomes/BiomesAddonManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package world.bentobox.biomes;


import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
Expand Down Expand Up @@ -45,6 +46,20 @@ protected BiomesAddonManager(BiomesAddon addon)
}

this.load();

// TODO: Remove this code after some time, as this is just a protective code against invalid world names.
if (Bukkit.getBukkitVersion().startsWith("1.14"))
{
this.biomesCacheData.values().forEach(biomesObject -> {
if (biomesObject.getWorld().matches(".*[A-Z]+.*"))
{
biomesObject.setWorld(biomesObject.getWorld().toLowerCase());
biomesObject.setUniqueId(biomesObject.getUniqueId().toLowerCase());

this.addon.logWarning("Biomes addon fixed your data for biome " + biomesObject.getUniqueId() + ". 1.14 does not allow to use capital letters in world names.");
}
});
}
}


Expand Down Expand Up @@ -460,7 +475,7 @@ public List<BiomesObject> getBiomes(String worldName)
{
return this.biomesCacheData.values().stream().
sorted(BiomesObject::compareTo).
filter(biome -> biome.getUniqueId().startsWith(worldName)).
filter(biome -> biome.getWorld().equals(worldName)).
collect(Collectors.toList());
}

Expand Down Expand Up @@ -547,7 +562,7 @@ public boolean hasAnyBiome(World world)
String worldName = Util.getWorld(world) == null ? "" : Util.getWorld(world).getName();

return !worldName.isEmpty() &&
this.biomesCacheData.values().stream().anyMatch(biome -> biome.getUniqueId().startsWith(worldName));
this.biomesCacheData.values().stream().anyMatch(biome -> biome.getWorld().equals(worldName));
}


Expand Down

0 comments on commit e5507f7

Please sign in to comment.