Skip to content

Commit

Permalink
Fix teleport to async teleport
Browse files Browse the repository at this point in the history
Bump version Energie
Change Version WE to return 7.3.0-SNAPSHOT for fix build
  • Loading branch information
Euphillya committed Mar 17, 2024
1 parent cf4f7c1 commit bb78f94
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.sk89q.worldedit
version=7.4.0-SNAPSHOT
version=7.3.0-SNAPSHOT

org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
Expand Down
2 changes: 1 addition & 1 deletion worldedit-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies {
"implementation"("org.bstats:bstats-bukkit:2.2.1")
"implementation"("it.unimi.dsi:fastutil")
"testImplementation"("org.mockito:mockito-core:1.9.0-rc1")
"implementation"("com.github.Euphillya:Energie:1.1.4")
"implementation"("com.github.Euphillya:Energie:1.1.7")

project.project(":worldedit-bukkit:adapters").subprojects.forEach {
"adapters"(project(it.path))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.NullWorld;
import fr.euphyllia.energie.Energie;
import fr.euphyllia.energie.model.SchedulerType;
import fr.euphyllia.energie.utils.EntityUtils;
import org.bukkit.event.player.PlayerTeleportEvent;

import java.lang.ref.WeakReference;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -74,7 +78,10 @@ public Location getLocation() {
public boolean setLocation(Location location) {
org.bukkit.entity.Entity entity = entityRef.get();
if (entity != null) {
return entity.teleport(BukkitAdapter.adapt(location));
WorldEditPlugin.getEnergieTask().getScheduler(Energie.SchedulerSoft.MINECRAFT).runTask(SchedulerType.SYNC, entity, schedulerTaskInter -> {
EntityUtils.teleportAsync(entity, BukkitAdapter.adapt(location), PlayerTeleportEvent.TeleportCause.PLUGIN);
}, null);
return true;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import fr.euphyllia.energie.Energie;
import fr.euphyllia.energie.model.SchedulerType;
import fr.euphyllia.energie.utils.EntityUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -146,8 +149,12 @@ public void print(Component component) {

@Override
public boolean trySetPosition(Vector3 pos, float pitch, float yaw) {
return player.teleport(new Location(player.getWorld(), pos.x(), pos.y(),
pos.z(), yaw, pitch));
WorldEditPlugin.getEnergieTask().getScheduler(Energie.SchedulerSoft.MINECRAFT)
.runTask(SchedulerType.SYNC, player, schedulerTaskInter -> {
EntityUtils.teleportAsync(player, new Location(player.getWorld(), pos.x(), pos.y(),
pos.z(), yaw, pitch));
}, null);
return true;
}

@Override
Expand Down Expand Up @@ -224,7 +231,10 @@ public com.sk89q.worldedit.util.Location getLocation() {

@Override
public boolean setLocation(com.sk89q.worldedit.util.Location location) {
return player.teleport(BukkitAdapter.adapt(location));
WorldEditPlugin.getEnergieTask().getScheduler(Energie.SchedulerSoft.MINECRAFT).runTask(SchedulerType.SYNC, player, schedulerTaskInter -> {
EntityUtils.teleportAsync(player, BukkitAdapter.adapt(location));
}, null);
return true;
}

@SuppressWarnings("deprecation") // Paper's deprecation, we need to support Spigot still
Expand Down

0 comments on commit bb78f94

Please sign in to comment.