Java 类org.bukkit.inventory.ItemStack 实例源码

项目:EpicBanRequests    文件:GUIManager.java   
public static Inventory mainMenu() {
    Inventory i = Bukkit.createInventory(null, 54, Messager.color("&bMain Menu"));


    ItemStack pending = new ItemStack(Material.BARRIER);
    ItemMeta pendingMeta = pending.getItemMeta();
    pendingMeta.setDisplayName(Messager.color("&cCurrent Ban Requests"));
    pendingMeta.setLore(Arrays.asList(Messager.color("&7Pending: " + Main.getPendingRequests())));
    pending.setItemMeta(pendingMeta);

    i.setItem(20, pending);

    // Remove the archived ones for now.

    /**
    ItemStack archive = new ItemStack(Material.CHEST);
    ItemMeta archiveMeta = archive.getItemMeta();
    archiveMeta.setDisplayName(Messager.color("&7Archived Requests"));
    archive.setItemMeta(archiveMeta);

    i.setItem(24, archive);
    **/

    return i;
}
项目:RPGInventory    文件:BackpackManager.java   
public static boolean playerCanTakeBackpack(Player player) {
    if (BACKPACK_LIMIT == 0) {
        return true;
    }

    // Check vanilla inventory
    Inventory inventory = player.getInventory();

    int count = 0;
    for (ItemStack item : inventory.getContents()) {
        if (isBackpack(item)) {
            count++;
        }
    }

    // Check RPGInventory slots
    inventory = InventoryManager.get(player).getInventory();
    Slot backpackSlot = SlotManager.instance().getBackpackSlot();
    if (BackpackManager.isBackpack(inventory.getItem(backpackSlot.getSlotId())) && !backpackSlot.isQuick()) {
        count++;
    }

    return count < BACKPACK_LIMIT;
}
项目:HCFCore    文件:BardClass.java   
@Override
public boolean isApplicableFor(Player player) {
    ItemStack helmet = player.getInventory().getHelmet();
    if (helmet == null || helmet.getType() != Material.GOLD_HELMET)
        return false;

    ItemStack chestplate = player.getInventory().getChestplate();
    if (chestplate == null || chestplate.getType() != Material.GOLD_CHESTPLATE)
        return false;

    ItemStack leggings = player.getInventory().getLeggings();
    if (leggings == null || leggings.getType() != Material.GOLD_LEGGINGS)
        return false;

    ItemStack boots = player.getInventory().getBoots();
    return !(boots == null || boots.getType() != Material.GOLD_BOOTS);
}
项目:BedwarsXP    文件:XPItemShop.java   
private boolean hasEnoughRessource(Player player, VillagerTrade trade) {
    if (trade instanceof XPVillagerTrade) {
        return XPManager.hasEnoughXP(bedwars.getName(), player,
                ((XPVillagerTrade) trade).getXP());
    } else {
        ItemStack item1 = trade.getItem1();
        ItemStack item2 = trade.getItem2();
        PlayerInventory inventory = player.getInventory();

        if (item2 != null) {
            if ((!inventory.contains(item1.getType(), item1.getAmount()))
                    || (!inventory.contains(item2.getType(),
                            item2.getAmount()))) {
                return false;
            }
        } else if (!inventory.contains(item1.getType(), item1.getAmount())) {
            return false;
        }

        return true;
    }
}
项目:ProjectAres    文件:KillRewardModule.java   
public static KillRewardModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    ImmutableList.Builder<KillReward> rewards = ImmutableList.builder();
    final ItemParser itemParser = context.needModule(ItemParser.class);
    final Optional<ItemModifyModule> itemModifier = context.module(ItemModifyModule.class);

    // Must allow top-level children for legacy support
    for(Element elKillReward : XMLUtils.flattenElements(doc.getRootElement(), ImmutableSet.of("kill-rewards"), ImmutableSet.of("kill-reward", "killreward"), 0)) {
        ImmutableList.Builder<ItemStack> items = ImmutableList.builder();
        for(Element itemEl : elKillReward.getChildren("item")) {
            final ItemStack item = itemParser.parseItem(itemEl, false);
            itemModifier.ifPresent(imm -> imm.applyRules(item));
            items.add(item.immutableCopy());
        }
        Filter filter = context.needModule(FilterParser.class).property(elKillReward, "filter").optional(StaticFilter.ALLOW);
        Kit kit = context.needModule(KitParser.class).property(elKillReward, "kit").optional(KitNode.EMPTY);

        rewards.add(new KillReward(items.build(), filter, kit));
    }

    ImmutableList<KillReward> list = rewards.build();
    if(list.isEmpty()) {
        return null;
    } else {
        return new KillRewardModule(list);
    }
}
项目:SurvivalAPI    文件:PuppyPowerModule.java   
/**
 * Give 64 bones, 64 rotten flesh and 64 wolf eggs to all the players
 *
 * @param game Game
 */
