Java 类org.bukkit.material.Wool 实例源码

项目:Warzone    文件:WoolChestModule.java   
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);
            }
        }
    }
}
项目:ProjectAres    文件:RaindropListener.java   
@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());
    }
}
项目:ProjectAres    文件:RaindropListener.java   
/**
 * 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;
}
项目:Cardinal-Plus    文件:WoolObjective.java   
@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));
        }
    }
}
项目:Cardinal-Plus    文件:WoolObjective.java   
@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));
                    }
                }
            }
        }
    }
}
项目:Credits    文件:Prefabs.java   
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;
}
项目:buildinggame    文件:ColorSelectionMenu.java   
/**
 * 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);
        });
}
项目:PlotSquared-Chinese    文件:BukkitUtil.java   
@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;
    }
}
项目:libelula    文件:MapManager.java   
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;
}
项目:libelula    文件:MapManager.java   
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();
        }
    });

}
项目:libelula    文件:GameManager.java   
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);
                    }
                }
            }
        }
    }
}
项目:libelula    文件:MapManager.java   
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;
}
项目:libelula    文件:MapManager.java   
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();
        }
    });

}
项目:libelula    文件:GameManager.java   
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);
                    }
                }
            }
        }
    }
}
项目:PlotSquared    文件:BukkitUtil.java   
@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;
    }
}
项目:sensibletoolbox    文件:DirectionGadget.java   
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;
        }
    });
}
项目:CardinalPGM    文件:GameObjectiveProximityHandler.java   
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);
}
项目:Romball    文件:Arena.java   
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();
}
项目:DiscoArmor    文件:DiscoArmor.java   
private void giveArmor(Player p) {
    PlayerInventory inv = p.getInventory();
    getAPI().getClass(); if (this.helmet.equals("armor")) {
        inv.setHelmet(colorArmor(new ItemStack(Material.LEATHER_HELMET), p));
    }
    getAPI().getClass(); if (this.chestplate.equals("armor")) {
        inv.setChestplate(colorArmor(new ItemStack(Material.LEATHER_CHESTPLATE), p));
    }
    getAPI().getClass(); if (this.leggings.equals("armor")) {
        inv.setLeggings(colorArmor(new ItemStack(Material.LEATHER_LEGGINGS), p));
    }
    getAPI().getClass(); if (this.boots.equals("armor")) {
        inv.setBoots(colorArmor(new ItemStack(Material.LEATHER_BOOTS), p));
    }
    getAPI().getClass(); if (this.helmet.equals("wool")) {
        ItemStack wool = new Wool(org.bukkit.DyeColor.values()[this.random.nextInt(org.bukkit.DyeColor.values().length)]).toItemStack();
        inv.setHelmet(wool);
    }
}
项目:Warzone    文件:WoolChestModule.java   
private void fillInventoryWithWool(Inventory inventory, DyeColor dyeColor) {
    Wool wool = new Wool(dyeColor);

    for (int i = 0; i < inventory.getSize(); i++) {
        inventory.setItem(i, new ItemStack(wool.getItemType(), 1, (short) 0, wool.getData()));
    }
}
项目:WC    文件:ItemUtil.java   
public static ItemStack createWool(String displayname, DyeColor dye) {
    ItemStack item = new Wool(dye).toItemStack(1);
    ItemMeta meta = item.getItemMeta();
    meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
            ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);
    meta.setDisplayName(displayname);
    item.setItemMeta(meta);
    return item;
}
项目:ProjectAres    文件:RaindropListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleCraft(final CraftItemEvent event) {
    ParticipantState player = PGM.getMatchManager().getParticipantState(event.getWhoClicked());
    if (player == null) return;

    for (ItemStack ingredient : event.getInventory().getMatrix()) {
        if(this.isDestroyableWool(ingredient, player.getParty())) {
            giveWoolDestroyRaindrops(player, ((Wool) ingredient.getData()).getColor());
        }
    }
}
项目:Kineticraft    文件:MatchPuzzle.java   
@SuppressWarnings("SuspiciousMethodCalls")
@PuzzleTrigger
public void changeColor(CommandBlock block) {
    Block wool = block.getBlock().getRelative(BlockFace.UP);
    int index = COLORS.indexOf(((Wool) wool.getState().getData()).getColor()) + 1;
    wool.setData(COLORS.get(index >= COLORS.size() ? 0 : index).getWoolData());
    scanBoard();
}
项目:BedwarsRel    文件:PlayerListener.java   
private void onLobbyInventoryClick(InventoryClickEvent ice, Player player, Game game) {
  Inventory inv = ice.getInventory();
  ItemStack clickedStack = ice.getCurrentItem();

  if (!inv.getTitle().equals(BedwarsRel._l(player, "lobby.chooseteam"))) {
    ice.setCancelled(true);
    return;
  }

  if (clickedStack == null) {
    ice.setCancelled(true);
    return;
  }

  if (clickedStack.getType() != Material.WOOL) {
    ice.setCancelled(true);
    return;
  }

  ice.setCancelled(true);
  Wool wool = (Wool) clickedStack.getData();
  Team team = game.getTeamByDyeColor(wool.getColor());
  if (team == null) {
    return;
  }

  game.playerJoinTeam(player, team);
  player.closeInventory();
}
项目:Credits    文件:Prefabs.java   
public boolean isEditing(ItemStack i)
{
    if (i != null && i.getType().equals(Material.WOOL))
    {
        Wool iw = (Wool) i.getData();
        return iw.getColor().equals(DyeColor.GREEN);
    }
    return false;
}
项目:libelula    文件:TeamManager.java   
public void cancelSpectator(InventoryClickEvent e) {
    if (e.getWhoClicked() instanceof Player == false) {
        return;
    }
    Player player = (Player) e.getWhoClicked();
    if (plugin.pm.isSpectator(player)) {
        e.setCancelled(true);
        if (e.getCurrentItem() != null) {
            if (e.getCurrentItem().equals(plugin.pm.getMenuItem())
                    && !joinMenuInventory.getViewers().contains(player)) {
                player.openInventory(joinMenuInventory);
            } else {
                switch (e.getCurrentItem().getType()) {
                    case NETHER_STAR:
                        player.closeInventory();
                        plugin.gm.movePlayerTo(player, null);
                        break;
                    case EYE_OF_ENDER:
                        player.closeInventory();
                        break;
                    case WOOL:
                        player.closeInventory();
                        Wool wool = (Wool) e.getCurrentItem().getData();
                        switch (wool.getColor()) {
                            case RED:
                                plugin.gm.joinInTeam(player, TeamId.RED);
                                break;
                            case BLUE:
                                plugin.gm.joinInTeam(player, TeamId.BLUE);
                                break;
                        }
                        break;
                }
            }

        }
    }
}
项目:libelula    文件:TeamManager.java   
public void cancelSpectator(InventoryClickEvent e) {
    if (e.getWhoClicked() instanceof Player == false) {
        return;
    }
    Player player = (Player) e.getWhoClicked();
    if (plugin.pm.isSpectator(player)) {
        e.setCancelled(true);
        if (e.getCurrentItem() != null) {
            if (e.getCurrentItem().equals(plugin.pm.getMenuItem())
                    && !joinMenuInventory.getViewers().contains(player)) {
                player.openInventory(joinMenuInventory);
            } else {
                switch (e.getCurrentItem().getType()) {
                    case NETHER_STAR:
                        player.closeInventory();
                        plugin.gm.movePlayerTo(player, null);
                        break;
                    case EYE_OF_ENDER:
                        player.closeInventory();
                        break;
                    case WOOL:
                        player.closeInventory();
                        Wool wool = (Wool) e.getCurrentItem().getData();
                        switch (wool.getColor()) {
                            case RED:
                                plugin.gm.joinInTeam(player, TeamId.RED);
                                break;
                            case BLUE:
                                plugin.gm.joinInTeam(player, TeamId.BLUE);
                                break;
                        }
                        break;
                }
            }

        }
    }
}
项目:sensibletoolbox    文件:BasicSolarCell.java   
@Override
public ItemStack getLightMeterIndicator() {
    if (pvCellLife == 0) {
        return GUIUtil.makeTexture(new Wool(DyeColor.BLACK),
                ChatColor.WHITE + "No PV Cell inserted!",
                ChatColor.GRAY + "Insert a PV Cell in the top left");
    } else {
        DyeColor dc = colors[effectiveLightLevel];
        ChatColor cc = STBUtil.dyeColorToChatColor(dc);
        double mult = getChargeMultiplier(effectiveLightLevel);
        return GUIUtil.makeTexture(new Wool(dc),
                ChatColor.WHITE + "Efficiency: " + cc + (int) (getChargeMultiplier(effectiveLightLevel) * 100) + "%",
                ChatColor.GRAY + "Power Output: " + getPowerOutput() * mult + " SCU/t");
    }
}
项目:Rixor    文件:MapTeam.java   
@SuppressWarnings("deprecation")
public WoolObjective getWool(Block block) {
    for(WoolObjective wool : getWools())
        if(new Wool(block.getType(), block.getData()).getColor() == wool.getWool())
            return wool;

    return null;
}
项目:MCWarClan    文件:BlockModule.java   
/**
 * Transform a BlockModule into a block in the real minecraft world
 */
