Solved Keeping a player inside a flat region

Discussion in 'Spigot Plugin Development' started by Remy2402, Nov 2, 2016.

Thread Status:
Not open for further replies.
  1. Heyo!

    I currently have a hub that is on a floating island and I would like to give donators the access to fly around but I don't want them going too far away from spawn. I don't care how high or low they go but I don't want them going too far out.

    I have 2 points in each corner of my flat region:

    // point 1: x: -293, z: -671
    // point 2: x: -117, z: -515

    I am having a hard time figuring out a good way to prevent players from leaving this area.

    Any ideas are much appreciated.

    Thanks
     
  2. Have you atleast tried anything at all?
     
  3. (I know it could be a stupid idea)
    Stick on the playermoveevent, check if the player is out of that cuboid area, and if yes, teleport him back subtracting -1 to the x/y axis.

    Sorry in case i said the dumbest thing in the world (i'm Learning too)
     
  4. That's not really efficient, I really don't like the whole PlayerMovement event, I never touch it as it really checks on stuff every single time a player moves...
     
  5. Yes I've tried a few things but nothing seems to be doing it correctly. I've just got home from a long day at school so my brain isn't working at 100%. I'm not asking for spoonfeed code, just for some potential solutions.

    Yes it would be ideal to avoid the player move event.
     
  6. I think that's the only way, btw, worldedit has this feature, you could see their sourcecode...
     
    • Agree Agree x 1
  7. What have you tried? Show us some code, please.
     
  8. Well the most efficcient way would be playermovevent, here:
    Code (Text):
    @EventHandler
    public void PlayerMove(PlayerMoveEvent event){
          if(event.getPlayer().getWorld().getName().equals("MyHubWorld")){
          //check if the player is outside the boundary
        }
    }
     
  9. Yeah, but he altready said that he won't stick with that, and i agree. It would be laggy
     
  10. Why not just use WorldEdit and WorldGuard for this?
     
  11. 3 checks in a player move event isn't gonna cause lag.
     
    • Agree Agree x 2
  12.  
  13. @Envici , @Pr0totype2 was right, you can use the flags of the worldguard to drag them back inside the hub. Or use /worldborder instead ;)
     
    • Like Like x 1
  14. ;(
     
  15. He is looking for plugin or something without the help of coding :3
     
  16. I'm not looking for a plugin. I would like to implement this into my own hub plugin I am currently developing
     
  17. ???
     
  18. Listen to a PlayerMoveEvent
    If the player is outside the area, give him a knockback (Player#setVelocity)
     
  19. My problem is defining that area and knowing if a player has reached the edge of it
     
  20. if(x < minX || x > maxX)

    Do the same for y and z
     
    • Agree Agree x 1
Thread Status:
Not open for further replies.