@Override
public void onGameStart(SurvivalGame game)
{
    ItemStack eggs = MojangShitUtils.getMonsterEgg(EntityType.WOLF);
    eggs.setAmount((int) this.moduleConfiguration.get("eggs"));

    for (GamePlayer player : (Collection<GamePlayer>) game.getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            continue;

        p.getInventory().addItem(new ItemStack(Material.BONE, (int) this.moduleConfiguration.get("bones")));
        p.getInventory().addItem(new ItemStack(Material.ROTTEN_FLESH, (int) this.moduleConfiguration.get("rotten-flesh")));
        p.getInventory().addItem(eggs);
    }
}
项目:AddGun    文件:StandardGun.java   
/**
 * Checks if the proferred item is a gun.
 * 
 * @param toCheck the item to check if this gun
 * @return true if gun, false otherwise
 */
@Override   
public boolean isGun(ItemStack toCheck) {
    if (!enabled || toCheck == null)
        return false;

    if (!gunExample.getType().equals(toCheck.getType()))
        return false;

    if (!toCheck.hasItemMeta())
        return false;

    ItemMeta meta = toCheck.getItemMeta();

    if (meta.hasLore() && meta.getLore().contains(tag))
        return true;

    return false;
}
项目:ZorahPractice    文件:MatchListener.java   
@EventHandler
public void onDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() != PlayerStatus.PLAYING) {
        return;
    }

    player.spigot().respawn();

    IMatch match = profile.getCurrentMatch();
    match.handleDeath(player, player.getLocation(), ChatColor.RED + player.getName() + ChatColor.GRAY + " has been slain.");

    event.setDeathMessage(null);
    player.setHealth(20.0);

    for (ItemStack i : event.getDrops()) {
        i.setType(Material.AIR);
    }
}
项目:QuarSK    文件:SExprItemEffectTypeAmplifier.java   
@Nullable
@Override
protected Number[] get(Event e) {
    ItemStack i = item.getSingle(e);
    if (i == null) {
        return null;
    }
    if (PotionUtils.isPotionItem(i)) {
        PotionMeta meta = (PotionMeta) i.getItemMeta();
        PotionEffect eff = PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e));
        if (eff == null) {
            return null;
        }
        return new Number[]{eff.getAmplifier()};
    }
    return null;
}
项目:AsgardAscension    文件:Tribe.java   
public ItemStack[] loadContent() {
    TribeFile.createConfig(getName());
    if(TribeFile.getChest() != null) {
        List<?> list = TribeFile.getChest();
        ItemStack[] turinys = new ItemStack[list.size()];
            for (int i = 0; i < list.size(); i++) {
                Object o = list.get(i);
                if (o instanceof ItemStack) {
                    turinys[i] = (ItemStack) o;
                } else {
                    turinys[i] = new ItemStack(Material.AIR);
                }
            }
        return turinys;
    }
    return new ItemStack[0];
}
项目:RPGInventory    文件:InventoryManager.java   
public static void syncInfoSlots(PlayerWrapper playerWrapper) {
    final Player player = (Player) playerWrapper.getPlayer();
    for (Slot infoSlot : SlotManager.instance().getInfoSlots()) {
        ItemStack cup = infoSlot.getCup();
        ItemMeta meta = cup.getItemMeta();
        List<String> lore = meta.getLore();

        for (int i = 0; i < lore.size(); i++) {
            String line = lore.get(i);
            lore.set(i, StringUtils.setPlaceholders(player, line));
        }

        meta.setLore(lore);
        cup.setItemMeta(meta);
        playerWrapper.getInventory().setItem(infoSlot.getSlotId(), cup);
    }

    player.updateInventory();
}
项目:MCLibrary    文件:PageGUI.java   
private void setLayout(Inventory inv) {
    String title = getData().title();
    int size = getData().size();
    int lastLineFirstIndex = size - 9;
    ItemStack wall = new ItemBuilder(Material.STAINED_GLASS)
            .display("")
            .build();
    for (int i = 0; i < 9; i++) {
        inv.setItem(i, wall);
    }
    for (int i = lastLineFirstIndex; i < size; i++) {
        inv.setItem(i, wall);
    }

    inv.setItem(4, new ItemBuilder(Material.NETHER_STAR).display(title).build());
    inv.setItem(prevPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
    inv.setItem(nextPageBtnIndex, new ItemBuilder(Material.WOOD_BUTTON).build());
}
项目:WC    文件:StaticCrate.java   
@Override
public ArrayList<ItemStack> contains(){
    ArrayList<ItemStack> items = new ArrayList<>();

    switch (getCrateType()){
        case NORMAL:
            items.add(new ItemMaker(Material.APPLE).setDisplayName("An apple a day keeps the doctor away").setAmount(7).build());
            items.add(new ItemMaker(Material.BOAT).build());
            items.add(new ItemMaker(Material.IRON_BLOCK).build());
            break;
        case EPICA:

            break;
        case LEGENDARIA:

            break;
    }
    return items;
}
项目:WC    文件:LobbySelector.java   
public LobbySelector(WCLobby instance){
    gameSelector = iu.createInventory(9, "&cServidores");

    ItemStack glass = ItemUtils.coloredBlock(DyeColor.ORANGE, "&cWorld&8Crafteros", ItemUtils.ColoredBlock.FLAT_GLASS);

    //Glass
    for (int x = 1; x < 8; x++){
        gameSelector = iu.setItem(gameSelector, x + 9, glass);
        gameSelector = iu.setItem(gameSelector, x + (9 * 4), glass);
    }
    gameSelector = iu.setItem(gameSelector, 18, glass);
    gameSelector = iu.setItem(gameSelector, 27, glass);
    gameSelector = iu.setItem(gameSelector, 26, glass);
    gameSelector = iu.setItem(gameSelector, 35, glass);
    //



}
项目:NineSlots    文件:ClickListener.java   
@EventHandler
public void on(PlayerDropItemEvent event) {
    ItemStack item = event.getItemDrop().getItemStack();

    if (item == null) {
        return;
    }

    if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
        return;
    }

    String name = item.getItemMeta().getDisplayName();

    if (name.equals("§4§lBlocked Slot")) {
        event.setCancelled(true);
    }
}
项目:Kineticraft    文件:ArmorStands.java   
public ArmorPose(ArmorStand a) {
    this(a.getHeadPose(), a.getBodyPose(), a.getLeftArmPose(), a.getRightArmPose(), a.getLeftLegPose(), a.getRightLegPose(), new JsonMap<>());
    for (EquipmentSlot slot : EquipmentSlot.values()) { // Save gear.
        ItemStack i = Utils.getItem(a, slot);
        if (!Utils.isAir(i))
            getGear().put(slot.name(), i);
    }
}
项目:QuarSK    文件:SExprItemLayers.java   
@Nullable
@Override
protected Pattern[] get(Event e) {
    ItemStack i = item.getSingle(e);
    if (i == null) {
        return null;
    }
    if (i.getType() == Material.BANNER || i.getType() == Material.SHIELD) {
        return ((BannerMeta) i.getItemMeta()).getPatterns().stream().toArray(Pattern[]::new);
    }
    return null;
}
项目:AsgardAscension    文件:RuneManager.java   
public void start(Player player, Rune rune) {
    startEffect(player, rune);
    setActiveRune(player, rune);
    switch(rune.getName()) {
        case "Freeze":
            handleFreeze(player, rune);
            return;
        case "Fire Storm":
            handleFireStorm(player, rune);
            break;
        case "Slowdown":
            handleSlowdown(player, rune);
            break;
        case "Invisibility":
            handleInvisibility(player, rune);
            break;
        case "Lightning":
            handleLightning(player, rune);
            break;
        case "Detonate":
            handleDetonate(player, rune);
            break;
        default:
            return;
    }
    player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
    player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_APPLY.toString()
        .replaceAll("%s", rune.getName()));
}
项目:RealSurvival    文件:FireCraftTableRecipe.java   
public FireCraftTableRecipe(int time, double temperature, int maxTime, String name, List<String> shape,
        HashMap<Character, ItemStack> materials, ItemStack[] product) {
    super();
    this.time = time;
    this.temperature = temperature;
    this.maxTime = maxTime;
    this.name = name;
    this.shape = shape;
    this.materials = materials;
    this.product = product;
}
项目:RPGInventory    文件:InventorySerializer.java   
static void savePlayer(PlayerWrapper playerWrapper, Path file) throws IOException {
    List<NbtCompound> slotList = new ArrayList<>();
    try (DataOutputStream dataOutput = new DataOutputStream(new GZIPOutputStream(Files.newOutputStream(file)))) {
        for (Slot slot : SlotManager.instance().getSlots()) {
            if (slot.getSlotType() == Slot.SlotType.ARMOR) {
                continue;
            }

            List<NbtCompound> itemList = new ArrayList<>();
            List<Integer> slotIds = slot.getSlotIds();
            Inventory inventory = playerWrapper.getInventory();
            for (int i = 0; i < slotIds.size(); i++) {
                int slotId = slotIds.get(i);
                ItemStack itemStack = inventory.getItem(slotId);
                if (!ItemUtils.isEmpty(itemStack) && !slot.isCup(itemStack)) {
                    itemList.add(ItemUtils.itemStackToNBT(itemStack, i + ""));
                }
            }

            if (itemList.size() > 0 || playerWrapper.isBuyedSlot(slot.getName())) {
                NbtCompound slotNbt = NbtFactory.ofCompound(slot.getName());
                slotNbt.put("type", slot.getSlotType().name());
                if (playerWrapper.isBuyedSlot(slot.getName())) {
                    slotNbt.put("buyed", "true");
                }
                slotNbt.put(NbtFactory.ofCompound("items", itemList));
                slotList.add(slotNbt);
            }
        }

        NbtCompound playerNbt = NbtFactory.ofCompound("Inventory");
        playerNbt.put(NbtFactory.ofCompound("slots", slotList));
        playerNbt.put("buyed-slots", playerWrapper.getBuyedGenericSlots());

        NbtBinarySerializer.DEFAULT.serialize(playerNbt, dataOutput);
    }
}
项目:Kineticraft    文件:Punishments.java   
/**
 * Create an item to represent this punishment
 * @return item
 */
