本文整理汇总了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;
}
示例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();
}
});
}
示例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);
}
}
}
}
}
}
示例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);
}