From ceb92d8eaa5a70881feacfe5c692e5984fbf7b82 Mon Sep 17 00:00:00 2001 From: ConChimCoDon <57979356+hieudieu393@users.noreply.github.com> Date: Mon, 2 Feb 2026 20:20:33 +0700 Subject: [PATCH 1/3] Refactor Floodgate player detection methods Refactor player detection methods for Bedrock support. Simplify error handling and improve readability. --- .../simpmc/simppay/util/FloodgateUtil.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/simppay-paper/src/main/java/org/simpmc/simppay/util/FloodgateUtil.java b/simppay-paper/src/main/java/org/simpmc/simppay/util/FloodgateUtil.java index 1f05307..d548c02 100644 --- a/simppay-paper/src/main/java/org/simpmc/simppay/util/FloodgateUtil.java +++ b/simppay-paper/src/main/java/org/simpmc/simppay/util/FloodgateUtil.java @@ -13,7 +13,8 @@ * Phase 7: Enhanced Floodgate Utility *

* Provides helper methods for Floodgate integration (Bedrock player support). - * Includes initialization, player detection, and form sending with proper error handling. + * Includes initialization, player detection, and form sending with proper error + * handling. */ public class FloodgateUtil { private static final Logger LOGGER = Logger.getLogger(FloodgateUtil.class.getName()); @@ -66,20 +67,7 @@ public static boolean isBedrockPlayer(Player player) { return false; } - UUID uuid = player.getUniqueId(); - - // Primary method: Use Floodgate API - if (initialized && floodgateApi != null) { - try { - return floodgateApi.isFloodgatePlayer(uuid); - } catch (Exception e) { - LOGGER.warning("Error checking if player is Bedrock via API: " + e.getMessage()); - } - } - - // Fallback method: Check UUID pattern - // Floodgate UUIDs have most significant bits set to 0 - return uuid.getMostSignificantBits() == 0; + return isBedrockPlayer(player.getUniqueId()); } /** @@ -93,14 +81,20 @@ public static boolean isBedrockPlayer(UUID uuid) { return false; } + // Primary method: Use Floodgate API (most reliable) if (initialized && floodgateApi != null) { try { return floodgateApi.isFloodgatePlayer(uuid); } catch (Exception e) { LOGGER.warning("Error checking UUID via Floodgate API: " + e.getMessage()); + // Only fall back to UUID pattern if API throws exception + return uuid.getMostSignificantBits() == 0; } } + // Fallback method: Check UUID pattern + // ONLY used when Floodgate is NOT initialized (plugin not available) + // Floodgate UUIDs have most significant bits set to 0 return uuid.getMostSignificantBits() == 0; } @@ -108,7 +102,8 @@ public static boolean isBedrockPlayer(UUID uuid) { * Gets the Bedrock username for a player (without the prefix). * * @param player Player to get username for - * @return Bedrock username, or player's regular username if not a Bedrock player + * @return Bedrock username, or player's regular username if not a Bedrock + * player */ public static String getBedrockUsername(Player player) { if (player == null) { From 346db48dcd715ab8f5e049d03847d2bc9479035b Mon Sep 17 00:00:00 2001 From: ConChimCoDon <57979356+hieudieu393@users.noreply.github.com> Date: Mon, 2 Feb 2026 20:21:07 +0700 Subject: [PATCH 2/3] Refactor NaptheCommand for Floodgate player detection --- .../org/simpmc/simppay/commands/root/NaptheCommand.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/NaptheCommand.java b/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/NaptheCommand.java index efc9d0e..12bd91a 100644 --- a/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/NaptheCommand.java +++ b/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/NaptheCommand.java @@ -4,6 +4,7 @@ import dev.jorel.commandapi.CommandPermission; import org.simpmc.simppay.SPPlugin; import org.simpmc.simppay.menu.card.CardListView; +import org.simpmc.simppay.util.FloodgateUtil; public class NaptheCommand { @@ -12,12 +13,12 @@ public NaptheCommand() { .withPermission(CommandPermission.NONE) .executesPlayer((player, args) -> { // start a new napthe session - boolean isFloodgateUUID = player.getUniqueId().getMostSignificantBits() == 0; - boolean floodgateEnabled = SPPlugin.getInstance().isFloodgateEnabled(); - if (floodgateEnabled && isFloodgateUUID) { + // Use FloodgateUtil for accurate Bedrock player detection + if (SPPlugin.getInstance().isFloodgateEnabled() && FloodgateUtil.isBedrockPlayer(player)) { try { Class naptheFormClass = Class.forName("org.simpmc.simppay.forms.NaptheForm"); - Object form = naptheFormClass.getMethod("getNapTheForm", org.bukkit.entity.Player.class).invoke(null, player); + Object form = naptheFormClass.getMethod("getNapTheForm", org.bukkit.entity.Player.class) + .invoke(null, player); Class floodgateUtilClass = Class.forName("org.simpmc.simppay.util.FloodgateUtil"); floodgateUtilClass.getMethod("sendForm", java.util.UUID.class, Object.class) From a9720e4286071ad98d9373197b6adb9da7f56d3d Mon Sep 17 00:00:00 2001 From: ConChimCoDon <57979356+hieudieu393@users.noreply.github.com> Date: Mon, 2 Feb 2026 20:21:31 +0700 Subject: [PATCH 3/3] Improve Bedrock player detection in ViewHistoryCommand Refactor player detection logic to use FloodgateUtil for Bedrock player identification. --- .../simpmc/simppay/commands/root/ViewHistoryCommand.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/ViewHistoryCommand.java b/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/ViewHistoryCommand.java index 70c165e..8dd164c 100644 --- a/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/ViewHistoryCommand.java +++ b/simppay-paper/src/main/java/org/simpmc/simppay/commands/root/ViewHistoryCommand.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.simpmc.simppay.SPPlugin; import org.simpmc.simppay.menu.PaymentHistoryView; +import org.simpmc.simppay.util.FloodgateUtil; public class ViewHistoryCommand { public ViewHistoryCommand() { @@ -12,12 +13,12 @@ public ViewHistoryCommand() { .withPermission(CommandPermission.NONE) .withAliases("napthehistory", "xemgdnapthe") .executesPlayer((player, args) -> { - boolean isFloodgateUUID = player.getUniqueId().getMostSignificantBits() == 0; - boolean floodgateEnabled = SPPlugin.getInstance().isFloodgateEnabled(); - if (floodgateEnabled && isFloodgateUUID) { + // Use FloodgateUtil for accurate Bedrock player detection + if (SPPlugin.getInstance().isFloodgateEnabled() && FloodgateUtil.isBedrockPlayer(player)) { try { Class viewHistoryFormClass = Class.forName("org.simpmc.simppay.forms.ViewHistoryForm"); - Object form = viewHistoryFormClass.getMethod("getHistoryForm", Player.class).invoke(null, player); + Object form = viewHistoryFormClass.getMethod("getHistoryForm", Player.class).invoke(null, + player); Class floodgateUtilClass = Class.forName("org.simpmc.simppay.util.FloodgateUtil"); floodgateUtilClass.getMethod("sendForm", java.util.UUID.class, Object.class)