HELP!

Discussion in 'Plugin Development' started by Famous Guy, Nov 2, 2013.

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

    Famous Guy

    How do I create a plugin where you do a command and it gives you a message, That's all! It just gives the player a message with a color like chatcolor.GOLD + ("Message") how would I make this?
     
  2. Offline

    Tss1410

    Code:java
    1. public boolean onCommand(CommandSender Sender, Command command, String commandLabel, String[] args){
    2. if(command.getName().equalsIgnoreCase("hello")){
    3. Sender.sendMessage(ChatColor.GREEN + "Hello!!");
    4.  
    5. }
    6. return true;
    7. }
    8. }
     
  3. Offline

    sgavster

    Famous Guy
    PHP:
    public boolean onCommand(CommandSender senderCommand cmdString commandLabelString[] args) {
    if(
    cmd.getName().equalsIgnoreCase("command")) {
    sender.sendMessage(ChatColor.GOLD "MESSAGE");
    }
    }
     
  4. Offline

    Famous Guy

    Like this? http://prntscr.com/21jipu
     
  5. Offline

    Tss1410

    Yes. thats correct.
    But one thing i saw.
    You have plugin.yml in the wrong place. you have to right click at the project file, not the package, to make the file
     
  6. Offline

    sgavster

  7. Offline

    Famous Guy

    Moved it but it isn't working :s
     
  8. Offline

    ThunderGemios10

    is your plugin.yml correct ?
     
  9. Offline

    Famous Guy

    name: Sweg
    version: 1.0
    main: me.Famous_Guy2.Sweg.Sweg
    description: a plugin
    commands:
    test:
    description: thx for testing
     
  10. Offline

    cruz2000

    Try this:

     
  11. Offline

    Famous Guy

    Nope, Doesn't work still ;-;
     
  12. Offline

    cruz2000

    ok give me a sec
     
  13. Offline

    BedRockets

    You don't have a onEnable and onDisable methods
     
  14. Offline

    maxben34

    Code:
    name: sweg
    version: 1.0
    main: me.Famous_Guy2.Sweg
    description: a plugin
    commands:
        test:
            usage: /<command>
            description: a test command.
    This is how your plugin.yml should be. You need to MAKE SURE that you are not "tabbing" when you use spaces in YAML configuration. You need to do 4 spaces per tab, otherwise it won't work!
     
    Famous Guy likes this.
  15. Offline

    sgavster

    maxben34 likes this.
  16. Offline

    maxben34

    You don't need on enable or ondisable methods unless you need to register events or call methods in onEnable() or onDisable(). In this case he just has commands so that isn't necessary.

    That's why I go on these forums. I help others and learn more stuffs in the process ;).

    EDIT: Sorry for the double post :/

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

    cruz2000

    Here:

    Code:java
    1. package me.cruz2000;
    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 MyFirstPlugin extends JavaPlugin {
    10.  
    11. @Override
    12. public void onEnable() {
    13. getLogger().info("Hello Youtube! onEnable has been enabled!");
    14. }
    15.  
    16. @Override
    17. public void onDisable() {
    18.  
    19. }
    20.  
    21. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    22.  
    23. if (cmd.getName().equalsIgnoreCase("hello") && sender instanceof Player) {
    24.  
    25. Player player = (Player) sender;
    26.  
    27. player.sendMessage(ChatColor.GOLD + "Hello");
    28.  
    29. return true;
    30.  
    31. }
    32.  
    33. return false;
    34. }
    35.  
    36. }
    37.  
     
  18. Offline

    Famous Guy

    Fixed it :p
     
  19. Offline

    BedRockets

    Are you sure about that, cause I had the same problem once, but it got fixed when I added the onEnable and onDisable methods...
     
  20. Offline

    maxben34

    I'm very sure that onEnable and onDisable methods aren't needed. In earlier versions of bukkit (about a year ago) it was a necessity, but it isn't needed anymore.
     
  21. Offline

    cruz2000

    I agree
     
  22. Offline

    clutchmasterman

    you need to return false not true
     
  23. Offline

    maxben34

    It doesn't matter if things return false or true when using a command Boolean method. But just so you know... the original poster already had his problem solved.
     
  24. Offline

    1Rogue Retired Staff

    No, no you don't
     
  25. Offline

    clutchmasterman

  26. Offline

    1Rogue Retired Staff

    what?

    You return the success of handling the command. If you handled it correctly or as intended, then you return true.
     
Thread Status:
Not open for further replies.

Share This Page