Teleport sound is only played when the teleport is complete and at the destination location as per PaperLib's CompletableFuture, Close #107

This commit is contained in:
William committed 2021-11-23 01:36:40 +00:00
1 parent db06622622
commit e6d9e53e90
1 file changed
+4 -4
@@ -19,6 +19,7 @@ import org.bukkit.entity.Player;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level; import java.util.logging.Level;
public class TeleportManager { public class TeleportManager {
@@ -88,11 +89,10 @@ public class TeleportManager {
DataManager.setPlayerTeleporting(p, false, connection); DataManager.setPlayerTeleporting(p, false, connection);
DataManager.deletePlayerDestination(p.getName(), connection); DataManager.deletePlayerDestination(p.getName(), connection);
Location targetLocation = teleportationPoint.getLocation(); Location targetLocation = teleportationPoint.getLocation();
Bukkit.getScheduler().runTask(plugin, () -> { Bukkit.getScheduler().runTask(plugin, () -> PaperLib.teleportAsync(p, targetLocation).thenRun(() -> {
PaperLib.teleportAsync(p, targetLocation); p.playSound(targetLocation, HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1);
p.playSound(p.getLocation(), HuskHomes.getSettings().getTeleportationCompleteSound(), 1, 1);
MessageManager.sendMessage(p, "teleporting_complete"); MessageManager.sendMessage(p, "teleporting_complete");
}); }));
} else if (HuskHomes.getSettings().doBungee()) { } else if (HuskHomes.getSettings().doBungee()) {
DataManager.setPlayerDestinationLocation(p, teleportationPoint, connection); DataManager.setPlayerDestinationLocation(p, teleportationPoint, connection);
DataManager.setPlayerTeleporting(p, true, connection); DataManager.setPlayerTeleporting(p, true, connection);