mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-10 00:57:34 +01:00
Fix issues with metadata IDs
Also log more info when the code couldn't be generated and send it to the sender when the iteminfo command is used
This commit is contained in:
parent
51495cdefb
commit
dd44217132
@ -206,17 +206,19 @@ public class MaterialUtil {
|
||||
metaData = "#" + Metadata.getItemCode(itemStack);
|
||||
}
|
||||
|
||||
String code = data + itemName + durability + metaData;
|
||||
if (maxLength > 0 && code.length() > maxLength) {
|
||||
int exceeding = code.length() - maxLength;
|
||||
code = data + getShortenedName(itemName, itemName.length() - exceeding) + durability + metaData;
|
||||
int codeLength = (data + itemName + durability + metaData).length();
|
||||
String code = data + itemName;
|
||||
if (maxLength > 0 && codeLength > maxLength) {
|
||||
int exceeding = codeLength - maxLength;
|
||||
code = getShortenedName(code, code.length() - exceeding);
|
||||
}
|
||||
|
||||
code = StringUtil.capitalizeFirstLetter(code, '_');
|
||||
|
||||
|
||||
code = StringUtil.capitalizeFirstLetter(code, '_') + durability + metaData;
|
||||
|
||||
ItemStack codeItem = getItem(code);
|
||||
if (!equals(itemStack, codeItem)) {
|
||||
throw new IllegalArgumentException("Cannot generate code for item " + itemStack + " with maximum length of " + maxLength + "(tried code " + code);
|
||||
throw new IllegalArgumentException("Cannot generate code for item " + itemStack + " with maximum length of " + maxLength
|
||||
+ " (code " + code + " results in item " + codeItem + ")");
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -36,8 +36,17 @@ public class ItemInfo implements CommandExecutor {
|
||||
}
|
||||
|
||||
sender.sendMessage(Messages.prefix(iteminfo));
|
||||
sender.sendMessage(ChatColor.WHITE + "Full Name: " + ChatColor.GRAY + MaterialUtil.getName(item));
|
||||
sender.sendMessage(ChatColor.WHITE + "Shop Sign: " + ChatColor.GRAY + MaterialUtil.getSignName(item));
|
||||
try {
|
||||
sender.sendMessage(ChatColor.WHITE + "Full Name: " + ChatColor.GRAY + MaterialUtil.getName(item));
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Full Name Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
sender.sendMessage(ChatColor.WHITE + "Shop Sign: " + ChatColor.GRAY + MaterialUtil.getSignName(item));
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Shop Sign Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
ItemInfoEvent event = new ItemInfoEvent(sender, item);
|
||||
ChestShop.callEvent(event);
|
||||
|
Loading…
Reference in New Issue
Block a user