Class CommandUtils

java.lang.Object
fr.hytale.loader.command.CommandUtils

public class CommandUtils extends Object
Utility class for working with commands in HytaleLoader.

Provides helper methods to convert native Hytale command data to HytaleLoader API objects.

Since:
1.0.3
Version:
1.0.4
Author:
HytaleLoader
  • Method Summary

    Modifier and Type
    Method
    Description
    static Player
    getPlayer(com.hypixel.hytale.server.core.command.system.CommandContext context)
    Gets the command sender as a HytaleLoader Player.
    static boolean
    isPlayer(com.hypixel.hytale.server.core.command.system.CommandContext context)
    Checks if the command sender is a player.
    static Player
    requirePlayer(com.hypixel.hytale.server.core.command.system.CommandContext context)
    Gets the command sender as a Player, or throws an exception.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isPlayer

      public static boolean isPlayer(@Nonnull com.hypixel.hytale.server.core.command.system.CommandContext context)
      Checks if the command sender is a player.
      Parameters:
      context - the command context
      Returns:
      true if the sender is a player
    • getPlayer

      @Nullable public static Player getPlayer(@Nonnull com.hypixel.hytale.server.core.command.system.CommandContext context)
      Gets the command sender as a HytaleLoader Player.

      Returns null if the sender is not a player (e.g., console).

      Parameters:
      context - the command context
      Returns:
      the Player wrapper, or null if sender is not a player
    • requirePlayer

      @Nonnull public static Player requirePlayer(@Nonnull com.hypixel.hytale.server.core.command.system.CommandContext context)
      Gets the command sender as a Player, or throws an exception.
      Parameters:
      context - the command context
      Returns:
      the Player wrapper
      Throws:
      IllegalStateException - if the sender is not a player