本文整理汇总了Java中org.bukkit.material.Wool类的典型用法代码示例。如果您正苦于以下问题:Java Wool类的具体用法?Java Wool怎么用?Java Wool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Wool类属于org.bukkit.material包,在下文中一共展示了Wool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerInventory
import org.bukkit.material.Wool; //导入依赖的package包/类
private void registerInventory(Inventory inventory) {
if (scannedChests.contains(inventory.getHolder())) {
return;
}
scannedChests.add(inventory.getHolder());
for (ItemStack itemStack : inventory) {
if (itemStack != null && itemStack.getType() != null) {
if (itemStack.getType() == Material.WOOL) {
DyeColor dyeColor = ((Wool) itemStack.getData()).getColor();
woolChests.put(inventory.getHolder(), dyeColor);
fillInventoryWithWool(inventory, dyeColor);
}
}
}
}
示例2: handleItemDespawn
import org.bukkit.material.Wool; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void handleItemDespawn(final EntityDespawnInVoidEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof Item)) return;
ItemStack stack = ((Item) entity).getItemStack();
PlayerId playerId = this.droppedWools.remove(entity);
if (playerId == null) return;
ParticipantState player = PGM.getMatchManager().getParticipantState(playerId);
if (player == null) return;
if(isDestroyableWool(stack, player.getParty())) {
giveWoolDestroyRaindrops(player, ((Wool) stack.getData()).getColor());
}
}
示例3: isDestroyableWool
import org.bukkit.material.Wool; //导入依赖的package包/类
/**
* Test if the given ItemStack is strictly an enemy wool i.e. not also
* a wool that the given team can capture.
*/
private boolean isDestroyableWool(ItemStack stack, Competitor team) {
if(stack == null || stack.getType() != Material.WOOL) {
return false;
}
DyeColor color = ((Wool) stack.getData()).getColor();
boolean enemyOwned = false;
for(Goal goal : team.getMatch().needMatchModule(GoalMatchModule.class).getGoals()) {
if(goal instanceof MonumentWool) {
MonumentWool wool = (MonumentWool) goal;
if(wool.isVisible() && !wool.isPlaced() && wool.getDyeColor() == color) {
if(wool.getOwner() == team) {
return false;
} else {
enemyOwned = true;
}
}
}
}
return enemyOwned;
}
示例4: onBlockPlace
import org.bukkit.material.Wool; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
if (event.getBlock().equals(place.getBlock())) {
if (event.getBlock().getType().equals(Material.WOOL)) {
if (((Wool) event.getBlock().getState().getData()).getColor().equals(color)) {
if (TeamUtils.getTeamByPlayer(event.getPlayer()) == team) {
this.complete = true;
if (this.show) ChatUtils.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.WHITE + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PLACED, team.getColor() + event.getPlayer().getName() + ChatColor.WHITE, team.getCompleteName() + ChatColor.WHITE, MiscUtils.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.WHITE)));
FireworkUtil.spawnFirework(event.getPlayer().getLocation(), event.getPlayer().getWorld(), MiscUtils.convertChatColorToColor(MiscUtils.convertDyeColorToChatColor(color)));
ObjectiveCompleteEvent compEvent = new ObjectiveCompleteEvent(this, event.getPlayer());
Bukkit.getServer().getPluginManager().callEvent(compEvent);
event.setCancelled(false);
} else {
event.setCancelled(true);
if (this.show) ChatUtils.sendWarningMessage(event.getPlayer(), "You may not complete the other team's objective.");
}
} else {
event.setCancelled(true);
if (this.show) ChatUtils.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_BLOCK_PLACE, MiscUtils.convertDyeColorToChatColor(color) + color.name().toUpperCase().replaceAll("_", " ") + " WOOL" + ChatColor.RED));
}
} else {
event.setCancelled(true);
if (this.show) ChatUtils.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_BLOCK_PLACE, MiscUtils.convertDyeColorToChatColor(color) + color.name().toUpperCase().replaceAll("_", " ") + " WOOL" + ChatColor.RED));
}
}
}
示例5: onSafetyPlace
import org.bukkit.material.Wool; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onSafetyPlace(BlockPlaceEvent event) {
if (!event.isCancelled() && this.touched) {
if (event.getBlock().getType().equals(Material.WOOL)) {
if (((Wool) event.getBlock().getState().getData()).getColor().equals(color)) {
if (TeamUtils.getTeamByPlayer(event.getPlayer()) == team) {
if (event.getBlockPlaced().getLocation().distance(place.getLocation()) < proximity) {
double old = proximity;
proximity = event.getBlockPlaced().getLocation().distance(place.getLocation());
Bukkit.getServer().getPluginManager().callEvent(new ObjectiveProximityEvent(this, event.getPlayer(), old, proximity));
}
}
}
}
}
}
示例6: 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;
}
示例7: ColorSelectionMenu
import org.bukkit.material.Wool; //导入依赖的package包/类
/**
* Constructs a new Gui
*
* @param entity the entity to change the color of
*/
public ColorSelectionMenu(Creature entity) {
super(null, 18, ChatColor.GREEN + "Select a color", 1);
for (DyeColor dyeColor : DyeColor.values())
addItem(new Wool(dyeColor).toItemStack(1), event -> {
if (entity instanceof Colorable)
((Colorable) entity).setColor(dyeColor);
else if (entity instanceof Wolf) {
Wolf wolf = (Wolf) entity;
wolf.setTamed(true);
wolf.setCollarColor(dyeColor);
}
event.setCancelled(true);
});
}
示例8: isBlockSolid
import org.bukkit.material.Wool; //导入依赖的package包/类
@Override
public boolean isBlockSolid(PlotBlock block) {
try {
Material material = Material.getMaterial(block.id);
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
Class<? extends MaterialData> data = material.getData();
if (data.equals(MaterialData.class) || data.equals(Tree.class) || data.equals(Sandstone.class) || data.equals(Wool.class) || data.equals(Step.class)) {
return true;
}
}
return false;
}
catch (Exception e) {
return false;
}
}
示例9: addwoolSpawner
import org.bukkit.material.Wool; //导入依赖的package包/类
public boolean addwoolSpawner(Block block) {
MapData mapData = maps.get(block.getWorld().getName());
if (mapData == null) {
return false;
}
if (block.getType() != Material.WOOL) {
return false;
}
Wool wool = new Wool(block.getType(), block.getData());
if (mapData.woolSpawners != null) {
mapData.woolSpawners.remove(wool.getColor().toString());
} else {
mapData.woolSpawners = new TreeMap<>();
}
mapData.woolSpawners.put(wool.getColor().toString(), block.getLocation());
placeWoolSpawner(block.getLocation(), wool.getColor().toString());
return true;
}
示例10: 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();
}
});
}
示例11: 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);
}
}
}
}
}
}
示例12: isBlockSolid
import org.bukkit.material.Wool; //导入依赖的package包/类
@Override
public boolean isBlockSolid(PlotBlock block) {
try {
Material material = Material.getMaterial(block.id);
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
Class<? extends MaterialData> data = material.getData();
if (data.equals(MaterialData.class) && !material.isTransparent() && material.isOccluding()
|| data.equals(Tree.class)
|| data.equals(Sandstone.class)
|| data.equals(Wool.class)
|| data.equals(Step.class)
|| data.equals(WoodenStep.class)) {
switch (material) {
case NOTE_BLOCK:
case MOB_SPAWNER:
return false;
default:
return true;
}
}
}
return false;
} catch (Exception ignored) {
return false;
}
}
示例13: makeDirectionButton
import org.bukkit.material.Wool; //导入依赖的package包/类
private ToggleButton makeDirectionButton(final InventoryGUI gui, final int slot, final BlockFace face) {
ItemStack trueStack = GUIUtil.makeTexture(new Wool(DyeColor.ORANGE), ChatColor.YELLOW + face.toString());
ItemStack falseStack = GUIUtil.makeTexture(new Wool(DyeColor.SILVER), ChatColor.YELLOW + face.toString());
final Directional owner = (Directional) gui.getOwningItem();
return new ToggleButton(gui, slot, owner.getFacing() == face, trueStack, falseStack, new ToggleButton.ToggleListener() {
@Override
public boolean run(boolean newValue) {
// acts sort of like a radio button - switching one on switches all other
// off, but switching one off leaves all switch off
if (!newValue && !allowSelf) {
return false;
}
if (newValue) {
owner.setFacingDirection(face);
for (int otherSlot : directionSlots.keySet()) {
if (slot != otherSlot) {
((ToggleButton) gui.getGadget(otherSlot)).setValue(false);
}
}
} else {
owner.setFacingDirection(BlockFace.SELF);
}
return true;
}
});
}
示例14: tryUpdate
import org.bukkit.material.Wool; //导入依赖的package包/类
private void tryUpdate(Player player, Block block) {
if (!teamAllowsUpdate(Teams.getTeamByPlayer(player))) return;
boolean update = true;
if (objective instanceof WoolObjective) {
update = !info.needsTouch;
if (info.needsTouch) {
if (info.metric.equals(ProximityMetric.CLOSEST_BLOCK)) {
if (block.getType().equals(Material.WOOL) && ((Wool) block.getState().getData()).getColor().equals(((WoolObjective) objective).getColor()))
update = true;
} else {
ItemStack item = new ItemStack(Material.WOOL, 1, ((WoolObjective) objective).getColor().getWoolData());
if (player.getInventory().containsAtLeast(item, 1)) update = true;
}
}
} else if (objective instanceof FlagObjective) {
if (info.needsTouch) {
update = Flags.getFlag(player) == objective;
}
}
if (update) setProximity(player.getLocation(), player);
}
示例15: addPlayer
import org.bukkit.material.Wool; //导入依赖的package包/类
public void addPlayer(Player p) {
players.add(new PlayerData(p.getName(), getTeamWithLessPlayers(), p.getInventory().getContents(), p.getInventory().getArmorContents(), p.getLocation()));
p.getInventory().clear();
p.getInventory().addItem(new ItemStack(Material.SNOW_BALL, 1));
p.getInventory().setHelmet(new Wool(DyeColor.valueOf(getData(p).getTeam().toString())).toItemStack(1));
p.getInventory().setChestplate(new Wool(DyeColor.valueOf(getData(p).getTeam().toString())).toItemStack(1));
p.getInventory().setLeggings(new Wool(DyeColor.valueOf(getData(p).getTeam().toString())).toItemStack(1));
p.getInventory().setBoots(new Wool(DyeColor.valueOf(getData(p).getTeam().toString())).toItemStack(1));
p.teleport(getSpawn(getData(p).getTeam()));
p.setScoreboard(sb);
p.setGameMode(GameMode.SURVIVAL);
p.setFlying(false);
MessageManager.getInstance().info(p, "You have joined the arena " + getID() + " and are on the " + ChatColor.valueOf(getData(p).getTeam().toString()) + getData(p).getTeam().toString().toLowerCase() + ChatColor.YELLOW + " team!");
if (players.size() >= 2 && !cd) start();
}