當前位置: 首頁>>代碼示例>>Java>>正文


Java MaterialData.getData方法代碼示例

本文整理匯總了Java中org.bukkit.material.MaterialData.getData方法的典型用法代碼示例。如果您正苦於以下問題:Java MaterialData.getData方法的具體用法?Java MaterialData.getData怎麽用?Java MaterialData.getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.material.MaterialData的用法示例。


在下文中一共展示了MaterialData.getData方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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.getData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。