Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Sample boundary teleporter
- Written in about 5 minutes by cembry90
- May contain imperfections; just a demonstration
- compass
- N (-Z)
- W (-X) E (+X)
- S (+Z)
- */
- public class BoundaryListener implements Listener {
- int minX = -1000, maxX = 1000,
- minZ = -1000, maxZ = 1000;
- @EventHandler(priority = EventPriority.NORMAL)
- public void onPlayerMove(PlayerMoveEvent e) {
- Player p = e.getPlayer();
- Location loc = p.getLocation();
- World world = p.getWorld();
- int curX = loc.getBlockX(),
- curY = loc.getBlockY(),
- curZ = loc.getBlockZ();
- if (curX < minX) {
- p.teleport(new Location(world, maxX, curY, curZ));
- } else if (curX > maxX) {
- p.teleport(new Location(world, minX, curY, curZ));
- } else if (curZ < minZ) {
- p.teleport(new Location(world, curX, curY, maxZ));
- } else if (curZ > maxZ) {
- p.teleport(new Location(world, curX, curY, minZ));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment