Java 类org.bukkit.block.Banner 实例源码

项目:ProjectAres    文件:Banners.java   
public static boolean placeStanding(Location location, BannerMeta meta) {
    Block block = location.getBlock();
    block.setType(Material.STANDING_BANNER, false);

    final BlockState state = block.getState();
    if(state instanceof Banner) {
        Banner banner = (Banner) block.getState();
        applyToBlock(banner, meta);

        org.bukkit.material.Banner material = (org.bukkit.material.Banner) banner.getData();
        material.setFacingDirection(BlockFaces.yawToFace(location.getYaw()));
        banner.setData(material);
        banner.update(true);
        return true;
    }
    return false;
}
项目:QuarSK    文件:SExprBannerBlockLayers.java   
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
    Block b = block.getSingle(e);
    if (b == null) {
        return;
    }
    if (b.getType() == Material.BANNER) {
        Banner banner = (Banner) b.getState();
        Pattern[] patterns = (Pattern[]) delta;
        switch (mode) {
            case ADD:
                Arrays.asList(patterns).forEach(banner::addPattern);
                break;
            case SET:
                banner.setPatterns(Arrays.asList(patterns));
                break;
            case DELETE:
            case RESET:
                for (int i = 1; i <= banner.numberOfPatterns(); i++)
                    banner.removePattern(i);
                break;
        }
        banner.update(true, false);
    }
}
项目:QuarSK    文件:SExprBannerBlockBaseColor.java   
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
    Block b = block.getSingle(e);
    if (b == null) {
        return;
    }
    if (b.getType() == Material.BANNER) {
        Banner banner = ((Banner) b.getState());
        switch (mode) {
            case SET:
                Color c = (Color) delta[0];
                banner.setBaseColor(c.getWoolColor());
                break;
            case RESET:
                banner.setBaseColor(DyeColor.WHITE);
                break;
        }
        banner.update(true, false);
    }

}
项目:Phantom    文件:Flag.java   
/**
 * Create a flag representing the given banner block
 * 
 * @param block
 *            the block. Does nothing if it is not a banner
 */
