diff --git a/gui/base/src/main/java/it/angrybear/yagl/guis/GUI.java b/gui/base/src/main/java/it/angrybear/yagl/guis/GUI.java index 3d09e179..cf343e4f 100644 --- a/gui/base/src/main/java/it/angrybear/yagl/guis/GUI.java +++ b/gui/base/src/main/java/it/angrybear/yagl/guis/GUI.java @@ -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 @@ -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 open = other.openGUIAction(); + if (!open.isPresent() || replace) other.onOpenGUI(a); + }); + closeGUIAction().ifPresent(a -> { + @NotNull Optional close = other.closeGUIAction(); + if (!close.isPresent() || replace) other.onCloseGUI(a); + }); + changeGUIAction().ifPresent(a -> { + @NotNull Optional change = other.changeGUIAction(); + if (!change.isPresent() || replace) other.onChangeGUI(a); + }); + clickOutsideAction().ifPresent(a -> { + @NotNull Optional clickOutside = other.clickOutsideAction(); + if (!clickOutside.isPresent() || replace) other.onClickOutside(a); + }); return this; }