本文整理汇总了Java中org.bukkit.entity.Player.playSound方法的典型用法代码示例。如果您正苦于以下问题:Java Player.playSound方法的具体用法?Java Player.playSound怎么用?Java Player.playSound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.playSound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPickupToQuickSlot
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPickupToQuickSlot(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player) || !ItemManager.allowedForPlayer(player, event.getItem().getItemStack(), false)) {
return;
}
for (Slot quickSlot : SlotManager.instance().getQuickSlots()) {
int slotId = quickSlot.getQuickSlot();
if (quickSlot.isCup(player.getInventory().getItem(slotId)) && quickSlot.isValidItem(event.getItem().getItemStack())) {
player.getInventory().setItem(slotId, event.getItem().getItemStack());
event.getItem().remove();
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, .3f, 1.7f);
if (Config.getConfig().getBoolean("attack.auto-held")) {
player.getInventory().setHeldItemSlot(quickSlot.getQuickSlot());
}
event.setCancelled(true);
}
}
}
示例2: setRank
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Set a player's rank.
* @param newRank
*/
public void setRank(EnumRank newRank) {
if (!getRank().isAtLeast(newRank)) // Broadcast the new rank if it's a promotion.
Core.broadcast(ChatColor.GREEN + " * " + ChatColor.YELLOW + getUsername() + ChatColor.GREEN
+ " has ranked up to " + newRank.getColor() + newRank.getName() + ChatColor.GREEN + ". * ");
this.rank = newRank;
if (isOnline()) {
// Tell the player they've been promoted.
Player player = getPlayer();
player.sendMessage(ChatColor.YELLOW + "Your rank is now: " + newRank.getColor() + newRank.getName());
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
updatePlayer();
}
updateDiscord();
}
示例3: onInventoryClick2
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick2(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 Here 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 " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
player.closeInventory();
targetPlayer.teleport(player);
player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
player.playEffect(location, Effect.ENDER_SIGNAL, 1);
targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
}
}
}
}
}
示例4: finishChallenge
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void finishChallenge(Player player, boolean buy) {
if(!buy) {
for(Entity e : player.getWorld().getEntities()) {
if(e.hasMetadata(metaData) && e.getMetadata(metaData).get(0).asString().contains(player.getName())) {
e.remove();
}
}
player.teleport(plugin.getChallengesFile().getVictorySpawnpoint(getChallenge(player)));
loadData(player);
player.playSound(player.getLocation(), Sound.ENTITY_FIREWORK_TWINKLE, 1F, 1F);
}
for(String cmd : plugin.getChallengesFile().getCommands(getChallenge(player))) {
cmd = cmd.replaceAll("%s", player.getName());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
if(!isTesting(player)) {
plugin.getPlayerManager().setRank(player, getChallenge(player));
player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
+ Lang.CHALLENGES_COMPLETE.toString()
.replaceAll("%s", plugin.getChallengesFile().getTitle(getChallenge(player))));
} else {
player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
+ Lang.CHALLENGES_TEST_COMPLETE.toString());
}
playerChallenge.remove(player.getName());
}
示例5: handleFreeze
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void handleFreeze(Player player, Rune rune) {
Player target = Utility.getTargetPlayer(player, 10);
if(target == null || !Utility.canAttack(player, target)) {
return;
}
LineEffect eff = new LineEffect(plugin.getEffectManager());
eff.setEntity(player);
eff.setTargetEntity(target);
eff.particle = ParticleEffect.SNOW_SHOVEL;
eff.start();
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 6));
target.playSound(target.getLocation(), Sound.ENTITY_SNOWMAN_DEATH, 1F, 1F);
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
player.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_RUNE_APPLY.toString()
.replaceAll("%s", rune.getName()));
target.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_FROZEN.toString()
.replaceAll("%s", player.getName()));
finish(player, false);
}
示例6: apply
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Plays the sound to all players in the world at the given location. Players to far away cannot hear the sound.
*
* @param location location
* @throws Exception exception
*/
public void apply(Location location) throws Exception {
if(this.text.equals("none"))
return;
for (final Player player : location.getWorld().getPlayers()) {
player.playSound(location, Sound.valueOf(this.text), this.volume, this.pitch);
}
}
示例7: play
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void play(Location location, Player... players) throws InterPreter19Exception {
try {
this.changeSound();
for (final Player player : players) {
player.playSound(location, getSoundFromName(this.sound), (float) this.volume, (float) this.pitch);
}
} catch (final Exception ex) {
throw new InterPreter19Exception("Cannot parse sound!");
}
}
示例8: playEngineSound
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void playEngineSound( Location loc, Sound sound, float volume, float pitch )
{
for( Player p : loc.getWorld().getPlayers() )
{
if( NavyCraft.playerEngineVolumes.containsKey(p) )
p.playSound(loc, sound, volume*NavyCraft.playerEngineVolumes.get(p)*.01f, pitch);
else
p.playSound(loc, sound, volume, pitch);
}
}
示例9: playSound
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void playSound(Sound sound, float idk2) {
for (Player p : getPlayers()) {
p.playSound(p.getLocation(), sound, 10.0f, idk2);
}
for (UUID uuid : spectators) {
if (Bukkit.getPlayer(uuid) != null) {
Bukkit.getPlayer(uuid).playSound(Bukkit.getPlayer(uuid).getLocation(), sound, 10.0F, idk2);
}
else {
spectators.remove(uuid);
}
}
}
示例10: onPlayerLevelUp
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerLevelUp(PlayerLevelUpEvent event) {
Player player = event.getPlayerContext().getPlayer();
player.sendMessage(ChatColor.AQUA + "" + ChatColor.STRIKETHROUGH + "----------------------------------------");
player.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + " Level up!" + ChatColor.GREEN + " You are now level " + ChatColor.RED + event.getToLevel());
player.sendMessage(ChatColor.AQUA + "" + ChatColor.STRIKETHROUGH + "----------------------------------------");
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
}
示例11: run
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run() {
if(api.getGameManager().getGameState() != GameState.INGAME) {
this.cancel();
return;
}
if(seconds <= 1 && minutes <= 0) {
this.cancel();
api.getGameManager().getCurrentGame().endGame();
api.getGameManager().endGame();
if(Arcadia.getPlugin(Arcadia.class).mainConfiguration.fetch().getBoolean("allow-game-voting")) {
new GameVotingRunnable();
} else {
new GameSwitchRunnable();
}
return;
}
if(seconds <= 0) {
minutes--;
seconds = 59;
} else {
seconds--;
}
if(minutes == 0 && seconds <= 3 && seconds > 0) {
for(Player player : Bukkit.getOnlinePlayers()) {
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BASS, 1f, 1f);
}
}
api.getGameManager().getMainBossBar().setTitle(ChatColor.translateAlternateColorCodes('&', "&6&lTime Left: &c&l" + Utils.formatTimeFancy(minutes, seconds)));
api.getGameManager().getMainBossBar().setProgress((((double)seconds+((double)minutes*60))/(double)totalSeconds));
api.getGameManager().getCurrentGame().getSidebar().updateDisplayName(minutes, seconds);
}
示例12: displayReducingMessage
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Function to display with a title that the border are reducing
*/
public void displayReducingMessage()
{
for (Player player : Bukkit.getOnlinePlayers())
{
Titles.sendTitle(player, 0, 100, 5, ChatColor.RED + "Attention !", ChatColor.YELLOW + "Les bordures se réduisent !");
player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1.0F, 1.0F);
}
this.game.getCoherenceMachine().getMessageManager().writeCustomMessage(ChatColor.RED + "Les bordures se réduisent !", true);
}
示例13: openBuyInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void openBuyInventory(MerchantCategory category, Player player,
Game game) {
ArrayList<VillagerTrade> offers = category.getOffers();
int sizeCategories = getCategoriesSize(player);
int sizeItems = offers.size();
int invSize = getBuyInventorySize(sizeCategories, sizeItems);
player.playSound(player.getLocation(),
SoundMachine.get("CLICK", "UI_BUTTON_CLICK"), 10.0F, 1.0F);
this.currentCategory = category;
Inventory buyInventory = Bukkit.createInventory(player, invSize,
Main._l("ingame.shop.name"));
addCategoriesToInventory(buyInventory, player);
for (int i = 0; i < offers.size(); i++) {
VillagerTrade trade = (VillagerTrade) offers.get(i);
if ((trade.getItem1().getType() != Material.AIR)
|| (trade.getRewardItem().getType() != Material.AIR)) {
int slot = getInventorySize(sizeCategories) + i;
ItemStack tradeStack = toItemStack(trade, player, game);
buyInventory.setItem(slot, tradeStack);
}
}
player.openInventory(buyInventory);
}
示例14: playerSpeaksOnCellPhone
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void playerSpeaksOnCellPhone(Player p, String message) {
PlayerObject pObject = main.getPlayerManager().getPlayer(p);
if (pObject == null)
return;
if (pObject.getContacts().size() == 0) {
p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7You have no contacts. Add some with &e/mtr add contact <name>"));
return;
}
if (pObject.getCurrentCellPhoneRecipient().equalsIgnoreCase(p.getName())) {
p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7You can't call yourself, what are you doing?"));
return;
}
Player recipient = main.getServer().getPlayer(pObject.getCurrentCellPhoneRecipient());
// Recipient not online, send as text message
if (recipient == null) {
main.getTextMessageManager().addTextMessage(p.getName(), pObject.getCurrentCellPhoneRecipient(), message);
p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7Contact is not online. Message sent as text."));
} else {
if (main.getPlayerManager().getPlayer(recipient).receiveNotificationSound())
recipient.playSound(recipient.getLocation(), Sound.BLOCK_NOTE_CHIME, 5, 1);
recipient.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&8&l[&e" + p.getName() + "&8&l] &7" + message));
p.sendMessage(MortuusTerraChat.CELLPHONE_PREFIX + color("&7Called &e" + pObject.getCurrentCellPhoneRecipient() + "&7: " + message));
}
}
示例15: onPlayerInteract
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
Action action = event.getAction();
if (event.hasItem() && (action == Action.RIGHT_CLICK_AIR || (action == Action.RIGHT_CLICK_BLOCK && !event.isCancelled()))) {
ItemStack stack = event.getItem();
if (!isBottledExperience(stack)) {
return;
}
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore();
Integer amount = null;
for (String loreLine : lore) {
if ((amount = JavaUtils.tryParseInt(ChatColor.stripColor(loreLine).split(" ")[0])) != null) {
break;
}
}
if (amount != null) {
event.setCancelled(true);
Player player = event.getPlayer();
int previousLevel = player.getLevel();
new ExperienceManager(player).changeExp(amount);
// Play a fancy sound if they earned 5 exp levels.
if ((player.getLevel() - previousLevel) > 5) {
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1.0F, 1.0F);
}
// If the hand is more than 1, decrease by 1
// otherwise remove. To prevent user error.
if (stack.getAmount() > 1) {
stack.setAmount(stack.getAmount() - 1);
} else {
player.setItemInHand(new ItemStack(Material.GLASS_BOTTLE, 1));
}
}
}
}