Solved Play sound on player join

Discussion in 'Plugin Development' started by jmmalcolm3, Jan 4, 2015.

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


    First off, I'm sorry if this is a stupid question, or problem, I'm a pretty big noob when it comes to coding. I really only need this one thing though.

    So this is my code ATM:
    package me.Jamez.main;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Sound;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerJoinEvent;
    public class Main extends JavaPlugin{
        public void onPlayerJoin(PlayerJoinEvent e)
                 for(Player p : Bukkit.getOnlinePlayers()){
                     p.playSound(p.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0);
                Bukkit.broadcastMessage(ChatColor.GOLD + "+ " + ChatColor.AQUA + ChatColor.BOLD + ChatColor.UNDERLINE + "The Multiplex staff member" + ChatColor.RED + ChatColor.BOLD + ChatColor.UNDERLINE + (" + e.getPlayer().getName()" + ChatColor.AQUA + ChatColor.BOLD + ChatColor.UNDERLINE + "has joined the server!"));
    I want it to play the EnderDragon Growl sound and broadcast the message above to all players in the server. Right now it doesn't do anything, at all. It doesn't make the sound, nor does it broadcast the message. I only want this to happen if the player has the permission "staff.join". Thanks, and again, sorry if this is a stupid question.
  2. Offline


    Register your events
  3. Offline


    Thanks for the quick response. I will do that and get back to you.
  4. Offline



    Where is your onEnable in the class that extends JavaPlugin?
  5. Offline


    Make sure your player has permission for staff.join. If it still doesn't work after registering your events then I would try and remove the if statement for seeing if the player hasPermission then go from there.
  6. Offline


    Alright, I registered the events, and it worked perfectly! Thanks guys! Well, actually, almost perfectly. The name part of the join message actually says e.getPlayer().getName()

    EDIT: Nevermind, fixed it :D thanks guys!
    Last edited: Jan 4, 2015
Thread Status:
Not open for further replies.

Share This Page