本文整理汇总了Java中org.bukkit.World.playSound方法的典型用法代码示例。如果您正苦于以下问题:Java World.playSound方法的具体用法?Java World.playSound怎么用?Java World.playSound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.World
的用法示例。
在下文中一共展示了World.playSound方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flightPath
import org.bukkit.World; //导入方法依赖的package包/类
/**
* Override this class, you can use it to provide particle effects along travel path.
*
* It is called after all other handling is done. Keep it lightweight
*
* @param start The start location of flight
* @param end The end location of impact / miss
* @param type the type of bullet in play
* @param endOfFlight is the bullet still flying after this or has it impacted?
*/
public void flightPath(Location start, Location end, Bullet type, boolean endOfFlight) {
// no special flight path stuff. maybe a whizzing sound?
World world = start.getWorld();
if (endOfFlight) {
// make a new sound where it hits.
world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
}
if (type.getFireChance() > 0.0d) {
if (start != null) {
double distance = end.distance(start);
Vector vector = end.subtract(start).toVector();
vector = vector.multiply(0.1d / distance);
for (int i = 0; i < distance; i++) {
world.spawnParticle(Particle.SMOKE_NORMAL, start.add(vector), 5, 0.01, 0.01, 0.01, 0.001);
}
}
}
}
示例2: preHit
import org.bukkit.World; //导入方法依赖的package包/类
/**
* Subclasses are encouraged to override this.
* Default behavior is to eject off of what you are riding, play a sound and spawn particle.
*
*
* @param hitData Data matrix showing hit
* @param hit What entity was hit
* @param bullet The bullet data.
*/
public void preHit(HitDigest hitData, Entity hit, Projectile bullet, Bullet type) {
Location end = hitData.hitLocation;
World world = end.getWorld();
hit.eject(); // eject the player
hit.getPassengers().forEach(e -> e.eject()); // and ejects your passengers
// make a new sound where it hits.
world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
// make a splash
world.spawnParticle(Particle.SMOKE_NORMAL, end, 35, 0.1, 0.1, 0.1, 0.1);
}
示例3: handleInstantActivation
import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleInstantActivation(BlockPlaceEvent event) {
if(this.properties.instantIgnite && event.getBlock().getType() == Material.TNT) {
World world = event.getBlock().getWorld();
TNTPrimed tnt = world.spawn(BlockUtils.base(event.getBlock()), TNTPrimed.class);
if(this.properties.fuse != null) {
tnt.setFuseTicks(this.getFuseTicks());
}
if(this.properties.power != null) {
tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield
}
if(callPrimeEvent(tnt, event.getPlayer(), true)) {
// Only cancel the block placement if the prime event is NOT cancelled.
// If priming is cancelled, the block is allowed to stay (unless some
// other handler has already cancelled the place event).
event.setCancelled(true);
world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
ItemStack inHand = event.getItemInHand();
if(inHand.getAmount() == 1) {
inHand = null;
} else {
inHand.setAmount(inHand.getAmount() - 1);
}
event.getPlayer().getInventory().setItem(event.getHand(), inHand);
}
}
}
示例4: execute
import org.bukkit.World; //导入方法依赖的package包/类
@Override
public void execute(KingdomFactionsPlayer player) {
noFallDamage.add(player.getName());
double forwardPowerModifier = 1.5D;
double upwardPowerModifier = forwardPowerModifier * 2.0D;
double fwv = 2.0D;
double uwv = 0.7D;
Vector dir = player.getLocation().getDirection();
dir.setY(0).normalize().multiply(fwv * forwardPowerModifier).setY(uwv * upwardPowerModifier);
player.getPlayer().setVelocity(dir);
final World w = player.getPlayer().getWorld();
w.playSound(player.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
new BukkitRunnable() {
int autoStopCount = 0;
@SuppressWarnings("deprecation")
public void run() {
if ((this.autoStopCount <= 30) && (Leap.noFallDamage.contains(player.getName()))
&& (Bukkit.getPlayer(player.getName()) != null)
&& (!Bukkit.getPlayer(player.getName()).isOnGround())) {
Player p = Bukkit.getPlayer((player.getName()));
w.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 1);
this.autoStopCount += 1;
} else {
if ((Leap.noFallDamage.contains(player.getName()))) {
Leap.noFallDamage.remove(player.getName());
}
cancel();
}
}
}.runTaskTimer(KingdomFactionsPlugin.getInstance(), 5L, 3L);
}
示例5: gunBulletHitGroundEvent
import org.bukkit.World; //导入方法依赖的package包/类
/**
* It hit the ground maybe!
*
* @param event the impact event, we ignore any that aren't just blockhits
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void gunBulletHitGroundEvent(ProjectileHitEvent event) {
if (!EntityType.SMALL_FIREBALL.equals(event.getEntityType()))
return;
if (event.getHitBlock() == null)
return;
SmallFireball bullet = (SmallFireball) event.getEntity();
if (!bullet.getName().equals(this.tag))
return;
Location end = event.getHitBlock().getLocation().clone().add(0.5, 0.5, 0.5);
World world = end.getWorld();
// make a new sound where it hits.
world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
// make a splash
world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.5, 0.0, 0.0), 5);
world.spawnParticle(Particle.BLOCK_DUST, end.clone().add(-0.5, 0.0, 0.0), 5);
world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.5, 0.0), 5);
world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0,-0.5, 0.0), 5);
world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0, 0.5), 5);
world.spawnParticle(Particle.BLOCK_DUST, end.clone().add( 0.0, 0.0,-0.5), 5);
Entity hit = event.getEntity();
if (hit == null) {
Location start = travelPaths.remove(bullet.getUniqueId());
if (start != null) {
double distance = end.distance(start);
Vector vector = end.subtract(start).toVector();
vector = vector.multiply(1.0d / distance);
for (int i = 0; i < distance; i++) {
world.spawnParticle(Particle.FLAME, start.add(vector), 5);
}
}
bullet.remove();
return;
}
}
示例6: nearMiss
import org.bukkit.World; //导入方法依赖的package包/类
/**
* Subclasses are encouraged to override this.
* Just makes a sounds and spawns a particle. Note that if you're OK with this but still want
* to do some custom stuff on a nearmiss (perhaps jerk the entity away or something? I dunno)
* then consider using {@link #postMiss(HitDigest, Entity, Projectile, Projectile, Bullet)}
* instead, which gives you this same detail as well as the projectile spawned to "keep going"
* post-miss.
*
* @param missData Data matrix showing miss
* @param missed What entity was almost hit
* @param bullet The bullet data
*/
public void nearMiss(HitDigest missData, Entity missed, Projectile bullet, Bullet type) {
Location end = missData.hitLocation;
World world = end.getWorld();
world.playSound(end, Sound.BLOCK_GLASS_HIT, 1.0f, 1.5f);
world.spawnParticle(Particle.SMOKE_NORMAL, end, 15, 0.1, 0.1, 0.1, 0.1);
}
示例7: manageHit
import org.bukkit.World; //导入方法依赖的package包/类
/**
* Override this class, you use it to manage what happens when a non-Damageable is hit.
*
* @param hitData the Data matrix showing hit information
* @param hit the non-damageable entity that was struck
* @param bullet The "Projectile" bullet doing the hitting
* @param bulletType The "Bullet" type of the projectile
*/
public void manageHit(HitDigest hitData, Entity hit, Projectile bullet, Bullet bulletType) {
// do nothing in standard gun.
Location end = hitData.hitLocation;
World world = end.getWorld();
world.playSound(end, Sound.BLOCK_GLASS_HIT, 1.0f, 1.5f);
world.spawnParticle(Particle.SMOKE_NORMAL, end, 35, 0.1, 0.1, 0.1, 0.1);
}