Solved Removing 'moving too fast'

Discussion in 'Plugin Development' started by Muizers, Sep 29, 2012.

Thread Status:
Not open for further replies.
  1. --------------------------------------------------------------------------------
    EDIT: Solution here!

    ------------------------------------------------------------------------------------------------
    Hey all!

    First said, I need a REAL answer to this. I've read over twenty of comparable threads on these and other forums and no-one has given a solution. I've seen many useless answers like 'enable allow-flight' or 'use NoCheat' or 'this happens when people move too fast'.

    Sigh, so here's my actual problem.

    How do I disable that Bukkit puts a player back in place if the player 'moves too fast'? I don't care about the console message, I don't care about the 'moving too fast' kick, I just want the player to be able to move.

    Furthermore, I would like to say that I have allow-flight=true, and what I'm doing is giving the player a velocity using Player.setVelocity(...) of the Bukkit API, within a plugin.

    That is also the only plugin in the server.

    Please, please answer my question! I've searched for it, but couldn't find, perhaps you can? Or know?

    Thanks so much in advance!

    PS I'm a plugin developer so I would like to block it using some code from within a plugin.
    BUT if you have a solution that must be done by the server owner, that's fine too.

    PPS Duplicate thread, I know. Don't kill me for it XD

    PPPS Once again, please don't post useless answers. Read my actual question thoroughly!
     
  2. Offline

    Scizzr

  3. My question was "How do I disable that Bukkit puts a player back in place if the player 'moves too fast'?"

    NoCheatPlus doesn't do that.
     
  4. try making your own plugin that stops the kicks whit the message that they moved to fast
     
  5. Offline

    one4me

    If you don't mind modifying CraftBukkit, it's as easy as removing a few lines of code.

    Now, if you don't want to modify CraftBukkit you could just listen to PlayerMoveEvent and do something like:
    (((CraftPlayer)event.getPlayer()).getHandle()).checkMovement = false;
    although the above code appeared to work for me I'm not sure that it is too efficient.

    If you didn't mind extending NetServerHandler you could override a method and remove the check that way as well, but this would require a little bit of reflection if you didn't want to break anything.

    Those are just a few ways of achieving what you want, there are probably countless other ways as well.
     
  6. Thank you that sounds like a very good solution! I'll try your suggestions out tomorrow.
    I hope PlayerMoveEvent is still called when I change the handle. And if not, well that's not the biggest problem.
     
  7. This did not work for me the way you said it, but THANK YOU SO MUCH!
    I found the answer via your way.

    My solution is to use
    ((CraftPlayer) event.getPlayer()).getHandle().netServerHandler.checkMovement = false;
    within PlayerJoinEvent

    It works like a charm. This way the message can even be disabled per player, and switched at any desired time.

    YES:D
     
  8. Offline

    ItsHarry

    Did you even read what he said?
     
  9. he was talking about the moving to fast code inside bukkit, not using an external plugin
     
  10. Offline

    Scizzr

    It's not working. Here's a simple plugin that just sets the player's velocity to 50 blocks straight up one second after they join. In short, the same thing happens with or without ((CraftPlayer)p).getHandle().netServerHandler.checkMovement = false;
    Code:
    //plugin.yml
    name: JoinFly
    description: Fly high when you join
    version: 1.0
    author: Scizzr
    main: com.example.joinfly.JoinFly
     
    
    Code:
    //JoinFly.java
    package com.example.joinfly;
     
    import org.bukkit.Bukkit;
    import org.bukkit.craftbukkit.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.util.Vector;
     
    public class JoinFly extends JavaPlugin {
        PluginManager pm;
        PlayerListener listenerPlayers;
       
        @Override
        public void onEnable() {
            pm = Bukkit.getPluginManager();
            listenerPlayers = new PlayerListener(this); pm.registerEvents(listenerPlayers, this);
        }
       
        public class PlayerListener implements Listener {
            JoinFly jf;
           
            PlayerListener (JoinFly jf) {
                this.jf = jf;
            }
           
            @EventHandler(priority = EventPriority.NORMAL)
            public void onPlayerJoin(PlayerJoinEvent e) {
                final Player p = e.getPlayer();
               
                ((CraftPlayer)p).getHandle().netServerHandler.checkMovement = false;
               
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(jf, new Runnable() {
                    public void run() {
                        p.setVelocity(new Vector(0, 50, 0));
                    }
                }, 20L);
            }
        }
    }
    
    Any other suggestions?

    PS: Using CraftBukkit 1.3.2-R1.0
     
  11. dont bumb a solved thread, instead make your own thread as the user from this thread gets now messages fromt he manny replies, and the people that help others wont look mostly to the solved threads, I saw the problem part, but I dont give the answer, because its unrelated to the question o the thread
     
  12. What are you trying to say? Do you still have the moving too fast message and set-back even when you use

    Code:
    ((CraftPlayer)p).getHandle().netServerHandler.checkMovement = false;
    ?

    Code:
    //plugin.yml
    name: JoinFly
    description: Fly high when you join
    version: 1.0
    author: Scizzr
    main: com.example.joinfly.JoinFly
     
    
    Code:
    //JoinFly.java
    package com.example.joinfly;
     
    import org.bukkit.Bukkit;
    import org.bukkit.craftbukkit.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.util.Vector;
     
    public class JoinFly extends JavaPlugin {
        PluginManager pm;
        PlayerListener listenerPlayers;
     
        @Override
        public void onEnable() {
            pm = Bukkit.getPluginManager();
            listenerPlayers = new PlayerListener(this); pm.registerEvents(listenerPlayers, this);
        }
     
        public class PlayerListener implements Listener {
            JoinFly jf;
         
            PlayerListener (JoinFly jf) {
                this.jf = jf;
            }
         
            @EventHandler(priority = EventPriority.NORMAL)
            public void onPlayerJoin(PlayerJoinEvent e) {
                final Player p = e.getPlayer();
             
                ((CraftPlayer)p).getHandle().netServerHandler.checkMovement = false;
             
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(jf, new Runnable() {
                    public void run() {
                        p.setVelocity(new Vector(0, 50, 0));
                    }
                }, 20L);
            }
        }
    }
    
    Any other suggestions?

    PS: Using CraftBukkit 1.3.2-R1.0[/quote]

    By the way there is an error in your code. If that is what you meant in the first place, then here is your mistake:

    You use

    Code:
    new Runnable() {
                    public void run() {
                        p.setVelocity(new Vector(0, 50, 0));
                    }
                }, 20L);
    and this is not allowed. You use the p variable inside the new Runnable() { ... }, which can't happen, cause the Runnable doesn't know about the variable, cause it exists inside onPlayerJoin, not the Runnable.

    I'm not very experienced when it comes to interfaces. But you need to use some kind of an interface here: for example, create a class that implements Runnable, and that has a player object in its data. Then you can use new RunnableWithPlayer(p) { ... } where you have a class called RunnableWithPlayer that implements Runnable and can be instantiated with data of a Player object.

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

    Scizzr


    There's no error in my code. I compiled and tested it before posting. I've made several plugins and used LOTS of runnables, so I feel fairly confident in myself that that is not a problem.

    Aside from that, the code you see is exactly what I am using. In the runnable, the p variable is definitely visible. That's not the problem. If it weren't visible, I wouldn't even get the message that I was moving too quickly. It simply wouldn't adjust my velocity at all.

    I would have posted another thread if my issue were different. However, that not being the case, I posted here instead of making another thread just to discuss the exact same issue. Thanks for your concern though.

    Thanks guys.
     
  14. If you install this, do you still get the message?

    http://dev.bukkit.org/media/files/634/719/DisableMovingTooQuickly.jar
     
  15. Offline

    Scizzr

  16. Offline

    Zidkon

    Wait I'm interested on this topic, so it worked or not?
     
  17. Offline

    Scizzr

    Not quite.

    With his code, I still have the same problem.
    With somewhat modified code of mine, I get a different problem. I can jump and move freely but when I land on the position that I was originally in, the netserverhandler gives the errors again. If I don't go back to that spot, the netserverhandler basically disconnects me.
     
  18. Offline

    Zidkon

    The code is ok, I can suppose that the server doesn't use the checkMovement as an option if you say you're still getting the error, why don't you try it every PlayerMove event too?
     
  19. Offline

    Scizzr

    The following code causes the NSH to stop responding. Chunks don't load and the server ignores the client overall. Block breaking can still be done if you break a block near where you started (aka where you first started moving) but you can't pickup any blocks.

    So in short, no. That does not work. :(

    Code:
    @EventHandler(priority = EventPriority.NORMAL)
    public void onPlayerMove(PlayerMoveEvent e) {
        /*
        * ???
        */
        final Player p = e.getPlayer();
        final CraftPlayer pC = (CraftPlayer)p;
        final net.minecraft.server.EntityPlayer pMC = pC.getHandle();
       
        pMC.netServerHandler.checkMovement = false;
    }
    
     
  20. That is odd. I see your problem as a valid continuation of this thread and will seek a solution, but I may not find one. Keep trying and searching!

    But I'll keep this topic 'SOLVED' as my issue was resolved earlier, just so you know.
     
  21. Offline

    Zidkon

    This worked for you? But not for Scizzr?
     
  22. Yes that is the case.
     
  23. Offline

    Scizzr

    What version of CB are you running?
    I still can't get it to work using 1.3.2-R1.0 with only one plugin.

    Thanks.
     
  24. 1.3.2-R1.0 too. I will see what I can today. I hope I can fix it, I'll post the results on here later.
     
  25. Offline

    Scizzr

    I'm still trying different things and delving into NMS code. Still no luck though.

    It's odd that it works for you and not for me though. Maybe we'll figure it out. ;)
     
  26. Offline

    Zidkon

    Why don't you send on a zip file the complete server folder with the unique plugin, pretty much sure that may not be the cause but we can try xD
     
Thread Status:
Not open for further replies.

Share This Page