From dff64c5c68f0fbb9170818f6fd2730daee1e938c Mon Sep 17 00:00:00 2001 From: sauilitired Date: Fri, 21 Dec 2018 17:49:04 +0100 Subject: [PATCH] Add support for 1.13 blocks --- .../bukkit/util/BukkitLegacyMappings.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java index 1e67b3463..9397f192e 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitLegacyMappings.java @@ -670,7 +670,21 @@ public class BukkitLegacyMappings extends LegacyMappings { private static final Map OLD_STRING_TO_STRING_PLOT_BLOCK = new HashMap<>(); public BukkitLegacyMappings() { - for (final LegacyBlock legacyBlock : BLOCKS) { + this.addAll(Arrays.asList(BLOCKS)); + // Make sure to add new blocks as well + final List missing = new ArrayList<>(); + for (final Material material : Material.values()) { + final String materialName = material.name().toLowerCase(Locale.ENGLISH); + if (OLD_STRING_TO_STRING_PLOT_BLOCK.get(materialName) == null) { + final LegacyBlock missingBlock = new LegacyBlock(material.getId(), materialName, materialName); + missing.add(missingBlock); + } + } + addAll(missing); + } + + private void addAll(@NonNull final Collection blocks) { + for (final LegacyBlock legacyBlock : blocks) { LEGACY_ID_TO_STRING_PLOT_BLOCK .put(legacyBlock.getNumericalId(), legacyBlock.toStringPlotBlock()); if (legacyBlock.getDataValue() != 0) {