public ItemStack getItem() {
    return ItemManager.createItem(isValid() ? getType().getIcon() : Material.BARRIER, getType().getDisplay(),
            "Source: " + ChatColor.WHITE + getSource(),
            "Date: " + ChatColor.WHITE + new Date(timestamp).toString(),
            "Click here to " + (isValid() ? "in" : "") + "validate this punishment.");
}
项目:Slimefun4-Chinese-Version    文件:ItemRequest.java   
public ItemRequest(Location terminal, int slot, ItemStack item, ItemTransportFlow flow)
{
    this.terminal = terminal;
    this.item = item;
    this.slot = slot;
    this.flow = flow;
}
项目:HCFCore    文件:ModeratorMode.java   
public static void loadInventory(Player p)
{
  p.getInventory().clear();
  p.getInventory().setContents((ItemStack[])inventoryContents.get(p.getName()));
  p.getInventory().setArmorContents((ItemStack[])armorContents.get(p.getName()));
  p.setLevel(((Integer)xplevel.get(p.getName())).intValue());

  inventoryContents.remove(p.getName());
  armorContents.remove(p.getName());
  xplevel.remove(p.getName());
}
项目:Arcadia-Spigot    文件:GameVotingRunnable.java   
public GameVotingRunnable() {
    this.api = Arcadia.getPlugin(Arcadia.class).getAPI();
    api.getGameManager().getMainBossBar().setColor(BarColor.YELLOW);
    List<Class<? extends BaseGame>> temp = api.getGameRegistry().getRegisteredGames();
    List<String> allowedGames = api.getPlugin().mainConfiguration.fetch().getStringList("games-in-voting");
    Iterator<Class<? extends BaseGame>> iterator = temp.iterator();
    while(iterator.hasNext()) {
        Class<? extends BaseGame> next = iterator.next();
        if(!allowedGames.contains(next.getName())) iterator.remove();
    }
    Collections.shuffle(temp);
    int slot = 2;
    for(int i=0; i<5; i++) {
        if(i < temp.size()) {
            slots.put(slot, temp.get(i));
            slot++;
        }
    }
    Bukkit.getOnlinePlayers().forEach(player -> {
        for(int i=0; i<9; i++) {
            Utils.setSpacer(player, i);
        }
        int s = 2;
        for(Class<? extends BaseGame> key : slots.values()) {
            final VotingData votingData = api.getGameRegistry().getVotingData(key);
            ItemStack itemStack = new ItemStack(votingData.getMaterialData().getItemType(), 1,
                votingData.getMaterialData().getData());
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&b&l" + votingData.getGameName()));
            itemStack.setItemMeta(itemMeta);
            player.getInventory().setItem(s, itemStack);
            s++;
        }
    });
    api.getPlugin().getServer().getPluginManager().registerEvents(this, api.getPlugin());
    this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 20L);
}
项目:HNRPG    文件:Lore.java   
public void addLore(int ID, int DATA, int STACK, List<String> Lore, CommandSender sender) {
    try {
        Integer.parseInt(String.valueOf(tempStr));

        ItemStack itemStack = new MaterialData(ID, (byte) DATA).toItemStack(STACK);
        ItemMeta itemMeta = itemStack.getItemMeta();

        itemMeta.setLore(Lore);

    } catch (NumberFormatException e) {
        sender.sendMessage("§c[ §4§l! §c] §3§l줄 수§7를 입력해주세요.");
        return;
    }
}
项目:SurvivalAPI    文件:PopeyeModule.java   
/**
 * Give strength on spinash use
 * @param event Event
 */
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
    if (event.getItem() != null && event.getItem().isSimilar(this.spinash))
    {
        event.getPlayer().addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(this.bonusTime * 20, 1));
        event.getPlayer().setItemInHand(new ItemStack(Material.AIR));
        event.setCancelled(true);
    }
}
项目:Slimefun4-Chinese-Version    文件:BackpackListener.java   
public void onItemDrop(PlayerDropItemEvent e)
{
    if(Variables.backpack.containsKey(e.getPlayer().getUniqueId()))
    {
        ItemStack item = e.getItemDrop().getItemStack();
        SlimefunItem sfItem = SlimefunItem.getByItem(item);
        if(sfItem instanceof SlimefunBackpack)
            e.setCancelled(true);
    }
}
项目:RPGInventory    文件:MyPetManager.java   
@EventHandler
public void onMyPetItemUse(PlayerInteractEvent event) {
    if (event.getItem() != null) {
        Player player = event.getPlayer();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Inventory inventory = InventoryManager.get(player).getInventory();

        if (isMyPetItem(event.getItem())
                && (event.getAction() == Action.RIGHT_CLICK_BLOCK
                || event.getAction() == Action.RIGHT_CLICK_AIR)) {
            Slot petSlot = getMyPetSlot();

            ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
            boolean hasPet = !petSlot.isCup(currentPet);
            ItemStack newPet = event.getItem();

            if (!hasPet) {
                currentPet = null;
            }

            player.getEquipment().setItemInMainHand(currentPet);
            inventory.setItem(petSlot.getSlotId(), newPet);

            swapMyPets(player, hasPet, newPet);
        }
    }
}
项目:RealSurvival    文件:CraftItemGUI.java   
public static Inventory resetSF(ItemStack itemKey){
    WorkbenchRecipe sf=rs.getSF(itemKey.getItemMeta().getDisplayName().split(":")[0]);
    Inventory inv=createDefaultGUI(rs.getWorkbenchItems()[7]+"*");
    inv.setItem(0, itemKey);
    inv.setItem(49, Items.createPItem((short) 14, "��b��l==>��c��l�����b��l<=="));
    return sf.setInv(inv);
}
项目:AsgardAscension    文件:PlayerListener.java   
public PlayerListener(Main plugin) {
    diamondMiner = new HashMap<String, Boolean>();
    speedMiner = new HashMap<String, ItemStack>();
    rainbowMiner = new HashMap<String, ItemStack>();
    randomGen = new Random();
    this.plugin = plugin;
}
项目:CaulCrafting    文件:CraftStorage.java   
@SuppressWarnings("unchecked")
public ArrayList<CraftArray> getCrafts(){
    ArrayList<CraftArray> craftlist = new ArrayList<CraftArray>();
    try {
        File craftfile = new File(plugin.getDataFolder(), "crafts.yml");
        craftfile.createNewFile();
        FileConfiguration craftconfig = YamlConfiguration.loadConfiguration(craftfile);
        if(craftconfig.isSet("Crafts")) {
            for(String craftpath : craftconfig.getConfigurationSection("Crafts").getKeys(false)) {
                craftpath = "Crafts." + craftpath;
                ArrayList<ItemStack> config_craft = (ArrayList<ItemStack>) craftconfig.getList(craftpath + ".craft");
                ArrayList<ItemStack> config_resultitems = (ArrayList<ItemStack>) craftconfig.getList(craftpath + ".result.items");
                ArrayList<Integer> config_resultprobs = (ArrayList<Integer>) craftconfig.getIntegerList(craftpath + ".result.probs");
                HashMap<ItemStack,Integer> config_result = new HashMap<ItemStack, Integer>();
                for(ItemStack resultitem : config_resultitems) {
                    config_result.put(resultitem, config_resultprobs.get(config_resultitems.indexOf(resultitem)));
                }
                ArrayList<String> config_cmds = (ArrayList<String>) craftconfig.getStringList(craftpath + ".cmds");
                boolean config_redstonepower = craftconfig.getBoolean(craftpath + ".redstonepower");
                int config_experience = craftconfig.getInt(craftpath + ".experience");
                CraftArray specraft = new CraftArray(config_craft, config_result, config_cmds, config_redstonepower, config_experience);
                craftlist.add(specraft);
            }
            return craftlist;
        } else {
            return craftlist;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return craftlist;
    }
   }
项目:black    文件:BasicElement.java   
private ItemStack encrypted(ItemStack itemStack, String textToEncrypt) {
    final ItemMeta itemMeta = itemStack.getItemMeta();
    final List<String> lore = itemMeta.getLore() != null
        ? itemMeta.getLore()
        : new ArrayList<String>();
    lore.add(encrypted(textToEncrypt));
    itemMeta.setLore(lore);

    final ItemStack encryptedItemStack = itemStack.clone();
    encryptedItemStack.setItemMeta(itemMeta);
    return encryptedItemStack;
}
项目:Kineticraft    文件:PacketUtil.java   
/**
 * Force open a book for the given player.
 * @param player
 * @param book
 */
public static void openBook(Player player, ItemStack book) {
    ItemStack saved = player.getEquipment().getItemInMainHand();
    player.getEquipment().setItemInMainHand(book); // Change hand item to book.

    PacketDataSerializer pds = new PacketDataSerializer(Unpooled.buffer());
    pds.a(EnumHand.MAIN_HAND);
    sendPacket(player, new PacketPlayOutCustomPayload("MC|BOpen", pds));

    player.getEquipment().setItemInMainHand(saved); // Restore hand item.
}
项目:SurvivalPlus    文件:WaterBowl.java   
@EventHandler
public void onDrop(ItemSpawnEvent event)
{
    if(event.isCancelled()) return;
    final Item itemDrop = event.getEntity();
    if(itemDrop.getItemStack().getType() == Material.BOWL)
    {
        final Runnable task = new Runnable()
        {
            public void run()
            {
                if(itemDrop.getItemStack().getAmount() != 1) return;
                Location itemLocation = itemDrop.getLocation();
                if(itemLocation.getBlock().getType() == Material.WATER || itemLocation.getBlock().getType() == Material.STATIONARY_WATER)
                {
                    itemDrop.remove();

                    ItemStack i_beetroot = new ItemStack(Material.BEETROOT_SOUP, 1);
                    ItemMeta beetrootMeta= i_beetroot.getItemMeta();
                    beetrootMeta.setDisplayName(ChatColor.RESET + Survival.instance.Words.get("Water Bowl"));
                    i_beetroot.setItemMeta(beetrootMeta);

                    itemDrop.getWorld().dropItem(itemLocation, i_beetroot);
                }
            }
        };

        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, task, 20L);
    }
}
项目:OnlineChecker-Spigot-SQL-Support    文件:UtilItem.java   
public static ItemStack rename(ItemStack i, String name) {

    ItemMeta meta = i.getItemMeta();
    meta.setDisplayName(name);
    i.setItemMeta(meta);
    return i;
}
项目:RPGInventory    文件:PetManager.java   
public static ItemStack toPetItem(ItemStack item) {
    List<String> itemLore = item.getItemMeta().getLore();
    for (PetType petType : PETS.values()) {
        List<String> petItemLore = petType.getSpawnItem().getItemMeta().getLore();
        if (itemLore.equals(petItemLore)) {
            return petType.getSpawnItem();
        }
    }

    return item;
}
项目:SaveableSerializing    文件:ItemStacks.java   
public ItemStacks(ItemStack sta){
    meta = new DefaultMeta(sta.getItemMeta());
    id = sta.getTypeId();
    durability = sta.getDurability();
    amount = sta.getAmount();
    array = new EnchantArray(sta);

}
项目:MystiCraft    文件:CasterCommands.java   
@Command(label = "bind", description = "Binds a spell to a wand in your hand", usage = "/bind <spell> <left|right>")
@Arguments(args = { @Argument(label = "spell", type = ArgumentType.STRING, required = true),
        @Argument(label = "hand", type = ArgumentType.OPTION, required = true, options = { "left", "right" }) })
