From 47f47bd3df3209268188aeeb183d4d790a899661 Mon Sep 17 00:00:00 2001 From: KingCreator11 <76130397+KingCreator11@users.noreply.github.com> Date: Tue, 1 Jun 2021 11:22:05 -0400 Subject: [PATCH] Fixed when some crops not displays the proper name (#1199) --- .../gamingmesh/jobs/CMILib/CMIMaterial.java | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java index 7c85907d..d0bb8538 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java @@ -1390,47 +1390,39 @@ public enum CMIMaterial { id = id.replaceAll("_| |minecraft:", "").toLowerCase(); - if (id.contains(":")) { - String[] split = id.split(":", 2); + String[] split = id.split(":", 2); + if (split.length > 1) { try { - Integer ids = Integer.parseInt(split[0]); - Integer data = Integer.parseInt(split[1]); + int ids = Integer.parseInt(split[0]); if (ids <= 0) return CMIMaterial.NONE; - return get(ids, data); - } catch (Exception ex) { + + return get(ids, Integer.parseInt(split[1])); + } catch (NumberFormatException ex) { } try { - Integer data = Integer.parseInt(split[1]); + int data = Integer.parseInt(split[1]); id = split[0]; + CMIMaterial mat = ItemManager.byName.get(id + ":" + data); - if (mat != null) { + if (mat != null && mat.getLegacyId() > 0 && (mat = get(mat.getLegacyId(), data)) != null) { return mat; } - CMIMaterial mat1 = ItemManager.byName.get(id); - if (mat1 != null && mat1.getLegacyId() > 0) { - mat = get(mat1.getLegacyId(), data); - if (mat != null) { - return mat; - } - } - } catch (Exception ex) { + } catch (NumberFormatException ex) { } } CMIMaterial mat = ItemManager.byName.get(id); - if (mat != null) { return mat; } try { - mat = ItemManager.byId.get(Integer.parseInt(id)); - if (mat != null) { + if ((mat = ItemManager.byId.get(Integer.parseInt(id))) != null) { return mat; } - } catch (Exception ex) { + } catch (NumberFormatException ex) { } return CMIMaterial.NONE; @@ -2765,4 +2757,4 @@ public enum CMIMaterial { public boolean isLegacy() { return legacy; } -} \ No newline at end of file +}