Skip to content

Commit

Permalink
[2.0.0-dev9]修复mod混合端无法获取mod物品的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Jan 14, 2024
1 parent b6b59ef commit 4d2b1e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import java.text.SimpleDateFormat
version = "2.0.0-dev8"
version = "2.0.0-dev9"

plugins {
`java-library`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,17 @@ public String matchItemName(ItemStack item, boolean ignoreAmount) {
* @return 物品
*/
public ItemStack matchVanillaItem(String itemKey, int amount) {
Material material = Material.matchMaterial(itemKey);
if (material == null)
String itemName;
String[] split = itemKey.split(":");
if (split.length < 2) {
itemName = itemKey;
} else {
itemName = split[1];
}
Material material = Material.matchMaterial(itemName);
if (material == null) {
throw new IllegalArgumentException("Can not found item " + itemKey);
}
return new ItemStack(material, amount);
}

Expand Down

0 comments on commit 4d2b1e3

Please sign in to comment.