Skip to content

Commit

Permalink
feat: onModifyとonInitializeを統合可能に
Browse files Browse the repository at this point in the history
  • Loading branch information
Maru32768 committed Mar 24, 2023
1 parent 075a765 commit 97d5bc4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions common/src/main/java/net/kunmc/lab/configlib/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,21 @@ final void onInitializeValue(E initValue) {
* Adds a listener triggered on value modified.
*/
public final T onModify(Consumer<E> listener) {
return onModify(listener, false);
}

/**
* Adds a listener triggered on value modified.
* If triggeredOnInitialize is true, The listener also will be triggered after the value has been initialized.
*
* @see Value#onInitialize(Consumer)
*/
public final T onModify(Consumer<E> listener, boolean triggeredOnInitialize) {
modifyListeners.add(listener);
if (triggeredOnInitialize) {
onInitialize(listener);
}

return ((T) this);
}

Expand Down

0 comments on commit 97d5bc4

Please sign in to comment.