Skip to content

Commit

Permalink
apply arguments as value in BackAction
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Sep 4, 2024
1 parent 0eb6fef commit 57e14c4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.hsgamer.bettergui.action.type;

import me.hsgamer.bettergui.Permissions;
import me.hsgamer.bettergui.api.menu.Menu;
import me.hsgamer.bettergui.builder.ActionBuilder;
import me.hsgamer.bettergui.util.SchedulerUtil;
Expand All @@ -14,10 +13,12 @@

public class BackAction implements Action {
private final Menu menu;
private final String value;
private final boolean bypass;

public BackAction(ActionBuilder.Input input) {
this.menu = input.getMenu();
this.value = input.getValue();
this.bypass = input.getOption().equalsIgnoreCase("bypassChecks");
}

Expand All @@ -29,8 +30,12 @@ public void apply(UUID uuid, TaskProcess process, StringReplacer stringReplacer)
return;
}

String[] args = !value.isEmpty()
? stringReplacer.replaceOrOriginal(value, uuid).split(" ")
: new String[0];

Runnable runnable = menu.getParentMenu(uuid)
.<Runnable>map(parentMenu -> () -> parentMenu.create(player, new String[0], bypass))
.<Runnable>map(parentMenu -> () -> parentMenu.create(player, args, bypass))
.orElse(player::closeInventory);
SchedulerUtil.entity(player)
.run(() -> {
Expand Down

0 comments on commit 57e14c4

Please sign in to comment.