本文整理汇总了Java中org.bukkit.FireworkEffect.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.bukkit.FireworkEffect包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNBT
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
static int getNBT(Type type) {
switch (type) {
case BALL:
return 0;
case BALL_LARGE:
return 1;
case STAR:
return 2;
case CREEPER:
return 3;
case BURST:
return 4;
default:
throw new IllegalStateException(type.toString()); // Spigot
}
}
示例2: getEffectType
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
static Type getEffectType(int nbt) {
switch (nbt) {
case 0:
return Type.BALL;
case 1:
return Type.BALL_LARGE;
case 2:
return Type.STAR;
case 3:
return Type.CREEPER;
case 4:
return Type.BURST;
default:
throw new IllegalStateException(Integer.toString(nbt)); // Spigot
}
}
示例3: spawnFireworkDisplay
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
public void spawnFireworkDisplay(Location center, Color color, int count, double radius, int power) {
FireworkEffect effect = FireworkEffect.builder().with(Type.BURST)
.withFlicker()
.withColor(color)
.withFade(Color.BLACK)
.build();
for(int i = 0; i < count; i++) {
double angle = 2 * Math.PI / count * i;
double dx = radius * Math.cos(angle);
double dz = radius * Math.sin(angle);
Location baseLocation = center.clone().add(dx, 0, dz);
Block block = baseLocation.getBlock();
if(block == null || !block.getType().isOccluding()) {
FireworkUtil.spawnFirework(FireworkUtil.getOpenSpaceAbove(baseLocation), effect, power);
}
}
}
示例4: run
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
@Override
public void run() {
// Build this list fresh every time, because MatchPlayers can unload, but Competitors can't.
final List<MatchPlayer> players = winners.stream()
.flatMap(c -> c.getPlayers().stream())
.collect(Collectors.toList());
Collections.shuffle(players);
for(int i = 0; i < players.size() && i < PostMatch.number(); i++) {
MatchPlayer player = players.get(i);
Type type = AVAILABLE_TYPES.get(match.getRandom().nextInt(AVAILABLE_TYPES.size()));
FireworkEffect effect = FireworkEffect.builder().with(type).withFlicker().withColor(this.colors).withFade(Color.BLACK).build();
FireworkUtil.spawnFirework(player.getBukkit().getLocation(), effect, PostMatch.power());
}
this.iterations++;
if(this.iterations >= PostMatch.iterations()) {
cancelTask();
}
}
示例5: getNBT
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
static int getNBT(Type type) {
switch (type) {
case BALL:
return 0;
case BALL_LARGE:
return 1;
case STAR:
return 2;
case CREEPER:
return 3;
case BURST:
return 4;
default:
throw new AssertionError(type);
}
}
示例6: getEffectType
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
static Type getEffectType(int nbt) {
switch (nbt) {
case 0:
return Type.BALL;
case 1:
return Type.BALL_LARGE;
case 2:
return Type.STAR;
case 3:
return Type.CREEPER;
case 4:
return Type.BURST;
default:
throw new AssertionError(nbt);
}
}
示例7: loop
import org.bukkit.FireworkEffect.Type; //导入依赖的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);
}
示例8: explode
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
public void explode() {
World world = Bukkit.getWorld(coord.getWorldname());
ItemManager.setTypeId(coord.getLocation().getBlock(), CivData.AIR);
world.playSound(coord.getLocation(), Sound.ANVIL_BREAK, 1.0f, -1.0f);
world.playSound(coord.getLocation(), Sound.EXPLODE, 1.0f, 1.0f);
FireworkEffect effect = FireworkEffect.builder().with(Type.BURST).withColor(Color.YELLOW).withColor(Color.RED).withTrail().withFlicker().build();
FireworkEffectPlayer fePlayer = new FireworkEffectPlayer();
for (int i = 0; i < 3; i++) {
try {
fePlayer.playFirework(world, coord.getLocation(), effect);
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例9: shootRandomFirework
import org.bukkit.FireworkEffect.Type; //导入依赖的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);
}
示例10: spawnFirework
import org.bukkit.FireworkEffect.Type; //导入依赖的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);
}
示例11: onInteract
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (this.hasAbility(player)) {
if (player.getItemInHand().getType() == Material.SPECKLED_MELON && player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("Zelda Heart")) {
this.removeOneFromHand(player);
if (player.getHealth() >= 14) {
player.setHealth(20);
}
if (player.getHealth() < 14)
player.setHealth(player.getHealth() + 6);
FireworkEffect fEffect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).withFade(Color.GREEN).with(Type.BALL).trail(true).build();
try {
FireworkEffectPlayer.getFireworkEffectPlayer().playFirework(event.getPlayer().getWorld(), event.getPlayer().getLocation(), fEffect);
} catch (Exception e) {
//If the firework dosen't work... to bad
}
}
}
}
示例12: onInteract
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (this.hasAbility(player)) {
if (player.getItemInHand().getType() == Material.GLOWSTONE_DUST && player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("Power Orb")) {
this.removeOneFromHand(player);
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 200, 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 2));
FireworkEffect fEffect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).withFade(Color.YELLOW).with(Type.STAR).trail(false).build();
try {
FireworkEffectPlayer.getFireworkEffectPlayer().playFirework(event.getPlayer().getWorld(), event.getPlayer().getLocation(), fEffect);
} catch (Exception e) {
//If the firework dosen't work... to bad
}
}
}
}
示例13: onInteract
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (this.hasAbility(player)) {
if (event.getPlayer().getItemInHand().getType() == Material.ENCHANTMENT_TABLE) {
this.removeOneFromHand(player);
Inventory inv = Bukkit.getServer().createInventory(null, InventoryType.ENCHANTING);
event.getPlayer().openInventory(inv);
FireworkEffect fEffect = FireworkEffect.builder().flicker(false).withColor(Color.PURPLE).withFade(Color.NAVY).with(Type.BURST).trail(false).build();
try {
FireworkEffectPlayer.getFireworkEffectPlayer().playFirework(event.getPlayer().getWorld(), event.getPlayer().getLocation(), fEffect);
} catch (Exception e) {
//If the firework dosen't work... to bad
}
}
}
}
示例14: spawnFirework
import org.bukkit.FireworkEffect.Type; //导入依赖的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);
}
示例15: throwKittyCannon
import org.bukkit.FireworkEffect.Type; //导入依赖的package包/类
private void throwKittyCannon(final World world, Player player, Location hookLoc) {
int i = random.nextInt(Ocelot.Type.values().length);
final Ocelot cat = (Ocelot) throwMob(world, player, hookLoc, EntityType.OCELOT);
cat.setCatType(Ocelot.Type.values()[i]);
cat.setTamed(true);
cat.setBaby();
mainInstance.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
final Location catLoc = cat.getLocation();
cat.remove();
world.createExplosion(catLoc.getX(), catLoc.getY(), catLoc.getZ(), 2.0F, false, false);
}
}, 20);
}