Solved ShowStatus

Discussion in 'Plugin Development' started by rob1998@, Oct 12, 2012.

Thread Status:
Not open for further replies.
  1. I want to make a status plugin but I don't know how to change the displayname of the player who uses /afk or something like that.
    I also have some trouble with sending a message to the world that playername is afk.
    Do I need to save the status somewhere?

    Can someone please help me?

    I have started, but I don't have the part with sending a message and when I type /afk it says there's no command like /afk


    this is my code:

    Show Spoiler

    Code:
    package com.gmail.grob1998.ShowStatus;
     
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    import java.util.logging.Logger;
     
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.*;
     
    public class main extends JavaPlugin implements Listener
    {
        public Logger log;
        public final Logger logger = Logger.getLogger("Minecraft");
        public void onEnable()
        {
            log = getLogger();
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + pdfFile.getVersion() + " has been Enabled");
            getServer().getPluginManager().registerEvents(this, this);
        }
     
            public void onDisable(){
                PluginDescriptionFile pdfFile = this.getDescription();
                this.logger.info(pdfFile.getName() + pdfFile.getVersion() + " has been Disabled");
            }
            public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
            {
                if (command.getName().equalsIgnoreCase("afk"))
                {
                    if (!(sender instanceof Player))
                    {
                        log.info("This is a player command!");
                        return true;
                    }
     
                    Player player = (Player)sender;
     
                    {
                        player.sendMessage(player.getName()+" is now AFK");
                        player.setDisplayName("[AFK]"+player.getName());
                    }
                    return true;
                }
                return false;
            }
    }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  2. Offline

    Drew1080

    rob1998@

    1. Have you registered the command yet in the plugin.yml file?

    2.You dont need to have {} around

    Code:
                        player.sendMessage(player.getName()+" is now AFK");
                        player.setDisplayName("[AFK]"+player.getName())
     
                    return true;
     
  3. Thanks, indeed i forgot to register the command
     
  4. Offline

    slam5000

    How do you know he doesn't have OCD? (Obsessive sCope Disorder)?
    He could need to make new scope for his own sanity! You're so inconsiderate!
    (trolololoolololol)
     
Thread Status:
Not open for further replies.

Share This Page