Help

Discussion in 'Plugin Development' started by XKnucklesX, Jan 31, 2014.

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

    XKnucklesX

    Solved

    Solved it :D

    This is confusing... I believe its because its not an actual event that I am doing. Maybe I have to include on PlayerChatEvent or something like that.

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

    Iaccidentally

    Well, first of all, this is the onCommand() method, not an event method, so @EventHandler isnt needed there.
    Secondly, system.out.println() prints to console.
    To get the player sending the command, you would first check in sender is an instance of Player, then if it is, cast that to a Player Object.
     
  3. Offline

    Jaaakee224

    XKnucklesX
    1. You need to extend JavaPlugin.
    2. No @EventHandler, onCommand is not an event.
    3. System.out.printIn() is only for console.
    4. Your error was caused because of the invalid @EventHandler.

    Your code should look like
    Code:java
    1. public class Main extends JavaPlugin {
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    4. Player player = (Player) sender;
    5. if(cmd.getName().equalsIgnoreCase("getworld")) {
    6. player.sendMessage("You are in " + player.getWorld().getName());
    7.  
    8. }
    9. return false;
    10. }
    11. }
     
  4. Offline

    XKnucklesX

    the event has just testing that I forgot to take out ._.
    System.out.println I must have got confused between bukkit and java
    The error was not the eventhandler because it was there already

    thanks though!

    i'm losing my bukkit sense :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page