Player can not seem to respawn

Discussion in 'Plugin Development' started by orange451, Mar 14, 2013.

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

    orange451

    This is a very odd bug...
    I have tried three different versions of Craftbukkit (#2643, #2636, #2600). What happens, is that every once in a while, when a player clicks "respawn" after dying, they cannot respawn. The death screen remains, and the respawn event doesn't seem to trigger.

    Any ideas?
     
  2. Offline

    TheUpdater

    have somthing connected to respawn event?
     
  3. Offline

    orange451

    I don't :/
     
  4. Offline

    TheUpdater

    server ip so i can join and test lol


    or remove your plugin die and test respawn if you respawn its your plugin

    then post sorce and i can look at it
     
  5. Offline

    orange451

    74.63.222.188
    Is the IP to the server.

    It appears as though when I have this in my EntityListener class:
    Code:
        @EventHandler(priority=EventPriority.NORMAL)
        public void onEntityDeath(EntityDeathEvent event) {
            try {
                event.setDroppedExp(0);
                LivingEntity dead = event.getEntity();
                if (dead instanceof Player) {
                    CSPlayer csplayer = MCCS.getCSPlugin().getCSPlayer((Player)dead);
                    if (csplayer != null) {
                        Player killed = csplayer.getPlayer();
                        Entity damager = null;
                        if (event.getEntity().getLastDamageCause() != null && event.getEntity() != null) {
                            damager = event.getEntity().getLastDamageCause().getEntity();
                        }
                        if (damager != null)
                            new KilledPlayer(killed, damager);
                    }
                }
            }catch(Exception e) {
                e.printStackTrace();
            }
        }
    The players cannot respawn every ONCE in a while.
    There are no errors however.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Offline

    Scyntrus

    I think
    Code:
    if (event.getEntity().getLastDamageCause() != null && event.getEntity() != null) {
    should be
    Code:
    if (event.getEntity().getLastDamageCause() != null && event.getEntity().getLastDamageCause().getEntity() != null) {
    But that shouldn't be the thing causing your problem.

    I'd take a look at your PlayerRespawnEvent.
     
  7. Offline

    orange451

    There is none.
    All I know is that when I do not do anything in the EntityDeathEvent, respawning works normally,
    Even if I just have a method which listens for an entitydeath, but does NOTHING, the glitch remains...
     
  8. Offline

    Scyntrus

    What's in your KilledPlayer constructor?

    Edit: It might be something other than your plugin.
     
  9. Offline

    orange451

    Code:
    public class KilledPlayer {
     
        public KilledPlayer(Player killed, Entity damager) {
            Player killer = null;
            if (damager instanceof Player)
                killer = (Player)damager;
            if (damager instanceof Projectile) {
                if (((Projectile)damager).getShooter() instanceof Player)
                    killer = (Player) (((Projectile)damager).getShooter());
            }
           
            if (killer != null) {
                execute_kill(killer, killed);
            }
            CSPlayer cskilled = MCCS.getCSPlugin().getCSPlayer(killed);
            if (cskilled != null) {
                cskilled.getArena().onDeath(cskilled);
            }
        }
     
        private void execute_kill(Player killer, Player killed) {
            CSPlayer cskiller = MCCS.getCSPlugin().getCSPlayer(killer);
            CSPlayer cskilled = MCCS.getCSPlugin().getCSPlayer(killed);
            if (cskiller != null && cskilled != null) {
                cskiller.getArena().broadcastMessage(cskiller.getTeamColor() + cskiller.getPlayer().getName() + ChatColor.GRAY + " killed " + cskilled.getTeamColor() + cskilled.getPlayer().getName());;
                cskiller.getArena().onKill(cskiller, cskilled);
            }
        }
     
    }
    I believe that the entitydeathevent was INDIRECTLY causing the bug.
    At the end of an arena, (which the entity death event triggered), the players healths were being reset to 20, so on the client, when they tried to respawn, it saw they had enough health to live, and wouldn't send the packet saying they were pressing the button (potential minecraft glitch?)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page