My code just doesn't work, and a evil entity called Asmaholeth the purple, will kill my father if i dont finish this until the next full moon. This is my main Code: package sugarpietro.Tutorialbooa; import org.bukkit.plugin.java.JavaPlugin; import sugarpietro.Tutorialbooa.Eventos.Eventos; public class Main extends JavaPlugin { public void OnEnable(){ getServer().getConsoleSender().sendMessage("Eu, eu fui ativado novamente"); getServer().getConsoleSender().sendMessage("de qualquer forma, minha missão e ajudar vocês com o que precisam, caso necessitem de minha benção podem chamar-me, "); getServer().getPluginManager().registerEvents(new Eventos(), this); } } This is the code Code: package sugarpietro.Tutorialbooa.Eventos; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class Eventos implements Listener{ @EventHandler public void onPlayerMove (PlayerMoveEvent evento){ Player jogador =evento.getPlayer(); jogador.sendMessage("Ricardo Milos"); Inventory inventario = jogador.getInventory(); ItemStack a = new ItemStack(Material.PUFFERFISH); inventario.addItem(a); } } It would be very nice if you guys could help me, i really like my father.
What doesn't work, what is the error? Do you get any errors in the console? Can you paste your console here? The first thing that I can spot is in your main class: Code: public void OnEnable(){ is sopposed to be: Code: public void onEnable(){ The o has to be lowercase. If that doesn't fix it then at least tell us what the problem is.
Having the @Override notation isn't required per say, your program will still run exactly the same without it, but you should have it, just in case. For example, if you try to override a function, but you miss a argument or misspell the method name, it will throw an error and you will know. It also improves the readability of your code.
So, Eclipse doesn't notice anything wrong with the code, but when I run it in minecraft nothing happens. I will try doing what was suggested and see what happens, thanks for the help.
You probably didn't even export the jar file to your plugins folder, check the server logs if it even enables your plugin.
Then what's not working here like is the server sending a message when you move? Are you just not receiving the item? Are you getting any errors in the console? Your code looks like it should work just fine.
We can't figure out your error, but I might have an idea? Change getServer().getPluginManager().registerEvents(new Eventos(), this); to this.getServer().getPluginManager().registerEvents((Listener)this, (Plugin)this); in your onEnable() The second one registers event correctly for me, so yours might be right, but use mine if you want, just in case, since mine works. EDIT: As Wick states, this won't change anything, nevermind!
No, don't do this. The only difference between those lines of code is that the first one is registering a listener as another class, whereas the second is registering your main class. OP has a separate class for his listener and therefore should not change this line of code.
Exactly, the console dont send the message, and i dont receive the item, nothing works, and i dont see any error message
@Yep, could you post your server log and current code for both classes (with pastebin or something similar)?
IT WORKED! Thank you very much to everyone who helped, this community is one of the most welcoming I have ever seen. My father is also very grateful to everyone!