本文整理汇总了Java中org.bukkit.Material.DIAMOND_SWORD属性的典型用法代码示例。如果您正苦于以下问题:Java Material.DIAMOND_SWORD属性的具体用法?Java Material.DIAMOND_SWORD怎么用?Java Material.DIAMOND_SWORD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.DIAMOND_SWORD属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enchantsGUI
static void enchantsGUI(Player player){
enchantsGUI = Bukkit.createInventory(null, 9, ChatColor.DARK_GRAY + "Enchantments");
ItemStack meleeCategory = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta meleeMeta = meleeCategory.getItemMeta();
meleeMeta.setDisplayName(ChatColor.RED + "Melee Enchantments");
meleeCategory.setItemMeta(meleeMeta);
ItemStack bowCategory = new ItemStack(Material.BOW);
ItemMeta bowMeta = bowCategory.getItemMeta();
bowMeta.setDisplayName(ChatColor.RED + "Bow Enchantments");
bowCategory.setItemMeta(bowMeta);
ItemStack armorCategory = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemMeta armorMeta = armorCategory.getItemMeta();
armorMeta.setDisplayName(ChatColor.RED + "Armor Enchantments");
armorCategory.setItemMeta(armorMeta);
ItemStack filler = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
ItemMeta fillerMeta = filler.getItemMeta();
fillerMeta.setDisplayName(ChatColor.GRAY + "");
filler.setItemMeta(fillerMeta);
enchantsGUI.setItem(0, filler);
enchantsGUI.setItem(1, meleeCategory);
enchantsGUI.setItem(2, filler);
enchantsGUI.setItem(3, filler);
enchantsGUI.setItem(4, bowCategory);
enchantsGUI.setItem(5, filler);
enchantsGUI.setItem(6, filler);
enchantsGUI.setItem(7, armorCategory);
enchantsGUI.setItem(8, filler);
player.openInventory(enchantsGUI);
}
示例2: CustomItemTexture
public CustomItemTexture(int texture) {
item = new ItemStack(Material.DIAMOND_SWORD);
item.setDurability((short) 2);
ItemMeta im = item.getItemMeta();
im.setUnbreakable(true);
item.setItemMeta(im);
}
示例3: onCraftItem
@EventHandler(priority = EventPriority.HIGH)
public void onCraftItem(CraftItemEvent event)
{
if( event.getRecipe().getResult().getType() == Material.STONE_SWORD
|| event.getRecipe().getResult().getType() == Material.IRON_SWORD
|| event.getRecipe().getResult().getType() == Material.GOLD_SWORD
|| event.getRecipe().getResult().getType() == Material.DIAMOND_SWORD
|| event.getRecipe().getResult().getType() == Material.LEATHER_BOOTS
|| event.getRecipe().getResult().getType() == Material.LEATHER_LEGGINGS
|| event.getRecipe().getResult().getType() == Material.LEATHER_CHESTPLATE
|| event.getRecipe().getResult().getType() == Material.LEATHER_HELMET
|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_BOOTS
|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_LEGGINGS
|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_CHESTPLATE
|| event.getRecipe().getResult().getType() == Material.CHAINMAIL_HELMET
|| event.getRecipe().getResult().getType() == Material.GOLD_BOOTS
|| event.getRecipe().getResult().getType() == Material.GOLD_LEGGINGS
|| event.getRecipe().getResult().getType() == Material.GOLD_CHESTPLATE
|| event.getRecipe().getResult().getType() == Material.GOLD_HELMET
|| event.getRecipe().getResult().getType() == Material.IRON_BOOTS
|| event.getRecipe().getResult().getType() == Material.IRON_LEGGINGS
|| event.getRecipe().getResult().getType() == Material.IRON_CHESTPLATE
|| event.getRecipe().getResult().getType() == Material.IRON_HELMET
|| event.getRecipe().getResult().getType() == Material.DIAMOND_BOOTS
|| event.getRecipe().getResult().getType() == Material.DIAMOND_LEGGINGS
|| event.getRecipe().getResult().getType() == Material.DIAMOND_CHESTPLATE
|| event.getRecipe().getResult().getType() == Material.DIAMOND_HELMET)
{
if( event.getWhoClicked().getType() == EntityType.PLAYER )
{
Player p = (Player)event.getWhoClicked();
p.sendMessage("Sorry, you are not allowed to craft this item. Purchase it from a Safe Dock instead.");
}
event.setCancelled(false);
}
}
示例4: onCraftItem
private static void onCraftItem(Recipe recipe, CraftingInventory inventory)
{
if (recipe.getResult().getType() == Material.WOOD_SWORD
|| recipe.getResult().getType() == Material.STONE_SWORD
|| recipe.getResult().getType() == Material.IRON_SWORD
|| recipe.getResult().getType() == Material.GOLD_SWORD
|| recipe.getResult().getType() == Material.DIAMOND_SWORD)
inventory.setResult(new ItemStack(Material.AIR));
}
示例5: onInteract
@EventHandler
public void onInteract(PlayerInteractEvent e) {
final TOAUser u = TOA.getPlayer(e.getPlayer());
if (e.getItem() != null) {
Material m = e.getItem().getType();
if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
Ability.useAbility(u, e.getItem().getType());
e.setCancelled(true);
}
if (!u.isOnRank(PACmd.Grupo.Builder)) {
if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
|| e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
|| e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
|| e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
|| e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
|| e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
|| e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
|| e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
|| e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
|| e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
|| e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
e.setCancelled(true);
}
}
}
}
示例6: isTool
static boolean isTool(ItemStack item) {
if (item == null) return false;
final Material material = item.getType();
// shears
if (material == Material.SHEARS) return true;
// wood tools
if (material == Material.WOOD_SWORD || material == Material.WOOD_AXE || material == Material.WOOD_HOE || material == Material.WOOD_PICKAXE || material == Material.WOOD_SPADE) {
return true;
}
// stone tools
if (material == Material.STONE_SWORD || material == Material.STONE_AXE || material == Material.STONE_HOE || material == Material.STONE_PICKAXE || material == Material.STONE_SPADE) {
return true;
}
// iron tools
if (material == Material.IRON_SWORD || material == Material.IRON_AXE || material == Material.IRON_HOE || material == Material.IRON_PICKAXE || material == Material.IRON_SPADE) {
return true;
}
// gold tools
if (material == Material.GOLD_SWORD || material == Material.GOLD_AXE || material == Material.GOLD_HOE || material == Material.GOLD_PICKAXE || material == Material.GOLD_SPADE) {
return true;
}
// diamond tools
if (material == Material.DIAMOND_SWORD || material == Material.DIAMOND_AXE || material == Material.DIAMOND_HOE || material == Material.DIAMOND_PICKAXE || material == Material.DIAMOND_SPADE) {
return true;
}
return false;
}
示例7: execute
@Override
public boolean execute(CommandSender sender, String[] args) throws CommandException {
if (!(sender instanceof Player)) {
throw new CommandException("Only players can use this command!");
}
Player player = (Player) sender;
ItemStack goditem = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta goditemMeta = goditem.getItemMeta();
goditemMeta.setDisplayName(ChatColor.BLUE + "GOD ITEM!");
goditemMeta.addEnchant(Enchantment.DAMAGE_ALL, 1000, true);
goditemMeta.addEnchant(Enchantment.DURABILITY, 1000, true);
goditem.setItemMeta(goditemMeta);
if (args.length == 0) {
player.getInventory().addItem(goditem);
player.sendMessage(ChatColor.AQUA + "Receiving item...");
return true;
}
if (args.length == 1) {
boolean x = false;
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getName().equals(args[0])) {
x = true;
break;
}
}
if (!x) {
player.sendMessage(ChatColor.RED + "Could not find the specified player.");
return true;
}
Player target = Bukkit.getPlayer(args[0]);
target.getInventory().addItem(goditem);
target.sendMessage(ChatColor.AQUA + "Receiving item...");
return true;
}
player.sendMessage(ChatColor.RED + "/givegoditem [player]");
return true;
}
示例8: clearJunk
public void clearJunk(){
World world = Bukkit.getWorld("kaospvp");
List<Entity> list = world.getEntities();
for(Entity e : list){
if(e instanceof Item){
Item it = (Item) e;
if( it.getItemStack().getType() == Material.POTION &&
it.getItemStack().getDurability() == 16453){
e.remove();
}
if( it.getItemStack().getType() == Material.GOLDEN_APPLE &&
it.getItemStack().getDurability() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.ARROW){
e.remove();
}
if( it.getItemStack().getType() == Material.GLASS_BOTTLE){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_BOOTS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_LEGGINGS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_CHESTPLATE &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_HELMET &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_SWORD &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.BOW &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.WOOD_AXE ||
it.getItemStack().getType() == Material.STONE_AXE ||
it.getItemStack().getType() == Material.GOLD_AXE ||
it.getItemStack().getType() == Material.IRON_AXE ||
it.getItemStack().getType() == Material.DIAMOND_AXE){
e.remove();
}
}
}
}
示例9: giveTitaniumKit
private void giveTitaniumKit(Player player) {
if(player.hasPermission("riots.titanium")) {
if(cooldowns.containsKey(player.getUniqueId())) {
if(cooldowns.get(player.getUniqueId()).containsKey("TitaniumKit")) {
this.closeInventory(player);
player.sendMessage(ChatColor.RED + "You cannot receive this kit for " + ChatColor.BOLD + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("TitaniumKit"), true, true) + ChatColor.RED + "!");
} else {
cooldowns.put(player.getUniqueId(), (Map<String, Long>) new AbstractMap.SimpleEntry<String, Long>("TitanKit", day * 3));
ItemStack helm = new ItemStack(Material.DIAMOND_HELMET, 1);
ItemMeta helmMeta = helm.getItemMeta();
helmMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
helm.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
helm.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
helm.setItemMeta(helmMeta);
ItemStack cp = new ItemStack(Material.DIAMOND_CHESTPLATE, 1);
ItemMeta cpMeta = cp.getItemMeta();
cpMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
cp.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
cp.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
cp.setItemMeta(cpMeta);
ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
ItemMeta legsMeta = legs.getItemMeta();
legsMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
legs.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
legs.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
legs.setItemMeta(legsMeta);
ItemStack booties = new ItemStack(Material.DIAMOND_BOOTS, 1);
ItemMeta bootiesMeta = booties.getItemMeta();
bootiesMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
booties.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, protection);
booties.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
booties.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 4);
booties.setItemMeta(bootiesMeta);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
ItemMeta swordMeta = sword.getItemMeta();
sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, sharpness);
sword.addUnsafeEnchantment(Enchantment.DURABILITY, unbreaking);
swordMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4&lTitanium &7Kit"));
sword.setItemMeta(swordMeta);
ItemStack pearls = new ItemStack(Material.ENDER_PEARL, 16);
player.getInventory().addItem(helm);
player.getInventory().addItem(cp);
player.getInventory().addItem(legs);
player.getInventory().addItem(booties);
player.getInventory().addItem(sword);
player.getInventory().addItem(pearls);
player.updateInventory();
}
}
} else {
player.sendMessage(ChatColor.RED + "You do not have access to this kit! Purchase it at store.hcriots.net!");
}
}