public Flag(Block block)
{
    this(DyeColor.WHITE);

    if(block.getState() instanceof Banner)
    {
        Banner bm = ((Banner) block.getState());
        baseColor = bm.getBaseColor();

        for(int i = 0; i < bm.numberOfPatterns(); i++)
        {
            if(bm.getPattern(i).getPattern().equals(PatternType.BASE))
            {
                continue;
            }

            addLayer(new FlagLayer(bm.getPattern(i)));
        }
    }
}
项目:BannerMaker    文件:SeeCommand.java   
@Override
public boolean executeCommand(CommandSender sender, Command command, String label, String[] args) {
    Player player = (Player) sender;
    Block block = player.getTargetBlock((Set<Material>) null, 20);
    if (block.getType() != Material.STANDING_BANNER && block.getType() != Material.WALL_BANNER) {
        player.sendMessage(MessageUtil.format(true, "&c" + tl("command.not-banner-see")));
        return true;
    }
    //根據方塊建立旗幟
    Banner blockState = (Banner) block.getState();
    KItemStack banner = new KItemStack(Material.BANNER)
        .durability(DyeColorUtil.toShort(blockState.getBaseColor()))
        .setPatterns(blockState.getPatterns());
    //顯示旗幟
    InventoryMenuUtil.showBannerInfo(player, banner);
    return true;
}
项目:KingKits    文件:ItemUtilities.java   
private static Map<String, Object> serializeBanner(Banner banner) {
    Map<String, Object> serializedBanner = new LinkedHashMap<>();
    if (banner != null) {
        DyeColor baseDyeColor = banner.getBaseColor();
        if (baseDyeColor != null) {
            serializedBanner.put("Base", Utilities.serializeColor(baseDyeColor.getColor()));
        }
        List<Pattern> bannerPatterns = banner.getPatterns();
        if (bannerPatterns != null && !bannerPatterns.isEmpty()) {
            Map<String, Map<String, Object>> serializedPatterns = new LinkedHashMap<>();
            for (int patternIndex = 0; patternIndex < bannerPatterns.size(); patternIndex++) {
                Pattern bannerPattern = bannerPatterns.get(patternIndex);
                Map<String, Object> serializedPattern = new LinkedHashMap<>();
                if (bannerPattern.getColor() != null) {
                    serializedPattern.put("Color", Utilities.serializeColor(bannerPattern.getColor().getColor()));
                }
                serializedPattern.put("Pattern", StringUtilities.capitalizeFully(bannerPattern.getPattern().name().replace('_', ' ')));
                serializedPatterns.put("Pattern " + (patternIndex + 1), serializedPattern);
            }
            serializedBanner.put("Patterns", serializedPatterns);
        }
    }
    return serializedBanner;
}
项目:bskyblock    文件:BannerBlock.java   
public boolean set(Block block) {
    Banner banner = (Banner) block.getState();
    banner.setBaseColor(bannerBaseColor);
    banner.setPatterns(bannerPattern);
    banner.update();
    return true;
}
项目:QuarSK    文件:ExprItemOfBannerBlock.java   
@Override
public ItemStack convert(Block block) {
    if (block.getType() == Material.STANDING_BANNER || block.getType() == Material.WALL_BANNER) {
        Banner banner = (Banner) block.getState();
        ItemStack item = new ItemStack(Material.BANNER);
        BannerMeta meta = (BannerMeta) item.getItemMeta();
        meta.setPatterns(banner.getPatterns());
        meta.setBaseColor(banner.getBaseColor());
        item.setItemMeta(meta);
        return item;
    }
    return null;
}
项目:QuarSK    文件:SExprBannerBlockLayers.java   
@Nullable
@Override
protected Pattern[] get(Event e) {
    Block b = block.getSingle(e);
    if (b == null) {
        return null;
    }
    if (b.getType() == Material.STANDING_BANNER || b.getType() == Material.WALL_BANNER) {
        return ((Banner) b.getState()).getPatterns().stream().toArray(Pattern[]::new);
    }
    return null;
}
项目:QuarSK    文件:EffApplyBannerItemToBlock.java   
@Override
protected void execute(Event e) {
    ItemStack i = item.getSingle(e);
    Block b = block.getSingle(e);
    if (i == null || b == null) {
        return;
    }
    if ((i.getType() == Material.BANNER || i.getType() == Material.SHIELD) && b.getType() == Material.BANNER) {
        BannerMeta itemMeta = ((BannerMeta) i.getItemMeta());
        Banner blockMeta = ((Banner) b.getState());
        blockMeta.setPatterns(itemMeta.getPatterns());
        blockMeta.setBaseColor(itemMeta.getBaseColor());
        blockMeta.update(true, false);
    }
}
项目:Arcade2    文件:FlagFactory.java   
public Flag parseFlagXml(CaptureGame game, Element xml, Flag flag) {
    // capture
    Element captureElement = xml.getChild("capture");
    if (captureElement == null) {
        return null;
    }

    FlagCapture capture = this.parseFlagCapture(game, captureElement, new FlagCapture(game, flag));
    if (capture == null) {
        return null;
    }

    int objective = XMLParser.parseInt(xml.getAttributeValue("objective"), Flag.NOT_OBJECTIVE);

    // spawn
    Element spawnElement = xml.getChild("spawn");
    if (spawnElement == null) {
        return null;
    }

    FlagSpawn spawn = this.parseFlagSpawn(game, captureElement, new FlagSpawn(game, flag));
    if (spawn == null) {
        return null;
    }

    Banner banner = findBannerIn(spawn.getRegion());
    if (banner == null) {
        return null;
    }

    // setup
    flag.setCapture(capture);
    flag.getItem().transferMetaFrom(banner);
    flag.setObjective(objective);
    flag.setSpawn(spawn);
    flag.getSpawn().setDirection(BlockFace.byYaw(banner.getBlock().getLocation().getYaw()));
    return flag;
}
项目:Arcade2    文件:FlagFactory.java   
public static Banner findBannerIn(Region region) {
    for (Block block : region.getBlocks()) {
        if (BannerUtils.isBanner(block)) {
            return (Banner) block.getState();
        }
    }

    return null;
}
项目:Arcade2    文件:BannerUtils.java   
public static ItemStack toItem(ItemStack item, Banner block) {
    BannerMeta meta = meta(item);
    if (meta != null) {
        item.setItemMeta(toMeta(meta, block));
    }

    return item;
}
项目:Steel    文件:BlockStateSerializer.java   
@SuppressWarnings("deprecation")
public static Optional<String> serializeState(BlockState state) {
    YamlConfiguration yaml = new YamlConfiguration();

    // http://minecraft.gamepedia.com/Block_entity was used as a reference for this method

    if (state instanceof InventoryHolder) {
        yaml.set(INVENTORY_KEY, InventoryHelper.serializeInventory(((InventoryHolder) state).getInventory()));
    }

    if (state instanceof Sign) {
        yaml.set(SIGN_LINES_KEY, Arrays.asList(((Sign) state).getLines()));
    } else if (Support.BANNER && state instanceof Banner) {
        yaml.set(BANNER_BASE_COLOR_KEY, ((Banner) state).getBaseColor().name());
        ConfigurationSection patternSection = yaml.createSection(BANNER_PATTERNS_KEY);
        List<Pattern> patterns = ((Banner) state).getPatterns();
        for (int i = 0; i < patterns.size(); i++) {
            ConfigurationSection subSection = patternSection.createSection("" + i);
            subSection.set(BANNER_PATTERN_COLOR_KEY, patterns.get(i).getColor().name());
            subSection.set(BANNER_PATTERN_TYPE_KEY, patterns.get(i).getPattern().name());
        }
    } else if (state instanceof CreatureSpawner) {
        yaml.set(SPAWNER_TYPE_KEY, ((CreatureSpawner) state).getSpawnedType().name());
        yaml.set(SPAWNER_DELAY_KEY, ((CreatureSpawner) state).getDelay());
    } else if (state instanceof NoteBlock) {
        yaml.set(NOTE_OCTAVE_KEY, ((NoteBlock) state).getNote().getOctave());
        yaml.set(NOTE_TONE_KEY, ((NoteBlock) state).getNote().getTone().name());
    } else if (state instanceof Jukebox) {
        if (((Jukebox) state).isPlaying()) {
            yaml.set(JUKEBOX_DISC_KEY, ((Jukebox) state).getPlaying());
        }
    } else if (state instanceof Skull) {
        yaml.set(SKULL_OWNER_KEY, ((Skull) state).getOwner());
        yaml.set(SKULL_ROTATION_KEY, ((Skull) state).getRotation().name());
    } else if (state instanceof CommandBlock) {
        yaml.set(COMMAND_NAME_KEY, ((CommandBlock) state).getName());
        yaml.set(COMMAND_CMD_KEY, ((CommandBlock) state).getCommand());
    } else if (state instanceof FlowerPot) {
        yaml.set(FLOWER_TYPE_KEY, ((FlowerPot) state).getContents().getItemType().name());
        yaml.set(FLOWER_DATA_KEY, ((FlowerPot) state).getContents().getData());
    }

    if (yaml.getKeys(false).size() > 0) {
        return Optional.of(yaml.saveToString());
    }
    return Optional.absent();
}
项目:NovaGuilds    文件:BannerUtils.java   
/**
 * Applies meta to a shield
 *
 * @param itemStack  shield item
 * @param bannerMeta banner meta
 * @return shield item
 */
