Skip to content

Commit

Permalink
Added copying for LazyEmbed
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Dec 4, 2023
1 parent 79b66e6 commit 98e63bc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions library/src/main/java/xyz/srnyx/lazylibrary/LazyEmbed.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,27 @@ public LazyEmbed(@NotNull ConfigurationNode node) {
if (timestampValue != 0) setTimestamp(Instant.ofEpochMilli(timestampValue));
}

/**
* Constructs a new {@link LazyEmbed} from another {@link LazyEmbed}
*
* @param lazyEmbed the {@link LazyEmbed} to copy
*/
public LazyEmbed(@NotNull LazyEmbed lazyEmbed) {
this.color = lazyEmbed.color;
this.authorName = lazyEmbed.authorName;
this.authorUrl = lazyEmbed.authorUrl;
this.authorIcon = lazyEmbed.authorIcon;
this.titleText = lazyEmbed.titleText;
this.titleUrl = lazyEmbed.titleUrl;
this.description = lazyEmbed.description;
this.thumbnail = lazyEmbed.thumbnail;
this.image = lazyEmbed.image;
this.fields.addAll(lazyEmbed.fields);
this.footerText = lazyEmbed.footerText;
this.footerIcon = lazyEmbed.footerIcon;
this.timestamp = lazyEmbed.timestamp;
}

/**
* Constructs a new {@link LazyEmbed} from a {@link MessageEmbed}
*
Expand Down Expand Up @@ -339,6 +360,16 @@ public Map<String, Object> toMap() {
return map;
}

/**
* Copies this {@link LazyEmbed} as a new instance
*
* @return the new {@link LazyEmbed} instance
*/
@NotNull
public LazyEmbed copy() {
return new LazyEmbed(this);
}

/**
* Replaces a key with a value in all parameters of the {@link LazyEmbed embed}
*
Expand Down

0 comments on commit 98e63bc

Please sign in to comment.