mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 21:22:09 +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) {
|
||||
return EnumSet.allOf(Material.class).stream()
|
||||
.filter(material -> material.getId() == id)
|
||||
.findFirst()
|
||||
.map(material -> Bukkit.getUnsafe().fromLegacy(new MaterialData(material, damage)))
|
||||
.orElse(null);
|
||||
for (Material material : EnumSet.allOf(Material.class)) {
|
||||
if (material.getId() == id) {
|
||||
try {
|
||||
return Bukkit.getUnsafe().fromLegacy(new MaterialData(material, damage));
|
||||
} catch (NoSuchMethodError error) {
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static DyeColor getColorOf(Material material) {
|
||||
|
|
Loading…
Reference in a new issue