Skip to content

O | Utility: GammaUtils

Sartaj Singh edited this page May 31, 2025 · 3 revisions

O | Utility: GammaUtils


Table of Contents


1. Overview

GammaUtils is a utility class in FXItems for toggling night vision effects for players via commands.
It is designed to make it easy for players (with permission) to enable or disable night vision, with persistent effects and clear messaging.


2. What is GammaUtils?

  • Lets players toggle night vision on or off with /nv or /nightvision commands.
  • Uses metadata to track if a player has night vision active.
  • Applies or removes the actual potion effect as needed.
  • Provides user feedback via chat messages.

3. Basic Usage

Usage: Toggle night vision

Players with the required permission can use:

/nv

or

/nightvision
  • Enables night vision if not already active.
  • Disables night vision if already active.

4. API Reference

// Command handler (implements CommandExecutor)
public boolean onCommand(CommandSender sender, Command command, String label, String[] args);
  • Enables Night Vision:
    Adds NIGHT_VISION potion effect to player and sets metadata.
  • Disables Night Vision:
    Removes NIGHT_VISION effect and metadata.

5. Advanced Patterns

  • Permission Control:
    Only players with the smp.nightvision permission can use the command.
  • Persistent Effect:
    Uses metadata to ensure the effect is not re-applied or removed incorrectly.
  • Integration:
    Can be hooked into other plugins by calling the same command handler.

6. Troubleshooting & Notes

  • Only works for players (not console or command blocks).
  • If a player does not have permission, they will receive a red error message.
  • The night vision effect is set to last effectively forever (Integer.MAX_VALUE duration).
  • Sends clear feedback when toggling on or off.

7. See Also


Clone this wiki locally