From 6a7678587b04f3e6a40d7c5b08eea32f66742bb9 Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Sat, 4 Jan 2025 21:56:42 +0100 Subject: [PATCH] fix: luckperms permission interceptor --- .../transoformer/PaperPlayerTransformer.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/util/transoformer/PaperPlayerTransformer.java b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/util/transoformer/PaperPlayerTransformer.java index acb0401e..7ac34c80 100644 --- a/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/util/transoformer/PaperPlayerTransformer.java +++ b/NookureStaff-Paper/src/main/java/com/nookure/staff/paper/util/transoformer/PaperPlayerTransformer.java @@ -16,7 +16,9 @@ import com.nookure.staff.paper.extension.FreezePlayerExtension; import com.nookure.staff.paper.factory.PaperPlayerWrapperFactory; import com.nookure.staff.paper.factory.StaffPaperPlayerWrapperFactory; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -31,6 +33,7 @@ public final class PaperPlayerTransformer implements PlayerTransformer { private final ConfigurationContainer messages; private final FreezeManager freezeManager; private final List> states; + private JavaPlugin plugin; @Inject public PaperPlayerTransformer( @@ -40,7 +43,8 @@ public PaperPlayerTransformer( @NotNull final Logger logger, @NotNull final ConfigurationContainer messages, @NotNull final FreezeManager freezeManager, - @NotNull final List> states + @NotNull final List> states, + @NotNull final JavaPlugin plugin ) { this.playerWrapperManager = playerWrapperManager; this.paperPlayerWrapperFactory = paperPlayerWrapperFactory; @@ -49,6 +53,7 @@ public PaperPlayerTransformer( this.logger = logger; this.messages = messages; this.states = states; + this.plugin = plugin; } @Override @@ -58,16 +63,20 @@ public void player2Staff(@NotNull final UUID uuid) { if (player instanceof StaffPlayerWrapper) { logger.debug("Player %s is already a staff member.", player.getName()); + return; } if (!(player instanceof PaperPlayerWrapper paperPlayerWrapper)) return; playerWrapperManager.removePlayerWrapper(paperPlayerWrapper.getPlayer()); - final StaffPaperPlayerWrapper staffPlayerWrapper = staffPaperPlayerWrapperFactory - .create(paperPlayerWrapper.getPlayer(), states); - playerWrapperManager.addPlayerWrapper(staffPlayerWrapper.getPlayer(), staffPlayerWrapper); - staffPlayerWrapper.sendMiniMessage(messages.get().youAreNowAnStaffDuringPermissionInterceptor()); + Bukkit.getScheduler().runTask(plugin, () -> { + final StaffPaperPlayerWrapper staffPlayerWrapper = staffPaperPlayerWrapperFactory + .create(paperPlayerWrapper.getPlayer(), states); + + playerWrapperManager.addPlayerWrapper(staffPlayerWrapper.getPlayer(), staffPlayerWrapper); + staffPlayerWrapper.sendMiniMessage(messages.get().youAreNowAnStaffDuringPermissionInterceptor()); + }); } @Override