Plugin Help player cannot be resolved to a variable?

Discussion in 'Plugin Help/Development/Requests' started by Timeist, Feb 15, 2017.

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

    Timeist

    The code I currently have doesn't work, and I'm sorry if it doesn't look too good, I'm new to Java.. Any help?
    upload_2017-2-15_18-17-10.png
     
  2. Offline

    Zombie_Striker

    @Timeist
    1. Use the package format "me.<your name>.<project>"
    2. Don't log your own plugins. Bukkit does this for you.
    3. You forgot to register the listener.
    4. Main problem: What is player? You never create that variable. This is why we ask members to learn Java before working on bukkit plugins. To get the player's instance, use Event#getPlayer() (where Event is the event instance)
    5. If you take into account for #2, your ondisable will do nothing. That means you should remove it/
     
    ipodtouch0218 likes this.
  3. Offline

    MattTheBeast

    Your not getting the player, I think you just watched a youtube video and saw Player player = (Player) sender and decided to change the sender to player...

    You need to do Player player = e.getPlayer and in other cases, e.getEntiy

    This means that Your getting the player by checking who triggerd the event. Since other Entity's dont have inventorys you can only get players but if it was a other entity triggering the event you would whant to check if its a player with A if statement.
     
    ipodtouch0218 likes this.
Thread Status:
Not open for further replies.

Share This Page