"Stick" player to location

Discussion in 'Plugin Development' started by HamOmlet, Nov 9, 2012.

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


    Any suggestion on how to go about "sticking" a player to a particular location? I could of course keep teleporting a player to a location, but I feel as though there is a cleaner solution.
  2. Offline


    Add the player to a list, then in OnPlayerMoveEvent check if the player is in the list, if it is the cancel the event.
  3. Offline


    If the player "sticks" to, let's say, a block in the air, wouldn't cancelling the event be similar to just teleporting them back to the location (in terms of the player constantly falling)?
  4. Offline


    you can do a check. if they are in the air set the block under them to dirt or something
  5. Offline


    cancelling the playerMoveEvent creates some very weird effects, such as being stuck in a constant tp back and forth. Your going to need to store the players location and check if they have moved from that location, if so, tp them back to that location

    HashMap<Player, Location>locations = new HashMap<Player, Location>();
    public void move(PlayerMoveEvent e){
       Location l = e.getPLayer().getLocation();
        Location l2 = locations.get(e.getPLayer());
         if(l.getX()!=l2.getX() || l.getZ() != l2.getX()){
Thread Status:
Not open for further replies.

Share This Page