Use valueOf as the class is no longer an Enum

This commit is contained in:
tastybento 2024-08-10 20:06:39 -07:00
parent ed700a1915
commit 50dba5cb82

View File

@ -37,7 +37,7 @@ import world.bentobox.bentobox.BentoBox;
* *
* @author tastybento, Poslovitch * @author tastybento, Poslovitch
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("removal")
public class ItemParser { public class ItemParser {
private ItemParser() {} // private constructor to hide the implicit public one. private ItemParser() {} // private constructor to hide the implicit public one.
@ -333,7 +333,7 @@ public class ItemParser {
* @param part String array that contains at least 2 elements. * @param part String array that contains at least 2 elements.
* @return Banner as item stack. * @return Banner as item stack.
*/ */
private static ItemStack parseBanner(String[] part) { static ItemStack parseBanner(String[] part) {
if (part.length >= 2) { if (part.length >= 2) {
Material bannerMat = Material.getMaterial(part[0]); Material bannerMat = Material.getMaterial(part[0]);
if (bannerMat == null) { if (bannerMat == null) {
@ -345,18 +345,13 @@ public class ItemParser {
BannerMeta meta = (BannerMeta) result.getItemMeta(); BannerMeta meta = (BannerMeta) result.getItemMeta();
if (meta != null) { if (meta != null) {
for (int i = 2; i < part.length; i += 2) { for (int i = 2; i < part.length; i += 2) {
PatternType pt = Enums.getIfPresent(PatternType.class, part[i]).orNull(); //if (!Util.inTest()) {
if (pt == null) { PatternType pt = PatternType.valueOf(part[i]);
// Try to convert old to new DyeColor dc = Enums.getIfPresent(DyeColor.class, part[i + 1]).orNull();
if (part[i].trim().equals("STRIPE_SMALL") if (dc != null) {
&& Enums.getIfPresent(PatternType.class, "SMALL_STRIPES").isPresent()) { meta.addPattern(new Pattern(dc, pt));
pt = PatternType.SMALL_STRIPES;
} }
} //}
DyeColor dc = Enums.getIfPresent(DyeColor.class, part[i + 1]).orNull();
if (pt != null && dc != null) {
meta.addPattern(new Pattern(dc, pt));
}
} }
result.setItemMeta(meta); result.setItemMeta(meta);
} }