Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some missing validation #15

Merged
merged 1 commit into from
Sep 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/org/bukkit/chat/Click.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public final class Click implements ConfigurationSerializable {
* @return a new Click of type OPEN_URL
*/
public static Click ofOpenUrl(String url) {
Validate.notNull(url, "Url cannot be null!");
Validate.isTrue(HTTP_REGEX.matcher(url).matches(), "Provided url is invalid: " + url);
return forType(Type.OPEN_URL, url);
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/bukkit/chat/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public final class Message implements Iterable<Part>, ConfigurationSerializable
/**
* Builds a Message from zero (empty Message), one or more Parts.
*
* @param parts parts of the Message
* @param parts parts of the Message, cannot be null and cannot contain null
* elements
* @return the built Message
*/
public static Message of(Part... parts) {
Message result = new Message();
Validate.notNull(parts, "Parts cannot be null!");
final Message result = new Message();
for (Part part : parts) {
result.append(part);
}
Expand Down Expand Up @@ -300,6 +302,7 @@ private Message() {
* @return this Message for chain calls
*/
public Message append(Message message) {
Validate.notNull(message, "Message cannot be null!");
this.parts.addAll(message.parts);
return this;
}
Expand All @@ -311,6 +314,7 @@ public Message append(Message message) {
* @return this Message for chain calls
*/
public Message append(Part part) {
Validate.notNull(part, "Part cannot be null!");
this.parts.add(part);
return this;
}
Expand Down Expand Up @@ -591,6 +595,7 @@ public Message appendLocalized(Click clickAction, Achievement achievement, Strin
* @return this Message for chain calls
*/
public Message insert(int pos, Part part) {
Validate.notNull(part, "Part cannot be null!");
this.parts.add(pos, part);
return this;
}
Expand Down