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


Java Firework类代码示例

本文整理汇总了Java中org.bukkit.entity.Firework的典型用法代码示例。如果您正苦于以下问题:Java Firework类的具体用法?Java Firework怎么用?Java Firework使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: remove

import org.bukkit.entity.Firework; //导入依赖的package包/类
public void remove(boolean got)
{
    this.entityTitle.remove();
    this.entityItem.remove();
    this.entityBase.remove();

    Color fwColor = got ? Color.BLUE : Color.RED;

    Firework fw = this.location.getWorld().spawn(this.location.clone().add(0.5, 1, 0.5), Firework.class);
    FireworkMeta fwm = fw.getFireworkMeta();
    FireworkEffect effect = FireworkEffect.builder().withColor(fwColor).with(this.parent.isSpecial() ? FireworkEffect.Type.STAR : FireworkEffect.Type.BALL).build();

    fwm.addEffects(effect);
    fwm.setPower(0);

    fw.setFireworkMeta(fwm);

    Bukkit.getScheduler().runTaskLater(SamaGamesAPI.get().getPlugin(), fw::detonate, 1L);

    this.particlesTask.cancel();

    this.alive = false;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:24,代码来源:ActivePowerup.java

示例2: showFlare

import org.bukkit.entity.Firework; //导入依赖的package包/类
private void showFlare() {
    float angle = (float) (this.random.nextFloat() * Math.PI * 2);
    Location location = this.definition.detectRegion.getBounds().center()
                            .plus(
                                new Vector(
                                    Math.sin(angle) * this.definition.flareRadius,
                                    0,
                                    Math.cos(angle) * this.definition.flareRadius
                                )
                            ).toLocation(this.match.getWorld());

    Set<Color> colors = new HashSet<>();

    for(MatchPlayer player : this.playersInside) {
        colors.add(player.getParty().getFullColor());
    }

    Firework firework = FireworkUtil.spawnFirework(location,
                                                   FireworkEffect.builder()
                                                       .with(FireworkEffect.Type.BALL)
                                                       .withColor(colors)
                                                       .build(),
                                                   0);
    NMSHacks.skipFireworksLaunch(firework);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:ProximityAlarm.java

示例3: onPlayerInteract

import org.bukkit.entity.Firework; //导入依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (!(Gizmos.gizmoMap.get(player) instanceof LauncherGizmo)) return;

    if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
    if (player.getItemInHand().getType() != this.getIcon()) return;

    Firework oldFirework = this.launchedPlayers.get(player);
    if (oldFirework == null || oldFirework.isDead()) {
        Firework firework = this.buildFirework(player.getLocation());
        firework.setPassenger(player);
        this.launchedPlayers.put(player, firework);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:LauncherGizmo.java

示例4: playFirework

import org.bukkit.entity.Firework; //导入依赖的package包/类
public void playFirework(Player p, Location loc, Color color1, Color color2, FireworkEffect.Type type) {
	loc.add(0.5, 1, 0.5);
	Firework fw = p.getWorld().spawn(loc, Firework.class);
	FireworkMeta fwmeta = ((org.bukkit.entity.Firework) fw).getFireworkMeta();
	FireworkEffect.Builder builder = FireworkEffect.builder();

	builder.withFlicker();
	builder.withFade(color2);
	builder.withColor(color1);
	builder.with(type);
	fwmeta.clearEffects();
	Field f;
	try {
		f = fwmeta.getClass().getDeclaredField("power");
		f.setAccessible(true);
		f.set(fwmeta, -1);
	} catch (Exception e) {
		return;
	}
	fwmeta.addEffect(builder.build());
	fw.setFireworkMeta(fwmeta);
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:23,代码来源:Utils.java

示例5: launchfw

import org.bukkit.entity.Firework; //导入依赖的package包/类
public static void launchfw(Hub hub, Location location, final FireworkEffect effect)
{
    Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
    FireworkMeta fwm = fw.getFireworkMeta();
    fwm.addEffect(effect);
    fwm.setPower(0);
    fw.setFireworkMeta(fwm);
    ((CraftFirework) fw).getHandle().setInvisible(true);

    hub.getServer().getScheduler().runTaskLater(hub, () ->
    {
        World world = (((CraftWorld) location.getWorld()).getHandle());
        EntityFireworks fireworks = ((CraftFirework) fw).getHandle();
        world.broadcastEntityEffect(fireworks, (byte) 17);
        fireworks.die();
    }, 1);
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:18,代码来源:FireworkUtils.java

示例6: launchFireworkDisplay

import org.bukkit.entity.Firework; //导入依赖的package包/类
public void launchFireworkDisplay(final World w, final Location loc) {
    Firework fw = (Firework) w.spawn(loc.clone().add(new Vector(getRandomNum(5, -5), 1, getRandomNum(5, -5))), Firework.class);
    FireworkMeta meta = fw.getFireworkMeta();
    FireworkEffect effect = SkyWarsReloaded.getNMS().getFireworkEffect(getRandomColor(),getRandomColor(), getRandomColor(), getRandomColor(), getRandomColor(), getRandomType());
    meta.addEffect(effect);
    meta.setPower(getRandomNum(4, 1));
    fw.setFireworkMeta(meta);
    fireworksCount++;
    if (fireworksCount < ((SkyWarsReloaded.getCfg().getTimeAfterGame() - 5)*4)) {
		SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(),  new Runnable() {
			public void run() {
				launchFireworkDisplay(w, loc);
			}
		}, 5);
    }
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:17,代码来源:Game.java

示例7: shot

import org.bukkit.entity.Firework; //导入依赖的package包/类
public static void shot(final Player p)
{

	 
        Location loc = p.getLocation();
        Firework fw = (Firework)loc.getWorld().spawn(loc, Firework.class);
        FireworkMeta data = fw.getFireworkMeta();
        Color c = null;
        Random r = new Random();
        int i = r.nextInt(5) + 1;
        if (i == 1) {
          c = Color.BLUE;
        } else if (i == 2) {
          c = Color.RED;
        } else if (i == 3) {
          c = Color.GREEN;
        } else if (i == 4) {
          c = Color.MAROON;
        } else if (i == 5) {
          c = Color.ORANGE;
        }
        data.addEffects(new FireworkEffect[] { FireworkEffect.builder().withColor(c).with(FireworkEffect.Type.STAR).build() });
        data.setPower(1);
        fw.setFireworkMeta(data);
 
}
 
开发者ID:SpikyBite,项目名称:BiteSkywars,代码行数:27,代码来源:Fireworks.java

示例8: shootFireworkRide

import org.bukkit.entity.Firework; //导入依赖的package包/类
private void shootFireworkRide(Player p) {
    if(!cdFireworkRide.containsKey(p.getName()) || MiscUtils.cooldownCheck(cdFireworkRide.get(p.getName()), cdFireworkRideSec)){
        final Location loc = p.getLocation();
        Firework fw = GadgetMethods.shootFirework(p.getLocation(), p.getWorld().getName());
        fw.setPassenger(p);
        TitleUtils.sendActionTag(p, "FireworkRide", "&lWHEEE!");
        final Player pfinal = p;
        cdFireworkRide.put(p.getName(), System.currentTimeMillis());
        ScheduleUtils.scheduleTask(100, new Runnable() {
            @Override
            public void run() {
                pfinal.teleport(loc);
            }
        });
    } else {
        TitleUtils.sendActionTag(p, "FireworkRide", ChatUtils.error + "Je moet nog &c" + MiscUtils.formatTime(MiscUtils.getTimeRemaining(cdFireworkRide.get(p.getName()), cdFireworkRideSec)) +
                " &awachten voordat je dit weer mag gebruiken.");
    }
}
 
开发者ID:Cooltimmetje,项目名称:PretparkCore,代码行数:20,代码来源:GadgetTriggers.java

示例9: KimuraFirework

import org.bukkit.entity.Firework; //导入依赖的package包/类
@EventHandler
public void KimuraFirework(PlayerDeathEvent event) {
    Player player = event.getEntity();

    // check if player is Kimura or not
    if (!player.getPlayerListName().contains("schinchig")) return;

    // spawn Firework
    World world = player.getWorld();
    Firework firework = (Firework) world.spawnEntity(player.getLocation(), EntityType.FIREWORK);

    // set firework random meta infomations
    FireworkMeta meta = firework.getFireworkMeta();
    FireworkEffect.Builder builder = FireworkEffect.builder();

    builder.withColor(getRandomColors(1 + rand.nextInt(5)));
    builder.withFade(getRandomColors(1 + rand.nextInt(3)));
    builder.flicker(rand.nextBoolean());
    builder.trail(rand.nextBoolean());
    builder.with(FireworkEffect.Type.values()[rand.nextInt(5)]);

    meta.setPower(1 + rand.nextInt(4));

    meta.addEffect(builder.build());
    firework.setFireworkMeta(meta);
}
 
开发者ID:popkirby,项目名称:KimuraPlugin,代码行数:27,代码来源:KimuraFireworkOnDeath.java

示例10: loop

import org.bukkit.entity.Firework; //导入依赖的package包/类
public void loop(){
	Bukkit.getScheduler().scheduleSyncRepeatingTask(Bukkit.getServer().getPluginManager().getPlugin("gFeatures"), new Runnable() {
       	public void run(){
       		try{
       			if(Basic.flagger instanceof Player){
       				Firework fw = (Firework) Bukkit.getServer().getWorld(Basic.mapName).spawnEntity(Basic.flagger.getLocation(), EntityType.FIREWORK);
       				FireworkMeta fwm = fw.getFireworkMeta();
       				FireworkEffect effect = FireworkEffect.builder().withColor(Color.WHITE).with(Type.BALL).build();

       				fwm.addEffect(effect);
       				fwm.setPower(2);

       				fw.setFireworkMeta(fwm);
       			}
       		}
       		catch(Exception e){}
       	}
       }, 80L, 80L);
}
 
开发者ID:EstiNet,项目名称:gFeatures,代码行数:20,代码来源:Capture.java

示例11: spawnFirework

import org.bukkit.entity.Firework; //导入依赖的package包/类
public void spawnFirework(Location location) {
    Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
    FireworkMeta fwm = fw.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;
    int r1i = r.nextInt(17) + 1;
    int r2i = r.nextInt(17) + 1;
    Color c1 = getColor(r1i);
    Color c2 = getColor(r2i);
    FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
    fwm.addEffect(effect);
    int rp = r.nextInt(2) + 1;
    fwm.setPower(rp);
    fw.setFireworkMeta(fwm);
}
 
开发者ID:ConnorLinfoot,项目名称:CratesPlus,代码行数:22,代码来源:CrateHandler.java

示例12: makePacket

import org.bukkit.entity.Firework; //导入依赖的package包/类
/**
 * Make a packet object
 *
 * @param location       Location to play firework effect at
 * @param fireworkEffect FireworkEffect to play
 * @return Packet constructed by the parameters
 */
private static Object makePacket(Location location, FireworkEffect fireworkEffect) {
    try {
        Firework firework = location.getWorld().spawn(location, Firework.class);
        FireworkMeta data = firework.getFireworkMeta();
        data.clearEffects();
        data.setPower(1);
        data.addEffect(fireworkEffect);
        firework.setFireworkMeta(data);
        Object nmsFirework = ReflectionUtil.getHandle(firework);
        firework.remove();
        return PACKET_PLAY_OUT_ENTITY_STATUS.newInstance(nmsFirework, (byte) 17);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:ModernDayPlayer,项目名称:SurvivalGamesX,代码行数:24,代码来源:FireworkEffectPlayer.java

示例13: onCreeperDetonate

import org.bukkit.entity.Firework; //导入依赖的package包/类
/**
 * Event handler called when an explosive is primed.
 * 
 * We use it to detect impending creeper explosions. The event is fired
 * immediately before the explosion.
 */
@EventHandler(ignoreCancelled = true)
public void onCreeperDetonate(ExplosionPrimeEvent event) {
    if (!CONFIG.isAffectedWorld(event)) {
        return;
    }

    if (event.getEntityType() == EntityType.CREEPER) {
        event.setRadius((float) CONFIG.BLAST_RADIUS_SCALE * event.getRadius());

        Entity creeper = event.getEntity();
        launchReinforcements(creeper);

        Location origin = creeper.getLocation();
        World world = origin.getWorld();
        Firework firework = (Firework) world.spawnEntity(origin, EntityType.FIREWORK);
        if (firework != null) {
            FireworkMeta meta = firework.getFireworkMeta();
            meta.setPower(random(0, 1));
            meta.addEffect(randomFireworkFffect(true));
            firework.setFireworkMeta(meta);
        }
    }
}
 
开发者ID:NerdNu,项目名称:Creepocalypse,代码行数:30,代码来源:Creepocalypse.java

示例14: shootRandomFirework

import org.bukkit.entity.Firework; //导入依赖的package包/类
public static void shootRandomFirework(Location loc, int height) {
	Firework f = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
	FireworkMeta fm = f.getFireworkMeta();
	fm.setPower(height);
	int effectAmount = random.nextInt(3) + 1;
	for(int i = 0; i < effectAmount; i++) {
		Builder b = FireworkEffect.builder();
		int colorAmount = random.nextInt(3) + 1;
		for(int ii = 0; ii < colorAmount; ii++) {
			b.withColor(Color.fromBGR(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
		}
		b.with(Type.values()[random.nextInt(Type.values().length)]);
		b.flicker(random.nextInt(2) == 0 ? false : true);
		b.trail(random.nextInt(2) == 0 ? false : true);
		fm.addEffect(b.build());
	}
	f.setFireworkMeta(fm);
}
 
开发者ID:maker56,项目名称:UltimateSurvivalGames,代码行数:19,代码来源:Util.java

示例15: spawnFirework

import org.bukkit.entity.Firework; //导入依赖的package包/类
public static void spawnFirework(Location loc) {
    Random colour = new Random();
    
    Firework fw = loc.getWorld().spawn(loc, Firework.class);
    FireworkMeta fwMeta = fw.getFireworkMeta();
    
    Type fwType = Type.BALL_LARGE;
    
    int c1i = colour.nextInt(17) + 1;
    int c2i = colour.nextInt(17) + 1;
    
    Color c1 = getFWColor(c1i);
    Color c2 = getFWColor(c2i);
    
    FireworkEffect effect = FireworkEffect.builder().withFade(c2).withColor(c1).with(fwType).build();
    
    fwMeta.addEffect(effect);
    fwMeta.setPower(1);
    fw.setFireworkMeta(fwMeta);
}
 
开发者ID:cancabron,项目名称:Annihilation,代码行数:21,代码来源:Util.java


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