本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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));
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}