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


Java FireworkMeta.addEffect方法代码示例

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


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

示例1: playFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的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

示例2: launchfw

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的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

示例3: launchFireworkDisplay

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的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

示例4: KimuraFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的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

示例5: getFireworkMeta

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public static FireworkMeta getFireworkMeta(JSONObject json) {
    try {
        FireworkMeta dummy = (FireworkMeta) new ItemStack(Material.FIREWORK).getItemMeta();
        dummy.setPower(json.optInt("power", 1));
        JSONArray effects = json.getJSONArray("effects");
        for (int i = 0; i < effects.length(); i++) {
            JSONObject effectDto = effects.getJSONObject(i);
            FireworkEffect effect = FireworkEffectSerialization.getFireworkEffect(effectDto);
            if (effect != null)
                dummy.addEffect(effect);
        }
        return dummy;
    } catch (JSONException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:ThisIzEthan,项目名称:NexusInventory,代码行数:18,代码来源:FireworkSerialization.java

示例6: spawnFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的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

示例7: onCreeperDetonate

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的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

示例8: spawnFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的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

示例9: Fireworks

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public static void Fireworks(Player p){
	Firework rfw = (Firework) p.getWorld()
			.spawnEntity(p.getLocation(),EntityType.FIREWORK);
	FireworkMeta rfwm = rfw.getFireworkMeta();
	FireworkEffect.Type rtype = FireworkEffect.Type.BALL_LARGE;
	FireworkEffect reffect = (FireworkEffect.builder().trail(false)
			.withColor(Color.RED).flicker(false).with(rtype).build());
	rfwm.addEffect(reffect);
	rfwm.setPower(0);
	rfw.setFireworkMeta(rfwm);

	Firework gfw = (Firework) p.getWorld()
			.spawnEntity(p.getLocation(),EntityType.FIREWORK);
	FireworkMeta gfwm = gfw.getFireworkMeta();
	FireworkEffect.Type gtype = FireworkEffect.Type.BALL_LARGE;
	FireworkEffect geffect = (FireworkEffect.builder().trail(false)
			.withColor(Color.LIME).flicker(false).with(gtype).build());
	gfwm.addEffect(geffect);
	gfwm.setPower(0);
	gfw.setFireworkMeta(gfwm);
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:22,代码来源:Fireworks.java

示例10: shot

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void shot(Location location)
{
    Firework firework = (Firework)location.getWorld().spawnEntity(location, EntityType.FIREWORK);
    FireworkEffect.Builder effect = FireworkEffect.builder();

    for (int cc = 1; cc <= colorCounter; cc++) {
        effect.withColor(colors[cc]);
    }

    FireworkMeta meta = firework.getFireworkMeta();
    effect.with(type);
    if (this.fadeTo != null) {
        effect.withFade(fadeTo);
    }

    meta.setPower(this.duration);
    meta.addEffect(effect.build());
    firework.setFireworkMeta(meta);
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:20,代码来源:FireworksFactory.java

示例11: getAsStack

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public ItemStack getAsStack(int _stackSize)
{
    ItemStack item = new ItemStack(Material.FIREWORK, _stackSize);
    FireworkEffect.Builder effect = FireworkEffect.builder();

    String colorString = "";

    for (int cc = 1; cc <= colorCounter; cc++) {
        effect.withColor(colors[cc]);
        colorString = colorString + " " + this.colorToString(colors[cc]);
    }

    FireworkMeta meta = (FireworkMeta) item.getItemMeta();
    meta.setDisplayName("Firework: " + colorString + " " + this.effectToString(this.type)  );
    effect.with(type);

    if (this.fadeTo != null) {
        effect.withFade(fadeTo);
    }

    meta.setPower(this.duration);
    meta.addEffect(effect.build());
    item.setItemMeta(meta);

    return item;
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:27,代码来源:FireworksFactory.java

示例12: LaunchFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
 * Launch a firework at a given location with specified properties
 * 
 * @param spawnLocation the location for the firework
 * @param type the firework type
 * @param power the power of the firework
 * @param colors the colors of the fireworks
 * @param fadecolors the colors for the firework to fade to
 * @param trail if the firework should leave a trail
 * @param flicker if the firework should flicker
 */
static public Firework LaunchFirework(Location spawnLocation, FireworkEffect.Type type, int power, ArrayList<Color> colors, ArrayList<Color> fadecolors, boolean flicker, boolean trail) {

	Firework firework = spawnLocation.getWorld().spawn(spawnLocation, Firework.class);
	FireworkMeta metadata = firework.getFireworkMeta();

	Builder builder = FireworkEffect.builder();
	builder.with(type);
	builder.flicker(flicker);
	builder.trail(trail);
	builder.withColor(colors);
	builder.withFade(fadecolors);

	FireworkEffect effect = builder.build();
	metadata.addEffect(effect);
	metadata.setPower(power);

	firework.setFireworkMeta(metadata);
	
	return firework;
}
 
开发者ID:CodingBadgers,项目名称:MineKart,代码行数:32,代码来源:FireworkFactory.java

示例13: onRankUpEvent

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
@EventHandler
public void onRankUpEvent(RankUpEvent event){
	Player player = Bukkit.getPlayer(event.getUserID());
	User user = userManager.getUser(event.getUserID());
	user.addRank();
	user.addToken();
	user.scoreboard();
	player.sendMessage(ChatColor.AQUA + "You Ranked up!");
	Location loc = player.getLocation();
	Firework firework = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
	FireworkMeta meta = firework.getFireworkMeta();
	FireworkEffect fe = FireworkEffect.builder().with(Type.BALL_LARGE).withColor(Color.BLUE).build();
	meta.addEffect(fe);
	meta.setPower(3);
	firework.setFireworkMeta(meta);
}
 
开发者ID:cblacks26,项目名称:VSkills,代码行数:17,代码来源:VSkillsListener.java

示例14: onBowShoot

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
@EventHandler
public void onBowShoot(EntityShootBowEvent event) {
    FireworkMeta fireworkMeta = (FireworkMeta) (new ItemStack(
            Material.FIREWORK)).getItemMeta();
    Firework firework = (Firework) event
            .getProjectile()
            .getLocation()
            .getWorld()
            .spawnEntity(event.getProjectile().getLocation(),
                    EntityType.FIREWORK);

    fireworkMeta.addEffect(FireworkEffect.builder().with(Type.BURST)
            .withColor(Color.RED).withColor(Color.WHITE)
            .withColor(Color.BLUE).withTrail().build());
    firework.setFireworkMeta(fireworkMeta);
    event.getProjectile().setPassenger(firework);
}
 
开发者ID:psgs,项目名称:ServerUtils,代码行数:18,代码来源:FestiveArrows.java

示例15: randomizeFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
private void randomizeFirework(Firework firework) {
    FireworkEffect.Builder effect = FireworkEffect.builder();
    FireworkMeta meta = firework.getFireworkMeta();

    // construct [1, 3] random colours
    int numColours = r.nextInt(3) + 1;
    Color[] colourArray = new Color[numColours];
    for (int i = 0; i < numColours; i++) {
        colourArray[i] = getColor(r.nextInt(17) + 1);
    }

    // randomize effects
    effect.withColor(colourArray);
    effect.flicker(r.nextDouble() < 0.5);
    effect.trail(r.nextDouble() < 0.5);
    effect.with(FireworkEffect.Type.values()[r.nextInt(FireworkEffect.Type.values().length)]);

    // set random effect and randomize power
    meta.addEffect(effect.build());
    meta.setPower(r.nextInt(2) + 1);

    // apply it to the given firework
    firework.setFireworkMeta(meta);
}
 
开发者ID:Gibstick,项目名称:DiscoSheep,代码行数:25,代码来源:FireworkParty.java


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