Made a portal-cancel bind, but it only works with nether portals, end portals glitch out

Discussion in 'CommandHelper' started by malon, Apr 10, 2018.

  1. malon

    malon Member

    PHP:
    bind('player_portal_travel', null, array('to': null), @event){
        cancel()
        sudo('/mv spawn')
        msg(color('RED').'Sorry, that world does not exist')
    }
    The issue:
    When entering a nether portal, it teleports you to the world spawn one time and tells you the message "Sorry, that world does not exist" only one time.
    When entering an end portal, it continuously teleports you to the world spawn and continuously spams the screen with "Sorry, that world does not exist"
  2. PseudoKnight

    PseudoKnight Well-Known Member Developer

    That Bukkit event is a bit odd with end portals, though I don't remember this particular issue. What I ended up doing is delaying a tick before teleporting the player, if I must teleport them inside the bind. You can see if that works for you. I also avoid cancelling when entering an end portal in the End, because that triggers the screen credits either way.
  3. malon

    malon Member

    PHP:
    bind('player_portal_travel', null, array('to': null), @event){
        cancel()
        set_timeout(50,closure(
            sudo('/mv spawn')
            msg(color('RED').'Sorry, that world does not exist')
        ))
    }
    This still spams the screen with a varying amount of messages, between 5 and 50, but it's no longer continuous. Did I write it correctly?
  4. PseudoKnight

    PseudoKnight Well-Known Member Developer

    Every server is different. MV might be doing something funky too. I had to stop using it because it was making it more difficult to work around portal issues.

    Have you tried not using /mv spawn? That's the only other difference. I use set_ploc(get_spawn()).
    Last edited: Apr 10, 2018
  5. PseudoKnight

    PseudoKnight Well-Known Member Developer

  6. PseudoKnight

    PseudoKnight Well-Known Member Developer

    BTW, it WILL repeat that message because you'll be hitting the end portal every tick. It shouldn't happen 50 times, though, since you're teleporting them out.
  7. malon

    malon Member

    I think this is just a glitch I will have to deal with, and it definitely does spam a random amount of times, between 5 and 50 seems fairly accurate, averaging about 15 to 20 messages. I notice you don't handle if the world doesn't exist (null) in your code, which is what I'm trying to do.

    I did replace "/mv spawn" with "set_pos(get_spawn())" but it doesn't change the issue. I would expect two messages when delaying a tick, one for the 1st tick I enter the frame, and one for the 2nd tick when I get TPed out, but for some reason, it detects many times more than twice.
  8. PseudoKnight

    PseudoKnight Well-Known Member Developer

    Actually, I handle those too. I handle all portal events there. Though technically I don't need to handle the main worlds.

    Might be a plugin conflict. But I don't message the player here, so it might be triggering multiple times on my server too, just harmlessly.