Kicked for moving too quickly!

Discussion in 'Plugin Development' started by killgoblen, Jun 27, 2011.

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

    killgoblen

    I just (thought I) finished my first plugin, when a pretty major bug came up during testing. It involves teleporting players just after canceling an onPlayerMove(). When I teleport any significant distance, I get kicked for moving too quickly. I tried installing the plugin that fixes that (In the FIX section), but then it just spams warnings about moving too quickly, then resets me back to where I tried to teleport from. Here's some source code:

    Inside the player listener:
    Code:
        public void onPlayerMove(PlayerMoveEvent event){
    
            Location loc = event.getPlayer().getLocation();
            List<String> below = SLAPI.loc(loc.add(0, -1, 0).getBlock().getLocation());
            if(mainsMap.containsKey(below) && below != null){
                event.setCancelled(true);
                tping.teleport(event.getPlayer(), mainsMap.get(below));
            }
        }
    and inside the tping class:
    Code:
        public static boolean teleport(Player player, String network){
            //if(player.isOp()){
                Map<String, Map<String, List<String>>> map = TeleportBlocksPlayerListener.map;
                if(map.get(network).containsKey(player.getDisplayName())){
                    player.teleport(SLAPI.readLoc(map.get(network).get(player.getDisplayName())).add(0.5, 0, 0.5));
                    return true;
                }
                return true;
            //}
        }
    So... is there any way to fix this inside my plugin? Thanks for any help!
     
  2. Offline

    nisovin

    Rather than cancelling and teleporting, use setTo().
     
  3. Offline

    killgoblen

    Oh that worked! Thanks! I just wonder why teleporting didn't...
     
  4. Offline

    Weltall 7

    You should not use the players' display names, as they can change at any time. Instead use their real names, which are unique and persistent for each player.
     
Thread Status:
Not open for further replies.

Share This Page