I Need Help with my Plugin AGAIN

Discussion in 'Spigot Plugin Development' started by TechWiz, May 31, 2015.

  1. Ok so I posted thread like this earlier. but I completely gave up on it. I think I know why... anyways I made another plugin. It's simliar, it appears in console when activating and in the plugins list with a green colour, but when I handle the event, nothing happens, and nothing is sent to the console for any errors. Please help!
    In My package (me.techwiz.penceperkill) i have 2 classes.



    The idea of the plugin is when you kill a mob, you get £0.50. But when I kill a mob, hostile or non-hostile, nothing happens. The message doesnt come up and the money doesnt be added to my account.

    It would be a pleasure if someone could see the problem that I'm facing and help me through it :)
  2. You can't have two JavaPlugin subclasses in your plugin.
  3. so replace JavaPlugin with EntityEvent ? And in which class
  4. What are you talking about? I never said anything about creating a new Event.
  5. If i have two JavaPlugins, what would I make one of them to be different?
  6. You need to implement Listener in your listener class, and extend JavaPlugin in your main class.
  7. Ok, in main.java I added implements Listener instead of javaplugin. But on the RegisteredServiceProvider, the getServer() is underlined, and when I create a method for it as it automatically does it for eclipse, I'm not sure what to put in here but getServicesManager gets underlined also and says Add cast to 'getServer()' and it changes the code alot and I'm not sure what to do. When I click add cast to 'getServer()' the line turns into this. What would I do to make it as if it will work next time I test it.

    RegisteredServiceProvider<Economy> economyProvider = ((Object) getServer()).getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);

    getServicesManager gets another underline saying change method reciever cast... I really do not know what to do
  8. Inkzzz

    Resource Staff

    onEnable method..
  9. Ummm, you need to add "implements Listener" in your LISTENER class only, not in your Main.java. Your PencePerKill should be your Listener class as you are using "@EventHandler" only in that class. Your Main.java is supposed to be your "main" class a.k.a extends JavaPlugin.
  10. in console it says me.techwiz.penceperkill does not extend JavaPlugin

    in plugin.yml I changed main to me.techwiz.penceperkill.Main instead

    But it still does not handle the event, nothin happens
    #10 TechWiz, May 31, 2015
    Last edited: May 31, 2015
  11. Now your plugin.yml is not configured properly....
  12. Go to the main class and right after "Main", You type "extends JavaPlugin"

    It should look like:
    Code (Text):
    public class Main extends JavaPlugin {
    If you haven't imported the "JavaPlugin" package yet, Hover over JavaPlugin and click on the bukkit-asssociated one.
  13. Your plugin.yml should have a field that says "main:". In that field, type "me.techwiz.penceperkill.Main" as Main is the class that extends JavaPlugin
  14. That's irrelavent if you read my post above.
  15. @CodeErrors
    It is very relevant. If for instance he only extended JavaPlugin in Main and mentioned that his "main:" class was the Listener Class, then the system would throw an error saying, "Main Class Not Found" as his Listener class does not extend JavaPlugin.

    EDIT: The error would be as he stated, "me.techwiz.penceperkill.PencePerKill does not extend JavaPlugin"... Sorry I don't memorize errors lol :p

    DOUBLE EDIT: @TechWiz Please send your code once again after you have made all the changes.
  16. His listener class isn't supposed to extend a JavaPlugin, it only implements a Listener.

    The Main class when controls the entire usage of the plugin is supposed to extend JavaPlugin
  17. @CodeErrors Yes, I know that. I didn't ask him to extend JavaPlugin on Listener Class. I was merely stating that he should mention the right class in the plugin.yml file.
  18. Okay here is your problem, you cannot extend JavaPlugin twice, there can only be one class that Extends the JavaPlugin and this should be the main class defined in your plugin.yml . You must define the CLASS that extends JavaPlugin, not just the package. Change your Event class to implement Listener and register the events in the main class. You'll need an instance of that class though so do something like new PencePerKill

    It also needs to be mentioned that you need to add an onEnable method to your main class, this will run when the plugin is activated or being loaded on your server. This is where you can register the events and load anything else.

    I'm not going to simply write the code for you, you need to figure that out on your own. If you are completely stumped pm me and I can give you some help. Honestly I feel you need to take some basic Java lessons before continuing with development.
  19. uh
    ok.. I am a beginner. So, just take the onEnable and onDisable from PencePerKill and slot it in the main.java. I'll try this, thanks