ChestShop-3/com/Acrobot/ChestShop/Commands/ItemInfo.java

35 lines
1.1 KiB
Java
Raw Normal View History

2011-05-29 13:25:25 +02:00
package com.Acrobot.ChestShop.Commands;
2011-06-09 22:54:01 +02:00
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
2011-05-29 13:25:25 +02:00
import com.Acrobot.ChestShop.Items.Items;
import org.bukkit.ChatColor;
2011-05-29 13:25:25 +02:00
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* @author Acrobot
*/
public class ItemInfo implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
ItemStack item;
2011-05-29 13:25:25 +02:00
if (args.length == 0) {
if (!(sender instanceof Player)) return false;
item = ((Player) sender).getItemInHand();
2011-05-29 13:25:25 +02:00
} else {
item = Items.getItemStack(args[0]);
}
2011-05-29 13:25:25 +02:00
if (item == null || item.getType() == Material.AIR) return false;
2011-05-29 13:25:25 +02:00
sender.sendMessage(Config.getLocal(Language.iteminfo));
sender.sendMessage(item.getTypeId() + (item.getDurability() != 0 ? " : " + item.getDurability() : "") + " - " + ChatColor.GRAY + item.getType().name());
return true;
2011-05-29 13:25:25 +02:00
}
}