下面列出了org.bukkit.World#playEffect ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@EventHandler(priority = EventPriority.MONITOR)
public void onBlitzPlayerEliminated(final BlitzPlayerEliminatedEvent event) {
this.eliminatedPlayers.add(event.getPlayer().getBukkit().getUniqueId());
World world = event.getMatch().getWorld();
Location death = event.getDeathLocation();
double radius = 0.1;
int n = 8;
for (int i = 0; i < 6; i++) {
double angle = 2 * Math.PI * i / n;
Location base =
death.clone().add(new Vector(radius * Math.cos(angle), 0, radius * Math.sin(angle)));
for (int j = 0; j <= 8; j++) {
world.playEffect(base, Effect.SMOKE, j);
}
}
}
private void handleElimination(final MatchPlayer player) {
if (!eliminatedPlayers.add(player.getBukkit().getUniqueId())) return;
World world = player.getMatch().getWorld();
Location death = player.getBukkit().getLocation();
double radius = 0.1;
int n = 8;
for(int i = 0; i < 6; i++) {
double angle = 2 * Math.PI * i / n;
Location base = death.clone().add(new Vector(radius * Math.cos(angle), 0, radius * Math.sin(angle)));
for(int j = 0; j <= 8; j++) {
world.playEffect(base, Effect.SMOKE, j);
}
}
checkEnd();
}
@SuppressWarnings("deprecation")
@Override
public void effect(Event e, ItemStack item, final int level) {
if(e instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
Entity target = event.getEntity();
World world = target.getWorld();
world.playEffect(target.getLocation(), Effect.POTION_BREAK, 10);
double boundaries = 0.1*level;
for(double x = boundaries; x >= -boundaries; x-=0.1)
for(double z = boundaries; z >= -boundaries; z-=0.1) {
FallingBlock b = world.spawnFallingBlock(target.getLocation(), Material.FIRE.getId(), (byte) 0x0);
b.setVelocity(new Vector(x, 0.1, z));
b.setDropItem(false);
}
}
}
public void flashStructureBlocks() {
World world = null;
for (BlockCoord coord : structureBlocks.keySet()) {
if (world == null) {
world = coord.getLocation().getWorld();
}
world.playEffect(coord.getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
}
}
public void onControlBlockHit(ControlPoint cp, World world, Player player, StructureBlock hit) {
world.playSound(hit.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
world.playEffect(hit.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
CivMessage.send(player, CivColor.LightGray+"Damaged Control Block ("+cp.getHitpoints()+" / "+cp.getMaxHitpoints()+")");
CivMessage.sendTown(hit.getTown(), CivColor.Yellow+"One of our Town Hall's Control Points is under attack!");
}
@Override
public void onDamage(int amount, World world, Player player, BlockCoord coord, BuildableDamageBlock hit) {
boolean wasTenPercent = false;
if(hit.getOwner().isDestroyed()) {
CivMessage.sendError(player, hit.getOwner().getDisplayName()+" is already destroyed.");
return;
}
if (!hit.getOwner().isComplete() && !(hit.getOwner() instanceof Wonder)) {
CivMessage.sendError(player, hit.getOwner().getDisplayName()+" is still being built, cannot be destroyed.");
return;
}
if ((hit.getOwner().getDamagePercentage() % 10) == 0) {
wasTenPercent = true;
}
this.damage(amount);
world.playSound(hit.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
world.playEffect(hit.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
if ((hit.getOwner().getDamagePercentage() % 10) == 0 && !wasTenPercent) {
onDamageNotification(player, hit);
}
}
public void onControlBlockHit(ControlPoint cp, World world, Player player) {
world.playSound(cp.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
world.playEffect(cp.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
CivMessage.send(player, CivColor.LightGray+"Damaged Control Block ("+cp.getHitpoints()+" / "+cp.getMaxHitpoints()+")");
CivMessage.sendCamp(this, CivColor.Yellow+"One of our camp's Control Points is under attack!");
}
public void onControlBlockHit(ControlPoint cp, World world, Player player, StructureBlock hit) {
world.playSound(hit.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
world.playEffect(hit.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
CivMessage.send(player, CivColor.LightGray+"Damaged Control Block ("+cp.getHitpoints()+" / "+cp.getMaxHitpoints()+")");
CivMessage.sendCiv(getCiv(), CivColor.Yellow+"Our War Camp's Control Points are under attack!");
}
@Override
public void run() {
Iterator<Entry<BlockCoord, Structure>> iter = CivGlobal.getStructureIterator();
while(iter.hasNext()) {
Structure struct = iter.next().getValue();
if (struct.isDestroyed()) {
int size = struct.getStructureBlocks().size();
World world = struct.getCorner().getBlock().getWorld();
for (int i = 0; i < size/10; i++) {
Random rand = new Random();
int index = rand.nextInt(size);
// slower but uses less memory.
int j = 0;
for (BlockCoord coord : struct.getStructureBlocks().keySet()) {
if (j < index) {
j++;
continue;
}
world.playEffect(coord.getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
break;
}
//BlockCoord coord = (BlockCoord) struct.getStructureBlocks().keySet().toArray()[index];
}
}
}
}
@Override
public boolean effect(Event event, Player player) {
// List<String> lore = e.getBow().getItemMeta().getLore();
// if(!lore.contains(placeHolder)) {
// for(int i = descriptionSize; i != 0; i--)
// lore.remove(i);
// e.getProjectile().setMetadata("ce." + this.getOriginalName(), new FixedMetadataValue(main, writeType(lore)));
// player.setMetadata("ce.CanUnleashBeasts", null);
// } else
// e.getProjectile().setMetadata("ce." + this.getOriginalName(), null);
if(event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if(e.getDamager() != player)
return false;
Entity ent = e.getEntity();
Location loc = ent.getLocation();
World w = ent.getWorld();
if(ent instanceof Silverfish || ent instanceof EnderDragon || ent instanceof Spider || ent instanceof Slime || ent instanceof Ghast || ent instanceof MagmaCube || ent instanceof CaveSpider || (ent instanceof Wolf && ((Wolf) ent).isAngry()) || ent instanceof PigZombie) {
e.setDamage(e.getDamage()*DamageMultiplication);
w.playEffect(loc, Effect.SMOKE, 50);
w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 50);
EffectManager.playSound(loc, "BLOCK_PISTON_RETRACT", 1.3f, 3f);
return true;
} else if (ent instanceof Player) {
for(int i = 0; i < MaximumMobs; i++) {
if(rand.nextInt(100) < MobAppearanceChance) {
w.spawnEntity(loc, rand.nextInt(2) == 1 ? EntityType.SPIDER : EntityType.SLIME);
w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 30);
w.playEffect(loc, Effect.SMOKE, 30);
EffectManager.playSound(loc, "BLOCK_ANVIL_BREAK", 0.3f, 0.1f);
}
}
}
}
return false;
}
@Override
public void onExplode(Item item, Location location) {
World world = location.getWorld();
world.playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 2f, 1f);
world.playEffect(location, Effect.ENDER_SIGNAL, 0);
world.playEffect(location, Effect.STEP_SOUND, Material.FIRE.getId());
super.onExplode(item, location);
}
@Override
public void onExplode(Item item, Location location) {
World world = location.getWorld();
world.playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 2f, 2f);
world.playEffect(location, Effect.ENDER_SIGNAL, 0);
world.playEffect(location, Effect.STEP_SOUND, Material.OBSIDIAN.getId());
super.onExplode(item, location);
}
public void onDamage(int amount, World world, Player player, BlockCoord coord, BuildableDamageBlock hit) {
boolean wasTenPercent = false;
if(hit.getOwner().isDestroyed()) {
if (player != null) {
CivMessage.sendError(player, hit.getOwner().getDisplayName()+" is already destroyed.");
}
return;
}
if (!hit.getOwner().isComplete() && !(hit.getOwner() instanceof Wonder)) {
if (player != null) {
CivMessage.sendError(player, hit.getOwner().getDisplayName()+" is still being built, cannot be destroyed.");
}
return;
}
if ((hit.getOwner().getDamagePercentage() % 10) == 0) {
wasTenPercent = true;
}
this.damage(amount);
world.playSound(hit.getCoord().getLocation(), Sound.ANVIL_USE, 0.2f, 1);
world.playEffect(hit.getCoord().getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
if ((hit.getOwner().getDamagePercentage() % 10) == 0 && !wasTenPercent) {
if (player != null) {
onDamageNotification(player, hit);
}
}
if (player != null) {
Resident resident = CivGlobal.getResident(player);
if (resident.isCombatInfo()) {
CivMessage.send(player, CivColor.LightGray+hit.getOwner().getDisplayName()+" has been damaged ("+
hit.getOwner().hitpoints+"/"+hit.getOwner().getMaxHitPoints()+")");
}
}
}