public void toBlock(Color color) {
    Location loc = _location.getLocation();
    loc.getBlock().setType(_material);
    if (loc.getBlock().getType() == Material.WOOL){
        BlockState bs = loc.getBlock().getState();
        Wool wool = (Wool) bs.getData();
        wool.setColor(color.get_dye());
        bs.update();
    }
}
项目:CardinalPGM    文件:WoolObjective.java   
@EventHandler
public void onWoolPickup(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    if (!this.complete && GameHandler.getGameHandler().getMatch().isRunning()) {
        try {
            if (event.getCurrentItem().getType().equals(Material.WOOL) && ((Wool) event.getCurrentItem().getData()).getColor().equals(color)) {
                if (Teams.getTeamByPlayer(player).orNull() == team) {
                    boolean touchMessage = false;
                    if (!this.playersTouched.contains(player.getUniqueId())) {
                        this.playersTouched.add(player.getUniqueId());
                        if (this.show && !this.complete) {
                            Teams.getTeamChannel(Optional.of(team)).sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.WHITE + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, team.getColor() + player.getName() + ChatColor.WHITE, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.WHITE, team.getCompleteName() + ChatColor.WHITE)));
                            for (Player player1 : Bukkit.getOnlinePlayers()) {
                                if (Teams.getTeamByPlayer(player1).isPresent() && Teams.getTeamByPlayer(player1).get().isObserver()) {
                                    player1.sendMessage(new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, team.getColor() + player.getName() + ChatColor.GRAY, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY, team.getCompleteName() + ChatColor.GRAY)).getMessage(player1.getLocale()));
                                }
                            }
                            touchMessage = true;
                        }
                    }
                    if (!touched) touched = true;
                    ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, player, touchMessage);
                    Bukkit.getServer().getPluginManager().callEvent(touchEvent);
                }
            }
        } catch (NullPointerException e) {
        }
    }
}
项目:CardinalPGM    文件:WoolObjective.java   
@EventHandler
public void onWoolPickup(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();
    if (!this.complete && GameHandler.getGameHandler().getMatch().isRunning()) {
        try {
            if (event.getItem().getItemStack().getType() == Material.WOOL && ((Wool) event.getItem().getItemStack().getData()).getColor().equals(color)) {
                if (Teams.getTeamByPlayer(player).orNull() == team) {
                    boolean touchMessage = false;
                    if (!this.playersTouched.contains(player.getUniqueId())) {
                        this.playersTouched.add(player.getUniqueId());
                        if (this.show && !this.complete) {
                            Teams.getTeamChannel(Optional.of(team)).sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.WHITE + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED, team.getColor() + player.getName() + ChatColor.WHITE, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.WHITE, team.getCompleteName() + ChatColor.WHITE)));
                            for (Player player1 : Bukkit.getOnlinePlayers()) {
                                if (Teams.getTeamByPlayer(player1).isPresent() && Teams.getTeamByPlayer(player1).get().isObserver()) {
                                    player1.sendMessage(new UnlocalizedChatMessage(ChatColor.GRAY + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PICKED_FOR, team.getColor() + player.getName() + ChatColor.GRAY, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.GRAY, team.getCompleteName() + ChatColor.GRAY)).getMessage(player1.getLocale()));
                                }
                            }
                            touchMessage = true;
                        }
                    }
                    if (!touched) touched = true;
                    ObjectiveTouchEvent touchEvent = new ObjectiveTouchEvent(this, player, touchMessage);
                    Bukkit.getServer().getPluginManager().callEvent(touchEvent);
                }
            }
        } catch (NullPointerException e) {
        }
    }
}
项目:CardinalPGM    文件:WoolObjective.java   
@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 (Teams.getTeamByPlayer(event.getPlayer()).orNull() == team) {
                    this.complete = true;
                    if (this.show)
                        ChatUtil.getGlobalChannel().sendLocalizedMessage(new UnlocalizedChatMessage(ChatColor.WHITE + "{0}", new LocalizedChatMessage(ChatConstant.UI_OBJECTIVE_PLACED, team.getColor() + event.getPlayer().getName() + ChatColor.WHITE, team.getCompleteName() + ChatColor.WHITE, MiscUtil.convertDyeColorToChatColor(color) + name.toUpperCase().replaceAll("_", " ") + ChatColor.WHITE)));
                    Fireworks.spawnFireworks(place.getCenterBlock().getAlignedVector(), 3, 6, MiscUtil.convertChatColorToColor(MiscUtil.convertDyeColorToChatColor(color)), 1);
                    ObjectiveCompleteEvent compEvent = new ObjectiveCompleteEvent(this, event.getPlayer());
                    Bukkit.getServer().getPluginManager().callEvent(compEvent);
                    event.setCancelled(false);
                } else {
                    event.setCancelled(true);
                    if (this.show)
                        ChatUtil.sendWarningMessage(event.getPlayer(), "You may not complete the other team's objective.");
                }
            } else {
                event.setCancelled(true);
                if (this.show)
                    ChatUtil.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_BLOCK_PLACE, MiscUtil.convertDyeColorToChatColor(color) + color.name().toUpperCase().replaceAll("_", " ") + " WOOL" + ChatColor.RED));
            }
        } else {
            event.setCancelled(true);
            if (this.show)
                ChatUtil.sendWarningMessage(event.getPlayer(), new LocalizedChatMessage(ChatConstant.ERROR_BLOCK_PLACE, MiscUtil.convertDyeColorToChatColor(color) + color.name().toUpperCase().replaceAll("_", " ") + " WOOL" + ChatColor.RED));
        }
    }
}
项目:CardinalPGM    文件:WoolObjective.java   
@EventHandler
public void onCraftWool(CraftItemEvent event) {
    if (!this.craftable && event.getRecipe().getResult().getType().equals(Material.WOOL)
            && ((Wool) event.getRecipe().getResult().getData()).getColor().equals(color)) {
        event.setCancelled(true);
    }
}
项目:CardinalPGM    文件:Snowflakes.java   
@EventHandler
public void onItemDespawnInVoid(EntityDespawnInVoidEvent event) {
    if (!(event.getEntity() instanceof Item) || !event.getEntity().hasMetadata(ITEM_THROWER_META)) return;
    Player player = Bukkit.getPlayer((UUID) event.getEntity().getMetadata(ITEM_THROWER_META).get(0).value());
    Item item = (Item) event.getEntity();
    if (testDestroy(player, item.getItemStack())) {
        addDestroyed(player, ((Wool) item.getItemStack().getData()).getColor());
    }
}
项目:tregmine    文件:Arena.java   
public void addPlayer(Player p) {
    players.add(new PlayerData(p.getName(), getTeamWithNoPlayers(), p.getInventory().getContents(), p.getInventory().getArmorContents(), p.getLocation()));

    if (getTeam(p) == Team.BLACK){
        PlayerData pd = getData(p);
        players.remove(pd);
        MessageManager.getInstance().info(p, "This arena is full, sorry.");
        return;
    }

    ItemStack spade = new ItemStack(Material.DIAMOND_SPADE, 1);
    ItemMeta im = spade.getItemMeta();
    im.setDisplayName("�3�lShovel");
    im.setLore(Arrays.asList("�oRight Click on Snow"));
    spade.setItemMeta(im);

    p.getInventory().clear();
    p.getInventory().addItem(spade);
    p.getInventory().setHelmet(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 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();
}
项目:DuelMe    文件:Util.java   
/**
 * create menu item with a certain wool color
 * @param color the color of the wool
 * @param name the name of the item
 * @param lore the lore of the item
 * @return the item stack
 */
public static ItemStack createMenuItem(DyeColor color, String name,String lore){
    ItemStack wool = new Wool(color).toItemStack(1);
    ItemMeta woolIm = wool.getItemMeta();
    woolIm.setDisplayName(name);
    woolIm.setLore(Arrays.asList(lore));
    wool.setItemMeta(woolIm);
    return wool;
}
项目:DuelMe    文件:Util.java   
/**
 * create menu item with a certain wool color
 * @param color the color of the wool
 * @param name the name of the item
 * @param lore the lore of the item
 * @return the item stack
 */
public static ItemStack createMenuItem(DyeColor color, String name,List<String> lore){
    ItemStack wool = new Wool(color).toItemStack(1);
    ItemMeta woolIm = wool.getItemMeta();
    woolIm.setDisplayName(name);
    woolIm.setLore(lore);
    wool.setItemMeta(woolIm);
    return wool;
}
项目:Abyss    文件:ParseUtils.java   
public static String prettyName(final ItemStack item) {
    final Material mat = item.getType();
    String out = prettyName(mat);

    if ( mat == Material.WOOL )
        out += " (" + prettyName(((Wool) item.getData()).getColor()) + ")";
    else if ( mat == Material.INK_SACK )
        out += " (" + prettyName(((Dye) item.getData()).getColor()) + ")";
    else if ( item.getDurability() != 0 )
        out += " (" + item.getDurability() + ")";

    return out;
}
项目:uppercore    文件:GuiUtil.java   
public static ItemStack wool(DyeColor color, String name, String... lores) {
    return setNameAndLores(new Wool(color).toItemStack(1), name, lores);
}