mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-31 12:31:24 +01:00
new command to check item info for usage with plugin
This commit is contained in:
parent
7edb06d6d6
commit
f307a747b6
1
com/gamingmesh/jobs/commands/list/.gitignore
vendored
1
com/gamingmesh/jobs/commands/list/.gitignore
vendored
@ -53,3 +53,4 @@
|
||||
/bp$1.class
|
||||
/bp.class
|
||||
/entitylist.class
|
||||
/iteminfo.class
|
||||
|
56
com/gamingmesh/jobs/commands/list/iteminfo.java
Normal file
56
com/gamingmesh/jobs/commands/list/iteminfo.java
Normal file
@ -0,0 +1,56 @@
|
||||
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;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
|
||||
public class iteminfo implements Cmd {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
@JobCommand(1450)
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length != 0) {
|
||||
Jobs.getCommandManager().sendUsage(sender, "blockinfo");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
ItemStack iih = Jobs.getNms().getItemInMainHand(player);
|
||||
|
||||
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;
|
||||
|
||||
String dataString = iih.getData().getData() == 0 ? "" : "-" + iih.getData().getData();
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.name", "%itemname%", iih.getType().name()));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.id", "%itemid%", iih.getTypeId()));
|
||||
if (!tool)
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.data", "%itemdata%", iih.getData().getData()));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.iteminfo.output.usage", "%first%", iih.getTypeId() + dataString,
|
||||
"%second%", iih.getType().name() + dataString));
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -166,6 +166,14 @@ public class LanguageManager {
|
||||
c.get("command.blockinfo.output.data", " &eBlock data: &6%blockdata%");
|
||||
c.get("command.blockinfo.output.usage", " &eUsage: &6%first% &eor &6%second%");
|
||||
|
||||
|
||||
c.get("command.iteminfo.help.info", "Shows item information you holding.");
|
||||
c.get("command.iteminfo.help.args", "");
|
||||
c.get("command.iteminfo.output.name", " &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.entitylist.help.info", "Shows all possible entities can be used with plugin.");
|
||||
c.get("command.entitylist.help.args", "");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user