mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Properly handle jail respawn in togglejail (#3522)
This commit is contained in:
parent
e34984513d
commit
9aec89f381
1 changed files with 7 additions and 1 deletions
|
@ -5,6 +5,7 @@ import com.earth2me.essentials.User;
|
|||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import net.ess3.api.events.JailStatusChangeEvent;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -101,7 +102,7 @@ public class Commandtogglejail extends EssentialsCommand {
|
|||
player.setJailTimeout(0);
|
||||
player.sendMessage(tl("jailReleasedPlayerNotify"));
|
||||
player.setJail(null);
|
||||
if (player.getBase().isOnline()) {
|
||||
if (player.getBase().isOnline() && ess.getSettings().isTeleportBackWhenFreedFromJail()) {
|
||||
CompletableFuture<Boolean> future = getNewExceptionFuture(sender, commandLabel);
|
||||
player.getAsyncTeleport().back(future);
|
||||
future.thenAccept(success -> {
|
||||
|
@ -109,6 +110,11 @@ public class Commandtogglejail extends EssentialsCommand {
|
|||
sender.sendMessage(tl("jailReleased", player.getName()));
|
||||
}
|
||||
});
|
||||
future.exceptionally(e -> {
|
||||
player.getAsyncTeleport().respawn(null, PlayerTeleportEvent.TeleportCause.PLUGIN, new CompletableFuture<>());
|
||||
sender.sendMessage(tl("jailReleased", player.getName()));
|
||||
return false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(tl("jailReleased", player.getName()));
|
||||
|
|
Loading…
Reference in a new issue