Im new to programming and i need help with a problem

Discussion in 'Plugin Development' started by porrinialex, Aug 19, 2013.

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

    porrinialex

    Well i cantt figure out why this plugin wont load in? Also remember im very new to this.



    Code:java
    1. package me.porrini.chatA;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class Main extends JavaPlugin{
    10. public void onEnable() {
    11.  
    12. }
    13. public void onDisable() {
    14.  
    15. }
    16. public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
    17. Player player = (Player) sender;
    18. if (alias.equalsIgnoreCase("sendme")) {
    19. player.sendMessage(ChatColor.BLUE + "Welcome to PerfectPvP");
    20.  
    21. } else if (alias.equalsIgnoreCase("hello")) {
    22. player.sendMessage("Hey!");
    23. }
    24.  
    25. return false;
    26.  
    27. }
    28. }




    plugin.yml

    Code:
    name: ChatA
    main: me.porrinialex.chatA.Main
    version: 1.0
    description: >
                ChatA plugin!
    commands:
      hello:
        description: Changes to GameMode Creative!
      sendme:
        description: Sends your self a message!
     
  2. Offline

    Sicka_gp

    Any error messages?
     
  3. Offline

    xTrollxDudex

  4. Offline

    Sabersamus

    Package declaration:
    Code:
    package me.porrini.chatA;
    In plugin.yml main class declaration:
    Code:
    main: me.porrinialex.chatA.Main
     
  5. Offline

    Tirelessly

    description in your plugin.yml seems off. Try completely removing it.
    Sabersamus is right
     
  6. Offline

    porrinialex

  7. Offline

    Jentagh

    Main is also a really bad name for your 'Main' class, try naming it something like PluginMain because Main is used in other syntax not as your class name ;) porrinialex
     
  8. Offline

    Samthelord1

    Jentagh I think you'll find most people call their main class Main and their event class Event and their is NOTHING wrong with that, I also don't see why you say this.
     
  9. Offline

    bloodless2010

    Am I the only one to spot this?
    Code:java
    1. if (alias.equalsIgnoreCase("sendme")) {
    2. player.sendMessage(ChatColor.BLUE + "Welcome to PerfectPvP");
    3.  
    4. } else if (alias.equalsIgnoreCase("hello")) {
    5. player.sendMessage("Hey!");
    6. }


    Shouldn't it be:
    Code:java
    1. if(command.getName().equalsIgnoreCase("sendme")) {
    2. player.sendMessage(ChatColor.BLUE + "Welcome to PerfectPvP");
    3. }
    4.  
    5. if(command.getName().equalsIgnoreCase("hello")) {
    6. player.sendMessage("Hey!");
    7. }


    If not, and you actually wanted to use alias', then you need to add the alias node to the plugin.yml
     
  10. Offline

    Samthelord1

  11. Offline

    porrinialex

    @bloodless2010 thats what i had before but someone told me to change it to that
     
  12. Offline

    Sabersamus

    Actually, you should use command.getName(), by using getName() you're also going through every alias. By using aliases, you have to manually go through every single alias.
     
  13. Offline

    porrinialex

    @Samthelord1 so do i just add "canihasbukkit" to the commands?

    Thanks guys it works!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  14. Offline

    Sabersamus

    What exactly did you do?
     
Thread Status:
Not open for further replies.

Share This Page