diff --git a/src/main/java/minevalley/core/api/discord/EmbeddedMessage.java b/src/main/java/minevalley/core/api/discord/EmbeddedMessage.java
index bf89580b..da21c4d7 100644
--- a/src/main/java/minevalley/core/api/discord/EmbeddedMessage.java
+++ b/src/main/java/minevalley/core/api/discord/EmbeddedMessage.java
@@ -1,26 +1,115 @@
package minevalley.core.api.discord;
+import org.jetbrains.annotations.Contract;
+
+import javax.annotation.Nonnull;
import java.awt.*;
public interface EmbeddedMessage {
- EmbeddedMessage setTitle(String title);
+ /**
+ * Sets the title of the embedded message.
+ *
+ * @param title The title of the embedded message.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the title is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ EmbeddedMessage setTitle(@Nonnull String title) throws IllegalArgumentException;
- EmbeddedMessage setDescription(String description);
+ /**
+ * Sets the description of the embedded message.
+ *
+ * @param description The description of the embedded message.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the description is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ EmbeddedMessage setDescription(@Nonnull String description) throws IllegalArgumentException;
- EmbeddedMessage setAuthor(String name, String url, String iconUrl);
+ /**
+ * Sets the author of the embedded message.
+ *
+ * @param name The name of the author.
+ * @param url The URL of the author.
+ * @param iconUrl The URL of the author's icon.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the name, URL or icon URL is null.
+ */
+ @Nonnull
+ @Contract("_, _, _ -> this")
+ EmbeddedMessage setAuthor(@Nonnull String name, @Nonnull String url, @Nonnull String iconUrl) throws IllegalArgumentException;
- EmbeddedMessage setThumbnail(String url);
+ /**
+ * Sets the thumbnail of the embedded message.
+ *
+ * @param url The URL of the thumbnail.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the URL is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ EmbeddedMessage setThumbnail(@Nonnull String url) throws IllegalArgumentException;
- EmbeddedMessage setColor(Color color);
+ /**
+ * Sets the color of the embedded message.
+ *
+ * @param color The color of the embedded message.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the color is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ EmbeddedMessage setColor(@Nonnull Color color) throws IllegalArgumentException;
- EmbeddedMessage addField(String title, String text, boolean inline);
+ /**
+ * Adds a field to the embedded message.
+ *
+ * @param title The title of the field.
+ * @param text The text of the field.
+ * @param inline Whether the field should be inline or not.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the title or text is null.
+ */
+ @Nonnull
+ @Contract("_, _, _ -> this")
+ EmbeddedMessage addField(@Nonnull String title, @Nonnull String text, boolean inline) throws IllegalArgumentException;
- EmbeddedMessage setImage(String url);
+ /**
+ * Sets the image of the embedded message.
+ *
+ * @param url The URL of the image.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the URL is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ EmbeddedMessage setImage(@Nonnull String url) throws IllegalArgumentException;
- EmbeddedMessage setFooter(String footer, String iconUrl);
+ /**
+ * Sets the footer of the embedded message.
+ *
+ * @param footer The footer of the embedded message.
+ * @param iconUrl The URL of the footer's icon.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the footer is null.
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ EmbeddedMessage setFooter(@Nonnull String footer, @Nonnull String iconUrl) throws IllegalArgumentException;
- default EmbeddedMessage setFooter(String footer) {
+ /**
+ * Sets the footer of the embedded message.
+ *
+ * @param footer The footer of the embedded message.
+ * @return The current instance of the embedded message.
+ * @throws IllegalArgumentException If the footer is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ default EmbeddedMessage setFooter(@Nonnull String footer) throws IllegalArgumentException {
return setFooter(footer, "");
}
}
\ No newline at end of file
diff --git a/src/main/java/minevalley/core/api/discord/Webhook.java b/src/main/java/minevalley/core/api/discord/Webhook.java
index 5f68163a..9a58ba9f 100644
--- a/src/main/java/minevalley/core/api/discord/Webhook.java
+++ b/src/main/java/minevalley/core/api/discord/Webhook.java
@@ -1,16 +1,45 @@
package minevalley.core.api.discord;
+import org.jetbrains.annotations.Contract;
+
+import javax.annotation.Nonnull;
import java.io.IOException;
/**
* This Webhook-builder is meant to help you to create discord-webhooks.
- * You can find helpful information here: ...
+ * You can find helpful information here.
*/
public interface Webhook {
- Webhook setUsername(String username);
+ /**
+ * Sets the username of the webhook.
+ *
+ * @param username The username of the webhook.
+ * @return The current instance of the webhook.
+ * @throws IllegalArgumentException If the username is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ Webhook setUsername(@Nonnull String username);
- Webhook setAvatar(String url);
+ /**
+ * Sets the avatar of the webhook.
+ *
+ * @param url The URL of the avatar.
+ * @return The current instance of the webhook.
+ * @throws IllegalArgumentException If the URL is null.
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ Webhook setAvatar(@Nonnull String url) throws IllegalArgumentException;
- void send(EmbeddedMessage... message) throws IOException;
+ /**
+ * Sends the given messages to the discord-webhook.
+ *
+ * @param message The messages to send.
+ * @throws IOException If an I/O error occurs.
+ * @throws IllegalArgumentException If the message is null, or the given {@code EmbeddedMessage} is another implementation than our internal.
+ */
+ @Contract(pure = true)
+ void send(@Nonnull EmbeddedMessage... message) throws IOException, IllegalArgumentException;
}
\ No newline at end of file