Skip to content

Commit

Permalink
Remove commands from UtilGuis, instead use CommonGUI.valueObject to s…
Browse files Browse the repository at this point in the history
…tore new value.

Proper ItemSwitchGUI implementation.
  • Loading branch information
BONNe committed Jan 17, 2019
1 parent bd48e85 commit dab5f2b
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 217 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package world.bentobox.challenges.panel.util;

import org.bukkit.Material;

import java.util.*;
import org.bukkit.Material;

import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
Expand All @@ -22,18 +20,11 @@ public class ConfirmationGUI
*
* @param user Gui Caller.
* @param parentGUI Parent GUI.
* @param command Command .
* @param parameters Variables at the end of command.
*/
public ConfirmationGUI(CommonGUI parentGUI,
User user,
CompositeCommand command,
String... parameters)
public ConfirmationGUI(CommonGUI parentGUI, User user)
{
this.user = user;
this.parentGUI = parentGUI;
this.command = command;
this.parameters = parameters;

this.build();
}
Expand All @@ -50,11 +41,8 @@ public void build()
panelBuilder.item(3, new PanelItemBuilder().
name(this.user.getTranslation("challenges.gui.admin.buttons.proceed")).
icon(Material.GREEN_STAINED_GLASS_PANE).
clickHandler((panel, user1, clickType, index) ->
{
this.command
.execute(this.user, "CONFIRMATION", Arrays.asList(this.parameters));

clickHandler((panel, user1, clickType, index) -> {
this.parentGUI.setValue(true);
this.user.closeInventory();
this.parentGUI.build();
return true;
Expand All @@ -66,6 +54,7 @@ public void build()
icon(Material.RED_STAINED_GLASS_PANE).
clickHandler((panel, user1, clickType, i) ->
{
this.parentGUI.setValue(null);
this.parentGUI.build();
return true;
}).
Expand All @@ -88,14 +77,4 @@ public void build()
* Parent GUI where should return on cancel or proceed.
*/
private CommonGUI parentGUI;

/**
* Command that must be run on confirmation.
*/
private CompositeCommand command;

/**
* List of variables.
*/
private String[] parameters;
}
129 changes: 0 additions & 129 deletions src/main/java/world/bentobox/challenges/panel/util/ItemGUI.java

This file was deleted.

0 comments on commit dab5f2b

Please sign in to comment.