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