Skip to content

Commit

Permalink
Updated copyAll to also copy actions
Browse files Browse the repository at this point in the history
  • Loading branch information
fulminazzo committed Apr 15, 2024
1 parent eb56bbc commit e2a52ce
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion gui/base/src/main/java/it/angrybear/yagl/guis/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ default GUI unsetVariable(final @NotNull String name) {
}

/**
* Copies all the contents and title from this gui to the given one.
* Copies all the contents, title and actions from this gui to the given one.
*
* @param other the other gui
* @param replace if false, if the other already has the content or title, it will not be replaced
Expand All @@ -335,6 +335,22 @@ default GUI unsetVariable(final @NotNull String name) {
if (!contents.isEmpty() && other.getContents(i).isEmpty())
other.setContents(i, contents.toArray(new GUIContent[0]));
}
openGUIAction().ifPresent(a -> {
@NotNull Optional<GUIAction> open = other.openGUIAction();
if (!open.isPresent() || replace) other.onOpenGUI(a);
});
closeGUIAction().ifPresent(a -> {
@NotNull Optional<GUIAction> close = other.closeGUIAction();
if (!close.isPresent() || replace) other.onCloseGUI(a);
});
changeGUIAction().ifPresent(a -> {
@NotNull Optional<BiGUIAction> change = other.changeGUIAction();
if (!change.isPresent() || replace) other.onChangeGUI(a);
});
clickOutsideAction().ifPresent(a -> {
@NotNull Optional<GUIAction> clickOutside = other.clickOutsideAction();
if (!clickOutside.isPresent() || replace) other.onClickOutside(a);
});
return this;
}

Expand Down

0 comments on commit e2a52ce

Please sign in to comment.