Hey Ya'll, I'm coding a kick on death plugin, and I'm having some trouble. I can't seem to find out how to kick the player... Code: @EventHandler public void onPlayerDeath(PlayerDeathEvent e) { player.kickPlayer("Kick Message"); Now, on "player.kickPlayer", the word "player" at the front cannot be resolved. I have tried playerEvent and other things, but it all doesn't seem to be working. Any help? Thanks in Advance
@BiskitDEV You haven't defined "player" anywhere. It doesn't know what "player" is. As @timtower said, there is a method to get the player from the event.
Alright, so: Code: @EventHandler public void onPlayerDeath(PlayerDeathEvent e) { e.getPlayer().kickPlayer("Kick Message");
@BiskitDEV try the method that is returning a player then. I know that there is one. Task is up to you to find it.
Yeah, looks like PlayerDeathEvent inherits from EntityDeathEvent, so there isn't a getPlayer method anywhere. @BiskitDEV If it also helps you in any way, you can always check the bukkit java docs, it's a very useful place to find nearly everything related to the api. In this case, try this one: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/event/entity/PlayerDeathEvent.html
@BiskitDEV Instead of event.getPlayer() PlayerDeathEvent should be used with event.getEntity() then see if the entity is an instance of Player and then kick them.
In this case, for PlayerDeathEvent, getEntity will return a Player object. The name is just inherited from EntityDeathEvent, as it is extending it.