Kicking People?

Discussion in 'Plugin Development' started by BiskitDEV, Jan 26, 2015.

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

    BiskitDEV

    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
     
  2. Offline

    timtower Administrator Administrator Moderator

    @BiskitDEV Try e.getPlayer() instead. You don't have a player variable at all
     
  3. Offline

    teej107

    @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.
     
    timtower likes this.
  4. Offline

    BiskitDEV

    So, how do I add it into the plugin? Just replace the "player" part with it?
     
  5. Offline

    timtower Administrator Administrator Moderator

  6. Offline

    BiskitDEV

    Alright, so:
    Code:
        @EventHandler
        public void onPlayerDeath(PlayerDeathEvent e) {
            e.getPlayer().kickPlayer("Kick Message");
     
  7. Offline

    timtower Administrator Administrator Moderator

    @BiskitDEV If eclipse isn't giving red lines and it is running: yes.
     
  8. Offline

    BiskitDEV

    The method getPlayer() is undefined for the type PlayerDeathEvent, eclipse says.
     
  9. Offline

    timtower Administrator Administrator Moderator

    @BiskitDEV try the method that is returning a player then. I know that there is one.
    Task is up to you to find it.
     
  10. Offline

    WinX64

  11. @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.
     
  12. Offline

    WinX64

    In this case, for PlayerDeathEvent, getEntity will return a Player object. The name is just inherited from EntityDeathEvent, as it is extending it.
     
Thread Status:
Not open for further replies.

Share This Page