mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 05:25:21 +01:00
Implement AnvilGUI into StringListGui so users could edit text via Anvil.
This commit is contained in:
parent
faa237ddf0
commit
be7435f73a
@ -9,6 +9,8 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
import net.wesjd.anvilgui.AnvilGUI;
|
||||||
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||||
@ -61,9 +63,9 @@ public class StringListGUI
|
|||||||
|
|
||||||
panelBuilder.item(8, this.getButton(Button.CANCEL));
|
panelBuilder.item(8, this.getButton(Button.CANCEL));
|
||||||
|
|
||||||
for (String element : this.value)
|
for (int i = 0; i < this.value.size(); i++)
|
||||||
{
|
{
|
||||||
panelBuilder.item(this.createStringElement(element));
|
panelBuilder.item(this.createStringElement(this.value.get(i), i));
|
||||||
}
|
}
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
@ -122,10 +124,14 @@ public class StringListGUI
|
|||||||
description = Collections.emptyList();
|
description = Collections.emptyList();
|
||||||
icon = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
icon = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
|
||||||
clickHandler = (panel, user, clickType, slot) -> {
|
clickHandler = (panel, user, clickType, slot) -> {
|
||||||
|
new AnvilGUI(BentoBox.getInstance(),
|
||||||
// TODO: Open Anvil GUI.
|
this.user.getPlayer(),
|
||||||
|
" ",
|
||||||
this.build();
|
(player, reply) -> {
|
||||||
|
this.value.add(reply);
|
||||||
|
this.build();
|
||||||
|
return reply;
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
@ -168,13 +174,20 @@ public class StringListGUI
|
|||||||
* @param element Paper Icon name
|
* @param element Paper Icon name
|
||||||
* @return PanelItem.
|
* @return PanelItem.
|
||||||
*/
|
*/
|
||||||
private PanelItem createStringElement(String element)
|
private PanelItem createStringElement(String element, int stringIndex)
|
||||||
{
|
{
|
||||||
return new PanelItemBuilder().
|
return new PanelItemBuilder().
|
||||||
name(element).
|
name(element).
|
||||||
icon(Material.PAPER).
|
icon(Material.PAPER).
|
||||||
clickHandler((panel, user1, clickType, i) -> {
|
clickHandler((panel, user1, clickType, i) -> {
|
||||||
// TODO: open anvil gui.
|
new AnvilGUI(BentoBox.getInstance(),
|
||||||
|
this.user.getPlayer(),
|
||||||
|
element,
|
||||||
|
(player, reply) -> {
|
||||||
|
this.value.set(stringIndex, reply);
|
||||||
|
this.build();
|
||||||
|
return reply;
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}).build();
|
}).build();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user