Class RewardObfuscator
java.lang.Object
com.Moshu.TreasureHunt.Components.Rewards.RewardObfuscator
- All Implemented Interfaces:
org.bukkit.event.Listener
Manages the obfuscation of treasure rewards to hide their true identity from players.
This class provides functionality to replace actual reward items with placeholder items
until players interact with them, creating a surprise element in treasure hunts.
The obfuscation system supports both ProtocolLib and PacketEvents for packet manipulation
and can be configured through the plugin configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
deobfuscate
(org.bukkit.entity.Player p, int slot, org.bukkit.inventory.ItemStack realItem) Deobfuscates a specific slot in a player's inventory, revealing the real item.static ObfuscatedReward
Gets the obfuscated reward configuration.static boolean
Checks if reward obfuscation is enabled.static boolean
Checks if the system is using PacketEvents for packet manipulation.static boolean
Checks if the system is using ProtocolLib for packet manipulation.static void
load()
Loads the reward obfuscation configuration and initializes the system.static void
obfuscateInventory
(org.bukkit.entity.Player player, org.bukkit.inventory.Inventory inventory) Obfuscates an entire inventory, replacing real items with placeholder items.void
onOpen
(org.bukkit.event.inventory.InventoryOpenEvent e) static void
putWindowId
(UUID uuid, int windowId) Stores a player's window ID for packet manipulation.static void
Registers the appropriate window listener based on the available protocol library.
-
Constructor Details
-
RewardObfuscator
public RewardObfuscator()
-
-
Method Details
-
load
public static void load()Loads the reward obfuscation configuration and initializes the system. Reads settings from the plugin configuration and sets up the appropriate protocol library for packet manipulation. -
isEnabled
public static boolean isEnabled()Checks if reward obfuscation is enabled.- Returns:
- True if obfuscation is enabled, false otherwise
-
getReward
Gets the obfuscated reward configuration.- Returns:
- The ObfuscatedReward object containing obfuscation settings
-
isUsingProtocolLib
public static boolean isUsingProtocolLib()Checks if the system is using ProtocolLib for packet manipulation.- Returns:
- True if using ProtocolLib, false otherwise
-
isUsingPacketEvents
public static boolean isUsingPacketEvents()Checks if the system is using PacketEvents for packet manipulation.- Returns:
- True if using PacketEvents, false otherwise
-
putWindowId
Stores a player's window ID for packet manipulation.- Parameters:
uuid
- The player's UUIDwindowId
- The window ID to store
-
registerOpenWindowListener
public static void registerOpenWindowListener()Registers the appropriate window listener based on the available protocol library. Sets up packet interception for inventory interactions. -
deobfuscate
public static void deobfuscate(org.bukkit.entity.Player p, int slot, org.bukkit.inventory.ItemStack realItem) Deobfuscates a specific slot in a player's inventory, revealing the real item.- Parameters:
p
- The player whose inventory to deobfuscateslot
- The slot to deobfuscaterealItem
- The real item to show
-
obfuscateInventory
public static void obfuscateInventory(org.bukkit.entity.Player player, org.bukkit.inventory.Inventory inventory) Obfuscates an entire inventory, replacing real items with placeholder items.- Parameters:
player
- The player whose inventory to obfuscateinventory
- The inventory to obfuscate
-
onOpen
public void onOpen(org.bukkit.event.inventory.InventoryOpenEvent e)
-