001/* 002 * Copyright 2021 Siroshun09 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.github.siroshun09.mccommand.common; 018 019/** 020 * Enumeration class of command execution results. 021 */ 022public enum CommandResult { 023 024 /** 025 * If an exception is thrown while executing the command. 026 */ 027 EXCEPTION_OCCURRED, 028 029 /** 030 * If the argument is invalid. 031 */ 032 INVALID_ARGUMENTS, 033 034 /** 035 * If the sender is not the player. 036 */ 037 NOT_PLAYER, 038 039 /** 040 * If there are no arguments. 041 */ 042 NO_ARGUMENT, 043 044 /** 045 * If the sender does not have the permission to execute command. 046 */ 047 NO_PERMISSION, 048 049 /** 050 * If the state is wrong. 051 */ 052 STATE_ERROR, 053 054 /** 055 * If the command is successfully executed. 056 */ 057 SUCCESS; 058 059 /** 060 * Checks if it is {@link CommandResult#SUCCESS}, indicating success. 061 * 062 * @return {@code true} if the enumeration value is {@link CommandResult#SUCCESS}, {@code false} otherwise. 063 */ 064 public boolean wasSuccessful() { 065 return this.equals(SUCCESS); 066 } 067 068 /** 069 * Checks if it indicates failure. 070 * 071 * @return {@code false} if the enumeration value is {@link CommandResult#SUCCESS}, {@code true} otherwise. 072 */ 073 public boolean wasFailure() { 074 return !wasSuccessful(); 075 } 076}