From 485415c551d6b0a2afc6d4b2d4bda56a5696fdee Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 23 Jun 2019 14:17:44 +0100 Subject: [PATCH] 1.14 id support (#2403) * Plausible fix for 1.14 support. - Allow 1.14 blocks to be specified in LegacyBlocks, but only saved if the server version is 1.14. - No snazzy config conversion, but it seems most people managed to figure it out on their own anyway * Ignore the "severe" output because of new 1.13/14 blocks --- .../bukkit/util/BukkitLegacyMappings.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) 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 061712d02..78b919672 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 @@ -1,5 +1,6 @@ package com.github.intellectualsites.plotsquared.bukkit.util; +import com.github.intellectualsites.plotsquared.bukkit.BukkitMain; import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; @@ -126,7 +127,7 @@ public final class BukkitLegacyMappings extends LegacyMappings { new LegacyBlock(43, 6, "double_step", "smooth_quartz"), new LegacyBlock(43, 8, "double_step", "smooth_stone"), new LegacyBlock(43, 9, "double_step", "smooth_sandstone"), - new LegacyBlock(44, "step", "stone_slab"), + new LegacyBlock(44, "step", "stone_slab", "smooth_stone_slab"), new LegacyBlock(44, 1, "step", "sandstone_slab"), new LegacyBlock(44, 2, "step", "petrified_oak_slab"), new LegacyBlock(44, 3, "step", "cobblestone_slab"), @@ -147,7 +148,7 @@ public final class BukkitLegacyMappings extends LegacyMappings { new LegacyBlock(58, "workbench", "crafting_table"), new LegacyBlock(59, "crops", "wheat"), new LegacyBlock(60, "soil", "farmland"), new LegacyBlock(61, "furnace"), new LegacyBlock(62, "burning_furnace"), - new LegacyBlock(63, "sign_post", "sign"), + new LegacyBlock(63, "sign_post", "sign", "oak_sign"), new LegacyBlock(64, "wooden_door", "oak_door"), new LegacyBlock(65, "ladder"), new LegacyBlock(66, "rails", "rail"), new LegacyBlock(67, "cobblestone_stairs"), new LegacyBlock(68, "wall_sign"), new LegacyBlock(69, "lever"), @@ -688,9 +689,7 @@ public final class BukkitLegacyMappings extends LegacyMappings { final LegacyBlock missingBlock = new LegacyBlock(material.getId(), materialName, materialName); missing.add(missingBlock); - } catch (Exception e) { - Bukkit.getLogger().severe( - "Error creating legacy block: " + materialName + ". Possibly a new block."); + } catch (Exception ignored) { } } } @@ -713,9 +712,8 @@ public final class BukkitLegacyMappings extends LegacyMappings { try { material = Material.getMaterial(legacyBlock.getLegacyName(), true); } catch (NoSuchMethodError error) { - PlotSquared.log( - "You can't use this version of PlotSquared on a server " - + "less than Minecraft 1.13.2"); + PlotSquared.log("You can't use this version of PlotSquared on a server " + + "less than Minecraft 1.13.2"); Bukkit.shutdown(); break; } @@ -831,6 +829,20 @@ public final class BukkitLegacyMappings extends LegacyMappings { this(numericalId, dataValue, legacyName, legacyName); } + LegacyBlock(final int numericalId, final int dataValue, @NonNull final String legacyName, + @NonNull final String newName, @NonNull final String new14Name) { + this(numericalId, dataValue, legacyName, + PlotSquared.get().IMP.getServerVersion()[1] == 13 ? newName : new14Name); + } + + LegacyBlock(final int numericalId, @NonNull final String legacyName, + @NonNull final String newName, @NonNull final String new14Name) { + this(numericalId, 0, legacyName, + Bukkit.getBukkitVersion().split("-")[0].split("\\.")[1].equals("13") ? + newName : + new14Name); + } + LegacyBlock(final int numericalId, @NonNull final String legacyName, @NonNull final String newName) { this(numericalId, 0, legacyName, newName);