Skip to content

Commit

Permalink
Update 0050-Redirect-teleport-to-teleportAsync.patch
Browse files Browse the repository at this point in the history
  • Loading branch information
AltronMaxX committed Nov 5, 2024
1 parent 6397c55 commit 88af822
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions patches/server/0050-Redirect-teleport-to-teleportAsync.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Redirect 'teleport' to 'teleportAsync'


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 7be80f2774b5ec3d0bede096da8f2b6d1cf7b09b..8dc22bff3a5e520f6b41ceb568f298bf5f9861b7 100644
index 7be80f2774b5ec3d0bede096da8f2b6d1cf7b09b..0f35888f9da10e72bd4ecdbe23f04718af5eb8bc 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -8,6 +8,8 @@ import com.google.common.collect.Lists;
Expand All @@ -17,7 +17,20 @@ index 7be80f2774b5ec3d0bede096da8f2b6d1cf7b09b..8dc22bff3a5e520f6b41ceb568f298bf
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
@@ -241,8 +243,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -230,6 +232,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {

@Override
public boolean teleport(Location location) {
+ if (true)
+ try {
+ return this.teleportAsync(location, TeleportCause.PLUGIN, new io.papermc.paper.entity.TeleportFlag[0]).get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
return this.teleport(location, TeleportCause.PLUGIN);
}

@@ -241,8 +249,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {

@Override
public boolean teleport(Location location, TeleportCause cause, io.papermc.paper.entity.TeleportFlag... flags) {
Expand All @@ -35,3 +48,27 @@ index 7be80f2774b5ec3d0bede096da8f2b6d1cf7b09b..8dc22bff3a5e520f6b41ceb568f298bf
throw new UnsupportedOperationException("Must use teleportAsync while in region threading");
}
// Folia end - region threading
@@ -300,11 +316,23 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {

@Override
public boolean teleport(org.bukkit.entity.Entity destination) {
+ if (true)
+ try {
+ return this.teleportAsync(destination.getLocation(), TeleportCause.PLUGIN, new io.papermc.paper.entity.TeleportFlag[0]).get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
return this.teleport(destination.getLocation());
}

@Override
public boolean teleport(org.bukkit.entity.Entity destination, TeleportCause cause) {
+ if (true)
+ try {
+ return this.teleportAsync(destination.getLocation(), cause, new io.papermc.paper.entity.TeleportFlag[0]).get();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
return this.teleport(destination.getLocation(), cause);
}

0 comments on commit 88af822

Please sign in to comment.