Class ParseResult

java.lang.Object
com.hypixel.hytale.server.core.command.system.ParseResult

public class ParseResult extends Object
This class assists in getting rid of using exceptions during command parsing by providing a way to send errors up the chain of command.
  • Constructor Details

    • ParseResult

      public ParseResult()
      Empty Constructor for a ParseResult instance.
    • ParseResult

      public ParseResult(boolean throwExceptionWhenFailed)
      Default Constructor for a ParseResult instance.
      Parameters:
      throwExceptionWhenFailed - Whether to throw an exception if parsing fails.
  • Method Details

    • fail

      public void fail(@Nonnull Message reason, @Nullable Message... otherMessages)
      Fail this ParseResult. NOTE: You should return/stop executing further after calling this method
      Parameters:
      reason - The reason for the failure
      otherMessages - Any other messages you want to send in addition to the reason
    • fail

      public void fail(@Nonnull Message reason)
      Called to fail this parse result, with a given reason.
      Parameters:
      reason - The reason for the failure.
    • failed

      public boolean failed()
      Returns:
      true if the parsing failed, false otherwise.
    • sendMessages

      public void sendMessages(@Nonnull CommandSender sender)
      Send the messages to the command sender.
      Parameters:
      sender - the sender to send the messages to.