diff --git a/gui/base/src/main/java/it/fulminazzo/yagl/guis/GUI.java b/gui/base/src/main/java/it/fulminazzo/yagl/guis/GUI.java index 1dffea95..ace3a1bc 100644 --- a/gui/base/src/main/java/it/fulminazzo/yagl/guis/GUI.java +++ b/gui/base/src/main/java/it/fulminazzo/yagl/guis/GUI.java @@ -1342,31 +1342,36 @@ default int southEast() { if (other.size() != size()) throw new IllegalArgumentException(String.format("Cannot copy from GUI with different size %s != %s", size(), other.size())); - if (other.getTitle() == null || replace) other.setTitle(getTitle()); - copyAll((Metadatable) other, replace); - for (int i = 0; i < size(); i++) { - final @NotNull List contents = getContents(i); - if (contents.isEmpty()) continue; - if (other.getContents(i).isEmpty() || replace) - other.setContents(i, contents.toArray(new GUIContent[0])); + else { + if (other.getTitle() == null || replace) other.setTitle(getTitle()); + + copyAll((Metadatable) other, replace); + + for (int i = 0; i < size(); i++) { + final @NotNull List contents = getContents(i); + if (!contents.isEmpty() && (other.getContents(i).isEmpty() || replace)) + 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; } - 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; } /**