当前位置: 首页>>代码示例>>Java>>正文


Java MaterialData.getItemType方法代码示例

本文整理汇总了Java中org.bukkit.material.MaterialData.getItemType方法的典型用法代码示例。如果您正苦于以下问题:Java MaterialData.getItemType方法的具体用法?Java MaterialData.getItemType怎么用?Java MaterialData.getItemType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.material.MaterialData的用法示例。


在下文中一共展示了MaterialData.getItemType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLeftOverItems

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public List<? extends ItemStack> getLeftOverItems(CraftingInventory craftingInventory) {
    ItemStack[] matrix = craftingInventory.getMatrix();
    List<ItemStack> leftOver = new ArrayList<>(matrix.length);
    
    for (int i = 0; i < matrix.length; i++) {
        ItemStack itemStack = matrix[i];
        
        if (InventoryUtils.isEmptyStack(itemStack)) {
            leftOver.add(null);
            continue;
        }
        
        ItemStack clone = itemStack.clone();
        MaterialData craftingResult = InventoryUtils.getSingleIngredientResult(itemStack.getData());
        if (craftingResult.getItemType() != Material.AIR) {
            clone.setData(craftingResult);
            leftOver.add(clone);           
            continue;
        }
    }
    
    craftingInventory.setContents(leftOver.toArray(new ItemStack[matrix.length]));
    return leftOver;
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:29,代码来源:SimpleCraftingRecipe.java

示例2: getSingleIngredientResult

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
/**
 * Get the MaterialData that vanilla crafting recipes leave in a crafting inventory if the ingredient is of stack size 1.
 * For most materials the returned data will have Material.AIR, but there are exceptions for filled buckets and dragons breath.
 * 
 * @param ingredient the material data used as a crafting ingredient.
 * @return the material data that vanilla recipes would give back upon crafting
 */
public static MaterialData getSingleIngredientResult(MaterialData ingredient) {
	if (ingredient == null) return new MaterialData(Material.AIR);
	
	switch(ingredient.getItemType()) {
		case MILK_BUCKET:
		case WATER_BUCKET:
		case LAVA_BUCKET:
			return new MaterialData(Material.BUCKET);
			
		case DRAGONS_BREATH:
			return new MaterialData(Material.GLASS_BOTTLE);
			
		default: return new MaterialData(Material.AIR);
	}
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:23,代码来源:InventoryUtils.java

示例3: removeColors

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
public void removeColors(MaterialData allowed) {
    for (int x = 0; x < squaresPerSide * squareSizes; x++) {
        int offsetX = location.getBlockX() + x;
        int squareX = x / 3;
        for (int z = 0; z < squaresPerSide * squareSizes; z++) {
            int offsetZ = location.getBlockZ() + z;
            int squareZ = z / 3;
            MaterialData materialData = colors[squareX][squareZ];
            if(materialData.getItemType() != allowed.getItemType()
                    || materialData.getData() != allowed.getData()) {
                new Location(location.getWorld(), offsetX, location.getY(), offsetZ)
                    .getBlock().setType(Material.AIR);
            }
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:17,代码来源:ColorShuffleGame.java

示例4: onPreStart

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
@Override
public void onPreStart() {
    Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
    MaterialData materialData = Utils.parseMaterialData((String) this.getGameMap().fetchSetting("item"));
    ItemStack itemStack = new ItemStack(materialData.getItemType(), 1, materialData.getData());
    itemStack.addUnsafeEnchantment(Enchantment.KNOCKBACK,
        Integer.parseInt((String) this.getGameMap().fetchSetting("knockbackAmount")));
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(!this.getAPI().getGameManager().isAlive(player)) continue;
        player.teleport(spawnLocation);
        player.setGameMode(GameMode.ADVENTURE);
        player.getInventory().addItem(itemStack);
    }
    this.hill = new Cuboid(Utils.parseLocation((String) this.getGameMap().fetchSetting("hillBoundsA")),
        Utils.parseLocation((String) this.getGameMap().fetchSetting("hillBoundsB")));
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:17,代码来源:KingOfTheHillGame.java

示例5: nextEvent

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
public void nextEvent() {
    if(getAPI().getGameManager().getGameState() != GameState.INGAME) return;
    this.currentLevel++;
    this.shuffleColors();
    final int totalTicks = 100-(5*currentLevel);
    final MaterialData nextColor = fetchRandomColor();
    ItemStack itemStack = new ItemStack(nextColor.getItemType(), 1, nextColor.getData());
    ItemMeta itemMeta = itemStack.getItemMeta();
    if(itemStack.getType() == Material.WOOL) {
        DyeColor dye = DyeColor.getByWoolData(itemStack.getData().getData());
        String name = dye.toString().toLowerCase().replace("_", " ");
        name = StringUtils.capitalize(name);
        itemMeta.setDisplayName(Utils.convertDyeColor(dye) + "" + ChatColor.BOLD + name);
    } else {
        if(itemMeta.getLocalizedName() != null) {
            itemMeta.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + itemMeta.getLocalizedName());
        }
    }
    itemStack.setItemMeta(itemMeta);
    Bukkit.getOnlinePlayers().forEach(player -> {
        if(getAPI().getGameManager().isAlive(player)) {
            player.setExp(1f);
            player.setLevel(currentLevel);
            for(int i=0; i<9; i++) {
                player.getInventory().setItem(i, itemStack);
            }
        }
    });
    new BukkitRunnable() {
        int ticks = 0;
        public void run() {
            if(getAPI().getGameManager().getGameState() != GameState.INGAME) {
                this.cancel();
                return;
            }
            if(ticks >= totalTicks) {
                this.cancel();
                removeColors(nextColor);
                Bukkit.getOnlinePlayers().forEach(player -> {
                    if(getAPI().getGameManager().isAlive(player)) {
                        player.setExp(0F);
                        for(int i=0; i<9; i++) {
                            player.getInventory().setItem(i, new ItemStack(Material.AIR, 1));
                        }
                    }
                });
                new BukkitRunnable() {
                    public void run() {
                        nextEvent();
                    }
                }.runTaskLater(Arcadia.getPlugin(Arcadia.class), 40L);
            } else {
                double percent = (100D-(((double) ticks/(double) totalTicks)*100D));
                float xp = ((Double.valueOf(percent).floatValue() % 100) / 100);
                Bukkit.getOnlinePlayers().forEach(player -> {
                    if(getAPI().getGameManager().isAlive(player)) {
                        player.setExp(xp);
                    }
                });
            }
            ticks++;
        }
    }.runTaskTimer(this.getAPI().getPlugin(), 0, 1L);
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:65,代码来源:ColorShuffleGame.java

示例6: match

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
public boolean match(Block block, MaterialData data) {
    return block.getType() == data.getItemType() && block.getData() == data.getData();
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:4,代码来源:FloorOrder.java

示例7: MaterialPattern

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
public MaterialPattern(MaterialData materialData) {
    this.material = materialData.getItemType();
    this.data = Optional.of(materialData.getData());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:5,代码来源:MaterialPattern.java

示例8: matches

import org.bukkit.material.MaterialData; //导入方法依赖的package包/类
@Override
public boolean matches(MaterialData materialData) {
    return materialData.getItemType() == this.material &&
           (!data.isPresent() || data.get() == materialData.getData());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:MaterialPattern.java


注:本文中的org.bukkit.material.MaterialData.getItemType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。