mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
Wrap UnsafeValues.fromLegacy() in try/catch for older versions
Should address #2352.
This commit is contained in:
parent
1388755d2a
commit
fd01b75c33
@ -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 New Issue
Block a user