Solved Invsible border

Discussion in 'Spigot Plugin Development' started by Hunzek_, Oct 18, 2020.

  1. Hello, please, don't you know how to make an invisible border? I have a set limit and I know how to check if a player is behind it, but I don't know how not to let a player go beyond that limit. Sprry for my very bad English :(.

    Thanks, Hunzek_
  2. If a player goes beyond the limit you can teleport them back.
  3. You can use the PlayerMoveEvent to see if the player is outside of the location, if so cancel the event.
  4. Code:
    Code (Text):
        public void onPlayerMove(PlayerMoveEvent e) {
            Player player = e.getPlayer();
            GamePlayer gp = PlayerManager.getGamePlayer(player);

            if (gp.getGame() != null) {
                if (gp.getGame().getState() == GameState.INGAME) {
                    if (gp.getGame().getCurrentMap().isOutsideBorder(player.getLocation())) {

                        if (player.getLocation().getY() <= 0) {

                        player.sendMessage("§cYou can't move behind the border!");

    I've tried other methods before and nothing.
  5. Yes, but how? :/ I've tried something like this before, but it didn't work.
  6. The player can then get easily stuck. :/
  7. Try changing where you check if players location is outside the border to e.getTo()
  8. Yes, it works. Thank you very much. I don't understand how I couldn't figure this out.:unsure::oops: