Class RewardObfuscator

java.lang.Object
com.Moshu.TreasureHunt.Components.Rewards.RewardObfuscator
All Implemented Interfaces:
org.bukkit.event.Listener

public class RewardObfuscator extends Object implements 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static ObfuscatedReward 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

      public static void putWindowId(UUID uuid, int windowId)
      Stores a player's window ID for packet manipulation.
      Parameters:
      uuid - The player's UUID
      windowId - 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 deobfuscate
      slot - The slot to deobfuscate
      realItem - 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 obfuscate
      inventory - The inventory to obfuscate
    • onOpen

      public void onOpen(org.bukkit.event.inventory.InventoryOpenEvent e)