Plugin Help Cannot resolve method

Discussion in 'Plugin Help/Development/Requests' started by burnshadowboy, Aug 2, 2016.

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

    burnshadowboy

    So I was coding today and learning off this tutorial from youtube but, when I wrote a certain line that was in the video into my code my code started showing errors so I checked the video and I wrote everything correct I was hoping someone here could help me out :)

    Code:

    Code:
    package me.shadowboy.minigame;import me.shadowboy.minigame.listeners.PlayerInteract;import org.bukkit.event.Listener;import org.bukkit.plugin.java.JavaPlugin;import java.lang.reflect.Array;public class Minigame extends JavaPlugin {
    
    @Overridepublic void onEnable() {
    
    registerListener(new PlayerInteract());}
    
    private void registerListener(Listener... listeners) {
    
    Array.stream(listeners).forEach(listener -> getServer().getPluginManager().registerEvent(listener(), this)); for (Listener listener : listeners) {
    getServer().getPluginManager().registerEvent(listener, this);}
    
    }
    
    
    
    }
    
     
    Last edited by a moderator: Aug 2, 2016
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    burnshadowboy

    line 11 at the party where it says (listener, this) it tells me Cannot resolve method 'registerEvent(org.bukkit.event.listener, me.shadowboy.minigame.minigame)"
     
  4. Offline

    timtower Administrator Administrator Moderator

    @burnshadowboy You know what, start with formatting the code, you have a lot of stuff on the same line, unreadable.
     
  5. Offline

    burnshadowboy

    its perfectly fine in my IDE here its just messed up for some reason
     
  6. @burnshadowboy
    ".registerEvent()" is a method that you need to specify which event you want to register. With ".registerEvents()" you don't have to do that.
     
  7. Offline

    burnshadowboy

    can you show me on the code cause I'm really confused
     
  8. @burnshadowboy
    I will not code for you, I will only tell you what's wrong and perhaps how to fix it.

    Alright so, you currently use the ".registerEvent()" method in your code. This method requires you to put in an Event aswell. Try using ".registerEvents()" instead.

    Also, why do you register all your listeners twice? You loop through each of the arguments of your method in two different ways and register them twice.

    And finally, these youtube tutorials (at least the good ones) do not intend you to carbon-copy their code, instead that you should learn to make the code yourself. Also, from what you have copied, it looks like the tutorial you're watching isn't very good, you might want to consider picking a new one from this link.
     
  9. Offline

    burnshadowboy

  10. @burnshadowboy
    It says exactly what the problem is. You can't input a lambda parameter.
     
  11. Offline

    burnshadowboy

    @AlvinB which is......

    @AlvinB i got it to work don't worry thanks for all the help though!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 3, 2016
  12. @burnshadowboy
    I was mistaken, that is a valid expression. Your problem is that the class Array has no method called "stream()". The class Arrays does though. I am very confused as to why your IDE doesn't tell you this.
     
  13. Offline

    HeartandSoul

    When your registering events in main, you want to use the new keyword. Like for instance: .registerEvents(new listener(), this);

    And what Alvin said, it tells you what the error is.
     
Thread Status:
Not open for further replies.

Share This Page