FireworkUtil.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:Warzone 作者:
public static @Nonnull Firework spawnFirework(@Nonnull Location location, @Nonnull FireworkEffect effect, int power) {
    Preconditions.checkNotNull(location, "location");
    Preconditions.checkNotNull(effect, "firework effect");
    Preconditions.checkArgument(power >= 0, "power must be positive");

    FireworkMeta meta = (FireworkMeta) Bukkit.getItemFactory().getItemMeta(Material.FIREWORK);
    meta.setPower(power > 0 ? (power - 1) : power);
    meta.addEffect(effect);

    Firework firework = (Firework) location.getWorld().spawnEntity(location.add(0.5, 0.0, 0.5), EntityType.FIREWORK);
    firework.setFireworkMeta(meta);
    if (power == 0) Bukkit.getScheduler().runTaskLater(TGM.get(), firework::detonate, 1L);

    return firework;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号