Skip to content

Commit

Permalink
add method replaceData(key, T ob)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafabinguldev committed May 6, 2023
1 parent 4ea5c99 commit 66066b3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/tech/bingulhan/hanguiapi/gui/HanGuiBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public Optional<GuiData> getData(@NotNull String key) {
return Optional.empty();
}



public <T> boolean addData(@NotNull String key,@NotNull T t) {
if (dataList.stream().anyMatch(guiData -> guiData.getT().equals(key))) {
Bukkit.getLogger().info("d");
Expand All @@ -98,6 +100,19 @@ public <T> boolean addData(@NotNull String key,@NotNull T t) {
return true;
}

public <T> boolean replaceData(@NotNull String key,@NotNull T t) {
if (dataList.stream().anyMatch(guiData -> guiData.getT().equals(key))) {
removeData(key);
addData(key, t);
return true;
}

dataList.add(new GuiData<T>(key, t));

return false;
}


public boolean removeData(@NotNull String key) {
if (!getData(key).isPresent()) {
return false;
Expand Down

0 comments on commit 66066b3

Please sign in to comment.