Skip to content

Commit

Permalink
- Fix FarmPlotBlock migration failing on server upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
LlmDl committed May 24, 2024
1 parent dc04f3d commit 2f151fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Towny/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<artifactId>towny</artifactId>
<packaging>jar</packaging>
<version>0.100.2.10</version>
<version>0.100.2.11</version>

<licenses>
<license>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Collectors;

@SuppressWarnings("FieldCanBeLocal")
public class RunnableMigrations {
Expand Down Expand Up @@ -97,11 +98,12 @@ else if (Boolean.parseBoolean(config.getString("notification.notifications_appea
for (Map<?, ?> plotType : config.getMapList("townblocktypes.types")) {
if (!plotType.get("name").equals("farm"))
continue;
List<String> currentBlocks = Arrays.asList(((String) plotType.get("allowedBlocks")).split(","));
Arrays.asList(TownySettings.getDefaultFarmblocks().split(",")).stream()
String rawBlocks = (String) plotType.get("allowedBlocks");
List<String> currentBlocks = Arrays.asList(rawBlocks.split(","));
List<String> missingBlocks = Arrays.asList(TownySettings.getDefaultFarmblocks().split(",")).stream()
.filter(block -> !currentBlocks.contains(block))
.forEach(block -> currentBlocks.add(block));
((Map<String, Object>) plotType).replace("allowedBlocks", StringMgmt.join(currentBlocks, ","));
.collect(Collectors.toList());
((Map<String, Object>) plotType).replace("allowedBlocks", rawBlocks + "," + StringMgmt.join(missingBlocks, ","));
}
};
}
4 changes: 3 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9777,4 +9777,6 @@ v0.92.0.11:
- Also includes other pom maintenance.
- Update FarmPlotBlocks to automatically update from ItemLists when generating defaults.
- Also adds a new ConfigMigration type specifically for farm blocks.
- Existing configs will add in any missing farm blocks.
- Existing configs will add in any missing farm blocks.
0.100.2.11:
- Fix FarmPlotBlock migration failing on server upgrade.

0 comments on commit 2f151fa

Please sign in to comment.