Skip to content

Commit

Permalink
Added Button#setNamedData, Button#getNamedData and Button#getDataRegi…
Browse files Browse the repository at this point in the history
…stry
  • Loading branch information
Mqzn committed Sep 19, 2024
1 parent bac1169 commit b5afe81
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/io/github/mqzen/menus/misc/button/Button.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.mqzen.menus.misc.button;

import io.github.mqzen.menus.base.MenuView;
import io.github.mqzen.menus.misc.DataRegistry;
import io.github.mqzen.menus.misc.button.actions.ButtonClickAction;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand All @@ -18,6 +19,8 @@ public class Button {
private @Nullable ItemStack item;
private @Nullable ButtonClickAction action = null;

private final DataRegistry data = new DataRegistry();

protected Button(@Nullable ItemStack item) {
this.item = item;
}
Expand Down Expand Up @@ -67,5 +70,17 @@ public Button copy() {
return new Button(this.item, this.action);
}

public Button setNamedData(String name, Object data) {
this.data.setData(name, data);
return this;
}

public <T> T getNamedData(String name) {
return data.getData(name);
}

public DataRegistry getDataRegistry() {
return data;
}

}

0 comments on commit b5afe81

Please sign in to comment.