org.bukkit.FireworkEffect#Type ( )源码实例Demo

下面列出了org.bukkit.FireworkEffect#Type ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Skript   文件: ExprFireworkEffect.java
@SuppressWarnings({"null", "unchecked"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
	flicker = parseResult.mark == 2 || parseResult.mark > 3;
	trail = parseResult.mark >= 3;
	hasFade = matchedPattern == 1;
	type = (Expression<FireworkEffect.Type>) exprs[0];
	color = (Expression<Color>) exprs[1];
	if (hasFade)
		fade = (Expression<Color>) exprs[2];
	return true;
}
 
源代码2 项目: DungeonsXL   文件: FireworkUtil.java
/**
 * Spawns a randomized firework.
 *
 * @param location the location where the firework is fired
 * @return the Firework
 */
public static Firework spawnRandom(Location location) {
    Firework firework = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
    FireworkMeta meta = firework.getFireworkMeta();
    Random r = new Random();
    int rt = r.nextInt(4) + 1;
    FireworkEffect.Type type = FireworkEffect.Type.BALL;
    if (rt == 1) {
        type = FireworkEffect.Type.BALL;
    }
    if (rt == 2) {
        type = FireworkEffect.Type.BALL_LARGE;
    }
    if (rt == 3) {
        type = FireworkEffect.Type.BURST;
    }
    if (rt == 4) {
        type = FireworkEffect.Type.CREEPER;
    }
    if (rt == 5) {
        type = FireworkEffect.Type.STAR;
    }
    FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(randomColor()).withFade(randomColor()).with(type).trail(r.nextBoolean()).build();
    meta.addEffect(effect);
    int rp = r.nextInt(2) + 1;
    meta.setPower(rp);
    firework.setFireworkMeta(meta);
    return firework;
}
 
源代码3 项目: SkyWarsReloaded   文件: Util.java
public void fireworks(final Player player, final int length, final int fireworksPer5Tick) {
    final List<FireworkEffect.Type> type = new ArrayList<>(Arrays.asList(FireworkEffect.Type.BALL, FireworkEffect.Type.BALL_LARGE, FireworkEffect.Type.BURST, FireworkEffect.Type.STAR, FireworkEffect.Type.CREEPER));
    final List<Color> colors = new ArrayList<>(Arrays.asList(Color.AQUA, Color.BLACK, Color.BLUE, Color.FUCHSIA, Color.GRAY, Color.GREEN, Color.LIME, Color.MAROON, Color.NAVY, Color.OLIVE, Color.ORANGE, Color.PURPLE, Color.RED, Color.SILVER, Color.TEAL, Color.WHITE, Color.YELLOW));
    final long currentTime = System.currentTimeMillis();
    Random rand = new Random();
    if (SkyWarsReloaded.get().isEnabled()) {
        new BukkitRunnable() {
            public void run() {
                if (System.currentTimeMillis() >= currentTime + length * 1000 || SkyWarsReloaded.get().getServer().getPlayer(player.getUniqueId()) == null) {
                    this.cancel();
                }
                else {
                    for (int i = 0; i < fireworksPer5Tick; ++i) {
                        final Location loc = player.getLocation();
                        @SuppressWarnings({ "unchecked", "rawtypes" })
			final Firework firework = (Firework)player.getLocation().getWorld().spawn(loc, (Class)Firework.class);
                        final FireworkMeta fMeta = firework.getFireworkMeta();
                        FireworkEffect fe = FireworkEffect.builder().withColor(colors.get(rand.nextInt(17))).withColor(colors.get(rand.nextInt(17)))
                                .withColor(colors.get(rand.nextInt(17))).with(type.get(rand.nextInt(5))).trail(rand.nextBoolean())
                                .flicker(rand.nextBoolean()).build();
                        fMeta.addEffects(fe);
                        fMeta.setPower(new Random().nextInt(2) + 2);
                        firework.setFireworkMeta(fMeta);
                    }
                }
            }
        }.runTaskTimer(SkyWarsReloaded.get(), 0L, 5L);
    }
}
 
 方法所在类
 同类方法