Skip to content

Commit 102200c

Browse files
committed
Added #getFirst and #getLast methods to the CommandArguments class
1 parent bb8e63d commit 102200c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/main/java/me/despical/commandframework/CommandArguments.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,28 @@ public String getArgument(int index) {
141141
return arguments.length > index && index >= 0 ? arguments[index] : null;
142142
}
143143

144+
/**
145+
* Gets the first argument.
146+
*
147+
* @return The first argument, or {@code null} if no arguments exist.
148+
*/
149+
@Nullable
150+
@Contract(pure = true)
151+
public String getFirst() {
152+
return this.getArgument(0);
153+
}
154+
155+
/**
156+
* Gets the last argument.
157+
*
158+
* @return The last argument, or {@code null} if no arguments exist.
159+
*/
160+
@Nullable
161+
@Contract(pure = true)
162+
public String getLast() {
163+
return this.getArgument(arguments.length - 1);
164+
}
165+
144166
/**
145167
* Returns the indexed element from the arguments array, or the {@code defaultValue}
146168
* if and only if index is out the bounds.

0 commit comments

Comments
 (0)