Java Code Examples for org.bukkit.World#playEffect()

The following examples show how to use org.bukkit.World#playEffect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlitzMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example 2
Source File: BlitzMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: Molotov.java    From ce with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
		}
	}
}
 
Example 4
Source File: Buildable.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
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);
	}
}
 
Example 5
Source File: TownHall.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
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!");
}
 
Example 6
Source File: Road.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@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);
	}
}
 
Example 7
Source File: Camp.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
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!");
}
 
Example 8
Source File: WarCamp.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
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!");
}
 
Example 9
Source File: DamagedStructureTimer.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@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];
			}
		}
	}
}
 
Example 10
Source File: BeastmastersBow.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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;
	}
 
Example 11
Source File: FireBomb.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: RepulsionBomb.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: Buildable.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
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()+")");
		}
	}
	
}