Skip to content

Commit

Permalink
fix Paper tools exploding pre-1.19
Browse files Browse the repository at this point in the history
Java is silly
  • Loading branch information
mcmonkey4eva committed Mar 22, 2023
1 parent ba0aa4b commit 5aef6ea
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -135,10 +135,19 @@ public InventoryView openAnvil(Player player, Location loc) {
return player.openAnvil(loc, true);
}

public static Object teleportRelative;

static {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) { // TODO: 1.19: replace with TeleportFlag.Relative.values()
// (That breaks loading pre-1.19 due to Java silliness)
teleportRelative = TeleportFlag.Relative.class.getEnumConstants();
}
}

@Override
public void teleportPlayerRelative(Player player, Location loc) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_19)) {
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN, TeleportFlag.Relative.values());
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN, (TeleportFlag[]) teleportRelative);
}
else {
super.teleportPlayerRelative(player, loc);
Expand Down

0 comments on commit 5aef6ea

Please sign in to comment.