From a527158cffee4c2bcdc78306e8366022cf03818b Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 29 Nov 2021 17:11:28 +0200 Subject: [PATCH] ItemInfo command update --- .../jobs/commands/list/blockinfo.java | 4 +- .../jobs/commands/list/iteminfo.java | 43 +++++++++++-------- .../jobs/config/LanguageManager.java | 7 +-- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/blockinfo.java b/src/main/java/com/gamingmesh/jobs/commands/list/blockinfo.java index 6037c1ba..f8ae03bf 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/blockinfo.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/blockinfo.java @@ -39,8 +39,8 @@ public class blockinfo implements Cmd { RawMessage rm = new RawMessage(); rm.addText(Jobs.getLanguage().getMessage("general.info.separator") + "\n"); - rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.material", "%blockname%", block.getType().name()) + "\n"); - rm.addSuggestion(block.getType().name()); + rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.material", "%blockname%", CMIMaterial.get(block).getName()) + "\n"); + rm.addSuggestion(CMIMaterial.get(block).getName()); if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) { rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getType().getId()) + "\n"); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/iteminfo.java b/src/main/java/com/gamingmesh/jobs/commands/list/iteminfo.java index ce36950f..0391a92d 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/iteminfo.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/iteminfo.java @@ -2,7 +2,6 @@ package com.gamingmesh.jobs.commands.list; import org.bukkit.Material; import org.bukkit.command.CommandSender; -import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -10,6 +9,8 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.commands.Cmd; import net.Zrips.CMILib.Items.CMIItemStack; +import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.Version.Version; public class iteminfo implements Cmd { @@ -32,32 +33,36 @@ public class iteminfo implements Cmd { if (iih == null || iih.getType() == Material.AIR) return true; - boolean tool = false; - if (EnchantmentTarget.TOOL.includes(iih) || - EnchantmentTarget.WEAPON.includes(iih) || - EnchantmentTarget.ARMOR.includes(iih) || - EnchantmentTarget.BOW.includes(iih) || - EnchantmentTarget.FISHING_ROD.includes(iih)) - tool = true; + CMIItemStack ci = new CMIItemStack(iih); byte data = (Version.isCurrentEqualOrHigher(Version.v1_13_R1) ? 0 : iih.getData().getData()); String dataString = data == 0 ? "" : "-" + data; - sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); - sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.name", "%itemname%", iih.getType().name())); - if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) - sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.id", "%itemid%", iih.getType().getId())); - if (!tool) - sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.data", "%itemdata%", data)); + RawMessage rm = new RawMessage(); + rm.addText(Jobs.getLanguage().getMessage("general.info.separator") + "\n"); + + rm.addText(Jobs.getLanguage().getMessage("command.iteminfo.output.material", "%itemname%", CMIMaterial.get(iih).getName()) + "\n"); + rm.addSuggestion(CMIMaterial.get(iih).getName()); + + if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) { + rm.addText(Jobs.getLanguage().getMessage("command.iteminfo.output.id", "%blockid%", iih.getType().getId()) + "\n"); + rm.addSuggestion(String.valueOf(iih.getType().getId())); + } + + if (ci.getMaxDurability() == 0 && Version.isCurrentEqualOrLower(Version.v1_13_R2)) { + rm.addText(Jobs.getLanguage().getMessage("command.iteminfo.output.data", "%itemdata%", data) + "\n"); + rm.addSuggestion(String.valueOf(data)); + } if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) - sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.usage", "%first%", "", - "%second%", iih.getType().name() + dataString)); + rm.addText(Jobs.getLanguage().getMessage("command.iteminfo.output.use", "%usage%", iih.getType().name() + dataString) + "\n"); else - sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.usage", "%first%", iih.getType().getId() + dataString, - "%second%", iih.getType().name() + dataString)); + rm.addText(Jobs.getLanguage().getMessage("command.iteminfo.output.deprecated", "%first%", iih.getType().getId() + dataString, "%second%", iih.getType().name() + dataString) + "\n"); + rm.addSuggestion(iih.getType().name() + dataString); + + rm.addText(Jobs.getLanguage().getMessage("general.info.separator")); + rm.show(sender); - sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 9f30c6d5..89e11009 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -271,7 +271,7 @@ public class LanguageManager { c.get("command.blockinfo.help.info", "Shows information for the block you are looking at."); c.get("command.blockinfo.help.args", ""); - c.get("command.blockinfo.output.material", " &eBlock material: &6%blockname%"); + c.get("command.blockinfo.output.material", " &eBlock name: &6%blockname%"); c.get("command.blockinfo.output.id", " &eBlock id: &6%blockid%"); c.get("command.blockinfo.output.state", " &eBlock sate: &6%blockdata%"); c.get("command.blockinfo.output.deprecated", " &eUsage: &6%first% &eor &6%second%"); @@ -279,10 +279,11 @@ public class LanguageManager { c.get("command.iteminfo.help.info", "Shows information for the item you are holding."); c.get("command.iteminfo.help.args", ""); - c.get("command.iteminfo.output.name", " &eItem name: &6%itemname%"); + c.get("command.iteminfo.output.material", " &eItem name: &6%itemname%"); c.get("command.iteminfo.output.id", " &eItem id: &6%itemid%"); c.get("command.iteminfo.output.data", " &eItem data: &6%itemdata%"); - c.get("command.iteminfo.output.usage", " &eUsage: &6%first% &eor &6%second%"); + c.get("command.iteminfo.output.deprecated", " &eUsage: &6%first% &eor &6%second%"); + c.get("command.iteminfo.output.use", " &eConfig file usage: &6%usage%"); c.get("command.placeholders.help.info", "List out all placeholders"); c.get("command.placeholders.help.args", "(parse) (placeholder)");