mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-26 18:07:35 +01:00
d6bdb0486a
- Formatting - Warning about old Bukkit version - Renamed "TOWNY_CANNOT_CREATE_SHOP_HERE" to "CANNOT_CREATE_SHOP_HERE" to avoid confusion - Renamed "NOT_ENOUGH_LWC_PROTECTIONS" to "NOT_ENOUGH_PROTECTIONS" and changed its message - Fixed armour enchantments - Logging shop location - Fixed Heroes for the newest version - Removed redutant plugin object - Added dev-url for CraftBukkitUpToDate - Removed redutant plugins from softdepend - Fixed a bug when the player interacts with a shop with a sign in hand
67 lines
2.4 KiB
Java
67 lines
2.4 KiB
Java
package com.Acrobot.ChestShop.Commands;
|
|
|
|
import com.Acrobot.ChestShop.Config.Config;
|
|
import com.Acrobot.ChestShop.Config.Language;
|
|
import com.Acrobot.ChestShop.Items.Items;
|
|
import com.Acrobot.ChestShop.Utils.uEnchantment;
|
|
import com.Acrobot.ChestShop.Utils.uSign;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.enchantments.Enchantment;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
public class ItemInfo implements CommandExecutor {
|
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
|
ItemStack item;
|
|
if (args.length == 0) {
|
|
if (!(sender instanceof Player)) return false;
|
|
item = ((Player) sender).getItemInHand();
|
|
} else {
|
|
item = Items.getItemStack(joinArray(args));
|
|
}
|
|
|
|
if (item == null || item.getType() == Material.AIR) return false;
|
|
|
|
String durability = (item.getDurability() != 0 ? ChatColor.DARK_GREEN + ":" + item.getDurability() : "");
|
|
String ench = uEnchantment.getEnchantment(item);
|
|
String enchantment = (ench != null ? ChatColor.DARK_AQUA + "-" + ench : "");
|
|
|
|
sender.sendMessage(Config.getLocal(Language.iteminfo));
|
|
String itemname = Items.getName(item);
|
|
sender.sendMessage(ChatColor.GRAY + itemname + ChatColor.WHITE + " "
|
|
+ item.getTypeId() + durability + enchantment + ChatColor.WHITE);
|
|
|
|
Map<Enchantment, Integer> map = item.getEnchantments();
|
|
for (Map.Entry<Enchantment, Integer> e : map.entrySet())
|
|
sender.sendMessage(ChatColor.DARK_GRAY + uSign.capitalizeFirst(e.getKey().getName()) + ' ' + intToRoman(e.getValue()));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
private static String intToRoman(int integer) {
|
|
if (integer == 1) return "I";
|
|
if (integer == 2) return "II";
|
|
if (integer == 3) return "III";
|
|
if (integer == 4) return "IV";
|
|
if (integer == 5) return "V";
|
|
return Integer.toString(integer);
|
|
}
|
|
|
|
|
|
private static String joinArray(String[] array) {
|
|
StringBuilder b = new StringBuilder(array.length);
|
|
for (String s : array) b.append(s).append(' ');
|
|
return b.toString();
|
|
}
|
|
}
|