Skip to content

Commit e8c7bed

Browse files
Add more missing null checks to gui builder clone
1 parent 91ed1ec commit e8c7bed

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

invui-core/src/main/java/xyz/xenondevs/invui/gui/AbstractPagedGui.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ protected void applyModifiers(@NotNull PagedGui<C> gui) {
255255
@Override
256256
public @NotNull PagedGui.Builder<C> clone() {
257257
var clone = (AbstractBuilder<C>) super.clone();
258-
if(this.content != null)
258+
if (this.content != null)
259259
clone.content = new ArrayList<>(this.content);
260-
if(this.pageChangeHandlers != null)
260+
if (this.pageChangeHandlers != null)
261261
clone.pageChangeHandlers = new ArrayList<>(this.pageChangeHandlers);
262262
return clone;
263263
}

invui-core/src/main/java/xyz/xenondevs/invui/gui/AbstractScrollGui.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ protected void applyModifiers(@NotNull ScrollGui<C> gui) {
257257
@Override
258258
public @NotNull ScrollGui.Builder<C> clone() {
259259
var clone = (AbstractBuilder<C>) super.clone();
260-
clone.content = new ArrayList<>(content);
261-
clone.scrollHandlers = new ArrayList<>(scrollHandlers);
260+
if (this.content != null)
261+
clone.content = new ArrayList<>(content);
262+
if (this.scrollHandlers != null)
263+
clone.scrollHandlers = new ArrayList<>(scrollHandlers);
262264
return clone;
263265
}
264266

invui-core/src/main/java/xyz/xenondevs/invui/gui/AbstractTabGui.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ public abstract class AbstractTabGui extends AbstractGui implements TabGui {
2626

2727
/**
2828
* Creates a new {@link AbstractTabGui}.
29-
* @param width The width of the gui.
30-
* @param height The height of the gui.
29+
*
30+
* @param width The width of the gui.
31+
* @param height The height of the gui.
3132
* @param tabAmount The amount of tabs.
3233
* @param listSlots The slots to be used for the content.
3334
*/
@@ -39,8 +40,9 @@ public AbstractTabGui(int width, int height, int tabAmount, int... listSlots) {
3940

4041
/**
4142
* Creates a new {@link AbstractTabGui}.
42-
* @param width The width of the gui.
43-
* @param height The height of the gui.
43+
*
44+
* @param width The width of the gui.
45+
* @param height The height of the gui.
4446
* @param tabAmount The amount of tabs.
4547
* @param structure The structure of the gui.
4648
*/
@@ -164,8 +166,10 @@ protected void applyModifiers(@NotNull TabGui gui) {
164166
@Override
165167
public @NotNull TabGui.Builder clone() {
166168
var clone = (AbstractBuilder) super.clone();
167-
clone.tabs = new ArrayList<>(tabs);
168-
clone.tabChangeHandlers = new ArrayList<>(tabChangeHandlers);
169+
if (tabs != null)
170+
clone.tabs = new ArrayList<>(tabs);
171+
if (tabChangeHandlers != null)
172+
clone.tabChangeHandlers = new ArrayList<>(tabChangeHandlers);
169173
return clone;
170174
}
171175

0 commit comments

Comments
 (0)