PlaySound Not Working

Discussion in 'Plugin Development' started by DashAhead, May 9, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    DashAhead

    For some reason my playsound code doesn't play a sound when I join my server. There are no errors and here is the code:

    Code:java
    1. package mineparty.hub;
    2.  
    3. import org.bukkit.Sound;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerJoinEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class Hub extends JavaPlugin implements Listener {
    11.  
    12. @EventHandler
    13. public void onPlayerJoin(PlayerJoinEvent event) {
    14. Player player = event.getPlayer();
    15. player.getWorld().playSound(player.getLocation(), Sound.ORB_PICKUP, 1F, 1F);
    16.  
    17. }
    18. }
    19.  
     
  2. Offline

    Jaaakee224

    DashAhead
    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent e) {
    3. Player p = (Player)e.getPlayer();
    4. p.playSound(p.getLocation(), Sound.ORB_PICKUP, 10, 1);
     
  3. Offline

    Zach_1919

    DashAhead Register your events in onEnable() like this:

    Code:java
    1. public void onEnable()
    2. {
    3. getServer().getPluginManager().registerEvents(this,this);
    4. }
     
  4. Offline

    DashAhead

    Zach_1919

    Yeah I figured it out, it's always the little things.
     
Thread Status:
Not open for further replies.

Share This Page