public static ItemStack applyMeta(ItemStack itemStack, BannerMeta bannerMeta) {
    if(itemStack.getType() != Material.SHIELD && itemStack.getType() != Material.BANNER) {
        throw new IllegalArgumentException("Passed ItemStack is not a shield nor a banner");
    }

    ItemMeta meta = itemStack.getItemMeta();
    BlockStateMeta blockStateMeta = (BlockStateMeta) meta;
    Banner banner = (Banner) blockStateMeta.getBlockState();
    applyMeta(banner, bannerMeta);
    banner.update();
    blockStateMeta.setBlockState(banner);
    itemStack.setItemMeta(blockStateMeta);
    return itemStack;
}
项目:NovaGuilds    文件:BannerUtils.java   
/**
 * Turns a banner into banner meta
 *
 * @param banner banner block
 * @return banner meta
 */
public static BannerMeta getBannerMeta(Banner banner) {
    if(ConfigManager.getServerVersion().isOlderThan(ConfigManager.ServerVersion.MINECRAFT_1_8_R2)) {
        return null;
    }

    BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);

    meta.setBaseColor(banner.getBaseColor());
    for(Pattern pattern : banner.getPatterns()) {
        meta.addPattern(pattern);
    }

    return meta;
}
项目:acidisland    文件:BannerBlock.java   
public boolean set(Block block) {
    Banner banner = (Banner) block.getState();
    banner.setBaseColor(bannerBaseColor);
    banner.setPatterns(bannerPattern);
    banner.update(true, false);
    return true;
}
项目:askyblock    文件:BannerBlock.java   
public boolean set(Block block) {
    Banner banner = (Banner) block.getState();
    banner.setBaseColor(bannerBaseColor);
    banner.setPatterns(bannerPattern);
    banner.update(true, false);
    return true;
}
项目:ProjectAres    文件:Flag.java   
protected Flag(Match match, FlagDefinition definition, ImmutableSet<Net> nets) throws ModuleLoadException {
    super(definition, match);
    this.nets = nets;

    final TeamMatchModule tmm = match.getMatchModule(TeamMatchModule.class);

    this.owner = definition.owner()
                           .map(def -> tmm.team(def)) // Do not use a method ref here, it will NPE if tmm is null
                           .orElse(null);

    this.capturers = Lazy.from(
        () -> Optionals.stream(match.module(TeamMatchModule.class))
                       .flatMap(TeamMatchModule::teams)
                       .filter(team -> getDefinition().canPickup(team) && canCapture(team))
                       .collect(Collectors.toSet())
    );

    this.controllers = Lazy.from(
        () -> nets.stream()
                  .flatMap(net -> Optionals.stream(net.returnPost()
                                                      .flatMap(Post::owner)))
                  .map(def -> tmm.team(def))
                  .collect(Collectors.toSet())
    );

    this.completers = Lazy.from(
        () -> nets.stream()
                  .flatMap(net -> Optionals.stream(net.returnPost()))
                  .filter(Post::isPermanent)
                  .flatMap(post -> Optionals.stream(post.owner()))
                  .map(def -> tmm.team(def))
                  .collect(Collectors.toSet())
    );

    Banner banner = null;
    pointLoop: for(PointProvider returnPoint : definition.getDefaultPost().getReturnPoints()) {
        Region region = returnPoint.getRegion();
        if(region instanceof PointRegion) {
            // Do not require PointRegions to be at the exact center of the block.
            // It might make sense to just override PointRegion.getBlockVectors() to
            // always do this, but it does technically violate the contract of that method.
            banner = toBanner(((PointRegion) region).getPosition().toLocation(match.getWorld()).getBlock());
            if(banner != null) break pointLoop;
        } else {
            for(BlockVector pos : returnPoint.getRegion().getBlockVectors()) {
                banner = toBanner(pos.toLocation(match.getWorld()).getBlock());
                if(banner != null) break pointLoop;
            }
        }
    }

    if(banner == null) {
        throw new ModuleLoadException("Flag '" + getName() + "' must have a banner at its default post");
    }

    final Location location = Banners.getLocationWithYaw(banner);
    bannerInfo = new BannerInfo(location,
                                Banners.getItemMeta(banner),
                                new ItemStack(Material.BANNER),
                                new StaticAngleProvider(location.getYaw()));
    bannerInfo.item.setItemMeta(bannerInfo.meta);

    match.registerEvents(this);

    this.state = new Returned(this, this.getDefinition().getDefaultPost(), bannerInfo.location);
    this.state.enterState();
}
项目:ProjectAres    文件:Flag.java   
private static Banner toBanner(Block block) {
    if(block == null) return null;
    BlockState state = block.getState();
    return state instanceof Banner ? (Banner) state : null;
}
项目:ProjectAres    文件:Banners.java   
public static BannerMeta getItemMeta(Banner block) {
    BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);
    meta.setBaseColor(block.getBaseColor());
    meta.setPatterns(block.getPatterns());
    return meta;
}
项目:ProjectAres    文件:Banners.java   
public static void applyToBlock(Banner block, BannerMeta meta) {
    block.setBaseColor(meta.getBaseColor());
    block.setPatterns(meta.getPatterns());
}
项目:ProjectAres    文件:Banners.java   
public static Location getLocationWithYaw(Banner block) {
    Location location = block.getLocation();
    location.setYaw(BlockFaces.faceToYaw(((org.bukkit.material.Banner) block.getData()).getFacing()));
    return location;
}
项目:QuarSK    文件:SExprBannerBlockBaseColor.java   
@Override
@Nullable
public Color convert(@NotNull Block block) {
    BlockState state = block.getState();
    return state instanceof Banner ? Color.byWoolColor(((Banner) state).getBaseColor()) : null;
}
项目:Arcade2    文件:PointRegionRender.java   
public boolean renderBanner(Banner banner, DyeColor color) {
    banner.setBaseColor(color);
    return banner.update(false, false);
}
项目:Arcade2    文件:PointRegionRender.java   
public boolean renderBanner(BlockState blockState, DyeColor color) {
    return blockState instanceof Banner && this.renderBanner((Banner) blockState, color);
}
项目:Arcade2    文件:FlagItem.java   
public BannerMeta transferMetaFrom(Banner banner) {
    return BannerUtils.toMeta(this.getItemMeta(), banner);
}
项目:Arcade2    文件:BannerUtils.java   
public static Banner toBlock(Banner block, BannerMeta meta) {
    block.setBaseColor(meta.getBaseColor());
    block.setPatterns(meta.getPatterns());
    return block;
}
项目:Arcade2    文件:BannerUtils.java   
public static BannerMeta toMeta(BannerMeta meta, Banner block) {
    meta.setBaseColor(block.getBaseColor());
    meta.setPatterns(block.getPatterns());
    return meta;
}
项目:MagicLib    文件:MaterialAndData.java   
@SuppressWarnings("deprecation")
public void updateFrom(Block block, Set<Material> restrictedMaterials) {
    if (block == null) {
        isValid = false;
        return;
    }
    if (!block.getChunk().isLoaded()) {
        block.getChunk().load(true);
        return;
    }

    Material blockMaterial = block.getType();
    if (restrictedMaterials != null && restrictedMaterials.contains(blockMaterial)) {
        isValid = false;
        return;
    }
    // Look for special block states
    extraData = null;

    material = blockMaterial;
    data = (short)block.getData();

    try {
        BlockState blockState = block.getState();
        if (material == Material.FLOWER_POT || blockState instanceof InventoryHolder || blockState instanceof Sign) {
            extraData = new BlockTileEntity(NMSUtils.getTileEntityData(block.getLocation()));
        } else if (blockState instanceof CommandBlock){
            // This seems to occasionally throw exceptions...
            CommandBlock command = (CommandBlock)blockState;
            extraData = new BlockCommand(command.getCommand(), command.getName());
        } else if (blockState instanceof Skull) {
            Skull skull = (Skull)blockState;
            data = (short)skull.getSkullType().ordinal();
            extraData = new BlockSkull(CompatibilityUtils.getSkullProfile(skull), skull.getSkullType(), skull.getRotation());
        } else if (blockState instanceof CreatureSpawner) {
            CreatureSpawner spawner = (CreatureSpawner)blockState;
            extraData = new BlockMobSpawner(spawner.getCreatureTypeName());
        } else if (blockMaterial == Material.STANDING_BANNER || blockMaterial == Material.WALL_BANNER) {
            if (blockState != null && blockState instanceof Banner) {
                Banner banner = (Banner)blockState;
                DyeColor color = banner.getBaseColor();
                extraData = new BlockBanner(banner.getPatterns(), color);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    isValid = true;
}
项目:MagicLib    文件:MaterialAndData.java   
@SuppressWarnings("deprecation")
public void modify(Block block, boolean applyPhysics) {
    if (!isValid) return;

    try {
        BlockState blockState = block.getState();
        // Clear chests so they don't dump their contents.
        if (blockState instanceof InventoryHolder) {
            NMSUtils.clearItems(block.getLocation());
        }

        if (material != null) {
            byte blockData = data != null ? (byte)(short)data : block.getData();
            block.setTypeIdAndData(material.getId(), blockData, applyPhysics);
            blockState = block.getState();
        }

        // Set tile entity data first
        // Command blocks still prefer internal data for parameterized commands
        if (blockState != null && blockState instanceof CommandBlock && extraData != null && extraData instanceof BlockCommand) {
            CommandBlock command = (CommandBlock)blockState;
            BlockCommand commandData = (BlockCommand)extraData;
            command.setCommand(commandData.command);
            if (commandData.customName != null) {
                command.setName(commandData.customName);
            }
            command.update();
        } else if (extraData != null && extraData instanceof BlockTileEntity) {
            // Tile entity data overrides everything else, and may replace all of this in the future.
            NMSUtils.setTileEntityData(block.getLocation(), ((BlockTileEntity) extraData).data);
        } else if (blockState != null && (material == Material.STANDING_BANNER || material == Material.WALL_BANNER) && extraData != null && extraData instanceof BlockBanner) {
            if (blockState != null && blockState instanceof Banner) {
                BlockBanner bannerData = (BlockBanner)extraData;
                Banner banner = (Banner)blockState;
                if (bannerData.patterns != null)
                {
                    banner.setPatterns(bannerData.patterns);
                }
                if (bannerData.baseColor != null)
                {
                    banner.setBaseColor(bannerData.baseColor);
                }
            }
            blockState.update(true, false);
        } else if (blockState != null && blockState instanceof Skull && extraData != null && extraData instanceof BlockSkull) {
            Skull skull = (Skull)blockState;
            BlockSkull skullData = (BlockSkull)extraData;
            if (skullData.skullType != null) {
                skull.setSkullType(skullData.skullType);
            }
            if (skullData.rotation != null) {
                skull.setRotation(skullData.rotation);
            }
            if (skullData.profile != null) {
                CompatibilityUtils.setSkullProfile(skull, skullData.profile);
            }
            skull.update(true, false);
        } else if (blockState != null && blockState instanceof CreatureSpawner && extraData != null && extraData instanceof BlockMobSpawner) {
            BlockMobSpawner spawnerData = (BlockMobSpawner)extraData;
            if (spawnerData.mobName != null && !spawnerData.mobName.isEmpty())
            {
                CreatureSpawner spawner = (CreatureSpawner)blockState;
                spawner.setCreatureTypeByName(spawnerData.mobName);
                spawner.update();
            }
        }
    } catch (Exception ex) {
        Bukkit.getLogger().warning("Error updating block state: " + ex.getMessage());
    }
}
项目:CardinalPGM    文件:FlagBuilder.java   
private ModuleCollection<? extends Module> getFlag(Element... elements) {
    ModuleCollection<Module> result =  new ModuleCollection<>();
    String id = elements[0].getAttributeValue("id");
    boolean required = Numbers.parseBoolean(Parser.getOrderedAttribute("required", elements), true);
    String name = elements[0].getAttributeValue("name");
    boolean show = Numbers.parseBoolean(Parser.getOrderedAttribute("show", elements), true);
    Post post = Flags.getPostById(Parser.getOrderedAttribute("post", elements));
    if (post == null) post = PostBuilder.parsePostElement(elements[0].getChild("post"));
    result.add(post);
    Set<Net> nets = new HashSet<>();
    if (elements[0].getChildren("net").size() > 0) {
        for (Element netEl : elements[0].getChildren("net")) {
            Net net = NetBuilder.parseNet(Parser.addElement(netEl, elements));
            nets.add(net);
            result.add(net);
        }
    }
    TeamModule owner = Parser.getOrderedAttribute("owner", elements) == null ? null : Teams.getTeamById(Parser.getOrderedAttribute("owner", elements)).orNull();
    boolean shared = Numbers.parseBoolean(Parser.getOrderedAttribute("shared", elements), false);
    DyeColor color = Parser.getOrderedAttribute("color", elements) == null ? ((Banner)post.getInitialBlock().getState()).getBaseColor() : Parser.parseDyeColor(Parser.getOrderedAttribute("color", elements));
    ChatColor chatColor = MiscUtil.convertBannerColorToChatColor(color);
    String carryMessage = ChatColor.AQUA + "" + ChatColor.BOLD + "You are carrying " + chatColor + ChatColor.BOLD + name;
    if (Parser.getOrderedAttributeOrChild("carry-message", elements) != null) carryMessage = ChatColor.translateAlternateColorCodes('`', Parser.getOrderedAttributeOrChild("carry-message", elements));
    int points = Numbers.parseInt(Parser.getOrderedAttribute("points", elements), 0);
    int pointsRate = Numbers.parseInt(Parser.getOrderedAttribute("points-rate", elements), 0);
    FilterModule pickupFilter = FilterModuleBuilder.getAttributeOrChild("pickup-filter", post.getPickupFilter(), elements);
    FilterModule dropFilter = FilterModuleBuilder.getAttributeOrChild("drop-filter", "always", elements);
    FilterModule captureFilter = FilterModuleBuilder.getAttributeOrChild("capture-filter", nets.size() > 0 ? nets.iterator().next().getCaptureFilter() : FilterModuleBuilder.getFilter("always"), elements);
    KitNode pickupKit = getKitOrChild("pickup-kit", result, elements);
    KitNode dropKit = getKitOrChild("drop-kit", result, elements);
    KitNode carryKit = getKitOrChild("carry-kit", result, elements);
    boolean dropOnWater = Numbers.parseBoolean(Parser.getOrderedAttribute("drop-on-water", elements), true);
    boolean beam = Numbers.parseBoolean(Parser.getOrderedAttribute("beam", elements), true);

    String flagProximityMetric = Parser.getOrderedAttribute("flagproximity-metric", elements);
    Boolean flagProximityHorizontal = Numbers.parseBoolean(Parser.getOrderedAttribute("flagproximity-horizontal", elements), false);
    ProximityInfo flagProximityInfo = new ProximityInfo(post.getInitialBlock().getLocation().toVector(), flagProximityHorizontal, false,
        flagProximityMetric == null ? GameObjectiveProximityHandler.ProximityMetric.CLOSEST_KILL : GameObjectiveProximityHandler.ProximityMetric.getByName(flagProximityMetric));

    String netProximityMetric = Parser.getOrderedAttribute("netproximity-metric", elements);
    Boolean netProximityHorizontal = Numbers.parseBoolean(Parser.getOrderedAttribute("netproximity-horizontal", elements), false);
    ProximityInfo netProximityInfo = new ProximityInfo(null, netProximityHorizontal, true,
            netProximityMetric == null ? GameObjectiveProximityHandler.ProximityMetric.CLOSEST_PLAYER : GameObjectiveProximityHandler.ProximityMetric.getByName(netProximityMetric));

    Map<String, GameObjectiveProximityHandler> flagProximityHandlers = new HashMap<>();
    Map<String, GameObjectiveProximityHandler> netProximityHandlers = new HashMap<>();
    for (TeamModule offender : Teams.getTeams()) {
        if (offender.isObserver() || offender == owner || !pickupFilter.evaluate(offender).equals(FilterState.ALLOW)) continue;
        GameObjectiveProximityHandler flagProximityHandler = new GameObjectiveProximityHandler(offender, flagProximityInfo);
        GameObjectiveProximityHandler netProximityHandler = new GameObjectiveProximityHandler(offender, netProximityInfo);
        flagProximityHandlers.put(offender.getId(), flagProximityHandler);
        netProximityHandlers.put(offender.getId(), netProximityHandler);
        result.add(flagProximityHandler);
        result.add(netProximityHandler);
    }
    result.add(new FlagObjective(id, required, name, color, chatColor, show, post, owner, shared, carryMessage, points, pointsRate, pickupFilter, dropFilter, captureFilter, pickupKit, dropKit, carryKit, dropOnWater, beam, nets, flagProximityHandlers, netProximityHandlers));

    return result;
}
项目:CardinalPGM    文件:FlagObjective.java   
private void spawnFlag() {
    if (!isOnPost()) {
        setLastValidBlock();
        if (currentFlagBlock == null) {
            armorStand.remove();
            currentFlagBlock = nextSpawn();
            state = FlagState.WAITING_TO_RESPAWN;
            respawnTime = getPost().getRespawnTime(picker.getLocation(), currentFlagBlock.getLocation());
            resetPlayer();
            updateFlags();
            return;
        }
    }
    currentFlagBlock.setType(banner.getMaterial());
    currentFlagBlock = currentFlagBlock.getLocation().getBlock();
    Banner newBanner = (Banner)currentFlagBlock.getState();
    newBanner.setPatterns(banner.getPatterns());
    newBanner.setBaseColor(banner.getBaseColor());
    armorStand = createArmorStand();
    if (!isOnPost()) {
        if (currentFlagBlock.getRelative(BlockFace.DOWN).getType().equals(Material.STATIONARY_WATER)) {
            currentFlagBlock.getRelative(BlockFace.DOWN).setType(Material.ICE);
            state = FlagState.DROPPED_ON_WATER;
        } else {
            state = FlagState.DROPPED;
        }
        Flags.setBannerFacing(Flags.yawToFace(picker.getLocation().getYaw()), newBanner);
        FlagDropEvent event = new FlagDropEvent(getPicker(), this);
        Bukkit.getPluginManager().callEvent(event);
    } else {
        Flags.setBannerFacing(getPost().getYaw(), newBanner);
    }
    Player oldPicker = picker;
    this.lastNet = null;
    resetPlayer();
    for (Player player : Bukkit.getOnlinePlayers()) {
        if (oldPicker != null && player.equals(oldPicker)) continue;
        getPost().tryPickupFlag(player, player.getLocation(), null, this);
        if (picker != null) break;
    }
}
项目:CardinalPGM    文件:Flags.java   
public static void setBannerFacing(BlockFace face, Banner banner) {
    org.bukkit.material.Banner data = (org.bukkit.material.Banner) banner.getMaterialData();
    data.setFacingDirection(face);
    banner.setMaterialData(data);
    banner.update();
}
项目:SupaCommons    文件:BlockUtils.java   
/**
 * Sets up a {@link BlockState} with the properties of a {@link BannerMeta}. This method finally
 * calls {@link BlockState#update(boolean, boolean)} with the first boolean as {@code true} and
 * the second as {@code false}, causing an update but without any physics checks.
 *
 * @param state block state to modify
 * @param bannerMeta banner metadata to apply to {@code block}
 *
 * @throws IllegalArgumentException if the {@code block} is not {@link Material#STANDING_BANNER}
 * or {@link Material#WALL_BANNER}
 */
public static void setBlockBanner(BlockState state, BannerMeta bannerMeta) {
  Preconditions.checkArgument(state instanceof Banner, "block state is not of Banner.");
  Banner bannerState = (Banner) state;
  bannerState.setBaseColor(bannerMeta.getBaseColor());
  bannerState.setPatterns(bannerMeta.getPatterns());
  bannerState.update(true, false);
}
项目:NovaGuilds    文件:BannerUtils.java   
/**
 * Serializes banner into a string
 *
 * @param banner banner meta
 * @return serialized meta
 */
public static String serialize(Banner banner) {
    return getSerializer().serialize(getBannerMeta(banner));
}
项目:NovaGuilds    文件:BannerUtils.java   
/**
 * Applies meta to a banner
 *
 * @param banner banner block
 * @param meta   banner meta
 * @return banner block
 */
public static Banner applyMeta(Banner banner, BannerMeta meta) {
    banner.setBaseColor(meta.getBaseColor());
    banner.setPatterns(meta.getPatterns());
    return banner;
}