From e2a52ceacae8c418947afdabcf762acc8af55917 Mon Sep 17 00:00:00 2001 From: Fulminazzo Date: Mon, 15 Apr 2024 02:34:02 +0200 Subject: [PATCH] Updated copyAll to also copy actions --- .../main/java/it/angrybear/yagl/guis/GUI.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 3d09e179f..cf343e4f3 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; }