mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-26 03:55:53 +01:00
Make CompatibleMaterial#getMaterial(String) with null and empty values
XMaterial throws an Exception if provided with `null` or `""`. We make sure that an empty Optional is returned instead. Mainly for backwards compatibility reasons.
This commit is contained in:
parent
ebd83688d3
commit
8c22f5d141
@ -15,10 +15,14 @@ import java.util.Optional;
|
||||
|
||||
public class CompatibleMaterial {
|
||||
public static Optional<XMaterial> getMaterial(@NotNull Material material) {
|
||||
return XMaterial.matchXMaterial(material.name());
|
||||
return getMaterial(material.name());
|
||||
}
|
||||
|
||||
public static Optional<XMaterial> getMaterial(String name) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static Optional<XMaterial> getMaterial(@NotNull String name) {
|
||||
return XMaterial.matchXMaterial(name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user