mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2025-01-19 22:51:24 +01:00
Set all util guis to 45 element size.
Add Glass Pane Borders to these guis.
This commit is contained in:
parent
ce794d771c
commit
60789276be
@ -5,9 +5,11 @@ import org.bukkit.Material;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.utils.GuiUtils;
|
||||
|
||||
|
||||
/**
|
||||
@ -37,28 +39,65 @@ public class ConfirmationGUI
|
||||
{
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.admin.confirm-title"));
|
||||
|
||||
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.consumer.accept(true);
|
||||
return true;
|
||||
}).
|
||||
build());
|
||||
GuiUtils.fillBorder(panelBuilder, Material.BLUE_STAINED_GLASS_PANE);
|
||||
|
||||
panelBuilder.item(5, new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons.cancel")).
|
||||
icon(Material.RED_STAINED_GLASS_PANE).
|
||||
clickHandler((panel, user1, clickType, i) -> {
|
||||
this.consumer.accept(false);
|
||||
return true;
|
||||
}).
|
||||
build());
|
||||
// Accept buttons
|
||||
panelBuilder.item(10, this.getButton(true));
|
||||
panelBuilder.item(11, this.getButton(true));
|
||||
panelBuilder.item(12, this.getButton(true));
|
||||
|
||||
panelBuilder.item(19, this.getButton(true));
|
||||
panelBuilder.item(20, this.getButton(true));
|
||||
panelBuilder.item(21, this.getButton(true));
|
||||
|
||||
panelBuilder.item(28, this.getButton(true));
|
||||
panelBuilder.item(29, this.getButton(true));
|
||||
panelBuilder.item(30, this.getButton(true));
|
||||
|
||||
// Cancel Buttons
|
||||
panelBuilder.item(14, this.getButton(false));
|
||||
panelBuilder.item(15, this.getButton(false));
|
||||
panelBuilder.item(16, this.getButton(false));
|
||||
|
||||
panelBuilder.item(23, this.getButton(false));
|
||||
panelBuilder.item(24, this.getButton(false));
|
||||
panelBuilder.item(25, this.getButton(false));
|
||||
|
||||
panelBuilder.item(32, this.getButton(false));
|
||||
panelBuilder.item(33, this.getButton(false));
|
||||
panelBuilder.item(34, this.getButton(false));
|
||||
|
||||
panelBuilder.item(44,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.OAK_DOOR).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.return")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.consumer.accept(false);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method creates button with requested value.
|
||||
* @param returnValue requested value
|
||||
* @return PanelItem button.
|
||||
*/
|
||||
private PanelItem getButton(boolean returnValue)
|
||||
{
|
||||
return new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons." + (returnValue ? "accept" : "cancel"))).
|
||||
icon(returnValue ? Material.GRAY_STAINED_GLASS_PANE : Material.RED_STAINED_GLASS_PANE).
|
||||
clickHandler((panel, user1, clickType, i) -> {
|
||||
this.consumer.accept(returnValue);
|
||||
return true;
|
||||
}).
|
||||
build();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Variables
|
||||
// ---------------------------------------------------------------------
|
||||
|
@ -13,6 +13,7 @@ import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.utils.GuiUtils;
|
||||
|
||||
|
||||
/**
|
||||
@ -54,11 +55,15 @@ public class NumberGUI
|
||||
{
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.edit-number-title"));
|
||||
|
||||
GuiUtils.fillBorder(panelBuilder);
|
||||
|
||||
// Others
|
||||
panelBuilder.item(0, this.getButton(Button.SAVE));
|
||||
panelBuilder.item(1, this.getButton(Button.VALUE));
|
||||
panelBuilder.item(8, this.getButton(Button.CANCEL));
|
||||
panelBuilder.item(10, this.getButton(Button.INPUT));
|
||||
panelBuilder.item(1, this.getButton(Button.SAVE));
|
||||
|
||||
panelBuilder.item(19, this.getButton(Button.VALUE));
|
||||
panelBuilder.item(44, this.getButton(Button.CANCEL));
|
||||
|
||||
panelBuilder.item(2, this.getButton(Button.INPUT));
|
||||
|
||||
// operations
|
||||
panelBuilder.item(3, this.getButton(Button.SET));
|
||||
@ -67,23 +72,23 @@ public class NumberGUI
|
||||
panelBuilder.item(6, this.getButton(Button.MULTIPLY));
|
||||
|
||||
// Numbers
|
||||
panelBuilder.item(20, this.createNumberButton(1));
|
||||
panelBuilder.item(21, this.createNumberButton(10));
|
||||
panelBuilder.item(22, this.createNumberButton(100));
|
||||
panelBuilder.item(23, this.createNumberButton(1000));
|
||||
panelBuilder.item(24, this.createNumberButton(10000));
|
||||
panelBuilder.item(11, this.createNumberButton(1));
|
||||
panelBuilder.item(12, this.createNumberButton(10));
|
||||
panelBuilder.item(13, this.createNumberButton(100));
|
||||
panelBuilder.item(14, this.createNumberButton(1000));
|
||||
panelBuilder.item(15, this.createNumberButton(10000));
|
||||
|
||||
panelBuilder.item(29, this.createNumberButton(2));
|
||||
panelBuilder.item(30, this.createNumberButton(20));
|
||||
panelBuilder.item(31, this.createNumberButton(200));
|
||||
panelBuilder.item(32, this.createNumberButton(2000));
|
||||
panelBuilder.item(33, this.createNumberButton(20000));
|
||||
panelBuilder.item(20, this.createNumberButton(2));
|
||||
panelBuilder.item(21, this.createNumberButton(20));
|
||||
panelBuilder.item(22, this.createNumberButton(200));
|
||||
panelBuilder.item(23, this.createNumberButton(2000));
|
||||
panelBuilder.item(24, this.createNumberButton(20000));
|
||||
|
||||
panelBuilder.item(38, this.createNumberButton(5));
|
||||
panelBuilder.item(39, this.createNumberButton(50));
|
||||
panelBuilder.item(40, this.createNumberButton(500));
|
||||
panelBuilder.item(41, this.createNumberButton(5000));
|
||||
panelBuilder.item(42, this.createNumberButton(50000));
|
||||
panelBuilder.item(29, this.createNumberButton(5));
|
||||
panelBuilder.item(30, this.createNumberButton(50));
|
||||
panelBuilder.item(31, this.createNumberButton(500));
|
||||
panelBuilder.item(32, this.createNumberButton(5000));
|
||||
panelBuilder.item(33, this.createNumberButton(50000));
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
@ -120,7 +125,7 @@ public class NumberGUI
|
||||
{
|
||||
name = this.user.getTranslation("challenges.gui.buttons.cancel");
|
||||
description = Collections.emptyList();
|
||||
icon = new ItemStack(Material.IRON_DOOR);
|
||||
icon = new ItemStack(Material.OAK_DOOR);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
this.consumer.accept(false, this.value);
|
||||
return true;
|
||||
|
@ -73,6 +73,7 @@ public class SelectBlocksGUI
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).
|
||||
name(this.user.getTranslation("challenges.gui.admin.select-block"));
|
||||
|
||||
GuiUtils.fillBorder(panelBuilder, Material.BLUE_STAINED_GLASS_PANE);
|
||||
|
||||
final int MAX_ELEMENTS = 21;
|
||||
final int correctPage;
|
||||
@ -93,7 +94,7 @@ public class SelectBlocksGUI
|
||||
int entitiesIndex = MAX_ELEMENTS * correctPage;
|
||||
|
||||
// I want first row to be only for navigation and return button.
|
||||
int index = 9;
|
||||
int index = 10;
|
||||
|
||||
while (entitiesIndex < ((correctPage + 1) * MAX_ELEMENTS) &&
|
||||
entitiesIndex < this.elements.size())
|
||||
@ -106,31 +107,44 @@ public class SelectBlocksGUI
|
||||
index++;
|
||||
}
|
||||
|
||||
// Add navigation Buttons
|
||||
panelBuilder.item(3,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.previous")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage - 1);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(4,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.OAK_DOOR).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.return")).
|
||||
icon(Material.RED_STAINED_GLASS_PANE).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.cancel")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.consumer.accept(false, null);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(5,
|
||||
if (this.elements.size() > MAX_ELEMENTS)
|
||||
{
|
||||
// Navigation buttons if necessary
|
||||
|
||||
panelBuilder.item(18,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.previous")).
|
||||
clickHandler((panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage - 1);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(26,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.next")).
|
||||
clickHandler((panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage + 1);
|
||||
return true;
|
||||
}).build());
|
||||
}
|
||||
|
||||
panelBuilder.item(44,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.next")).
|
||||
icon(Material.OAK_DOOR).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.return")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage + 1);
|
||||
this.consumer.accept(false, null);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
|
@ -10,6 +10,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.database.object.Challenges;
|
||||
import world.bentobox.challenges.utils.GuiUtils;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,8 +35,10 @@ public class SelectChallengeGUI
|
||||
{
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.choose-challenge-title"));
|
||||
|
||||
GuiUtils.fillBorder(panelBuilder, Material.BLUE_STAINED_GLASS_PANE);
|
||||
|
||||
// Maximal elements in page.
|
||||
final int MAX_ELEMENTS = 36;
|
||||
final int MAX_ELEMENTS = 21;
|
||||
|
||||
final int correctPage;
|
||||
|
||||
@ -52,18 +55,57 @@ public class SelectChallengeGUI
|
||||
correctPage = pageIndex;
|
||||
}
|
||||
|
||||
// Navigation buttons
|
||||
|
||||
panelBuilder.item(3,
|
||||
panelBuilder.item(4,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.previous")).
|
||||
icon(Material.RED_STAINED_GLASS_PANE).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.return")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage - 1);
|
||||
this.consumer.accept(false, null);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(4,
|
||||
if (this.challengesList.size() > MAX_ELEMENTS)
|
||||
{
|
||||
// Navigation buttons if necessary
|
||||
|
||||
panelBuilder.item(18,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.previous")).
|
||||
clickHandler((panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage - 1);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(26,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.next")).
|
||||
clickHandler((panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage + 1);
|
||||
return true;
|
||||
}).build());
|
||||
}
|
||||
|
||||
int challengesIndex = MAX_ELEMENTS * correctPage;
|
||||
|
||||
// I want first row to be only for navigation and return button.
|
||||
int index = 10;
|
||||
|
||||
while (challengesIndex < ((correctPage + 1) * MAX_ELEMENTS) &&
|
||||
challengesIndex < this.challengesList.size() &&
|
||||
index < 36)
|
||||
{
|
||||
if (!panelBuilder.slotOccupied(index))
|
||||
{
|
||||
panelBuilder.item(index,
|
||||
this.createChallengeButton(this.challengesList.get(challengesIndex++)));
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
panelBuilder.item(44,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.OAK_DOOR).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.return")).
|
||||
@ -72,28 +114,6 @@ public class SelectChallengeGUI
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(5,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.next")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage + 1);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
int challengesIndex = MAX_ELEMENTS * correctPage;
|
||||
|
||||
// I want first row to be only for navigation and return button.
|
||||
int index = 9;
|
||||
|
||||
while (challengesIndex < ((correctPage + 1) * MAX_ELEMENTS) &&
|
||||
challengesIndex < this.challengesList.size())
|
||||
{
|
||||
panelBuilder.item(index++, this.createChallengeButton(this.challengesList.get(challengesIndex++)));
|
||||
}
|
||||
|
||||
panelBuilder.build();
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,10 @@ public class SelectEntityGUI
|
||||
{
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.choose-entity-title"));
|
||||
|
||||
GuiUtils.fillBorder(panelBuilder, Material.BLUE_STAINED_GLASS_PANE);
|
||||
|
||||
// Maximal elements in page.
|
||||
final int MAX_ELEMENTS = 36;
|
||||
final int MAX_ELEMENTS = 21;
|
||||
|
||||
final int correctPage;
|
||||
|
||||
@ -79,46 +81,65 @@ public class SelectEntityGUI
|
||||
correctPage = pageIndex;
|
||||
}
|
||||
|
||||
// Navigation buttons
|
||||
|
||||
panelBuilder.item(3,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.previous")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage - 1);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(4,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.OAK_DOOR).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.return")).
|
||||
icon(Material.RED_STAINED_GLASS_PANE).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.cancel")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.consumer.accept(false, null);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(5,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.next")).
|
||||
clickHandler( (panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage + 1);
|
||||
return true;
|
||||
}).build());
|
||||
if (this.entities.size() > MAX_ELEMENTS)
|
||||
{
|
||||
// Navigation buttons if necessary
|
||||
|
||||
panelBuilder.item(18,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.previous")).
|
||||
clickHandler((panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage - 1);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.item(26,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.SIGN).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.next")).
|
||||
clickHandler((panel, user1, clickType, slot) -> {
|
||||
this.build(correctPage + 1);
|
||||
return true;
|
||||
}).build());
|
||||
}
|
||||
|
||||
int entitiesIndex = MAX_ELEMENTS * correctPage;
|
||||
|
||||
// I want first row to be only for navigation and return button.
|
||||
int index = 9;
|
||||
int slot = 10;
|
||||
|
||||
while (entitiesIndex < ((correctPage + 1) * MAX_ELEMENTS) &&
|
||||
entitiesIndex < this.entities.size())
|
||||
entitiesIndex < this.entities.size() &&
|
||||
slot < 36)
|
||||
{
|
||||
panelBuilder.item(index++, this.createEntityButton(this.entities.get(entitiesIndex++)));
|
||||
if (!panelBuilder.slotOccupied(slot))
|
||||
{
|
||||
panelBuilder.item(slot,
|
||||
this.createEntityButton(this.entities.get(entitiesIndex++)));
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
panelBuilder.item(44,
|
||||
new PanelItemBuilder().
|
||||
icon(Material.OAK_DOOR).
|
||||
name(this.user.getTranslation("challenges.gui.buttons.return")).
|
||||
clickHandler( (panel, user1, clickType, i) -> {
|
||||
this.consumer.accept(false, null);
|
||||
return true;
|
||||
}).build());
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import java.util.function.BiConsumer;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.utils.GuiUtils;
|
||||
|
||||
|
||||
/**
|
||||
@ -35,6 +36,8 @@ public class SelectEnvironmentGUI
|
||||
{
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.admin.environment-title"));
|
||||
|
||||
GuiUtils.fillBorder(panelBuilder, Material.BLUE_STAINED_GLASS_PANE);
|
||||
|
||||
panelBuilder.item(3, new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons.save")).
|
||||
icon(Material.GREEN_STAINED_GLASS_PANE).
|
||||
@ -53,7 +56,7 @@ public class SelectEnvironmentGUI
|
||||
}).
|
||||
build());
|
||||
|
||||
panelBuilder.item(12, new PanelItemBuilder().
|
||||
panelBuilder.item(20, new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons.nether")).
|
||||
icon(Material.NETHERRACK).
|
||||
clickHandler((panel, user1, clickType, i) -> {
|
||||
@ -71,7 +74,7 @@ public class SelectEnvironmentGUI
|
||||
}).
|
||||
glow(this.values.contains(World.Environment.NETHER)).
|
||||
build());
|
||||
panelBuilder.item(13, new PanelItemBuilder().
|
||||
panelBuilder.item(22, new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons.normal")).
|
||||
icon(Material.DIRT).
|
||||
clickHandler((panel, user1, clickType, i) -> {
|
||||
@ -89,7 +92,7 @@ public class SelectEnvironmentGUI
|
||||
}).
|
||||
glow(this.values.contains(World.Environment.NORMAL)).
|
||||
build());
|
||||
panelBuilder.item(14, new PanelItemBuilder().
|
||||
panelBuilder.item(24, new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons.end")).
|
||||
icon(Material.END_STONE).
|
||||
clickHandler((panel, user1, clickType, i) -> {
|
||||
@ -108,6 +111,16 @@ public class SelectEnvironmentGUI
|
||||
glow(this.values.contains(World.Environment.THE_END)).
|
||||
build());
|
||||
|
||||
|
||||
panelBuilder.item(44, new PanelItemBuilder().
|
||||
name(this.user.getTranslation("challenges.gui.admin.buttons.return")).
|
||||
icon(Material.OAK_DOOR).
|
||||
clickHandler((panel, user1, clickType, i) -> {
|
||||
this.consumer.accept(false, Collections.emptySet());
|
||||
return true;
|
||||
}).
|
||||
build());
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,7 @@ package world.bentobox.challenges.panel.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import net.wesjd.anvilgui.AnvilGUI;
|
||||
@ -15,6 +12,7 @@ import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
||||
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.utils.GuiUtils;
|
||||
|
||||
|
||||
/**
|
||||
@ -35,7 +33,7 @@ public class StringListGUI
|
||||
this.user = user;
|
||||
this.value = value;
|
||||
|
||||
if (this.value.size() > 18)
|
||||
if (this.value.size() > 21)
|
||||
{
|
||||
// TODO: throw error that so large list cannot be edited.
|
||||
this.consumer.accept(false, this.value);
|
||||
@ -52,20 +50,31 @@ public class StringListGUI
|
||||
*/
|
||||
private void build()
|
||||
{
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(this.user.getTranslation("challenges.gui.text-edit-title"));
|
||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).
|
||||
name(this.user.getTranslation("challenges.gui.text-edit-title"));
|
||||
|
||||
panelBuilder.item(0, this.getButton(Button.SAVE));
|
||||
panelBuilder.item(1, this.getButton(Button.VALUE));
|
||||
GuiUtils.fillBorder(panelBuilder, Material.BLACK_STAINED_GLASS_PANE);
|
||||
|
||||
panelBuilder.item(3, this.getButton(Button.ADD));
|
||||
panelBuilder.item(4, this.getButton(Button.REMOVE));
|
||||
panelBuilder.item(4, this.getButton(Button.CLEAR));
|
||||
panelBuilder.item(1, this.getButton(Button.SAVE));
|
||||
panelBuilder.item(2, this.getButton(Button.VALUE));
|
||||
|
||||
panelBuilder.item(8, this.getButton(Button.CANCEL));
|
||||
panelBuilder.item(4, this.getButton(Button.ADD));
|
||||
panelBuilder.item(5, this.getButton(Button.REMOVE));
|
||||
panelBuilder.item(6, this.getButton(Button.CLEAR));
|
||||
|
||||
for (int i = 0; i < this.value.size(); i++)
|
||||
panelBuilder.item(44, this.getButton(Button.CANCEL));
|
||||
|
||||
int slot = 10;
|
||||
|
||||
for (int stringIndex = 0; stringIndex < this.value.size() && slot < 36; stringIndex++)
|
||||
{
|
||||
panelBuilder.item(this.createStringElement(this.value.get(i), i));
|
||||
if (!panelBuilder.slotOccupied(slot))
|
||||
{
|
||||
panelBuilder.item(slot,
|
||||
this.createStringElement(this.value.get(stringIndex), stringIndex));
|
||||
}
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
panelBuilder.build();
|
||||
@ -90,7 +99,7 @@ public class StringListGUI
|
||||
{
|
||||
name = this.user.getTranslation("challenges.gui.buttons.save");
|
||||
description = Collections.emptyList();
|
||||
icon = new ItemStack(Material.COMMAND_BLOCK);
|
||||
icon = new ItemStack(Material.GREEN_STAINED_GLASS_PANE);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
this.consumer.accept(true, this.value);
|
||||
|
||||
@ -102,7 +111,7 @@ public class StringListGUI
|
||||
{
|
||||
name = this.user.getTranslation("challenges.gui.buttons.cancel");
|
||||
description = Collections.emptyList();
|
||||
icon = new ItemStack(Material.IRON_DOOR);
|
||||
icon = new ItemStack(Material.OAK_DOOR);
|
||||
clickHandler = (panel, user, clickType, slot) -> {
|
||||
this.consumer.accept(false, this.value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user