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


Java FireworkMeta.addEffects方法代码示例

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


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

示例1: remove

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

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

示例3: onNewLevel

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
@EventHandler
public void onNewLevel(PlayerLevelChangeEvent event) {
    Player player = event.getPlayer();
    if (event.getNewLevel() == 30) {
        MessageFormat formatter = new MessageFormat(Language.getBundle().getString("exp-treasury.reminder"));
        player.sendMessage(formatter.format(new Object[]{30}));
    }

    if (event.getOldLevel() < event.getNewLevel() && bank.getConfig().getBoolean("fireworks")) {
        Firework firework = player.getWorld().spawn(event.getPlayer().getLocation(), Firework.class);
        FireworkMeta meta = firework.getFireworkMeta();
        meta.addEffects(FireworkEffect.builder().withColor(Color.BLACK, Color.YELLOW, Color.RED).withFlicker().withFade(Color.YELLOW, Color.RED, Color.BLACK).withTrail().build());
        meta.setPower(1);
        firework.setFireworkMeta(meta);
    }

}
 
开发者ID:caspervg,项目名称:ExpTreasury,代码行数:18,代码来源:ExpLevelListener.java

示例4: processMeta

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
@Override
public void processMeta(Player player, ItemMeta m) {
    super.processMeta(player, m);
    FireworkMeta meta = (FireworkMeta) m;
    meta.clearEffects();
    meta.addEffects(effects);
    if(power != null)
        meta.setPower(power.resolve(player));
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:10,代码来源:FireworkCustomItem.java

示例5: spawnFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
 * Spawn a firework at the given location.
 * @param loc
 * @param firework
 */
public static void spawnFirework(Location loc, FireworkEffect.Builder firework) {
    Firework fw = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
    FireworkMeta meta = fw.getFireworkMeta();
    meta.setPower(0);
    meta.addEffects(firework.build());
    fw.setFireworkMeta(meta);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:13,代码来源:Utils.java

示例6: displayFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
 * Launches firework when receiving an achievement.
 *
 * @param player
 */
private void displayFirework(Player player) {
	Location location = player.getLocation();
	try {
		// Set firework to launch beneath user.
		location.setY(location.getY() - 1);

		Firework firework = player.getWorld().spawn(location, Firework.class);
		FireworkMeta fireworkMeta = firework.getFireworkMeta();
		Builder effectBuilder = FireworkEffect.builder().flicker(false).trail(false)
				.withColor(Color.WHITE.mixColors(Color.BLUE.mixColors(Color.NAVY))).withFade(Color.PURPLE);
		setFireworkType(effectBuilder);
		fireworkMeta.addEffects(effectBuilder.build());
		firework.setVelocity(player.getLocation().getDirection().multiply(0));
		firework.setFireworkMeta(fireworkMeta);

		// Firework launched by plugin: damage will later be cancelled out.
		plugin.getFireworkListener().addFirework(firework);
	} catch (Exception e) {
		// Particle effect workaround to handle various bugs in early Spigot 1.9 and 1.11 releases. We try to
		// simulate a firework.
		player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_LAUNCH, 1, 0.6f);
		ParticleEffect.FIREWORKS_SPARK.display(0, 3, 0, 0.1f, 500, location, 1);
		player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_BLAST, 1, 0.6f);
		player.getWorld().playSound(location, Sound.ENTITY_FIREWORK_TWINKLE, 1, 0.6f);
	}
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:32,代码来源:PlayerAdvancedAchievementListener.java

示例7: playFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
/**
 * <p>
 * This method provides a version independent way to instantly explode {@code FireworkEffect}s at a given location.
 * It uses {@link org.bukkit.entity.Entity#setTicksLived(int) setTicksLived} to accomplish this.
 * </p>
 * @param location The location at which to display the firework effects.
 * @param effects The firework effects to render.
 */
public static void playFirework(Location location, FireworkEffect... effects) {
	Validate.notNull(location, "The location of the effect must not be null.");
	Validate.notNull(location.getWorld(), "The location must not have a null world.");
	Validate.noNullElements(effects, "Null firework effects are not allowed.");

	// Bukkity load (CraftFirework)
	World world = location.getWorld();
	Firework fw = world.spawn(location, Firework.class);

	/*
	 * Now we mess with the metadata, allowing nice clean spawning of a pretty firework (look, pretty lights!)
	 */
	// metadata load
	FireworkMeta data = fw.getFireworkMeta();
	// clear existing
	data.clearEffects();
	// power of one
	data.setPower(1);
	// add the effects
	data.addEffects(effects);
	// set the meta
	fw.setFireworkMeta(data);

	// Set the "ticks flown" to a high value - game will remove everything after playing the effect
	fw.setTicksLived(123);
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:35,代码来源:Utilities.java

示例8: launchRandomFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void launchRandomFirework(Location loc){
Firework fw = loc.getWorld().spawn(loc, Firework.class);
FireworkMeta fm = fw.getFireworkMeta();
fm.setPower(1);
//Adding all the effects to the firework meta
fm.addEffects(FireworkEffect.builder().with(getRandomType()).withColor(getRandomBGRColor()).build());
//set the firework meta to the firework!
fw.setFireworkMeta(fm);
}
 
开发者ID:devBuzzy,项目名称:Dexoria-Hub,代码行数:10,代码来源:RandomFirework.java

示例9: launchRandomFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void launchRandomFirework(Location loc)
{
    Firework fw = loc.getWorld().spawn(loc, Firework.class);
    FireworkMeta fm = fw.getFireworkMeta();
    fm.setPower(1);
    //Adding all the effects to the firework meta
    fm.addEffects(FireworkEffect.builder().with(getRandomType()).withColor(getRandomColor()).build());
    //set the firework meta to the firework!
    fw.setFireworkMeta(fm);
}
 
开发者ID:Dudemister1999,项目名称:Keywords,代码行数:11,代码来源:RandomFireworks.java

示例10: launchRandomFirework

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void launchRandomFirework(Location loc){
Firework fw = loc.getWorld().spawn(loc, Firework.class);
FireworkMeta fm = fw.getFireworkMeta();
fm.setPower(1);
fm.addEffects(FireworkEffect.builder().with(getRandomType()).withColor(getRandomColor()).build());
fw.setFireworkMeta(fm);
}
 
开发者ID:McKiller5252,项目名称:ParticlePack,代码行数:8,代码来源:RandomFireworks.java

示例11: build

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
@Override
public ItemStack build(ItemStack stack) {
  if(valid) {
    FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
    meta.setPower(power);
    meta.addEffects(effects);
    stack.setItemMeta(meta);
  }
  return stack;
}
 
开发者ID:TheNewEconomy,项目名称:TNE-Bukkit,代码行数:11,代码来源:FireworkData.java

示例12: doStep

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
@Override
public void doStep(final Altar altar) {
    final Location loc = altar.getCenterLocation().toBukkitLocation().add(this.firework.getRelativeLocation());
    final Firework f = (Firework)loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
    if (f != null) {
        if (this.firework.hasVelocity()) {
            f.setVelocity(this.firework.getVelocity());
        }
        final FireworkMeta meta = f.getFireworkMeta();
        meta.addEffects(this.firework.getEffects());
        meta.setPower(0);
        f.setFireworkMeta(meta);
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:15,代码来源:FireworkStep.java

示例13: parseFireworkMetaString

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
private static void parseFireworkMetaString(final String string, final FireworkMeta meta, final String[] separators) {
    final String[] split = StringUtil.splitKeepEmpty(string, separators[1]);

    final int power = Integer.parseInt(split[0]);
    final List<FireworkEffect> effects = new ArrayList<>();
    for (int i = 1; i < split.length; i++) {
        effects.add(parseFireworkEffectString(split[i]));
    }

    meta.setPower(power);
    meta.addEffects(effects);
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:13,代码来源:ItemMetaUtil.java

示例14: createMeta

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public static FireworkMeta createMeta(FireworkMeta meta, int power, FireworkEffect... effects) {
    meta.addEffects(effects);
    meta.setPower(power);
    return meta;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:6,代码来源:FireworkUtils.java

示例15: selfDestruct

import org.bukkit.inventory.meta.FireworkMeta; //导入方法依赖的package包/类
public void selfDestruct(Player player) {
//		Block block = player.getLocation().getBlock();
//		block.setType(Material.CHEST);
//		final Chest chest = (Chest) block.getState();
//		for (ItemStack is : player.getInventory()) {
//			if (is != null)
//				chest.getInventory().addItem(is);
//		}
		
//		final Inventory inv = player.getInventory();
//		final World world = player.getWorld();
//		final Location loc = player.getLocation();
		
		Random r = new Random();
		double x, z;
		for (ItemStack is : player.getInventory()) {
			if (is != null) {
				Entity i = player.getWorld().dropItemNaturally(player.getLocation(), is);

				x = r.nextDouble()/2 - .25;
				z = r.nextDouble()/2 - .25;

				i.setVelocity(new Vector(x, 1, z));
			}
		}
		Firework fw = player.getWorld().spawn(player.getLocation(), Firework.class);
		FireworkMeta fwm = fw.getFireworkMeta();
		           
		FireworkEffect effect = FireworkEffect.builder().withColor(Color.RED).with(Type.BALL).build();
		       
		fwm.addEffects(effect);
		fwm.setPower(0);       
		fw.setFireworkMeta(fwm);
		
//		((CraftWorld)player.getWorld()).getHandle().broadcastEntityEffect(
//                ((CraftFirework)fw).getHandle(),
//                (byte)17);
		
		player.getInventory().clear();
		player.setHealth(0);
		selfDestructing.remove(player);
//		log(inv.toString());
		
//		plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
//			@Override 
//			public void run() {
//				log(inv.toString());
//				Random r = new Random();
//				double x, z;
//				for (ItemStack is : chest.getInventory()) {
//					if (is != null) {
//						Entity i = chest.getWorld().dropItemNaturally(chest.getLocation(), is);
//
//						x = r.nextDouble()/2 - .25;
//						z = r.nextDouble()/2 - .25;
//
//						log("x: " + x + " z: " + z);
//						i.setVelocity(new Vector(x, 5, z));
//					}
//				}
//			}
//		}, 20 * 3);
//		Bukkit.getWorld("Survival").createExplosion(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), (float)5, false, false);
	}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:65,代码来源:LegitWarzone.java


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