Discussion: Oops, I broke your plugins!

Discussion in 'Plugin Development' started by EvilSeph, Jan 17, 2011.

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

    matejdro

    Bump. I'm doing some stuff after teleporting, so this is important to me.
     
  2. Offline

    Rigby90

    If I understand the question correectly then... Once the event has passed through all the plugins and continues to process the move event the teleport happens. However because each plugin has a say in .setTo() you could set the location then the plugin next in line could then change it... However that should be no different than 2 plugins teleporting within the event... only one will come out victorious.

    https://github.com/Bukkit/CraftBukk...t/minecraft/server/NetServerHandler.java#L147

    Hopefully that comment within the source as well as the source itself can better explain things, I tried to explain in the comment as to why we have to immediately teleport the player if a plugins changes the setTo() location.
     
  3. Offline

    matejdro

    Ouch. I want to do some stuff after teleporting (like changing vectors etc.), and it seems like It's impossible now :(

    What was wrong with the old system?
     
  4. Offline

    Rigby90

    Apologies I forgot to add....

    The method used to teleport after the event is fired is -
    PHP:
    ((CraftPlayerthis.player.getBukkitEntity()).teleport(event.getTo());

    This method calls the Teleport event, so after the move event if a plugin has changed the setTo() a Teleport event will fire after it, this is to allow plugins to act upon the fact that a player may of changed world during a move event or simply moved 2000 blocks away and out of the border...

    When a plugin teleported during the onPlayerMove event or changed the .setTo() to too far of a distance from their previous location... then Notchs speedhack check would trigger and the player would be kicked from the server.

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

    matejdro

    Oh, so now i will have to split my code into two events?

    I see that is the problem, but what was wrong with the old system where you manually teleported and activated setTo()?
     
  6. Offline

    Rigby90

     
  7. Offline

    matejdro

    No, if you triggered teleport event and then used .setTo(), nothing would go wrong.
     
  8. Offline

    Rigby90

    Just out of curiosity... What are you trying to do with vectors straight after a teleport? What is the outcome you're after?
     
  9. Offline

    matejdro

    I simply set vectors (PortalStick plugin)
     
  10. Offline

    Drakia

    Do you mean yaw/pitch? Cause you can do that before you warp them.
     
  11. Offline

    Rigby90

    I believe he wants to continue the players momentum when teleporting the player... so if he jumped into a hole with a portal in then his momentum would continue, and you do that via velocity.

    @matejdro - All I can think would be to cancel the event and call the teleport/velocity change 1 tick later... This should be a cleaner method which would avoid the speed check and prevents you from having to listen to multiple events to achieve the same task.

    Also a side note... teleporting the player and then calling .setTo() would still cause the player to be kicked. The speed check compares the location from the packet sent by the client compared to the player entities current position... So even if you teleport them before event.setTo() their entity location is updated but the location it's still comparing against is the one in the packet. (Anyways that's what's meant to happen and has happened during our extensive testing in trying to resolve the issue in a different matter... the event.setTo() change was the only logical choice for now.)
     
  12. Offline

    matejdro

    Yeah, i should wrote velocity instead of vector, sorry about that.

    It sounds like interesting solution. But my point is that i should not be doing that. Why should i do workarounds for changes in API?

    @EvilSeph what was wrong with the old system, where you manually teleported player and used .setTo()?
     
  13. Offline

    EvilSeph

    Rigby explained above.
     
  14. Offline

    matejdro

    But i already manually teleported player, so that should not be an issue.
     
  15. Offline

    Rigby90

    Since Notches speed check got implemented teleporting within the onPlayerMove event would almost certainly kick a player from the server... We needed an easy solution for this instead of requesting that every plugin utilizes the scheduler and did it one tick later.
     
  16. Offline

    matejdro

    I used this solution and did not have any problems.
     
  17. Offline

    Drakia

    @matejdro You have been told numerous times now why it was changed. Just because you do not notice the bug does not mean it does not exist, as a plugin dev I can say that this bug does exist, this change fixes it, and they aren't going to undo it.
     
  18. Offline

    Dinnerbone Bukkit Team Member

     
  19. Offline

    Celtic Minstrel

    By "initialize method" do you mean the onEnable method?
     
  20. Offline

    Shamebot

    probably, because
    Code:
    JavaPlugin.
    initialize(PluginLoader loader, Server server,PluginDescriptionFile description, File dataFolder, File file,ClassLoader classLoader)
    is final.
     
  21. Offline

    Dinnerbone Bukkit Team Member

  22. Offline

    matejdro

    It seems like this setTo() teleport won't change velocity. No problem for me then :)

    Thanks for trying to explain it to me anyway.
     
  23. Offline

    Maeyanie

    Would you mind telling us what the option is, instead of just that there is one? I can't seem to find it mentioned in the Bukkit javadocs. Of course, I may just be blind. :)

    Edit:
    Ok, found the PluginLoadOrder enum... still haven't found where to put it...
     
  24. Offline

    Dinnerbone Bukkit Team Member

    It's "order" in plugin.yml (read the commits! :p)

    It defaults to "postworld", but if you absolutely need to get there before the first world then do "startup".
     
  25. Offline

    Maeyanie

    My mistake, didn't realize "RTFS" was the standard way of finding out update details. :p That would explain why I couldn't find it in the javadocs though. Thanks for the answer! :)
     
  26. Offline

    Telgar

    Hey backing up to the PlayerMoveEvent and portals, the actual teleportation works fine, but I have an issue with failed teleporting. When a player enters one of my portals but the destination is not available, it fails and sends a message. Before this update, I prevented spamming the message by only checking when the player changed blocks:
    if(!event.getTo().getBlock().equals(event.getFrom()))
    This no longer works, and I do not know why, probably due to my lack of understanding of how events work.
    I also tried
    if(!event.getFrom().getBlock().equals(event.getPlayer().getLocation().getBlock()))
    any help? I apologize for any aggravatingly simple solutions.
     
  27. Offline

    tyzoid

    the legacy method player.teleportTo();
    has been removed from craftbukkit in #1060
     
  28. Offline

    Dinnerbone Bukkit Team Member

     
  29. Offline

    Drakia

    As of CB 1192 you can no longer instantiate a ColouredConsoleSender, this is a break from previous behaviour and should probably be noted.
     
  30. Offline

    Dinnerbone Bukkit Team Member

    Yeah, but it's unsupported behaviour that I've been yelling at people for doing for a very long time. We don't tell you that we're going to break things that you shouldn't be using :p
     
    sddddgjd likes this.
Thread Status:
Not open for further replies.

Share This Page