Help with Making Commands

Discussion in 'Plugin Development' started by BigAl512, Jun 29, 2014.

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


    Recently I started making a plugin, and i have tried to make a command /pn info that displays information about the plugin. When i go ingame and type /pn info it says unknown command, but /help pn brings up the command. Here is my code

    Main Class
    1. package;
    2. import;
    3. public class Main extends JavaPlugin {
    4. public static void main(String[] args){
    5. }
    6. public void onEnable() {
    7. String author = "BigAl512";
    8. String version = "1.0 Beta";
    9. getLogger().info("Player Join has been Enabled!");
    10. getLogger().info("Player joins is currently developed by " + author + "And is running version " + version);
    11. getServer().getPluginManager().registerEvents(new JoinEvents(), this);
    12. getCommand("pn info").setExecutor(new Commands());
    13. }
    14. }
    15. Command Class

    1. package;
    2. import org.bukkit.ChatColor;
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandExecutor;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. public class Commands implements CommandExecutor {
    8. @Override
    9. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    10. if (cmd.getName().equalsIgnoreCase("pn info")){
    11. Player player = (Player) sender;
    12. player.sendMessage(ChatColor.BLUE + "[" + ChatColor.GRAY + "Player Notifications" + ChatColor.BLUE + "]" );
    13. }
    14. return false;
    15. }
    16. }

     name: Player Notifications
    version: 1.1.0
    description: This plugin is so awesome!
    # We could place every author in the authors list, but chose not to for illustrative purposes
    # Also, having an author distinguishes that person as the project lead, and ensures their
    # name is displayed first
    author: BigAl512
    database: false
      pn info:
        description: Information about Player Notifications
        aliases: [pn about]
  2. Offline



    You don't need public static void main(String[] args) as it is a Bukkit plugin...
  3. BigAl512 likes this.
  4. Offline


    I could point out so many errors but it would take a while.

    Would be nice if you learned a little bit of Java and some Bukkit API and then come ask for help if still needed.
    ZanderMan9 likes this.
  5. Offline


Thread Status:
Not open for further replies.

Share This Page