Making my first Plugin.

Discussion in 'Plugin Development' started by klutch2013, Feb 10, 2012.

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

    klutch2013

    not sure if this is the right place to post this (didn't really see anywhere else) but i was making my first Bukkit Plugin based off of a tutorial that i'm following located here:


    and i got some errors that i don't know what to do with. Now i know that bukkit changed the API but since this is my first time ever coding Java i don't know if its my mistakes or its something with bukkit that i need to fix.
    So here is the pastbin of the code of the plugin and screen shots,
    http://pastebin.com/PmgFL9jB

    all help is appreciated. if it is just because of the change in the Bukkit API, and someone has an easier to understand page then this,http://wiki.bukkit.org/Introduction_to_the_New_Configuration
    it would be really helpful.
     
  2. Offline

    Sabersamus

    change this:
    Code:java
    1. pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerlistener, Event.Priority.normal, this);


    to this:
    Code:java
    1. pm.registerEvents(this.playerListener, this);


    and change this:
    Code:java
    1. public class SeverChatPlayerListener extends PlayerListener {


    to this:
    Code:java
    1. public class SeverChatPlayerListener implements Listener {


    dont forget to import Listner from bukkit (if that doesnt help, or doesnt work let me know)

    edit: oh yeah and do this:

    Code:text
    1. @EventHandler
    2. public void onPlayerChat(PlayerChatEvent chat) {


    the above goes in your PlayerListener.java (or what ever you have it set for, i believe you set it to ServerPlayerChatListener.java
     
  3. Offline

    klutch2013

    that fixed all issues in my ServerChatPlayerListener.java class now. There is still a few errors within my helloworld.java class.

    here is the raw code and a new screenshot:
    http://pastebin.com/PmgFL9jB
     
  4. Offline

    Sabersamus

    can you show me the player listener?

    change
    Code:java
    1. public final Logger Logger = Logger.getLogger("Minecraft");


    to
    Code:java
    1. public final Logger logger = Logger.getLogger("Minecraft");


    it MIGHT help,
     
  5. I would suggest using
    Code:
    Bukkit.getLogger();
    instead of
    Code:
    Logger.getLogger("Minecraft");
     
  6. Offline

    klutch2013

    Yea, in the tutorial he said there was an easier way but for the purpose of the tutorial he used the longer one.


    I did that fix you suggested and that fixed that error. now theres just a few more. i updated the pastebin with all of the information
    http://pastebin.com/PmgFL9jB
     
  7. Offline

    thehutch

    Which bukkit build are you using? Because there is a new Event system, also paste your Listener class it might help
     
  8. Offline

    klutch2013

    i pasted the listener class in the Pastebin and i am using Bukkit 1.1 R4
     
  9. Offline

    thehutch

    Your problem is that you forgot the @EventHandler above the onPlayerChat() method do that and it will work
     
  10. Offline

    klutch2013

    that didn't work sorry, i updated the pastebin:
    http://pastebin.com/PmgFL9jB
     
  11. Offline

    thehutch

    You should remove that import for one, and import the Logger and such
     
  12. Offline

    klutch2013

    Ok i removed 'import org.bukkit.event.player.PlayerChatEvent;" and then reimported it and its not showing any errors on the "ServerChatPlayerListener.java
    so now i'm just down to the errors in "hellowworld.java"
    here is an image of the "problems" eclipse says there is:
    http://dl.dropbox.com/u/3104034/2.png

    i also updated the Pastebin with all of the information:
    http://pastebin.com/PmgFL9jB
     
  13. since you changed the name of the variable of the logger like in post #4, you'll also change that in the code later when you use
    Code:
    this.Logger.
    you'll need to change that as well to
    Code:
    this.logger.
     
  14. Offline

    klutch2013

    thanks, that is all fixed now. just 3 more errors left all involving the "ServerChatPlayerListener" inside of my "helloworld.java" file heres an image:
    http://dl.dropbox.com/u/3104034/almostthere!.png

    and heres the pastebin with all information updated:
    http://pastebin.com/PmgFL9jB
     
  15. Offline

    thehutch

    Is your ServerChatPlayerListener in another package if so try importing it :D or maybe some spelling mistake?
     
  16. Offline

    klutch2013

    o wow, i am so blind...it was spelled wrong lol there is no errors now. thanks for all your help everyone!
     
  17. Offline

    thehutch

    (facepalm) :D:D:D
     
  18. Offline

    klutch2013

  19. Offline

    thehutch

    Check your plugin.yml. Did you add the main?
     
  20. Offline

    klutch2013

    i'm sorry i'm still really new and don't understand what you mean. heres my plugin.yml
    http://pastebin.com/JtGeJfx2
     
  21. Offline

    Sabersamus

    what he means is this
    Code:
    main: me.klutch2013.TestPlugin.helloworld

    seeing as its there ;) you got it, you just put the wrong path XD

    change
    Code:
    main: me.klutch2013.TestPlugin.helloworld
    to this
    Code:
    main: com.github.klutch2013.TestPlugin.helloworld
    that otta fix things up :)
     
  22. Offline

    klutch2013

    ah thanks, fixed that but still an error :(
    The error is here:
    http://pastebin.com/mPv7MM23
     
  23. Offline

    Sabersamus

    can you show me your main class?
     
  24. Offline

    klutch2013

Thread Status:
Not open for further replies.

Share This Page