Ignore player movement

Discussion in 'Plugin Development' started by Muizers, Nov 5, 2012.

Thread Status:
Not open for further replies.
  1. Is there a way to ignore the movement packets that the client sends to the server?

    What I want is to let the server decide that a player should stay in place and sometimes move. But that is not decided by the player, but by the server.
    • I do not need anything with the PlayerMoveEvent because that would block my own changes to the player movemen too (and more reasons)
    • I think I need something to do with the way packets are received in Bukkit.
    • Doing anything with the player velocity also won't solve my case
    Who can help me?
     
  2. try protecall lib to stop the packets from entering the server
     
  3. Haha thanks I'll try that!

    But it's called Protocol Lib it seems. I spent half an hour searching before I found that XD
     
  4. Offline

    fireblast709

    Muizers you know that if you cancel the PlayerMoveEvent yourself, it would be obvious that your own changes would be ignored as well
     
  5. Yes that I what I said in my own post too.
     
  6. Offline

    fireblast709

    Muizers then edit and do not cancel if not needed :3
     
  7. What are you talking about? I'm not cancelling any events at the moment.


    Please read carefully, you don't understand my question at all.
     
  8. Offline

    toothplck1

    public void onMoveEvent(PlayerMoveEvent event) {
    if(myplugin.does-not-need-to-act-on-this-move-event) {
    event.setcancelled(true);
    } else {
    do-stuff-on-this-move-event
    }
    }
     
  9. No no no, that is not what I'm asking.....

    I use things to set the velocity outside the move event, such as Player.teleport(...).

    But if you know how to distinguish between the moving events I've called myself and the ones I haven't in some way, let me know!
     
  10. Offline

    toothplck1

    Maybe store the event on a list and when you cal it you could be like (if list.contains(event)) I think this might work but haven't tried it myself so like:
    Code:
    public void otherFunction() {
    PlayerMoveEvent ev = new blah blah
      bukkit.blah.call(ev)
      myevents.add(ev)
    }
     
    public void onmove(PlayerMoveEvent ev){
      if(myevents.contains(ev)){
    blah
    }
    else {
    blach
    }
    }
     
  11. Hm, I don't think this is possible, for the reasons that Events are not comparable that way I think (due to difference in thread time and/or handlers) and also I think that I can't identify my event with the actions I want to execute.

    But I'll try this kind of solution, thanks.
     
  12. Offline

    toothplck1

    I was just throwing out the idea of putting some sort of identifying mark on your events and making sure they aren't those onMoveEvent. The code I posted was just a do something kinda like this concept, not necessarily working code but an idea that could work if looked into a bit.
     
  13. Yeah I got that.

    As far as I've gotten now this seems hard to implement and also it seems Bukkit sometimes throws a PlayerMoveEvent of movements combined, at LEAST some server and client modifications to the movement added up.

    Which makes it quite impossible unfortunately :(

    Protocol Lib can let me ignore the movement packets, but then the client doesn't get a 'confirmation' from the server and tries to send lots of packets to make up for it (it still wants to do the movement) resulting in the server getting angry and the server kicking the player for various reasons, such as 'moving too fast' and 'illegal stance' (the latter being the most common).

    Messing with packets is not the neatest thing.

    Basically, because of how great Protocol Lib is made (it's very sophisticated) this has made me pretty sure it is impossible what I want. :(

    If anyone has a solution please tell me! :eek:

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

    toothplck1

    Code:
     
    public void onMove(PlayerMoveEvent event) {
      if(!(event instanceof MySuperSpecialMoveEventExtender) {
            event.setCancelled(true);
      } else {
            //Do my stuff here
      }
    }
    
    Muizers, you could do what mcmmo does and create a class that extends move event and then you can check if its an instance of your special class, all other plugins will just think of it as a regular move event. Then you could cancel any move events that are not your special class and do action on them when they are your special class. Mcmmo uses this method to create fakeblock breaks and such to check that other plugins allow certain actions in places.
     
  15. Interesting find! Thank you!
     
Thread Status:
Not open for further replies.

Share This Page