Created
September 18, 2022 13:45
-
-
Save Koboo/15763f24dc5226a03547fefbf205e801 to your computer and use it in GitHub Desktop.
"Infinite" room in bukkit through player move event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EventHandler(priority = EventPriority.HIGHEST) | |
public void onMove(PlayerMoveEvent event) { | |
Location from = event.getFrom(); | |
Location to = event.getTo(); | |
if(!from.getWorld().getName().equalsIgnoreCase(to.getWorld().getName())) { | |
return; | |
} | |
boolean flipYaw = false; | |
double x = to.getX(); | |
double z = to.getZ(); | |
if(x < -roomSize || x > roomSize) { | |
flipYaw = true; | |
} | |
if(z < -roomSize || z > roomSize) { | |
flipYaw = true; | |
} | |
float yaw = event.getPlayer().getLocation().getYaw() + 180; | |
if(flipYaw) { | |
event.setTo(new Location(to.getWorld(), from.getX(), from.getY(), from.getZ(), yaw, to.getPitch())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment