Skip to content

Commit

Permalink
Improve LazyEmbed#invalidArguments(...)
Browse files Browse the repository at this point in the history
- Removed `#invalidArguments(String, Object...)`, was useless and caused conflict
- `#invalidArguments(Object...)` now allows null keys/values
  • Loading branch information
srnyx committed May 13, 2024
1 parent 37475b2 commit 8d0e1cf
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/main/java/xyz/srnyx/lazylibrary/LazyEmbed.java
Original file line number Diff line number Diff line change
Expand Up @@ -805,26 +805,7 @@ public static LazyEmbed invalidArguments(@NotNull Object... argumentsValues) {
final LazyEmbed embed = new LazyEmbed()
.setColor(Color.RED)
.setTitle("Invalid argument!");
for (int i = 0; i < argumentsValues.length; i += 2) embed.addField(argumentsValues[i].toString(), argumentsValues[i + 1].toString(), true);
return embed;
}

/**
* A pre-built {@link LazyEmbed} for when multiple provided arguments are invalid
*
* @param description the description of the embed
* @param argumentsValues the arguments and values that are invalid (argument1, value1, argument2, value2, ...)
*
* @return the {@link LazyEmbed}
*/
@NotNull
public static LazyEmbed invalidArguments(@NotNull String description, @NotNull Object... argumentsValues) {
if (argumentsValues.length % 2 != 0) throw new IllegalArgumentException("Each argument must have a value!");
final LazyEmbed embed = new LazyEmbed()
.setColor(Color.RED)
.setTitle("Invalid argument!")
.setDescription(description);
for (int i = 0; i < argumentsValues.length; i += 2) embed.addField(argumentsValues[i].toString(), argumentsValues[i + 1].toString(), true);
for (int i = 0; i < argumentsValues.length; i += 2) embed.addField(String.valueOf(argumentsValues[i]), String.valueOf(argumentsValues[i + 1]), true);
return embed;
}
}

0 comments on commit 8d0e1cf

Please sign in to comment.