mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-15 05:33:40 +00:00
Wrap UnsafeValues.fromLegacy() in try/catch for older versions
Should address #2352.
This commit is contained in:
parent
1388755d2a
commit
fd01b75c33
1 changed files with 10 additions and 5 deletions
|
@ -103,11 +103,16 @@ public class MaterialUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material convertFromLegacy(int id, byte damage) {
|
public static Material convertFromLegacy(int id, byte damage) {
|
||||||
return EnumSet.allOf(Material.class).stream()
|
for (Material material : EnumSet.allOf(Material.class)) {
|
||||||
.filter(material -> material.getId() == id)
|
if (material.getId() == id) {
|
||||||
.findFirst()
|
try {
|
||||||
.map(material -> Bukkit.getUnsafe().fromLegacy(new MaterialData(material, damage)))
|
return Bukkit.getUnsafe().fromLegacy(new MaterialData(material, damage));
|
||||||
.orElse(null);
|
} catch (NoSuchMethodError error) {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DyeColor getColorOf(Material material) {
|
public static DyeColor getColorOf(Material material) {
|
||||||
|
|
Loading…
Reference in a new issue