diff --git a/build.gradle.kts b/build.gradle.kts index e02438d16e..d80164407e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,7 @@ repositories { maven("https://repo.opencollab.dev/maven-releases/") // Cumulus (for Floodgate) maven("https://repo.codemc.io/repository/maven-releases/") // PacketEvents maven("https://repo.codemc.io/repository/maven-snapshots/") + maven("https://papermc.io/repo/repository/maven-public/") // PaperLib mavenCentral() // FastUtil, Discord-Webhooks } @@ -36,6 +37,8 @@ dependencies { implementation("it.unimi.dsi:fastutil:8.5.13") implementation("github.scarsz:configuralize:1.4.0") + implementation("io.papermc:paperlib:1.0.8") + implementation("com.github.grimanticheat:grimapi:9f5aaef74b") // Used for local testing: implementation("ac.grim.grimac:grimapi:1.0") @@ -146,4 +149,5 @@ tasks.shadowJar { relocate("org.json", "ac.grim.grimac.shaded.json") relocate("org.intellij", "ac.grim.grimac.shaded.intellij") relocate("org.jetbrains", "ac.grim.grimac.shaded.jetbrains") + relocate("io.papermc.lib", "ac.grim.grimac.shaded.io.papermc.lib") } diff --git a/src/main/java/ac/grim/grimac/commands/GrimSpectate.java b/src/main/java/ac/grim/grimac/commands/GrimSpectate.java index 2b6617c4e9..2028d95cc5 100644 --- a/src/main/java/ac/grim/grimac/commands/GrimSpectate.java +++ b/src/main/java/ac/grim/grimac/commands/GrimSpectate.java @@ -10,6 +10,8 @@ import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.manager.server.ServerVersion; import io.github.retrooper.packetevents.adventure.serializer.legacy.LegacyComponentSerializer; +import io.github.retrooper.packetevents.util.folia.FoliaScheduler; +import io.papermc.lib.PaperLib; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; @@ -52,8 +54,7 @@ public void onSpectate(CommandSender sender, @Optional OnlinePlayer target) { } player.setGameMode(GameMode.SPECTATOR); - player.teleport(target.getPlayer()); + PaperLib.teleportAsync(player, target.getPlayer().getLocation()); } - } diff --git a/src/main/java/ac/grim/grimac/manager/SpectateManager.java b/src/main/java/ac/grim/grimac/manager/SpectateManager.java index e7e3fa154b..39476fdd08 100644 --- a/src/main/java/ac/grim/grimac/manager/SpectateManager.java +++ b/src/main/java/ac/grim/grimac/manager/SpectateManager.java @@ -4,6 +4,7 @@ import ac.grim.grimac.manager.init.Initable; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfo; +import io.papermc.lib.PaperLib; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -61,7 +62,7 @@ public void onQuit(Player player) { public void disable(Player player, boolean teleportBack) { PreviousState previousState = spectatingPlayers.get(player.getUniqueId()); if (previousState != null) { - if (teleportBack) player.teleport(previousState.location); + if (teleportBack) PaperLib.teleportAsync(player, previousState.location); player.setGameMode(previousState.gameMode); } handlePlayerStopSpectating(player.getUniqueId());