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
This commit is contained in:
dordsor21 2019-06-23 14:17:44 +01:00 committed by GitHub
parent d6401d1638
commit 485415c551
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package com.github.intellectualsites.plotsquared.bukkit.util; 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.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock; import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; 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, 6, "double_step", "smooth_quartz"),
new LegacyBlock(43, 8, "double_step", "smooth_stone"), new LegacyBlock(43, 8, "double_step", "smooth_stone"),
new LegacyBlock(43, 9, "double_step", "smooth_sandstone"), 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, 1, "step", "sandstone_slab"),
new LegacyBlock(44, 2, "step", "petrified_oak_slab"), new LegacyBlock(44, 2, "step", "petrified_oak_slab"),
new LegacyBlock(44, 3, "step", "cobblestone_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(58, "workbench", "crafting_table"),
new LegacyBlock(59, "crops", "wheat"), new LegacyBlock(60, "soil", "farmland"), new LegacyBlock(59, "crops", "wheat"), new LegacyBlock(60, "soil", "farmland"),
new LegacyBlock(61, "furnace"), new LegacyBlock(62, "burning_furnace"), 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(64, "wooden_door", "oak_door"), new LegacyBlock(65, "ladder"),
new LegacyBlock(66, "rails", "rail"), new LegacyBlock(67, "cobblestone_stairs"), new LegacyBlock(66, "rails", "rail"), new LegacyBlock(67, "cobblestone_stairs"),
new LegacyBlock(68, "wall_sign"), new LegacyBlock(69, "lever"), new LegacyBlock(68, "wall_sign"), new LegacyBlock(69, "lever"),
@ -688,9 +689,7 @@ public final class BukkitLegacyMappings extends LegacyMappings {
final LegacyBlock missingBlock = final LegacyBlock missingBlock =
new LegacyBlock(material.getId(), materialName, materialName); new LegacyBlock(material.getId(), materialName, materialName);
missing.add(missingBlock); missing.add(missingBlock);
} catch (Exception e) { } catch (Exception ignored) {
Bukkit.getLogger().severe(
"Error creating legacy block: " + materialName + ". Possibly a new block.");
} }
} }
} }
@ -713,9 +712,8 @@ public final class BukkitLegacyMappings extends LegacyMappings {
try { try {
material = Material.getMaterial(legacyBlock.getLegacyName(), true); material = Material.getMaterial(legacyBlock.getLegacyName(), true);
} catch (NoSuchMethodError error) { } catch (NoSuchMethodError error) {
PlotSquared.log( PlotSquared.log("You can't use this version of PlotSquared on a server "
"You can't use this version of PlotSquared on a server " + "less than Minecraft 1.13.2");
+ "less than Minecraft 1.13.2");
Bukkit.shutdown(); Bukkit.shutdown();
break; break;
} }
@ -831,6 +829,20 @@ public final class BukkitLegacyMappings extends LegacyMappings {
this(numericalId, dataValue, legacyName, legacyName); 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, LegacyBlock(final int numericalId, @NonNull final String legacyName,
@NonNull final String newName) { @NonNull final String newName) {
this(numericalId, 0, legacyName, newName); this(numericalId, 0, legacyName, newName);