diff --git a/build.gradle.kts b/build.gradle.kts index f033a7ba..6688bcad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -58,7 +58,7 @@ tasks { finalizedBy(rootProject.tasks.jacocoTestReport) } runServer { - minecraftVersion("1.21.4") + minecraftVersion("1.21.10") jvmArgs("-Dcom.mojang.eula.agree=true") } jacocoTestReport { diff --git a/src/main/java/net/onelitefeather/stardust/api/PlayerVanishService.java b/src/main/java/net/onelitefeather/stardust/api/PlayerVanishService.java index 17364201..8a29a212 100644 --- a/src/main/java/net/onelitefeather/stardust/api/PlayerVanishService.java +++ b/src/main/java/net/onelitefeather/stardust/api/PlayerVanishService.java @@ -1,61 +1,66 @@ package net.onelitefeather.stardust.api; -import org.bukkit.entity.Player; +import java.util.UUID; -public interface PlayerVanishService
{
+public interface PlayerVanishService {
/**
* Hides a player for other players
*
- * @param player to be hide
+ * @param playerId to be hidden
*/
- void hidePlayer(P player);
+ void hidePlayer(UUID playerId);
/**
* Shows a player for other players
*
- * @param player to be shown to other player
+ * @param playerId to be shown to other players
*/
- void showPlayer(P player);
+ void showPlayer(UUID playerId);
- /**
- * Toggle vanish status of a player
- *
- * @param player be affected
+ /*
+ * @param playerId to be affected
+ * @return new vanish state
*/
- boolean toggle(P player);
+ boolean toggle(UUID playerId);
/**
- * Check if the player in vanish
+ * Check if the player is vanished
*
* @return the current status
*/
- boolean isVanished(P player);
+ boolean isVanished(UUID playerId);
/**
* Set a user explicit the vanish status
*
- * @param player to be affected
- * @param vanished status of the user
+ * @param playerId to be affected
+ * @param vanished status of the user
*/
- void setVanished(P player, boolean vanished);
+ void setVanished(UUID playerId, boolean vanished);
/**
* Handles if a player joining the server
*
- * @param player be affected
+ * @param playerId to be affected
* @return true if the player is vanished
*/
- boolean handlePlayerJoin(P player);
+ boolean handlePlayerJoin(UUID playerId);
/**
* Handles if a player quits the server
*
- * @param player be affected
+ * @param playerId to be affected
*/
- void handlePlayerQuit(P player);
+ void handlePlayerQuit(UUID playerId);
- boolean canSee(P player, P target);
+ boolean canSee(UUID viewerId, UUID targetId);
- boolean isVanishPermitted(P player);
+ /**
+ * Check if a player has permission to vanish
+ *
+ * @param playerId to be checked
+ * @return true if the player has permission to vanish
+ */
+ boolean isVanishPermitted(UUID playerId);
}
diff --git a/src/main/java/net/onelitefeather/stardust/command/commands/VanishCommand.java b/src/main/java/net/onelitefeather/stardust/command/commands/VanishCommand.java
index d15071b7..48269dd2 100644
--- a/src/main/java/net/onelitefeather/stardust/command/commands/VanishCommand.java
+++ b/src/main/java/net/onelitefeather/stardust/command/commands/VanishCommand.java
@@ -71,7 +71,7 @@ public void commandVanishToggleProperty(
toggleProperty(commandSender, target, property);
return;
}
- if (stardustPlugin.getUserService().getVanishService().canSee((Player) commandSender, target)) {
+ if (stardustPlugin.getUserService().getVanishService().canSee(((Player) commandSender).getUniqueId(), target.getUniqueId())) {
toggleProperty(commandSender, target, property);
}
}
@@ -114,7 +114,7 @@ public void toggleVanish(CommandSender commandSender, Player target) {
.arguments(stardustPlugin.getPrefix()));
return;
}
- stardustPlugin.getUserService().getVanishService().toggle(target);
+ stardustPlugin.getUserService().getVanishService().toggle(target.getUniqueId());
} catch (Exception e) {
stardustPlugin.getLogger().throwing(VanishCommand.class.getSimpleName(), "toggleVanish", e);
}
diff --git a/src/main/java/net/onelitefeather/stardust/listener/PlayerAdvancementListener.java b/src/main/java/net/onelitefeather/stardust/listener/PlayerAdvancementListener.java
index 6ce404ec..9cce0fe7 100644
--- a/src/main/java/net/onelitefeather/stardust/listener/PlayerAdvancementListener.java
+++ b/src/main/java/net/onelitefeather/stardust/listener/PlayerAdvancementListener.java
@@ -15,7 +15,7 @@ public PlayerAdvancementListener(StardustPlugin plugin) {
@EventHandler
public void onPlayerAdvancement(PlayerAdvancementCriterionGrantEvent event) {
var player = event.getPlayer();
- if (plugin.getUserService().getVanishService().isVanished(player)) {
+ if (plugin.getUserService().getVanishService().isVanished(player.getUniqueId())) {
event.setCancelled(true);
}
}
diff --git a/src/main/java/net/onelitefeather/stardust/listener/PlayerConnectionListener.java b/src/main/java/net/onelitefeather/stardust/listener/PlayerConnectionListener.java
index d4105745..098db02f 100644
--- a/src/main/java/net/onelitefeather/stardust/listener/PlayerConnectionListener.java
+++ b/src/main/java/net/onelitefeather/stardust/listener/PlayerConnectionListener.java
@@ -1,7 +1,5 @@
package net.onelitefeather.stardust.listener;
-import org.bukkit.event.Listener;
-
import net.kyori.adventure.text.Component;
import net.onelitefeather.stardust.StardustPlugin;
import net.onelitefeather.stardust.user.User;
@@ -57,7 +55,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
} else {
event.quitMessage(Component.translatable("listener.quit-message").arguments(player.displayName()));
}
- stardustPlugin.getUserService().getVanishService().handlePlayerQuit(player);
+ stardustPlugin.getUserService().getVanishService().handlePlayerQuit(player.getUniqueId());
} catch (Exception e) {
stardustPlugin.getLogger().log(Level.SEVERE, "Something went wrong during the quit process", e);
}
@@ -65,7 +63,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
private void joinMessage(PlayerJoinEvent event) {
Player player = event.getPlayer();
- boolean isVanished = stardustPlugin.getUserService().getVanishService().handlePlayerJoin(player);
+ boolean isVanished = stardustPlugin.getUserService().getVanishService().handlePlayerJoin(player.getUniqueId());
if (isVanished) {
event.joinMessage(null);
} else {
diff --git a/src/main/java/net/onelitefeather/stardust/listener/PlayerVanishListener.java b/src/main/java/net/onelitefeather/stardust/listener/PlayerVanishListener.java
index 8e62cc5e..b1686bdd 100644
--- a/src/main/java/net/onelitefeather/stardust/listener/PlayerVanishListener.java
+++ b/src/main/java/net/onelitefeather/stardust/listener/PlayerVanishListener.java
@@ -44,7 +44,7 @@ public PlayerVanishListener(StardustPlugin stardustPlugin) {
}
private boolean isVanished(Player player) {
- return stardustPlugin.getUserService().getVanishService().isVanished(player);
+ return stardustPlugin.getUserService().getVanishService().isVanished(player.getUniqueId());
}
@EventHandler
@@ -245,7 +245,7 @@ public void handleGameEvent(BlockReceiveGameEvent event) {
}
if (resultPlayer == null) return;
- event.setCancelled(stardustPlugin.getUserService().getVanishService().isVanished(resultPlayer));
+ event.setCancelled(stardustPlugin.getUserService().getVanishService().isVanished(resultPlayer.getUniqueId()));
}
@EventHandler
diff --git a/src/main/java/net/onelitefeather/stardust/listener/VanishNoPacketListener.java b/src/main/java/net/onelitefeather/stardust/listener/VanishNoPacketListener.java
index 242ab186..094998f2 100644
--- a/src/main/java/net/onelitefeather/stardust/listener/VanishNoPacketListener.java
+++ b/src/main/java/net/onelitefeather/stardust/listener/VanishNoPacketListener.java
@@ -49,6 +49,6 @@ private boolean isVanished(WrapperPlayServerPlayerInfo.PlayerData data) {
if (userProfile == null) return false;
var user = this.stardustPlugin.getUserService().getUser(userProfile.getUUID());
if (user == null) return false;
- return this.stardustPlugin.getUserService().getVanishService().isVanished(user.getBase());
+ return this.stardustPlugin.getUserService().getVanishService().isVanished(user.getUniqueId());
}
}
diff --git a/src/main/java/net/onelitefeather/stardust/listener/VanishSilentContainerFeature.java b/src/main/java/net/onelitefeather/stardust/listener/VanishSilentContainerFeature.java
index c26bde33..dae663f3 100644
--- a/src/main/java/net/onelitefeather/stardust/listener/VanishSilentContainerFeature.java
+++ b/src/main/java/net/onelitefeather/stardust/listener/VanishSilentContainerFeature.java
@@ -35,7 +35,7 @@ public void handleInventoryClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player whoClicked)) return;
Inventory clickedInventory = event.getInventory();
- if (stardustPlugin.getUserService().getVanishService().isVanished(whoClicked)) {
+ if (stardustPlugin.getUserService().getVanishService().isVanished(whoClicked.getUniqueId())) {
Inventory inventory = silentContainerLooter.get(whoClicked);
if (inventory == null) return;
boolean canInteract = whoClicked.hasPermission("stardust.vanish.silentopen.interact");
@@ -52,7 +52,7 @@ public void handlePlayerInteract(PlayerInteractEvent event) {
BlockState blockState = event.getClickedBlock().getState();
boolean hasPermission = player.hasPermission("stardust.vanish.silentopen");
- boolean vanished = stardustPlugin.getUserService().getVanishService().isVanished(player);
+ boolean vanished = stardustPlugin.getUserService().getVanishService().isVanished(player.getUniqueId());
if (blockState instanceof EnderChest) {
boolean useInteractBlock = vanished && !player.isSneaking() || player.isSneaking();
diff --git a/src/main/java/net/onelitefeather/stardust/service/BukkitPlayerVanishService.java b/src/main/java/net/onelitefeather/stardust/service/BukkitPlayerVanishService.java
index 55b7e30c..9b6ec4ef 100644
--- a/src/main/java/net/onelitefeather/stardust/service/BukkitPlayerVanishService.java
+++ b/src/main/java/net/onelitefeather/stardust/service/BukkitPlayerVanishService.java
@@ -11,7 +11,11 @@
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
-public class BukkitPlayerVanishService implements PlayerVanishService