1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Fixed when some crops not displays the proper name (#1199)

This commit is contained in:
KingCreator11 2021-06-01 11:22:05 -04:00 committed by GitHub
parent 03effd2e13
commit 47f47bd3df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1390,47 +1390,39 @@ public enum CMIMaterial {
id = id.replaceAll("_| |minecraft:", "").toLowerCase(); id = id.replaceAll("_| |minecraft:", "").toLowerCase();
if (id.contains(":")) { String[] split = id.split(":", 2);
String[] split = id.split(":", 2); if (split.length > 1) {
try { try {
Integer ids = Integer.parseInt(split[0]); int ids = Integer.parseInt(split[0]);
Integer data = Integer.parseInt(split[1]);
if (ids <= 0) if (ids <= 0)
return CMIMaterial.NONE; return CMIMaterial.NONE;
return get(ids, data);
} catch (Exception ex) { return get(ids, Integer.parseInt(split[1]));
} catch (NumberFormatException ex) {
} }
try { try {
Integer data = Integer.parseInt(split[1]); int data = Integer.parseInt(split[1]);
id = split[0]; id = split[0];
CMIMaterial mat = ItemManager.byName.get(id + ":" + data); CMIMaterial mat = ItemManager.byName.get(id + ":" + data);
if (mat != null) { if (mat != null && mat.getLegacyId() > 0 && (mat = get(mat.getLegacyId(), data)) != null) {
return mat; return mat;
} }
CMIMaterial mat1 = ItemManager.byName.get(id); } catch (NumberFormatException ex) {
if (mat1 != null && mat1.getLegacyId() > 0) {
mat = get(mat1.getLegacyId(), data);
if (mat != null) {
return mat;
}
}
} catch (Exception ex) {
} }
} }
CMIMaterial mat = ItemManager.byName.get(id); CMIMaterial mat = ItemManager.byName.get(id);
if (mat != null) { if (mat != null) {
return mat; return mat;
} }
try { try {
mat = ItemManager.byId.get(Integer.parseInt(id)); if ((mat = ItemManager.byId.get(Integer.parseInt(id))) != null) {
if (mat != null) {
return mat; return mat;
} }
} catch (Exception ex) { } catch (NumberFormatException ex) {
} }
return CMIMaterial.NONE; return CMIMaterial.NONE;
@ -2765,4 +2757,4 @@ public enum CMIMaterial {
public boolean isLegacy() { public boolean isLegacy() {
return legacy; return legacy;
} }
} }