public static boolean bindSpellCommand(CommandContext ctx) {
    if (!ctx.isPlayer()) {
        ctx.getSender().sendMessage(ChatColor.RED + "Only in-game players can bind spells");
        return true;
    }
    String spell = ctx.getParamater("spell").toString().toLowerCase();
    Caster caster = MystiCraft.getCasterManager().getCaster(ctx.getPlayer());
    if (MystiCraft.getSpellManager().getSpell(spell) != null && caster.getKnowledge().isSpellKnown(spell)) {
        ItemStack item = null;
        Wand wand = null;
        if (ctx.getParamater("hand").equals("right")) {
            item = ctx.getPlayer().getInventory().getItemInMainHand();
        } else if (ctx.getParamater("hand").equals("left")) {
            item = ctx.getPlayer().getInventory().getItemInOffHand();
        }
        if ((wand = MystiCraft.getWandManager().getWand(item)) != null) {
            wand.bind(item, spell);
        } else {
            ctx.getPlayer().sendMessage(ChatColor.RED + "The item in your " + ctx.getParamater("hand") + " hand is not a wand");
        }
    } else {
        ctx.getPlayer().sendMessage(ChatColor.RED + "You do not know " + spell);
    }
    return true;
}
项目:Transport-Pipes    文件:VanillaPipeUDModel.java   
private List<ArmorStandData> createIceASD() {
    List<ArmorStandData> asds = new ArrayList<>();
    ItemStack block = ITEM_ICE_BLOCK;

    asds.add(new ArmorStandData(new RelLoc(0.05f + 1.3f, -1.3f, 0.5f - 0.25f), new Vector(1, 0, 1), false, null, ITEM_BLAZE, new Vector(0f, 0f, 0f), new Vector(-10f, 90f, 90f)));
    asds.add(new ArmorStandData(new RelLoc(0.05f + 0.8f, -1.3f, 0.5f - 0.75f), new Vector(1, 0, 1), false, null, ITEM_BLAZE, new Vector(0f, 0f, 0f), new Vector(-10f, 90f, 90f)));
    asds.add(new ArmorStandData(new RelLoc(0.05f + 1.2f, -1.3f, 0.5f + 0.4f), new Vector(-1, 0, 1), false, null, ITEM_BLAZE, new Vector(0f, 0f, 0f), new Vector(-10f, 90f, 90f)));
    asds.add(new ArmorStandData(new RelLoc(0.05f + 0.74f, -1.3f, 0.5f + 0.84f), new Vector(-1, 0, 1), false, null, ITEM_BLAZE, new Vector(0f, 0f, 0f), new Vector(-10f, 90f, 90f)));
    asds.add(new ArmorStandData(new RelLoc(0.5f, -0.675f, 0.5f), new Vector(1, 0, 0), true, block, null, new Vector(0f, 0f, 0f), new Vector(0f, 0f, 0f)));
    asds.add(new ArmorStandData(new RelLoc(0.5f, -0.175f, 0.5f), new Vector(1, 0, 0), true, block, null, new Vector(0f, 0f, 0f), new Vector(0f, 0f, 0f)));

    return asds;

}
项目:AsgardAscension    文件:RuneListener.java   
@EventHandler
public void onRuneUse(PlayerInteractEvent event) {
    if(!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
        return;
    }

    if(event.getHand() == null || !event.getHand().equals(EquipmentSlot.HAND)) {
        return;
    }

    ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
    if(item == null || item.getItemMeta() == null || !item.getType().equals(Material.ENCHANTED_BOOK)) {
        return;
    }

    Player player = event.getPlayer();
    Rune rune = plugin.getRuneManager().getRune(item.getItemMeta().getDisplayName().substring(2));
    if(rune == null) {
        return;
    }

    event.setCancelled(true);

    if(plugin.getRuneManager().hasActiveRune(player)) {
        player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_ALREADY_ACTIVE.toString());
        return;
    }

    if(Cooldowns.getCooldown(player, "rune") > 0) {
        player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_COOLDOWN.toString()
            .replaceAll("%d", Convert.timeToString((int) (Cooldowns.getCooldown(player, "rune") / 1000))));
        return;
    }

    plugin.getRuneManager().start(player, rune);
}