BlockPlaceEvent teleport back to getFrom

Discussion in 'Plugin Development' started by Maxx_Qc, May 21, 2015.

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

    Maxx_Qc

    Hi, I'm making a plugin with worldedit to stop people from usebugging. I just want to make sure that people won't go on top of my spawn. This is my actual event:
    Code:
    @EventHandler
        public void onBlockPlace(BlockPlaceEvent e) {
            Selection s = cfg.getArea();
                if (s != null) {
                    if (s.contains(e.getBlock().getLocation())) {
                        e.setCancelled(true);
                    }
                }
        }
    Can someone tell me how to teleport the player to y-1 if when he place a block he get up?
    Example: I place a block under me so I got Y+1, I want my plugin to stop this so to teleport me Y-1, to my original position. I wish you understand, thank you in advance.
     
    Last edited: May 21, 2015
  2. Offline

    scrollbar

    You can use PlayerMoveEvent and check for event.getTo().

    Something like this should work for you.

    Code:
    public void onPlayerMove(PlayerMoveEvent e) {
        Location loc = e.getPlayer().getLocation();
        if (e.getTo().getBlockY() == HighestY) {
            e.getPlayer().teleport(loc);
        }
    }
    
    


    @Maxx_Qc
     
  3. Offline

    caderape

    @scrollbar I think he's talking about lag that make the block posed for milisecond and people go up with it.
    This is not the good way to check it with the move event.


    @Maxx_Qc teleport the player to the block location
     
    scrollbar likes this.
Thread Status:
Not open for further replies.

Share This Page