diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be5651e7..0c0e5883 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "SongodaCore" path: "/builds/$CI_PROJECT_PATH" - version: "2.3.40" + version: "2.3.41" build: stage: build diff --git a/Core/src/main/java/com/songoda/core/SongodaPlugin.java b/Core/src/main/java/com/songoda/core/SongodaPlugin.java index 3bca031b..34f94bc8 100644 --- a/Core/src/main/java/com/songoda/core/SongodaPlugin.java +++ b/Core/src/main/java/com/songoda/core/SongodaPlugin.java @@ -53,13 +53,13 @@ public abstract class SongodaPlugin extends JavaPlugin { } @Override - public void reloadConfig​() { + public void reloadConfig() { config.load(); onConfigReload(); } @Override - public void saveConfig​() { + public void saveConfig() { config.save(); } diff --git a/Core/src/main/java/com/songoda/core/compatibility/CompatibleMaterial.java b/Core/src/main/java/com/songoda/core/compatibility/CompatibleMaterial.java index 1dfe5d51..a3ef8a30 100644 --- a/Core/src/main/java/com/songoda/core/compatibility/CompatibleMaterial.java +++ b/Core/src/main/java/com/songoda/core/compatibility/CompatibleMaterial.java @@ -1353,12 +1353,59 @@ public enum CompatibleMaterial { * @return LegacyMaterial or null if none found */ public static CompatibleMaterial getMaterial(Block block) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { // Flattening + return CompatibleMaterial.getMaterialFromNewBlock(block); + } else { // Pre-Flattening + if(block != null){ + if (block.getData() != 0) { + for (CompatibleMaterial cm : CompatibleMaterial.values()) { + if (cm.getMaterial().equals(block.getType())) { + if (cm.getData() == block.getData()) { + return cm; + } + } + } + } + return CompatibleMaterial.getMaterialFromNewBlock(block); + } + } + return null; + } + + /** + * Lookup a Material by Material and data, corrected for legacy + * + * @param mat material to check + * @param data data of the block + * @return LegacyMaterial or null if none found + */ + public static CompatibleMaterial getMaterial(Material mat, byte data) { + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { // Flattening + return CompatibleMaterial.getMaterial(mat); + } else { // Pre-Flattening + if(mat != null){ + if (data != 0) { + for (CompatibleMaterial cm : CompatibleMaterial.values()) { + if (cm.getMaterial() != null + && cm.getMaterial().equals(mat)) { + if (cm.getData() == data) { + return cm; + } + } + } + } + return CompatibleMaterial.getMaterial(mat); + } + } + return null; + } + + private static CompatibleMaterial getMaterialFromNewBlock(Block block) { if (block == null) { return null; } Material mat = block.getType(); - if (mat == null) return null; - else if (useLegacy) { + if (useLegacy) { LegacyMaterialBlockType legacyBlock = LegacyMaterialBlockType.getFromLegacy(mat.name()); if (legacyBlock != null) { return lookupMap.get(legacyBlock.name());