當前位置: 首頁>>代碼示例>>Java>>正文


Java FireworkEffect.Type方法代碼示例

本文整理匯總了Java中org.bukkit.FireworkEffect.Type方法的典型用法代碼示例。如果您正苦於以下問題:Java FireworkEffect.Type方法的具體用法?Java FireworkEffect.Type怎麽用?Java FireworkEffect.Type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.FireworkEffect的用法示例。


在下文中一共展示了FireworkEffect.Type方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static FireworkEffect parse(Config config) {
    boolean flicker = config.getBool("flicker", false);
    boolean trail = config.getBool("trail", false);
    List<Color> colors = ((Collection<String>)config.getCollection("colors", Collections.emptyList()))
            .stream()
            .map(ConfigUtil::parseColor)
            .collect(Collectors.toList());
    List<Color> fadeColors = ((Collection<String>)config.getCollection("fade-colors", Collections.emptyList()))
            .stream()
            .map(ConfigUtil::parseColor)
            .collect(Collectors.toList());
    FireworkEffect.Type type = parseFireworkEffectType(config.getString("type", FireworkEffect.Type.BALL.name()));
    return FireworkEffect.builder()
            .flicker(flicker)
            .trail(trail)
            .withColor(colors)
            .withFade(fadeColors)
            .with(type)
            .build();
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:22,代碼來源:FireworkChargeCustomItem.java

示例2: playFirework

import org.bukkit.FireworkEffect; //導入方法依賴的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

示例3: randomType

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
private FireworkEffect.Type randomType() {
	int i = random.nextInt(5) + 1;
	FireworkEffect.Type type = null;
	if (i == 1) {
		type = FireworkEffect.Type.BALL;
	} else if (i == 2) {
		type = FireworkEffect.Type.BALL_LARGE;
	} else if (i == 3) {
		type = FireworkEffect.Type.BURST;
	} else if (i == 4) {
		type = FireworkEffect.Type.CREEPER;
	} else if (i == 5) {
		type = FireworkEffect.Type.STAR;
	}
	return type;
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:17,代碼來源:EffFirework.java

示例4: parseFireworkEffectType

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
public static FireworkEffect.Type parseFireworkEffectType(String s) {
    if (s == null)
        throw new InvalidConfigException("Missing firework effect type!");
    try {
        return FireworkEffect.Type.valueOf(s.replace(' ', '_').toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException e) {
        throw new InvalidConfigException("Cannot find firework effect type: \"" + s + "\"");
    }
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:10,代碼來源:ConfigUtil.java

示例5: onProjectileHit

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) throws Exception {
	if (fireballList.contains(e.getEntity().getUniqueId())) {
		Location fireballHitLocation = e.getEntity().getLocation();
		if(!KingdomFactionsPlugin.getInstance().getDataManager().getBoolean("Test.enabled")) {
		fireballHitLocation.getWorld().createExplosion(fireballHitLocation.getX(), fireballHitLocation.getY(),
				fireballHitLocation.getZ(), 4, true, true);
		} else {
			fireballHitLocation.getWorld().createExplosion(fireballHitLocation.getX(), fireballHitLocation.getY(),
					fireballHitLocation.getZ(), 4, true, false);
		}

		FireworkEffect.Type type = FireworkEffect.Type.BALL_LARGE;
		Color c1 = Color.ORANGE;
		Color c2 = Color.RED;

		FireworkEffect effect = FireworkEffect.builder().flicker(true).withColor(c1).withFade(c2).with(type)
				.trail(true).build();

		FireworkEffectPlayer fireworkPlayer = new FireworkEffectPlayer();

		fireworkPlayer.playFirework(fireballHitLocation.getWorld(), fireballHitLocation, effect);
		for (Entity ent : Utils.getInstance().getNearbyEntities(fireballHitLocation, 5)) {
			if ((ent instanceof LivingEntity)) {
				ent.setFireTicks(ent.getFireTicks() + 60);
			}
		}
		fireballList.remove(e.getEntity().getUniqueId());
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:31,代碼來源:Comet.java

示例6: spawnRandom

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
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;
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:29,代碼來源:FireworkUtil.java

示例7: getOriginal

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
@Override
public Object getOriginal() {
    FireworkEffect.Type t =  FireworkEffect.Type.BALL;
    try{
        t = FireworkEffect.Type.valueOf(fireworkType);
    }catch (Exception ex){}
    if(((List<Color>)main.getOriginal()).size() >= 1)
     return FireworkEffect.builder().with(t).flicker(isFlicker).trail(trail).withColor((List<Color>)main.getOriginal()).withFade((List<Color>)fade.getOriginal()).build();
    return null;
}
 
開發者ID:DevCrafters,項目名稱:SaveableSerializing,代碼行數:11,代碼來源:FireworkEffects.java

示例8: spawnRandomFirework

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
/**
 * Spawn a firework with a randomized meta at the location.
 * @param loc The location to spawn at.
 */
public static Firework spawnRandomFirework(Location loc) {
    Firework fw = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
    FireworkMeta fwm = fw.getFireworkMeta();
    FireworkEffect.Type type = FireworkEffect.Type.values()[(int) (Math.random() * FireworkEffect.Type.values().length - 1)];
    Color c1 = Color.fromRGB(RMath.randInt(0, 255), RMath.randInt(0, 255), RMath.randInt(0, 255));
    Color c2 = Color.fromRGB(RMath.randInt(0, 255), RMath.randInt(0, 255), RMath.randInt(0, 255));
    FireworkEffect effect = FireworkEffect.builder().flicker(Math.random() > 0.5).withColor(c1).withFade(c2).with(type).trail(Math.random() > 0.5).build();
    fwm.addEffect(effect);
    fwm.setPower(RMath.randInt(1, 2));
    fw.setFireworkMeta(fwm);
    return fw;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:17,代碼來源:RParticles.java

示例9: shootFirework

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
public static Firework shootFirework(Location loc, String world){
    //Spawn the Firework, get the FireworkMeta.
    final Firework fw = (Firework) Bukkit.getWorld(world).spawnEntity(loc, EntityType.FIREWORK);
    FireworkMeta fwm = fw.getFireworkMeta();

    //Our random generator
    Random r = new Random();

    //Get the type
    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.BURST;
    if (rt == 3) type = FireworkEffect.Type.STAR;
    if (rt == 4) type = FireworkEffect.Type.CREEPER;
    if (rt == 5) type = FireworkEffect.Type.BALL_LARGE;

    //Get our random colours
    int r1i = r.nextInt(17) + 1;
    int r2i = r.nextInt(17) + 1;
    Color c1 = getColor(r1i);
    Color c2 = getColor(r2i);

    //Create our effect with this
    FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(c1).withFade(c2).with(type).trail(true).build();

    //Then apply the effect to the meta
    fwm.addEffect(effect);

    //Generate some random power and set it
    int rp = r.nextInt(2) + 1;
    fwm.setPower(rp);

    //Then apply this to our rocket
    fw.setFireworkMeta(fwm);
    return fw;
}
 
開發者ID:Cooltimmetje,項目名稱:PretparkCore,代碼行數:38,代碼來源:MiscUtils.java

示例10: shootFirework

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
public static Firework shootFirework(Location loc, String world){
    //Spawn the Firework, get the FireworkMeta.
    Firework fw = (Firework) Bukkit.getWorld(world).spawnEntity(loc, EntityType.FIREWORK);
    FireworkMeta fwm = fw.getFireworkMeta();

    //Our random generator
    Random r = new Random();

    //Get the type
    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.BURST;
    if (rt == 3) type = FireworkEffect.Type.STAR;
    if (rt == 4) type = FireworkEffect.Type.CREEPER;
    if (rt == 5) type = FireworkEffect.Type.BALL_LARGE;

    //Get our random colours
    int r1i = r.nextInt(17) + 1;
    int r2i = r.nextInt(17) + 1;
    Color c1 = getColor(r1i);
    Color c2 = getColor(r2i);

    //Create our effect with this
    FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(c1).withFade(c2).with(type).trail(true).build();

    //Then apply the effect to the meta
    fwm.addEffect(effect);

    //Generate some random power and set it
    int rp = r.nextInt(2) + 1;
    fwm.setPower(rp);

    //Then apply this to our rocket
    fw.setFireworkMeta(fwm);
    return fw;
}
 
開發者ID:Cooltimmetje,項目名稱:PretparkCore,代碼行數:38,代碼來源:GadgetMethods.java

示例11: run

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
@Override
public void run()
{
    if (this.time < 20)
    {
        Firework fw = (Firework) player.getWorld().spawnEntity(player.getPlayer().getLocation(), 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;
        else if (rt == 2)
            type = FireworkEffect.Type.BALL_LARGE;
        else if (rt == 3)
            type = FireworkEffect.Type.BURST;
        else if (rt == 4)
            type = FireworkEffect.Type.CREEPER;
        else if (rt == 5)
            type = FireworkEffect.Type.STAR;

        int r1i = r.nextInt(15) + 1;
        int r2i = r.nextInt(15) + 1;

        Color c1 = ColorUtils.getColor(r1i);
        Color c2 = ColorUtils.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);

        this.time++;
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:42,代碼來源:WinEffect.java

示例12: getFireworkEffect

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
public FireworkEffect getFireworkEffect(Color one, Color two, Color three, Color four, Color five, FireworkEffect.Type type)
{
  return FireworkEffect.builder().flicker(false).withColor(new Color[] { one, two, three, four }).withFade(five).with(type).trail(true).build();
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:5,代碼來源:NMSHandler.java

示例13: spawnFirework

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
public static Firework spawnFirework(Location l, FireworkEffect.Type type, Color color, Color fade, int power){
    return spawnFirework(l, type, color, fade, true, true, power);
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:4,代碼來源:FireworkAPI.java

示例14: get

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
public static FireworkEffect.Type get(String string) {
    return instance()._get(string);
}
 
開發者ID:GameBoxx,項目名稱:GameBoxx,代碼行數:4,代碼來源:FireworkEffects.java

示例15: getName

import org.bukkit.FireworkEffect; //導入方法依賴的package包/類
public static String getName(FireworkEffect.Type key) {
    return instance()._getName(key);
}
 
開發者ID:GameBoxx,項目名稱:GameBoxx,代碼行數:4,代碼來源:FireworkEffects.java


注:本文中的org.bukkit.FireworkEffect.Type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。