本文整理汇总了Java中org.bukkit.Sound类的典型用法代码示例。如果您正苦于以下问题:Java Sound类的具体用法?Java Sound怎么用?Java Sound使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sound类属于org.bukkit包,在下文中一共展示了Sound类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerToggleFlight
import org.bukkit.Sound; //导入依赖的package包/类
@EventHandler
public void onPlayerToggleFlight(PlayerToggleFlightEvent event)
{
if (!this.allowed.contains(event.getPlayer().getUniqueId()))
return;
this.allowed.remove(event.getPlayer().getUniqueId());
if (this.hub.getPlayerManager().isBusy(event.getPlayer()))
return;
event.setCancelled(true);
event.getPlayer().setVelocity(event.getPlayer().getLocation().getDirection().multiply(1.6D).setY(1.0D));
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 1.0F, 1.0F);
for (int i = 0; i < 20; i++)
ParticleEffect.CLOUD.display(0.5F, 0.15F, 0.5F, 0.25F, 20, event.getPlayer().getLocation().subtract(0.0F, 0.20F, 0.0F));
event.getPlayer().setAllowFlight(false);
}
示例2: divingBellThread
import org.bukkit.Sound; //导入依赖的package包/类
public static void divingBellThread(final Location loc) {
new Thread() {
@Override
public void run() {
setPriority(Thread.MIN_PRIORITY);
// taskNum = -1;
try {
World cw = loc.getWorld();
for (int i = 0; i < 8; i++) {
sleep(200);
if ((i % 2) == 0) {
cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 1.0f, 1.2f);
} else {
cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 1.0f, 1);
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start(); // , 20L);
}
示例3: onInventoryClick1
import org.bukkit.Sound; //导入依赖的package包/类
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack is = event.getCurrentItem();
if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
event.setCancelled(true);
for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
Location location = player.getLocation();
if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
player.closeInventory();
player.teleport(targetPlayer);
player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
player.playEffect(location, Effect.ENDER_SIGNAL, 1);
targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
}
}
}
}
}
示例4: sonarPingThread
import org.bukkit.Sound; //导入依赖的package包/类
public static void sonarPingThread(final Location loc) {
new Thread() {
@Override
public void run() {
setPriority(Thread.MIN_PRIORITY);
// taskNum = -1;
try {
World cw = loc.getWorld();
for (int i = 0; i < 2; i++) {
sleep(400);
if( i==0 )
cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 2.0f, 1.6f);
else
cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 2.0f, 2.0f);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start(); // , 20L);
}
示例5: execute
import org.bukkit.Sound; //导入依赖的package包/类
public void execute(MatchPlayer player) {
checkNotNull(player, "player");
this.sendMessage(player.getBukkit());
if(this.teleportPoint != null) {
Location teleport = this.getSafeTeleport(player);
if(teleport != null) {
player.getBukkit().teleport(teleport);
player.getBukkit().setFlying(true);
} else {
player.sendMessage(" " + ChatColor.YELLOW + ChatColor.BOLD + PGMTranslations.t("tutorial.teleport.unsafe", player));
}
player.playSound(Sound.ENTITY_ENDERMEN_TELEPORT, 0.5f, 1.0f);
} else {
player.playSound(Sound.BLOCK_PISTON_EXTEND, 0.5f, 2.0f);
}
}
示例6: surfaceBellThread
import org.bukkit.Sound; //导入依赖的package包/类
public static void surfaceBellThread(final Location loc) {
new Thread() {
@Override
public void run() {
setPriority(Thread.MIN_PRIORITY);
// taskNum = -1;
try {
World cw = loc.getWorld();
for (int i = 0; i < 2; i++) {
sleep(300);
cw.playSound(loc, Sound.BLOCK_NOTE_PLING, 1.0f, 2);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
}
示例7: notify
import org.bukkit.Sound; //导入依赖的package包/类
@Override
public void notify(Player player, Object extra) {
Location eye = player.getEyeLocation();
Vector direction = eye.getDirection().multiply(2);
Block source = (Block) extra;
Projectile projectile = player.getWorld().spawn(source.getRelative(BlockFace.UP).getLocation().setDirection(direction), LargeFireball.class);
projectile.setShooter(player);
projectile.setVelocity(direction);
Inventory inv = player.getInventory();
if (inv.contains(Material.TNT)) {
int slot = inv.first(Material.TNT);
ItemStack ammo = inv.getItem(slot);
int amount = ammo.getAmount();
if (amount > 1) {
ammo.setAmount(amount - 1);
inv.setItem(slot, ammo);
} else {
inv.setItem(slot, null);
}
projectile.setCustomName("recreator.structure.turret.tnt");
}
AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true);
}
示例8: onPlayerInteract
import org.bukkit.Sound; //导入依赖的package包/类
/**
* Give old player enchants on head eating
*
* @param event Event
*/
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM || event.getItem().getDurability() != 3
|| (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
return;
SkullMeta skullMeta = (SkullMeta)event.getItem().getItemMeta();
List<PotionEffect> effectList = this.effects.get(skullMeta.getOwner());
if (effectList != null)
{
effectList.forEach(event.getPlayer()::addPotionEffect);
this.effects.remove(skullMeta.getOwner());
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1F, 1F);
}
}
示例9: enforce
import org.bukkit.Sound; //导入依赖的package包/类
private void enforce(Punishment punishment, Player punished) {
final Audience audience = audiences.get(punished);
switch(punishment.type()) {
case WARN:
audience.playSound(new BukkitSound(Sound.ENTITY_ENDERDRAGON_GROWL, 1f, 1f));
punishmentFormatter.warning(punishment)
.feed((title, subtitle) -> audience.showTitle(title, subtitle, 5, 200, 10));
break;
case KICK:
case BAN:
playerServerChanger.kickPlayer(punished, punishmentFormatter.screen(punishment, punished));
break;
}
punishmentService.update(punishment._id(), (PunishmentDoc.Enforce) () -> true);
}
示例10: playSound
import org.bukkit.Sound; //导入依赖的package包/类
public static void playSound(InventoryClickEvent event) {
if (event.getSlot() == -999) {
return;
}
HumanEntity human = event.getWhoClicked();
if (!(human instanceof Player)) {
return;
}
ItemStack clicked = event.getCurrentItem();
if (clicked == null || clicked.getType() == Material.AIR) {
return;
}
if (clicked.getType() == Material.BARRIER) {
((Player) human).playSound(human.getLocation(), Sound.BLOCK_ANVIL_PLACE, 1, 1);
} else if (clicked != null && !clicked.equals(PLACEHOLDER)) {
((Player) human).playSound(human.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
}
}
示例11: playSound
import org.bukkit.Sound; //导入依赖的package包/类
@Override
public void playSound(Player p) {
RScheduler.schedule(plugin, new Runnable() {
int counter = 0;
public void run() {
if (p == null || !p.isOnline())
return;
if (Math.random() < 0.5)
RSound.playSound(p, Sound.ENTITY_ZOMBIE_AMBIENT);
else
RSound.playSound(p, Sound.ENTITY_ZOMBIE_STEP);
counter++;
if (counter < 10)
RScheduler.schedule(plugin, this, RTicks.seconds(0.5));
}
});
}
示例12: playSound
import org.bukkit.Sound; //导入依赖的package包/类
@Override
public void playSound(Player p) {
RScheduler.schedule(plugin, new Runnable() {
int counter = 0;
public void run() {
if (p == null || !p.isOnline())
return;
if (Math.random() < 0.5)
RSound.playSound(p, Sound.ENTITY_LIGHTNING_THUNDER);
else
RSound.playSound(p, Sound.ENTITY_SKELETON_AMBIENT);
counter++;
if (counter < 10)
RScheduler.schedule(plugin, this, RTicks.seconds(0.5));
}
});
}
示例13: playSound
import org.bukkit.Sound; //导入依赖的package包/类
@Override
public void playSound(Player p) {
RScheduler.schedule(plugin, new Runnable() {
int counter = 0;
public void run() {
if (p == null || !p.isOnline())
return;
RSound.playSound(p, Sound.ENTITY_SKELETON_STEP);
RSound.playSound(p, Sound.ENTITY_SKELETON_AMBIENT);
counter++;
if (counter < 10)
RScheduler.schedule(plugin, this, RTicks.seconds(0.5));
}
});
}
示例14: handleDeath
import org.bukkit.Sound; //导入依赖的package包/类
@Override
public void handleDeath(Player player, Location location, String deathMessage) {
if (location != null) {
player.teleport(location.clone().add(0, 3, 0));
}
this.startSpectating(player);
this.sendMessage(deathMessage);
if (!deathMessage.contains("left the match")) {
playSound(Sound.AMBIENCE_THUNDER, 10.0f);
ManagerHandler.getEntityHider().hideEntity(this.player1, this.player2);
ManagerHandler.getEntityHider().hideEntity(this.player2, this.player1);
}
Cache.storeInventory(player, true);
if (player == this.player1) {
this.endMatch(this.player2, this.player1);
}
if (player == this.player2) {
this.endMatch(this.player1, this.player2);
}
}
示例15: priorityKick
import org.bukkit.Sound; //导入依赖的package包/类
protected boolean priorityKick(MatchPlayer joining) {
if(!jmm.canPriorityKick(joining)) return false;
List<MatchPlayer> kickable = new ArrayList<>();
for(MatchPlayer player : getMatch().getParticipatingPlayers()) {
if(!jmm.canPriorityKick(player)) kickable.add(player);
}
if(kickable.isEmpty()) return false;
MatchPlayer kickMe = kickable.get(getMatch().getRandom().nextInt(kickable.size()));
kickMe.sendWarning(new TranslatableComponent("gameplay.ffa.kickedForPremium"), false);
kickMe.sendMessage(Links.shopPlug("shop.plug.ffa.neverKicked"));
kickMe.playSound(Sound.ENTITY_VILLAGER_HURT, kickMe.getBukkit().getLocation(), 1, 1);
getMatch().setPlayerParty(kickMe, getMatch().getDefaultParty());
return true;
}