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


Java Wool.toItemStack方法代码示例

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


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

示例1: getEditing

import org.bukkit.material.Wool; //导入方法依赖的package包/类
public ItemStack getEditing(boolean editing)
{
    DyeColor color;
    String displayName;
    if (editing)
    {
        color = DyeColor.GREEN;
        displayName = colorize("&a&lEditing mode");
    }
    else
    {
        color = DyeColor.RED;
        displayName = colorize("&6&lShop mode");
    }

    Wool w = new Wool(color);
    ItemStack i = w.toItemStack(1);

    ItemMeta im = i.getItemMeta();
    im.setDisplayName(displayName);
    im.setLore(Collections.singletonList(colorize("&fClick to change mode.")));
    i.setItemMeta(im);

    return i;
}
 
开发者ID:stashingco,项目名称:Credits,代码行数:26,代码来源:Prefabs.java

示例2: placeWoolSpawner

import org.bukkit.material.Wool; //导入方法依赖的package包/类
private void placeWoolSpawner(Location loc, String colorName) {
    Wool wool = new Wool(DyeColor.valueOf(colorName));
    final Block block = loc.getBlock();
    block.setType(Material.MOB_SPAWNER);
    final BlockState genericBlockState = block.getState();
    final CreatureSpawner cs = (CreatureSpawner) block.getState();
    final ItemStack stack = wool.toItemStack(1);
    Bukkit.getScheduler().runTask(plugin, new Runnable() {
        @Override
        public void run() {
            cs.setSpawnedType(block.getWorld().dropItem(block.getLocation(), stack).getType());
            genericBlockState.update();
        }
    });

}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:17,代码来源:MapManager.java

示例3: spawnWool

import org.bukkit.material.Wool; //导入方法依赖的package包/类
private void spawnWool(TreeMap<String, Game> games) {
    for (Game game : games.values()) {
        if (game.mapData.woolSpawners != null) {
            for (String woolColor : game.mapData.woolSpawners.keySet()) {
                DyeColor dyeColor = DyeColor.valueOf(woolColor);
                Wool wool = new Wool(dyeColor);
                ItemStack stack = wool.toItemStack(1);
                Location loc = new Location(game.world,
                        game.mapData.woolSpawners.get(woolColor).getBlockX(),
                        game.mapData.woolSpawners.get(woolColor).getBlockY(),
                        game.mapData.woolSpawners.get(woolColor).getBlockZ());
                for (Player player : game.world.getPlayers()) {
                    if (player.getLocation().distance(loc) <= 6
                            && !plugin.pm.isSpectator(player)) {
                        game.world.dropItem(loc, stack);
                    }
                }
            }
        }
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:22,代码来源:GameManager.java

示例4: openTeamSelection

import org.bukkit.material.Wool; //导入方法依赖的package包/类
public void openTeamSelection(Game game) {
  BedwarsOpenTeamSelectionEvent openEvent = new BedwarsOpenTeamSelectionEvent(game, this.player);
  BedwarsRel.getInstance().getServer().getPluginManager().callEvent(openEvent);

  if (openEvent.isCancelled()) {
    return;
  }

  HashMap<String, Team> teams = game.getTeams();

  int nom = (teams.size() % 9 == 0) ? 9 : (teams.size() % 9);
  Inventory inv =
      Bukkit.createInventory(this.player, teams.size() + (9 - nom),
          BedwarsRel._l(this.player, "lobby.chooseteam"));
  for (Team team : teams.values()) {
    List<Player> players = team.getPlayers();
    if (players.size() >= team.getMaxPlayers()) {
      continue;
    }
    Wool wool = new Wool(team.getColor().getDyeColor());
    ItemStack is = wool.toItemStack(1);
    ItemMeta im = is.getItemMeta();

    im.setDisplayName(team.getChatColor() + team.getName());
    ArrayList<String> teamplayers = new ArrayList<>();

    int teamPlayerSize = team.getPlayers().size();
    int maxPlayers = team.getMaxPlayers();

    String current = "0";
    if (teamPlayerSize >= maxPlayers) {
      current = ChatColor.RED + String.valueOf(teamPlayerSize);
    } else {
      current = ChatColor.YELLOW + String.valueOf(teamPlayerSize);
    }

    teamplayers.add(ChatColor.GRAY + "(" + current + ChatColor.GRAY + "/" + ChatColor.YELLOW
        + String.valueOf(maxPlayers) + ChatColor.GRAY + ")");
    teamplayers.add(ChatColor.WHITE + "---------");

    for (Player teamPlayer : players) {
      teamplayers.add(team.getChatColor() + ChatColor.stripColor(teamPlayer.getDisplayName()));
    }

    im.setLore(teamplayers);
    is.setItemMeta(im);
    inv.addItem(is);
  }

  this.player.openInventory(inv);
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:52,代码来源:PlayerStorage.java


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