Java 类org.bukkit.Material 实例源码

项目:UltraCore    文件:Events.java   
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
            event.setCancelled(true);
               for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {   
               Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
               Location location = player.getLocation();
               if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
                   player.closeInventory();
                   player.teleport(targetPlayer);
                player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
                player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
               }
               }
           }
    }
}
项目:Transport-Pipes    文件:InventoryUtils.java   
public static ItemStack createSkullItemStack(String uuid, String textureValue, String textureSignature) {

        WrappedGameProfile wrappedProfile = new WrappedGameProfile(UUID.fromString(uuid), null);
        wrappedProfile.getProperties().put("textures", new WrappedSignedProperty("textures", textureValue, textureSignature));

        ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
        SkullMeta sm = (SkullMeta) skull.getItemMeta();

        Field profileField = null;
        try {
            profileField = sm.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(sm, wrappedProfile.getHandle());
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
            e1.printStackTrace();
        }

        skull.setItemMeta(sm);
        return skull;
    }
项目:SurvivalAPI    文件:DiamondFlowerModule.java   
/**
 * Chance to drop a diamond when a player breaks a flower
 *
 * @param event Event
 */
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM)
        return;

    if (event.getEntity().hasMetadata("playerDrop"))
        return;

    if (event.getEntity().getItemStack().getType() != Material.YELLOW_FLOWER
            && event.getEntity().getItemStack().getType() != Material.RED_ROSE
            && (event.getEntity().getItemStack().getType() != Material.DOUBLE_PLANT
                || (event.getEntity().getItemStack().getDurability() > 1 && event.getEntity().getItemStack().getDurability() < 4)))
        return;

    if (this.random.nextDouble() <= (double) this.moduleConfiguration.get("chance"))
        event.getEntity().getWorld().dropItemNaturally(event.getLocation(), Meta.addMeta(new ItemStack(Material.DIAMOND, (int) this.moduleConfiguration.get("diamonds"))));

    event.setCancelled(true);
}
项目:SurvivalAPI    文件:FastTreeModule.java   
public boolean isNearWood(Block block, int range)
{
    if(range <= 0)
        return false;

    for(BlockFace face : this.faces)
    {
        Block block1 = block.getRelative(face);

        if(block1.getType() == Material.LOG || block1.getType() == Material.LOG_2)
            return true;
        else if((block1.getType() == Material.LEAVES || block1.getType() == Material.LEAVES_2) && this.isNearWood(block1, range-1))
            return true;
    }

    return false;
}
项目:Kineticraft    文件:Pinata.java   
private void spawnZombie() {
    Location center = new Location(Parties.getPartyWorld(), -74.5, 76, 30);
    Zombie z = center.getWorld().spawn(Utils.scatter(center, 4, 0, 4), Zombie.class);
    z.setCustomNameVisible(true);
    z.setCustomName(ChatColor.RED + "Piñata");

    z.getEquipment().setHelmet(ItemManager.createSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZn"
                    + "QubmV0L3RleHR1cmUvM2IyNTI2NmQ0MGNlY2Q5M2QwNTMxNTZlNGE0YTc4NDE0MGQwMzQyNTVjNzIxY2MzNzVkMWMzNjQ4MzQyYjZmZCJ9fX0",
            "Pinata Skull", "He doesn't want to party anymore."));
    z.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
    z.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
    z.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
    z.getEquipment().setItemInMainHand(ItemManager.createItem(Material.STICK, ChatColor.RED + "Pinata Bat", ChatColor.DARK_PURPLE + "Stop hitting me!"));
    z.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(40);
    z.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(.4F);
    z.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(6);
    z.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(1);
    z.setSilent(true);
    z.setGlowing(true);
    getScheduler().runTaskLater(z::remove, 1200L); // Remove zombie in 1 minute.
}
项目: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);
}
项目:SurvivalPlus    文件:StarBattleaxeWither.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
    if(event.isCancelled()) return;
    if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
    {
        Player player = (Player)event.getDamager();
        ItemStack mainItem = player.getInventory().getItemInMainHand();
        LivingEntity enemy = (LivingEntity)event.getEntity();

        Random rand = new Random();

        if(mainItem.getType() == Material.GOLD_AXE)
        {
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
            enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
            enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
        }
    }
}
项目:Debuggery    文件:InputFormatterTest.java   
@Test
public void testMaterialData() throws InputException {
    Class[] inputTypes = {MaterialData.class};
    String[] input = {"diamond_spade:24"};

    Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null);

    // First let's make sure we didn't lose anything, or get anything
    assertEquals(inputTypes.length, output.length);

    // Next let's make sure everything is the right type
    for (Object object : output) {
        assertTrue(object instanceof MaterialData);
    }

    // Finally, let's make sure the values are correct
    assertSame(((MaterialData) output[0]).getItemType(), Material.DIAMOND_SPADE);
}
项目:EscapeLag    文件:BonemealDupePatch.java   
@EventHandler
public void TreeGrowChecker(StructureGrowEvent event) {
    if (ConfigPatch.safetyBonemeal) {
        if(event.isFromBonemeal() == false) {
            return;
        }
        List<BlockState> blocks = event.getBlocks();
        int bs = blocks.size();
        for(int i = 0;i<bs;i++){
            Block block = blocks.get(i).getBlock();
            if(block.getType() != Material.AIR && block.getType() != Material.SAPLING && block.getType() != event.getLocation().getBlock().getRelative(BlockFace.DOWN).getType()){
                event.setCancelled(true);
                if (event.getPlayer() != null) {
                    AzureAPI.log(event.getPlayer(), "§c这棵树生长区域有方块阻挡,请不要尝试利用骨粉BUG!");
                    return;
                }
            }
        }
    }
}
项目:Crescent    文件:InventoryTweaksB.java   
@Override
public void call(Event event) {
    if (event instanceof InventoryClickEvent) {
        final InventoryClickEvent ice = (InventoryClickEvent) event;

        if (ice.getCurrentItem().getType() == Material.BOWL) {

            final int slot = ice.getSlot();

            if (!slotsChosen.containsKey(slot)) {
                slotsChosen.put(slot, 1);
            } else {
                slotsChosen.put(slot, slotsChosen.get(slot) + 1);
            }

            if (getStackChance() >= 100.0) {
                callback(true);
            }
        }
    }
}
项目:FactionsXL    文件:SetBannerCommand.java   
@Override
public void onExecute(String[] args, CommandSender sender) {
    Player player = (Player) sender;
    Faction faction = getSenderFactionOrFromArg(sender, args, 1);
    if (faction == null) {
        return;
    }

    if (!faction.isAdmin(player)) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
        return;
    }

    ItemStack item = player.getInventory().getItemInMainHand();
    if (item == null || item.getType() != Material.BANNER) {
        displayHelp(player);
        return;
    }

    faction.setBanner(item);
    faction.sendMessage(FMessage.CMD_SET_BANNER_SUCCESS.getMessage(), player, faction);
}
项目:AsgardAscension    文件:RuneManager.java   
private void handleFreeze(Player player, Rune rune) {
    Player target = Utility.getTargetPlayer(player, 10);
    if(target == null || !Utility.canAttack(player, target)) {
        return;
    }

    LineEffect eff = new LineEffect(plugin.getEffectManager());
    eff.setEntity(player);
    eff.setTargetEntity(target);
    eff.particle = ParticleEffect.SNOW_SHOVEL;
    eff.start();
    target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 6));
    target.playSound(target.getLocation(), Sound.ENTITY_SNOWMAN_DEATH, 1F, 1F);

    player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
    player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_APPLY.toString()
        .replaceAll("%s", rune.getName()));
    target.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_FROZEN.toString()
            .replaceAll("%s", player.getName()));
    finish(player, false);
}
项目:Kineticraft    文件:LazerPuzzle.java   
@SuppressWarnings("deprecation")
@Override
public void onBlockClick(PlayerInteractEvent evt, Block bk, boolean rightClick) {
    if (!canTrigger() || MetadataManager.updateCooldownSilently(evt.getPlayer(), "lazerBk", 2))
        return;

    int y = getGateLocation().getBlockY();
    Block above = bk.getRelative(BlockFace.UP);
    if (isPuzzle(bk, y, Material.WOOL) && above.getType() == Material.AIR && rightClick) {
        above.setType(Material.DIODE_BLOCK_OFF);
        above.setData((byte) 0);
    }

    // Remove the next
    if (isPuzzle(bk, y + 1, Material.DIODE_BLOCK_OFF)) {
        if (!rightClick) {
            bk.setType(Material.AIR);
            return;
        }

        bk.setData((byte) (bk.getData() >= 3 ? 0 : bk.getData() + 1));
        evt.setCancelled(true);
    }
}
项目:OpenUHC    文件:Overcook.java   
/**
 * Handles the action of smelting all items at once, exploding the furnace, and dropping the smelted items on the
 * ground.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
  ItemStack resultItem = event.getResult();
  final Material result = resultItem.getType();
  //TODO: Verify that the "smelting amount" contains any extra ingredients
  final int amount = ((Furnace) event.getBlock().getState()).getInventory().getSmelting().getAmount();

  event.getSource().setType(Material.AIR);
  resultItem.setType(Material.AIR);

  Block block = event.getBlock();
  block.setType(Material.AIR);
  Location location = block.getLocation().add(0.5, 0.5, 0.5);
  World world = location.getWorld();
  world.createExplosion(location, 7);
  world.dropItem(location, new ItemStack(result, amount));
}
项目:HCFCore    文件:UnRepairableListener.java   
@EventHandler
public void onRepair(final PrepareAnvilRepairEvent e) {
    if (e.getInventory().getContents() == null) {
        return;
    }
    for (final ItemStack itemStack : e.getInventory().getContents()) {
        if (!itemStack.hasItemMeta()) {
            return;
        }
        if (!itemStack.getItemMeta().hasLore()) {
            return;
        }
        if (itemStack.getItemMeta().getLore() == null) {
            return;
        }
        for (final String lore : itemStack.getItemMeta().getLore()) {
            final String fixedLore = ChatColor.stripColor(lore.toLowerCase());
            if (fixedLore.contains("no repair") || fixedLore.contains("unrepairable") || fixedLore.contains("norepair") || fixedLore.contains("nofix") || fixedLore.contains("no fix")) {
                e.setCancelled(true);
                e.setResult(new ItemStack(Material.AIR));
                e.getRepairer().closeInventory();
                ((Player)e.getRepairer()).sendMessage(ChatColor.RED + "This item cannot be repaired.");
            }
        }
    }
}
项目:Uranium    文件:CraftBlock.java   
public static void dumpMaterials() {
    if (MinecraftServer.getServer().cauldronConfig.dumpMaterials.getValue())
    {
        FMLLog.info("Cauldron Dump Materials is ENABLED. Starting dump...");
        for (int i = 0; i < 32000; i++)
        {
            Material material = Material.getMaterial(i);
            if (material != null)
            {
                FMLLog.info("Found material " + material + " with ID " + i);
            }
        }
        FMLLog.info("Cauldron Dump Materials complete.");
        FMLLog.info("To disable these dumps, set cauldron.dump-materials to false in bukkit.yml.");
    }
}
项目:ProjectAres    文件:Uncarried.java   
public Uncarried(Flag flag, Post post, @Nullable Location location) {
    super(flag, post);
    if(location == null) location = flag.getReturnPoint(post);
    this.location = new Location(location.getWorld(),
                                 location.getBlockX() + 0.5,
                                 location.getBlockY(),
                                 location.getBlockZ() + 0.5,
                                 location.getYaw(),
                                 location.getPitch());

    if(!flag.getMatch().getWorld().equals(this.location.getWorld())) {
        throw new IllegalStateException("Tried to place flag in the wrong world");
    }

    Block block = this.location.getBlock();
    if(block.getType() == Material.STANDING_BANNER) {
        // Banner may already be here at match start
        this.oldBlock = BlockStateUtils.cloneWithMaterial(block, Material.AIR);
    } else {
        this.oldBlock = block.getState();
    }
    this.oldBase = block.getRelative(BlockFace.DOWN).getState();
}
项目:PA    文件:AntiGravity.java   
@Override
public void play(PAUser u) {
    if (isInCooldown(u, getName())) return;

    final ArmorStand as = (ArmorStand) spawnEntity(u.getLoc(), EntityType.ARMOR_STAND);
    as.setGravity(false);
    as.setSmall(true);
    as.setVisible(false);
    as.setHelmet(new ItemStack(Material.SEA_LANTERN));
    as.setPassenger(u.getPlayer());

    as.teleport(as.getLocation().add(0, 5, 0));

    bt = plugin.getServer().getScheduler().runTaskTimer(plugin, ()-> {
        as.teleport(as.getLocation().add(0, 0.2, 0));

        if (count <= 0) {
            remove(u, as);
            bt.cancel();
            return;
        }
        count--;
    }, 0, 20);
}
项目:HCFCore    文件:KitsCommand.java   
private ItemStack titaniumKitGlass(Player player) {
    ItemStack stack = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0, (byte) 14);
    ItemMeta meta = stack.getItemMeta();
    addGlow(stack);
    meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&4Titanium &7Kit"));
    List<String> lore = new ArrayList<String>();
    lore.add(ChatColor.translateAlternateColorCodes('&', "&7This is a kit contains:"));
    lore.add(ChatColor.translateAlternateColorCodes('&', "&fGod Diamond kit!"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &cPurchase the Titanium Rank from store.hcriots.net"));
    lore.add("");
    lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7CoolDown: &c3 Days"));
    if(cooldowns.containsKey(player.getUniqueId())) {
        if(cooldowns.get(player.getUniqueId()).containsKey("TitaniumKit")) {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &c" + DurationFormatUtils.formatDurationWords(cooldowns.get(player.getUniqueId()).get("TitaniumKit"), true, true)));
        } else {
            lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
        }
    } else {
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l* &7Available in: &aNow"));
    }
    meta.setLore(lore);
    stack.setItemMeta(meta);
    return stack;
}
项目:Hub    文件:StepEffect.java   
@Override
public void onRun()
{
    // Prevents an excess of particles
    if (last != null && last.getX() == getEntity().getLocation().getX() && last.getZ() == getEntity().getLocation().getZ())
        return;
    last = getEntity().getLocation();

    Block block = this.getEntity().getLocation().add(0, -0.4, 0).getBlock();
    Material type = block.getType();

    // If the step should be displayed or not
    if (type.isBlock() && type.isSolid() && !type.isTransparent()) {
        Location loc = getEntity().getLocation();
        loc.setY(block.getY());
        loc = loc.add(0, 1 + Math.random() / 100, 0);
        Vector dir = VectorUtils.rotateAroundAxisY(getEntity().getLocation().getDirection().setY(0).normalize(), p ? 90 : -90).multiply(0.25);
        display(ParticleEffect.FOOTSTEP, loc.add(dir.getX(), 0, dir.getZ()), 7, 0);

        p = !p;
    }
}
项目:NavyCraft2-Lite    文件:MoveCraft_PlayerListener.java   
public void playerDisableUpdate(final Player player, final Craft craft) {
    plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
        if ((craft != null) && (player != null) && player.isOnline()) {
            craft.doRemove = true;
            if (player.getInventory().contains(Material.GOLD_SWORD)) {
                player.getInventory().remove(Material.GOLD_SWORD);
            }
            player.sendMessage("Vehicle disabled.");
        }
    });
}
项目:QuarSK    文件:SExprBannerBlockLayers.java   
@Nullable
@Override
protected Pattern[] get(Event e) {
    Block b = block.getSingle(e);
    if (b == null) {
        return null;
    }
    if (b.getType() == Material.STANDING_BANNER || b.getType() == Material.WALL_BANNER) {
        return ((Banner) b.getState()).getPatterns().stream().toArray(Pattern[]::new);
    }
    return null;
}
项目:AsgardAscension    文件:MainInventory.java   
public static void setupInventory(Player player){
    Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Asgard Ascension");
    inv.setItem(0, ItemStackGenerator.createItem(Material.NETHER_STAR, 0, 0, 
            ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Rank-ups and Challenges", null));
    inv.setItem(1, ItemStackGenerator.createItem(Material.DIAMOND, 0, 0,
            ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Ragnorak", null));
    inv.setItem(2, ItemStackGenerator.createItem(Material.GOLDEN_CARROT, 0, 0,
            ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Food of the Gods", null));
    inv.setItem(8, ItemStackGenerator.createItem(Material.REDSTONE_BLOCK, 0, 0,
            ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Reload Configs", null));
    player.openInventory(inv);
}
项目:AstralEdit    文件:DisplayArmorstand.java   
/**
 * Initializes the armorstand
 *
 * @param player   player
 * @param location location
 * @param id       id
 * @param data     data
 * @param watchers watchers
 */
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
    super();
    this.watchers = watchers;
    this.player = player;
    this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.armorStand.a(compound);
    this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
    this.storedId = id;
    this.storedData = data;

    ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
    this.getCraftEntity().setHelmet(stackBuilder.build());
    this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));

    if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
        stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
        if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
            stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
        } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
            stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
        } else {
            stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
        }
        ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
    }
}
项目:Slimefun4-Chinese-Version    文件:ItemEnergy.java   
public static float addStoredEnergy(ItemStack item, float energy)
{
    if(item == null || item.getType() == null || item.getType().equals(Material.AIR))
        return 0.0F;
    if(!item.hasItemMeta() || !item.getItemMeta().hasLore())
        return 0.0F;
    float rest = 0.0F;
    float capacity = getMaxEnergy(item);
    if(capacity == 0.0F)
        return rest;
    float stored = getStoredEnergy(item);
    if(stored + energy > capacity)
    {
        rest = (stored + energy) - capacity;
        stored = capacity;
    } else
    if(stored + energy < 0.0F)
        stored = 0.0F;
    else
        stored += energy;
    List lore = item.getItemMeta().getLore();
    int index = -1;
    for(int i = 0; i < lore.size(); i++)
    {
        String line = (String)lore.get(i);
        if(!line.startsWith(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7")) || !line.contains(" / ") || !line.endsWith(" J"))
            continue;
        index = i;
        break;
    }

    BigDecimal decimal = (new BigDecimal(stored)).setScale(2, 4);
    lore.set(index, (new StringBuilder(String.valueOf(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7")))).append(decimal.floatValue()).append(" / ").append(capacity).append(" J").toString());
    ItemMeta im = item.getItemMeta();
    im.setLore(lore);
    item.setItemMeta(im);
    return rest;
}
项目:MCLibrary    文件:PageGUI.java   
private void setContents(Inventory inv) {
    GUIData data = getData();
    ItemStack[] contents = data.contents();
    int start = currPage * spaceSize;
    int end = start + spaceSize;
    for (int i = start; i < end; i++) {
        if (contents.length <= i)
            break;
        ItemStack item = contents[i];
        if (item != null && item.getType() != Material.AIR) {
            inv.setItem(i - start + 9, item);
        }
    }
}
项目:BedwarsXP    文件:XPItemShop.java   
private VillagerTrade getTradingItem(MerchantCategory category,
        ItemStack stack, Game game, Player player) {
    for (VillagerTrade trade : category.getOffers()) {
        if ((trade.getItem1().getType() != Material.AIR)
                || (trade.getRewardItem().getType() != Material.AIR)) {
            ItemStack iStack = toItemStack(trade, player, game);
            if ((iStack.getType() == Material.ENDER_CHEST)
                    && (stack.getType() == Material.ENDER_CHEST))
                return trade;
            if (((iStack.getType() == Material.POTION) || ((Main
                    .getInstance().getCurrentVersion().startsWith("v1_9")) && ((iStack
                    .getType().equals(Material.valueOf("TIPPED_ARROW")))
                    || (iStack.getType().equals(Material
                            .valueOf("LINGERING_POTION"))) || (iStack
                        .getType()
                    .equals(Material.valueOf("SPLASH_POTION"))))))
                    && (((PotionMeta) iStack.getItemMeta())
                            .getCustomEffects().equals(((PotionMeta) stack
                            .getItemMeta()).getCustomEffects()))) {
                return trade;
            }
            if (iStack.equals(stack)) {
                return trade;
            }
        }
    }
    return null;
}
项目:DungeonGen    文件:Passageway.java   
/** Opens or closes the exit of this Passageway according to its DoorType.
 * @param open  true: opens, false: closes
 */
public void toggleExit(boolean open) {
    switch (exitType) {
    case APPEARING:
        if (open)
            genWall(exit.doorLoc,exit.height,exit.width,Material.AIR);
        else//close
            genWall(exit.doorLoc,exit.height,exit.width,exit.doorMaterial);
        break;
    case FALLING:
        Vector v_above = exit.doorLoc.add(0,exit.height,0); // the door location but height higher for stuff to fall down
        Vector v_below = exit.doorLoc.add(0,-exit.height,0); // the door location but height deeper
        if (open) {
            genWall(v_below,exit.height,exit.width,Material.AIR);
            genWall(v_above,exit.height,exit.width,Material.SMOOTH_BRICK);
        }else{//close
            genWall(v_above,exit.height,exit.width,exit.doorMaterial);
        }
        break;
    case PISTON:
        Vector v = toGlobal(exit.redstonePos);
        if (open)
            parent.world.getBlockAt(v.getBlockX(),v.getBlockY(),v.getBlockZ()).setType(Material.AIR);
        else //close
            parent.world.getBlockAt(v.getBlockX(),v.getBlockY(),v.getBlockZ()).setType(Material.REDSTONE_BLOCK);
        break;
    }
}
项目:Warzone    文件:WoolObjective.java   
@EventHandler
public void onCollect(InventoryClickEvent event) {
    if (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.WOOL) {
        if (event.getCurrentItem().getData().getData() == color) {
            handleWoolPickup((Player) event.getWhoClicked());
        }
    }
}
项目:Slimefun4-Chinese-Version    文件:ItemEnergy.java   
public static float getMaxEnergy(ItemStack item)
{
    if(item == null || item.getType() == null || item.getType().equals(Material.AIR))
        return 0.0F;
    if(!item.hasItemMeta() || !item.getItemMeta().hasLore())
        return 0.0F;
    for(Iterator iterator = item.getItemMeta().getLore().iterator(); iterator.hasNext();)
    {
        String line = (String)iterator.next();
        if(line.startsWith(ChatColor.translateAlternateColorCodes('&', "&c&o&8\u21E8 &e\u26A1 &7")) && line.contains(" / ") && line.endsWith(" J"))
            return Float.valueOf(line.split(" / ")[1].replace(" J", "")).floatValue();
    }

    return 0.0F;
}
项目:ZentrelaCore    文件:RParticles.java   
public static boolean isAirlike(Material m) {
    switch (m.getId()) {
        case 0: //air
        case 78: //snow layer
        case 51: //fire
        case 50: //torch
        case 59: //wheat
        case 39: //mushroom
        case 40: //mushroom
        case 55: //redstone wire
        case 70: //stone pressure
        case 72: //wood pressure
        case 106: //vines
        case 141: //carrots
        case 142: //potatoes
        case 175: //flowers
        case 31: //grasses
        case 32: //dead shrub
        case 323: //sign (item, just in case)
        case 63: //standing sign
        case 68: //wall-mounted sign
        case 69: //lever
        case 77: //stone button
        case 143: //wood button
        case 75: //redstone torch on
        case 76: //redstone torch off
        case 65: //ladder
        case 66: //rail
        case 83: //sugar cane
        case 171: // carpet
            return true;
        default:
            return false;
    }
}
项目:SparseBukkitAPI    文件:ExampleMenu.java   
public ExampleMenu()
{
    super("Test Menu", 4);

    setItem(0, 0, new MenuItem()
    {
        public ItemStack getItem()
        {
            return new ItemBuilder(Material.PAPER).colorName("&a0,0").enchantEffect().build();
        }

        public boolean shouldUpdateItem()
        {
            return false;
        }

        public boolean onClick(Player player, ClickType clickType, InventoryAction action)
        {
            Bukkit.broadcastMessage(player.getName()+" clicked");
            return false;
        }
    });

    setItem(1,1, new BasicItem(
            new ItemBuilder(Material.PAPER).colorName("&a1,1").enchantEffect().build(),
            (player, clickType, action) ->
            {
                Bukkit.broadcastMessage(player.getName() + " clicked BasicItem");
                return false;
            })
    );
}
项目:ZentrelaRPG    文件:MelodaBomb.java   
@Override
public void castSpell(LivingEntity caster, MobData md, Player target) {
    for (int k = 0; k < RMath.randInt(20, 35); k++) {
        RScheduler.schedule(Spell.plugin, new Runnable() {
            public void run() {
                if (caster == null || !caster.isValid() || caster.isDead() || md.dead || md.despawned)
                    return;
                Location loc = caster.getLocation();
                double range = 10;
                Location l = loc.clone().add(RMath.randDouble(-range, range), RMath.randDouble(10, 15), RMath.randDouble(-range, range));
                FallingBlock fall = l.getWorld().spawnFallingBlock(l, Material.PACKED_ICE, (byte) 0);
                fall.setDropItem(false);
                fall.setHurtEntities(false);
                RScheduler.schedule(Spell.plugin, new Runnable() {
                    public void run() {
                        if (fall.isDead()) {
                            MelodaBombEffect effect = new MelodaBombEffect(EffectFactory.em(), fall.getLocation());
                            effect.run();
                            Spell.damageNearby(md.getDamage() * 3, caster, fall.getLocation(), 2, null);
                        } else {
                            RScheduler.schedule(Spell.plugin, this, 3);
                        }
                    }
                });
            }
        }, RMath.randInt(RTicks.seconds(1), RTicks.seconds(7)));
    }
}
项目:HCFCore    文件:HCF.java   
public void resetGlowstoneMountain() {
    for(int x = 502 ; x <= 582 ; x++) {
        for(int y = 76 ; y <= 112 ; y++) {
            for(int z = 594 ; z > 514 ; z--) {
                    Block block = Bukkit.getWorld("world_nether").getBlockAt(new Location(Bukkit.getWorld("world_nether"), -1 * x, y ,z));
                    if(block.getType().equals(Material.BEDROCK)) {
                        block.setType(Material.GLOWSTONE);
                    }
            }
        }
    }
}
项目:HCFCore    文件:ModeratorMode.java   
@EventHandler
public void onRightClick2(PlayerInteractEvent event)
{
    if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
          Player player = event.getPlayer();
          if ((modMode.contains(player.getName())) && (player.getItemInHand().getType() == Material.FEATHER)) {
              player.chat("/v");
          }
    }
}
项目:WC    文件:PokeEgg.java   
public void registerRecipe(){
    ItemStack i = getPokeEgg();

    ShapedRecipe pokeEgg = new ShapedRecipe(i);

    pokeEgg.shape("BAB", "DCD", "BAB");

    pokeEgg.setIngredient('B', Material.WOOL);
    pokeEgg.setIngredient('A', Material.STRING);
    pokeEgg.setIngredient('D', Material.GOLD_NUGGET);
    pokeEgg.setIngredient('C', Material.EGG);

    Bukkit.addRecipe(pokeEgg);
}
项目:KingdomFactions    文件:Item.java   
public ItemStack getItem(Material m, String name, int amount, ArrayList<String> lore, int in) {
    ItemStack i = new ItemStack(m, amount, (short) in);
    ItemMeta im = i.getItemMeta();
    im.setDisplayName(name);
    im.setLore(lore);
    i.setItemMeta(im);
    return i;
}
项目:RealSurvival    文件:Items.java   
public static ItemStack getPlaceholder13(){
    ItemStack sw=new ItemStack(Material.STAINED_GLASS_PANE,1,(short)9);
    ItemMeta im = sw.getItemMeta();
    im.setDisplayName("��3��l��ˮ");
    sw.setItemMeta(im);
    return sw;
}
项目:ProjectAres    文件:BukkitTranslatorImpl.java   
@Override
public Optional<String> materialKey(Material material) {
    return Optionals.first(
        Optional.ofNullable(substance(material))
                .map(Substance::key),
        Optional.ofNullable(NMSHacks.getTranslationKey(material))
    );
}
项目:KingdomFactions    文件:PortalTravelEventListener.java   
@EventHandler
public void onPortalDestroy(BlockBreakEvent e) {
    if (e.getBlock() == null)
        return;
    if(e.getBlock().getType() == Material.PORTAL) {
        if(!e.getPlayer().isOp()) {
            e.setCancelled(true);
        }
    }
}