Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added paperlib to fix teleportation on folia #1576

Open
wants to merge 3 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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")

Expand Down Expand Up @@ -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")
}
5 changes: 3 additions & 2 deletions src/main/java/ac/grim/grimac/commands/GrimSpectate.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}


}
3 changes: 2 additions & 1 deletion src/main/java/ac/grim/grimac/manager/SpectateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand Down