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


Java Player.setArrowsStuck方法代码示例

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


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

示例1: cycleToUnsafe

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Creates and loads a new {@link Match} on the given map, optionally unloading an old
 * match and transferring all players to the new one.
 *
 * @param oldMatch      if given, this match is unloaded and all players are transferred to the new match
 * @param newMap        the map to load for the new match
 * @return              the newly loaded {@link Match}
 * @throws Throwable    generally, any exceptions thrown during loading/unloading are propagated
 */
private Match cycleToUnsafe(@Nullable Match oldMatch, PGMMap newMap) throws Throwable {
    this.log.info("Cycling to " + newMap.toString());

    // End the old match if it's still running
    if(oldMatch != null) oldMatch.ensureNotRunning();

    // Create and load the new match.
    // Starting here, there are two "current" matches. While that is true,
    // we have to explicitly specify a current match during any calls that
    // might try to acquire it, either by calling one of the getCurrentMatch
    // methods in this class, or injecting a @MatchScoped dependency.
    final Match newMatch = loadMatch(newMap);

    if(oldMatch != null) {
        // Build a list of players to move from the old match to the new one.
        // Ensure player is online before moving them. This should clean up
        // any mess caused by a previous failure to remove them.
        final List<Player> players = oldMatch.players()
                                             .filter(MatchPlayer::isOnline)
                                             .map(MatchPlayer::getBukkit)
                                             .collect(Collectors.toCollection(ArrayList::new));

        // Add players to the new match in random order, to avoid any
        // repetition between matches when auto-join is enabled.
        Collections.shuffle(players);

        // Teleport players between worlds
        for(Player player : players) {
            player.teleport(newMatch.getWorld().getSpawnLocation());
            player.setArrowsStuck(0);
        }

        // Remove players from the old match
        oldMatch.asCurrentScope(oldMatch::removeAllPlayers);

        // Add them to the new one
        newMatch.asCurrentScope(() -> newMatch.addAllPlayers(players.stream()));

        // Unload the old match.
        // After this method returns, there is a single "current match",
        // and we don't need to specify it explicitly any more.
        unloadMatch(oldMatch);
    }

    eventBus.callEvent(new CycleEvent(newMatch, oldMatch));
    log.info("Loaded " + newMap.toString());
    return newMatch;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:58,代码来源:MatchLoader.java


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