org.bukkit.World#playEffect ( )源码实例Demo

下面列出了org.bukkit.World#playEffect ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PGM   文件: BlitzMatchModule.java
@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);
    }
  }
}
 
源代码2 项目: ProjectAres   文件: BlitzMatchModule.java
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();
}
 
源代码3 项目: ce   文件: Molotov.java
@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);
		}
	}
}
 
源代码4 项目: civcraft   文件: Buildable.java
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);
	}
}
 
源代码5 项目: civcraft   文件: TownHall.java
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!");
}
 
源代码6 项目: civcraft   文件: Road.java
@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);
	}
}
 
源代码7 项目: civcraft   文件: Camp.java
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!");
}
 
源代码8 项目: civcraft   文件: WarCamp.java
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!");
}
 
源代码9 项目: civcraft   文件: DamagedStructureTimer.java
@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];
			}
		}
	}
}
 
源代码10 项目: ce   文件: BeastmastersBow.java
@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;
	}
 
源代码11 项目: NBTEditor   文件: FireBomb.java
@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);
}
 
源代码12 项目: NBTEditor   文件: RepulsionBomb.java
@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);
}
 
源代码13 项目: civcraft   文件: Buildable.java
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()+")");
		}
	}
	
}