mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-28 13:36:06 +01:00
Apply single GUI style to all admin GUIs.
This commit is contained in:
parent
c78c690818
commit
10a5dc1940
@ -13,6 +13,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
import world.bentobox.challenges.panel.CommonGUI;
|
import world.bentobox.challenges.panel.CommonGUI;
|
||||||
|
import world.bentobox.challenges.utils.GuiUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,28 +90,31 @@ public class AdminGUI extends CommonGUI
|
|||||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
||||||
this.user.getTranslation("challenges.admin.gui-title"));
|
this.user.getTranslation("challenges.admin.gui-title"));
|
||||||
|
|
||||||
|
GuiUtils.fillBorder(panelBuilder);
|
||||||
|
|
||||||
panelBuilder.item(1, this.createButton(Button.COMPLETE_USER_CHALLENGES));
|
panelBuilder.item(10, this.createButton(Button.COMPLETE_USER_CHALLENGES));
|
||||||
panelBuilder.item(10, this.createButton(Button.RESET_USER_CHALLENGES));
|
panelBuilder.item(19, this.createButton(Button.RESET_USER_CHALLENGES));
|
||||||
|
|
||||||
// Add Challenges
|
// Add Challenges
|
||||||
panelBuilder.item(3, this.createButton(Button.ADD_CHALLENGE));
|
panelBuilder.item(12, this.createButton(Button.ADD_CHALLENGE));
|
||||||
panelBuilder.item(12, this.createButton(Button.ADD_LEVEL));
|
panelBuilder.item(13, this.createButton(Button.ADD_LEVEL));
|
||||||
|
|
||||||
// Edit Challenges
|
// Edit Challenges
|
||||||
panelBuilder.item(4, this.createButton(Button.EDIT_CHALLENGE));
|
panelBuilder.item(21, this.createButton(Button.EDIT_CHALLENGE));
|
||||||
panelBuilder.item(13, this.createButton(Button.EDIT_LEVEL));
|
panelBuilder.item(22, this.createButton(Button.EDIT_LEVEL));
|
||||||
|
|
||||||
// Remove Challenges
|
// Remove Challenges
|
||||||
panelBuilder.item(5, this.createButton(Button.DELETE_CHALLENGE));
|
panelBuilder.item(30, this.createButton(Button.DELETE_CHALLENGE));
|
||||||
panelBuilder.item(14, this.createButton(Button.DELETE_LEVEL));
|
panelBuilder.item(31, this.createButton(Button.DELETE_LEVEL));
|
||||||
|
|
||||||
|
|
||||||
// Import Challenges
|
// Import Challenges
|
||||||
panelBuilder.item(7, this.createButton(Button.IMPORT_CHALLENGES));
|
panelBuilder.item(15, this.createButton(Button.IMPORT_CHALLENGES));
|
||||||
|
|
||||||
// Edit Addon Settings
|
// Edit Addon Settings
|
||||||
panelBuilder.item(8, this.createButton(Button.EDIT_SETTINGS));
|
panelBuilder.item(16, this.createButton(Button.EDIT_SETTINGS));
|
||||||
|
|
||||||
|
panelBuilder.item(44, this.returnButton);
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import world.bentobox.challenges.panel.util.ItemSwitchGUI;
|
|||||||
import world.bentobox.challenges.panel.util.NumberGUI;
|
import world.bentobox.challenges.panel.util.NumberGUI;
|
||||||
import world.bentobox.challenges.panel.util.SelectEnvironmentGUI;
|
import world.bentobox.challenges.panel.util.SelectEnvironmentGUI;
|
||||||
import world.bentobox.challenges.panel.util.StringListGUI;
|
import world.bentobox.challenges.panel.util.StringListGUI;
|
||||||
|
import world.bentobox.challenges.utils.GuiUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,6 +82,8 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
||||||
this.user.getTranslation("challenges.gui.admin.edit-challenge-title"));
|
this.user.getTranslation("challenges.gui.admin.edit-challenge-title"));
|
||||||
|
|
||||||
|
GuiUtils.fillBorder(panelBuilder);
|
||||||
|
|
||||||
panelBuilder.item(2, this.createMenuButton(MenuType.PROPERTIES));
|
panelBuilder.item(2, this.createMenuButton(MenuType.PROPERTIES));
|
||||||
panelBuilder.item(4, this.createMenuButton(MenuType.REQUIREMENTS));
|
panelBuilder.item(4, this.createMenuButton(MenuType.REQUIREMENTS));
|
||||||
panelBuilder.item(6, this.createMenuButton(MenuType.REWARDS));
|
panelBuilder.item(6, this.createMenuButton(MenuType.REWARDS));
|
||||||
@ -109,7 +112,7 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
this.buildRewardsPanel(panelBuilder);
|
this.buildRewardsPanel(panelBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
panelBuilder.item(53, this.returnButton);
|
panelBuilder.item(44, this.returnButton);
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
@ -140,14 +143,14 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
*/
|
*/
|
||||||
private void buildIslandRequirementsPanel(PanelBuilder panelBuilder)
|
private void buildIslandRequirementsPanel(PanelBuilder panelBuilder)
|
||||||
{
|
{
|
||||||
panelBuilder.item(10, this.createButton(Button.REQUIRED_ENTITIES));
|
panelBuilder.item(19, this.createButton(Button.REQUIRED_ENTITIES));
|
||||||
panelBuilder.item(11, this.createButton(Button.REMOVE_ENTITIES));
|
panelBuilder.item(28, this.createButton(Button.REMOVE_ENTITIES));
|
||||||
|
|
||||||
panelBuilder.item(15, this.createButton(Button.REQUIRED_BLOCKS));
|
panelBuilder.item(21, this.createButton(Button.REQUIRED_BLOCKS));
|
||||||
panelBuilder.item(16, this.createButton(Button.REMOVE_BLOCKS));
|
panelBuilder.item(29, this.createButton(Button.REMOVE_BLOCKS));
|
||||||
|
|
||||||
panelBuilder.item(19, this.createButton(Button.SEARCH_RADIUS));
|
panelBuilder.item(23, this.createButton(Button.SEARCH_RADIUS));
|
||||||
panelBuilder.item(28, this.createButton(Button.REQUIRED_PERMISSIONS));
|
panelBuilder.item(25, this.createButton(Button.REQUIRED_PERMISSIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,9 +161,9 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
private void buildInventoryRequirementsPanel(PanelBuilder panelBuilder)
|
private void buildInventoryRequirementsPanel(PanelBuilder panelBuilder)
|
||||||
{
|
{
|
||||||
panelBuilder.item(10, this.createButton(Button.REQUIRED_ITEMS));
|
panelBuilder.item(10, this.createButton(Button.REQUIRED_ITEMS));
|
||||||
panelBuilder.item(11, this.createButton(Button.REMOVE_ITEMS));
|
panelBuilder.item(19, this.createButton(Button.REMOVE_ITEMS));
|
||||||
|
|
||||||
panelBuilder.item(28, this.createButton(Button.REQUIRED_PERMISSIONS));
|
panelBuilder.item(25, this.createButton(Button.REQUIRED_PERMISSIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,14 +174,14 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
private void buildOtherRequirementsPanel(PanelBuilder panelBuilder)
|
private void buildOtherRequirementsPanel(PanelBuilder panelBuilder)
|
||||||
{
|
{
|
||||||
panelBuilder.item(10, this.createButton(Button.REQUIRED_EXPERIENCE));
|
panelBuilder.item(10, this.createButton(Button.REQUIRED_EXPERIENCE));
|
||||||
panelBuilder.item(11, this.createButton(Button.REMOVE_EXPERIENCE));
|
panelBuilder.item(19, this.createButton(Button.REMOVE_EXPERIENCE));
|
||||||
|
|
||||||
panelBuilder.item(13, this.createButton(Button.REQUIRED_LEVEL));
|
panelBuilder.item(12, this.createButton(Button.REQUIRED_MONEY));
|
||||||
|
panelBuilder.item(21, this.createButton(Button.REMOVE_MONEY));
|
||||||
|
|
||||||
panelBuilder.item(15, this.createButton(Button.REQUIRED_MONEY));
|
panelBuilder.item(23, this.createButton(Button.REQUIRED_LEVEL));
|
||||||
panelBuilder.item(16, this.createButton(Button.REMOVE_MONEY));
|
|
||||||
|
|
||||||
panelBuilder.item(28, this.createButton(Button.REQUIRED_PERMISSIONS));
|
panelBuilder.item(25, this.createButton(Button.REQUIRED_PERMISSIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -188,12 +191,12 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
*/
|
*/
|
||||||
private void buildRewardsPanel(PanelBuilder panelBuilder)
|
private void buildRewardsPanel(PanelBuilder panelBuilder)
|
||||||
{
|
{
|
||||||
panelBuilder.item(11, this.createButton(Button.REWARD_TEXT));
|
panelBuilder.item(10, this.createButton(Button.REWARD_TEXT));
|
||||||
panelBuilder.item(20, this.createButton(Button.REWARD_ITEM));
|
panelBuilder.item(19, this.createButton(Button.REWARD_COMMANDS));
|
||||||
panelBuilder.item(29, this.createButton(Button.REWARD_EXPERIENCE));
|
|
||||||
panelBuilder.item(38, this.createButton(Button.REWARD_MONEY));
|
|
||||||
panelBuilder.item(47, this.createButton(Button.REWARD_COMMANDS));
|
|
||||||
|
|
||||||
|
panelBuilder.item(11, this.createButton(Button.REWARD_ITEM));
|
||||||
|
panelBuilder.item(20, this.createButton(Button.REWARD_EXPERIENCE));
|
||||||
|
panelBuilder.item(29, this.createButton(Button.REWARD_MONEY));
|
||||||
|
|
||||||
panelBuilder.item(22, this.createButton(Button.REPEATABLE));
|
panelBuilder.item(22, this.createButton(Button.REPEATABLE));
|
||||||
|
|
||||||
@ -202,10 +205,11 @@ public class EditChallengeGUI extends CommonGUI
|
|||||||
panelBuilder.item(31, this.createButton(Button.REPEAT_COUNT));
|
panelBuilder.item(31, this.createButton(Button.REPEAT_COUNT));
|
||||||
|
|
||||||
panelBuilder.item(15, this.createButton(Button.REPEAT_REWARD_TEXT));
|
panelBuilder.item(15, this.createButton(Button.REPEAT_REWARD_TEXT));
|
||||||
panelBuilder.item(24, this.createButton(Button.REPEAT_REWARD_ITEM));
|
panelBuilder.item(24, this.createButton(Button.REPEAT_REWARD_COMMANDS));
|
||||||
panelBuilder.item(33, this.createButton(Button.REPEAT_REWARD_EXPERIENCE));
|
|
||||||
panelBuilder.item(42, this.createButton(Button.REPEAT_REWARD_MONEY));
|
panelBuilder.item(16, this.createButton(Button.REPEAT_REWARD_ITEM));
|
||||||
panelBuilder.item(51, this.createButton(Button.REPEAT_REWARD_COMMANDS));
|
panelBuilder.item(25, this.createButton(Button.REPEAT_REWARD_EXPERIENCE));
|
||||||
|
panelBuilder.item(34, this.createButton(Button.REPEAT_REWARD_MONEY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import world.bentobox.challenges.panel.util.ItemSwitchGUI;
|
|||||||
import world.bentobox.challenges.panel.util.NumberGUI;
|
import world.bentobox.challenges.panel.util.NumberGUI;
|
||||||
import world.bentobox.challenges.panel.util.SelectChallengeGUI;
|
import world.bentobox.challenges.panel.util.SelectChallengeGUI;
|
||||||
import world.bentobox.challenges.panel.util.StringListGUI;
|
import world.bentobox.challenges.panel.util.StringListGUI;
|
||||||
|
import world.bentobox.challenges.utils.GuiUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,6 +83,8 @@ public class EditLevelGUI extends CommonGUI
|
|||||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
||||||
this.user.getTranslation("challenges.gui.admin.edit-level-title"));
|
this.user.getTranslation("challenges.gui.admin.edit-level-title"));
|
||||||
|
|
||||||
|
GuiUtils.fillBorder(panelBuilder);
|
||||||
|
|
||||||
panelBuilder.item(2, this.createMenuButton(MenuType.PROPERTIES));
|
panelBuilder.item(2, this.createMenuButton(MenuType.PROPERTIES));
|
||||||
panelBuilder.item(4, this.createMenuButton(MenuType.REWARDS));
|
panelBuilder.item(4, this.createMenuButton(MenuType.REWARDS));
|
||||||
panelBuilder.item(6, this.createMenuButton(MenuType.CHALLENGES));
|
panelBuilder.item(6, this.createMenuButton(MenuType.CHALLENGES));
|
||||||
@ -99,7 +102,7 @@ public class EditLevelGUI extends CommonGUI
|
|||||||
this.buildRewardsPanel(panelBuilder);
|
this.buildRewardsPanel(panelBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
panelBuilder.item(53, this.returnButton);
|
panelBuilder.item(44, this.returnButton);
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
@ -127,11 +130,12 @@ public class EditLevelGUI extends CommonGUI
|
|||||||
*/
|
*/
|
||||||
private void buildRewardsPanel(PanelBuilder panelBuilder)
|
private void buildRewardsPanel(PanelBuilder panelBuilder)
|
||||||
{
|
{
|
||||||
panelBuilder.item(11, this.createButton(Button.REWARD_DESCRIPTION));
|
panelBuilder.item(12, this.createButton(Button.REWARD_DESCRIPTION));
|
||||||
panelBuilder.item(20, this.createButton(Button.REWARD_ITEM));
|
panelBuilder.item(21, this.createButton(Button.REWARD_COMMANDS));
|
||||||
panelBuilder.item(29, this.createButton(Button.REWARD_EXPERIENCE));
|
|
||||||
panelBuilder.item(38, this.createButton(Button.REWARD_MONEY));
|
panelBuilder.item(13, this.createButton(Button.REWARD_ITEM));
|
||||||
panelBuilder.item(47, this.createButton(Button.REWARD_COMMANDS));
|
panelBuilder.item(22, this.createButton(Button.REWARD_EXPERIENCE));
|
||||||
|
panelBuilder.item(31, this.createButton(Button.REWARD_MONEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,39 +145,45 @@ public class EditLevelGUI extends CommonGUI
|
|||||||
*/
|
*/
|
||||||
private void buildChallengesPanel(PanelBuilder panelBuilder)
|
private void buildChallengesPanel(PanelBuilder panelBuilder)
|
||||||
{
|
{
|
||||||
List<Challenges> challenges = this.addon.getChallengesManager().getChallenges(this.challengeLevel);
|
List<Challenges> challengeList = this.addon.getChallengesManager().getChallenges(this.challengeLevel);
|
||||||
|
|
||||||
|
final int MAX_ELEMENTS = 21;
|
||||||
|
|
||||||
if (this.pageIndex < 0)
|
if (this.pageIndex < 0)
|
||||||
|
{
|
||||||
|
this.pageIndex = challengeList.size() / MAX_ELEMENTS;
|
||||||
|
}
|
||||||
|
else if (this.pageIndex > (challengeList.size() / MAX_ELEMENTS))
|
||||||
{
|
{
|
||||||
this.pageIndex = 0;
|
this.pageIndex = 0;
|
||||||
}
|
}
|
||||||
else if (this.pageIndex > (challenges.size() / 18))
|
|
||||||
|
int challengeIndex = MAX_ELEMENTS * this.pageIndex;
|
||||||
|
|
||||||
|
// I want first row to be only for navigation and return button.
|
||||||
|
int index = 10;
|
||||||
|
|
||||||
|
while (challengeIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
||||||
|
challengeIndex < challengeList.size() &&
|
||||||
|
index < 36)
|
||||||
{
|
{
|
||||||
this.pageIndex = challenges.size() / 18;
|
if (!panelBuilder.slotOccupied(index))
|
||||||
|
{
|
||||||
|
panelBuilder.item(index, this.createChallengeIcon(challengeList.get(challengeIndex++)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int challengeIndex = 18 * this.pageIndex;
|
index++;
|
||||||
int elementIndex = 9;
|
|
||||||
|
|
||||||
while (challengeIndex < ((this.pageIndex + 1) * 18) &&
|
|
||||||
challengeIndex < challenges.size())
|
|
||||||
{
|
|
||||||
panelBuilder.item(elementIndex++, this.createChallengeIcon(challenges.get(challengeIndex)));
|
|
||||||
challengeIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pageIndex > 0)
|
// Navigation buttons only if necessary
|
||||||
|
if (challengeList.size() > MAX_ELEMENTS)
|
||||||
{
|
{
|
||||||
panelBuilder.item(29, this.getButton(CommonButtons.PREVIOUS));
|
panelBuilder.item(18, this.getButton(CommonButtons.PREVIOUS));
|
||||||
|
panelBuilder.item(26, this.getButton(CommonButtons.NEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (challengeIndex < challenges.size())
|
panelBuilder.item(39, this.createButton(Button.ADD_CHALLENGE));
|
||||||
{
|
panelBuilder.item(41, this.createButton(Button.REMOVE_CHALLENGE));
|
||||||
panelBuilder.item(33, this.getButton(CommonButtons.NEXT));
|
|
||||||
}
|
|
||||||
|
|
||||||
panelBuilder.item(30, this.createButton(Button.ADD_CHALLENGE));
|
|
||||||
panelBuilder.item(32, this.createButton(Button.REMOVE_CHALLENGE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
import world.bentobox.challenges.panel.CommonGUI;
|
import world.bentobox.challenges.panel.CommonGUI;
|
||||||
|
import world.bentobox.challenges.utils.GuiUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,8 +61,10 @@ public class EditSettingsGUI extends CommonGUI
|
|||||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
||||||
this.user.getTranslation("challenges.gui.admin.settings-title"));
|
this.user.getTranslation("challenges.gui.admin.settings-title"));
|
||||||
|
|
||||||
|
GuiUtils.fillBorder(panelBuilder);
|
||||||
|
|
||||||
// resetChallenges
|
// resetChallenges
|
||||||
panelBuilder.item(0, new PanelItemBuilder().
|
panelBuilder.item(19, new PanelItemBuilder().
|
||||||
name(this.user.getTranslation("challenges.gui.admin.buttons.reset")).
|
name(this.user.getTranslation("challenges.gui.admin.buttons.reset")).
|
||||||
description(this.user.getTranslation("challenges.gui.admin.descriptions.reset")).
|
description(this.user.getTranslation("challenges.gui.admin.descriptions.reset")).
|
||||||
icon(Material.LAVA_BUCKET).
|
icon(Material.LAVA_BUCKET).
|
||||||
@ -74,7 +77,7 @@ public class EditSettingsGUI extends CommonGUI
|
|||||||
build());
|
build());
|
||||||
|
|
||||||
// broadcastMessages
|
// broadcastMessages
|
||||||
panelBuilder.item(1, new PanelItemBuilder().
|
panelBuilder.item(20, new PanelItemBuilder().
|
||||||
name(this.user.getTranslation("challenges.gui.admin.buttons.broadcast")).
|
name(this.user.getTranslation("challenges.gui.admin.buttons.broadcast")).
|
||||||
description(this.user.getTranslation("challenges.gui.admin.descriptions.broadcast")).
|
description(this.user.getTranslation("challenges.gui.admin.descriptions.broadcast")).
|
||||||
icon(Material.JUKEBOX).
|
icon(Material.JUKEBOX).
|
||||||
@ -87,7 +90,7 @@ public class EditSettingsGUI extends CommonGUI
|
|||||||
build());
|
build());
|
||||||
|
|
||||||
// removeCompleteOneTimeChallenges
|
// removeCompleteOneTimeChallenges
|
||||||
panelBuilder.item(2, new PanelItemBuilder().
|
panelBuilder.item(21, new PanelItemBuilder().
|
||||||
name(this.user.getTranslation("challenges.gui.admin.buttons.remove-on-complete")).
|
name(this.user.getTranslation("challenges.gui.admin.buttons.remove-on-complete")).
|
||||||
description(this.user.getTranslation("challenges.gui.admin.descriptions.remove-on-complete")).
|
description(this.user.getTranslation("challenges.gui.admin.descriptions.remove-on-complete")).
|
||||||
icon(Material.MAGMA_BLOCK).
|
icon(Material.MAGMA_BLOCK).
|
||||||
@ -100,7 +103,7 @@ public class EditSettingsGUI extends CommonGUI
|
|||||||
build());
|
build());
|
||||||
|
|
||||||
// addCompletedGlow
|
// addCompletedGlow
|
||||||
panelBuilder.item(3, new PanelItemBuilder().
|
panelBuilder.item(22, new PanelItemBuilder().
|
||||||
name(this.user.getTranslation("challenges.gui.admin.buttons.glow")).
|
name(this.user.getTranslation("challenges.gui.admin.buttons.glow")).
|
||||||
description(this.user.getTranslation("challenges.gui.admin.descriptions.glow")).
|
description(this.user.getTranslation("challenges.gui.admin.descriptions.glow")).
|
||||||
icon(Material.GLOWSTONE).
|
icon(Material.GLOWSTONE).
|
||||||
@ -112,8 +115,21 @@ public class EditSettingsGUI extends CommonGUI
|
|||||||
glow(this.addon.getChallengesSettings().isAddCompletedGlow()).
|
glow(this.addon.getChallengesSettings().isAddCompletedGlow()).
|
||||||
build());
|
build());
|
||||||
|
|
||||||
|
// freeChallengesAtTheTop
|
||||||
|
panelBuilder.item(23, new PanelItemBuilder().
|
||||||
|
name(this.user.getTranslation("challenges.gui.admin.buttons.free-challenges")).
|
||||||
|
description(this.user.getTranslation("challenges.gui.admin.descriptions.free-challenges")).
|
||||||
|
icon(Material.FILLED_MAP).
|
||||||
|
clickHandler((panel, user1, clickType, i) -> {
|
||||||
|
this.addon.getChallengesSettings().setFreeChallengesFirst(
|
||||||
|
!this.addon.getChallengesSettings().isFreeChallengesFirst());
|
||||||
|
return true;
|
||||||
|
}).
|
||||||
|
glow(this.addon.getChallengesSettings().isFreeChallengesFirst()).
|
||||||
|
build());
|
||||||
|
|
||||||
// Return Button
|
// Return Button
|
||||||
panelBuilder.item(8, this.returnButton);
|
panelBuilder.item(44, this.returnButton);
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package world.bentobox.challenges.panel.admin;
|
package world.bentobox.challenges.panel.admin;
|
||||||
|
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ import world.bentobox.challenges.ChallengesAddon;
|
|||||||
import world.bentobox.challenges.database.object.Challenges;
|
import world.bentobox.challenges.database.object.Challenges;
|
||||||
import world.bentobox.challenges.panel.CommonGUI;
|
import world.bentobox.challenges.panel.CommonGUI;
|
||||||
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
||||||
|
import world.bentobox.challenges.utils.GuiUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,42 +73,53 @@ public class ListChallengesGUI extends CommonGUI
|
|||||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
||||||
this.user.getTranslation("challenges.gui.admin.choose-challenge-title"));
|
this.user.getTranslation("challenges.gui.admin.choose-challenge-title"));
|
||||||
|
|
||||||
|
if (this.currentMode.equals(Mode.DELETE))
|
||||||
|
{
|
||||||
|
GuiUtils.fillBorder(panelBuilder, Material.RED_STAINED_GLASS_PANE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GuiUtils.fillBorder(panelBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
List<Challenges> challengeList = this.addon.getChallengesManager().getChallengesList();
|
List<Challenges> challengeList = this.addon.getChallengesManager().getChallengesList();
|
||||||
|
|
||||||
int MAX_ELEMENTS = 45;
|
final int MAX_ELEMENTS = 21;
|
||||||
|
|
||||||
if (this.pageIndex < 0)
|
if (this.pageIndex < 0)
|
||||||
{
|
{
|
||||||
this.pageIndex = 0;
|
this.pageIndex = challengeList.size() / MAX_ELEMENTS;
|
||||||
}
|
}
|
||||||
else if (this.pageIndex > (challengeList.size() / MAX_ELEMENTS))
|
else if (this.pageIndex > (challengeList.size() / MAX_ELEMENTS))
|
||||||
{
|
{
|
||||||
this.pageIndex = challengeList.size() / MAX_ELEMENTS;
|
this.pageIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int challengeIndex = MAX_ELEMENTS * this.pageIndex;
|
int challengeIndex = MAX_ELEMENTS * this.pageIndex;
|
||||||
|
|
||||||
|
// I want first row to be only for navigation and return button.
|
||||||
|
int index = 10;
|
||||||
|
|
||||||
while (challengeIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
while (challengeIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
||||||
challengeIndex < challengeList.size())
|
challengeIndex < challengeList.size() &&
|
||||||
|
index < 36)
|
||||||
{
|
{
|
||||||
panelBuilder.item(this.createChallengeIcon(challengeList.get(challengeIndex)));
|
if (!panelBuilder.slotOccupied(index))
|
||||||
challengeIndex++;
|
{
|
||||||
|
panelBuilder.item(index, this.createChallengeIcon(challengeList.get(challengeIndex++)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextIndex = challengeIndex % MAX_ELEMENTS == 0 ?
|
index++;
|
||||||
MAX_ELEMENTS :
|
|
||||||
(((challengeIndex % MAX_ELEMENTS) - 1) / 9 + 1) * 9;
|
|
||||||
|
|
||||||
if (challengeIndex > MAX_ELEMENTS)
|
|
||||||
{
|
|
||||||
panelBuilder.item(nextIndex + 2, this.getButton(CommonButtons.PREVIOUS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (challengeIndex < challengeList.size())
|
// Navigation buttons only if necessary
|
||||||
|
if (challengeList.size() > MAX_ELEMENTS)
|
||||||
{
|
{
|
||||||
panelBuilder.item(nextIndex + 6, this.getButton(CommonButtons.NEXT));
|
panelBuilder.item(18, this.getButton(CommonButtons.PREVIOUS));
|
||||||
|
panelBuilder.item(26, this.getButton(CommonButtons.NEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
panelBuilder.item(nextIndex + 8, this.returnButton);
|
panelBuilder.item(44, this.returnButton);
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package world.bentobox.challenges.panel.admin;
|
package world.bentobox.challenges.panel.admin;
|
||||||
|
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ import world.bentobox.challenges.ChallengesAddon;
|
|||||||
import world.bentobox.challenges.database.object.ChallengeLevels;
|
import world.bentobox.challenges.database.object.ChallengeLevels;
|
||||||
import world.bentobox.challenges.panel.CommonGUI;
|
import world.bentobox.challenges.panel.CommonGUI;
|
||||||
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
||||||
|
import world.bentobox.challenges.utils.GuiUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,42 +73,53 @@ public class ListLevelsGUI extends CommonGUI
|
|||||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
||||||
this.user.getTranslation("challenges.gui.admin.choose-level-title"));
|
this.user.getTranslation("challenges.gui.admin.choose-level-title"));
|
||||||
|
|
||||||
|
if (this.currentMode.equals(Mode.DELETE))
|
||||||
|
{
|
||||||
|
GuiUtils.fillBorder(panelBuilder, Material.RED_STAINED_GLASS_PANE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GuiUtils.fillBorder(panelBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
List<ChallengeLevels> levelList = this.addon.getChallengesManager().getChallengeLevelList();
|
List<ChallengeLevels> levelList = this.addon.getChallengesManager().getChallengeLevelList();
|
||||||
|
|
||||||
int MAX_ELEMENTS = 45;
|
final int MAX_ELEMENTS = 21;
|
||||||
|
|
||||||
if (this.pageIndex < 0)
|
if (this.pageIndex < 0)
|
||||||
{
|
{
|
||||||
this.pageIndex = 0;
|
this.pageIndex = levelList.size() / MAX_ELEMENTS;
|
||||||
}
|
}
|
||||||
else if (this.pageIndex > (levelList.size() / MAX_ELEMENTS))
|
else if (this.pageIndex > (levelList.size() / MAX_ELEMENTS))
|
||||||
{
|
{
|
||||||
this.pageIndex = levelList.size() / MAX_ELEMENTS;
|
this.pageIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int levelIndex = MAX_ELEMENTS * this.pageIndex;
|
int levelIndex = MAX_ELEMENTS * this.pageIndex;
|
||||||
|
|
||||||
|
// I want first row to be only for navigation and return button.
|
||||||
|
int index = 10;
|
||||||
|
|
||||||
while (levelIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
while (levelIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
||||||
levelIndex < levelList.size())
|
levelIndex < levelList.size() &&
|
||||||
|
index < 36)
|
||||||
{
|
{
|
||||||
panelBuilder.item(this.createLevelIcon(levelList.get(levelIndex)));
|
if (!panelBuilder.slotOccupied(index))
|
||||||
levelIndex++;
|
{
|
||||||
|
panelBuilder.item(index, this.createLevelIcon(levelList.get(levelIndex++)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextIndex = levelIndex % MAX_ELEMENTS == 0 ?
|
index++;
|
||||||
MAX_ELEMENTS :
|
|
||||||
(((levelIndex % MAX_ELEMENTS) - 1) / 9 + 1) * 9;
|
|
||||||
|
|
||||||
if (levelIndex > MAX_ELEMENTS)
|
|
||||||
{
|
|
||||||
panelBuilder.item(nextIndex + 2, this.getButton(CommonButtons.PREVIOUS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (levelIndex < levelList.size())
|
// Navigation buttons only if necessary
|
||||||
|
if (levelList.size() > MAX_ELEMENTS)
|
||||||
{
|
{
|
||||||
panelBuilder.item(nextIndex + 6, this.getButton(CommonButtons.NEXT));
|
panelBuilder.item(18, this.getButton(CommonButtons.PREVIOUS));
|
||||||
|
panelBuilder.item(26, this.getButton(CommonButtons.NEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
panelBuilder.item(nextIndex + 8, this.returnButton);
|
panelBuilder.item(44, this.returnButton);
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import world.bentobox.challenges.ChallengesManager;
|
|||||||
import world.bentobox.challenges.panel.CommonGUI;
|
import world.bentobox.challenges.panel.CommonGUI;
|
||||||
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
import world.bentobox.challenges.panel.util.ConfirmationGUI;
|
||||||
import world.bentobox.challenges.panel.util.SelectChallengeGUI;
|
import world.bentobox.challenges.panel.util.SelectChallengeGUI;
|
||||||
|
import world.bentobox.challenges.utils.GuiUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +51,7 @@ public class ListUsersGUI extends CommonGUI
|
|||||||
private enum ViewMode
|
private enum ViewMode
|
||||||
{
|
{
|
||||||
ONLINE,
|
ONLINE,
|
||||||
OFFLINE,
|
WITH_ISLAND,
|
||||||
IN_WORLD
|
IN_WORLD
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,45 +115,48 @@ public class ListUsersGUI extends CommonGUI
|
|||||||
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
PanelBuilder panelBuilder = new PanelBuilder().user(this.user).name(
|
||||||
this.user.getTranslation("challenges.gui.admin.choose-user-title"));
|
this.user.getTranslation("challenges.gui.admin.choose-user-title"));
|
||||||
|
|
||||||
int MAX_ELEMENTS = 45;
|
GuiUtils.fillBorder(panelBuilder);
|
||||||
|
|
||||||
|
final int MAX_ELEMENTS = 21;
|
||||||
|
|
||||||
if (this.pageIndex < 0)
|
if (this.pageIndex < 0)
|
||||||
{
|
{
|
||||||
this.pageIndex = 0;
|
this.pageIndex = this.onlineUsers.size() / MAX_ELEMENTS;
|
||||||
}
|
}
|
||||||
else if (this.pageIndex > (this.onlineUsers.size() / MAX_ELEMENTS))
|
else if (this.pageIndex > (this.onlineUsers.size() / MAX_ELEMENTS))
|
||||||
{
|
{
|
||||||
this.pageIndex = this.onlineUsers.size() / MAX_ELEMENTS;
|
this.pageIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerIndex = MAX_ELEMENTS * this.pageIndex;
|
int playerIndex = MAX_ELEMENTS * this.pageIndex;
|
||||||
|
|
||||||
|
// I want first row to be only for navigation and return button.
|
||||||
|
int index = 10;
|
||||||
|
|
||||||
while (playerIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
while (playerIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
||||||
playerIndex < this.onlineUsers.size())
|
playerIndex < this.onlineUsers.size() &&
|
||||||
|
index < 36)
|
||||||
{
|
{
|
||||||
panelBuilder.item(this.createPlayerIcon(this.onlineUsers.get(playerIndex)));
|
if (!panelBuilder.slotOccupied(index))
|
||||||
playerIndex++;
|
{
|
||||||
|
panelBuilder.item(index, this.createPlayerIcon(this.onlineUsers.get(playerIndex++)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int nextIndex = playerIndex % MAX_ELEMENTS == 0 ?
|
index++;
|
||||||
MAX_ELEMENTS :
|
|
||||||
(((playerIndex % MAX_ELEMENTS) - 1) / 9 + 1) * 9;
|
|
||||||
|
|
||||||
if (playerIndex > MAX_ELEMENTS)
|
|
||||||
{
|
|
||||||
panelBuilder.item(nextIndex, this.getButton(CommonButtons.PREVIOUS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerIndex < this.onlineUsers.size())
|
// Add button that allows to toogle different player lists.
|
||||||
|
panelBuilder.item( 4, this.createToggleButton());
|
||||||
|
|
||||||
|
// Navigation buttons only if necessary
|
||||||
|
if (this.onlineUsers.size() > MAX_ELEMENTS)
|
||||||
{
|
{
|
||||||
panelBuilder.item(nextIndex + 8, this.getButton(CommonButtons.NEXT));
|
panelBuilder.item(18, this.getButton(CommonButtons.PREVIOUS));
|
||||||
|
panelBuilder.item(26, this.getButton(CommonButtons.NEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.returnButton != null)
|
panelBuilder.item(44, this.returnButton);
|
||||||
{
|
|
||||||
panelBuilder.item(nextIndex + 6, this.returnButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
panelBuilder.item(nextIndex + 3, this.createToggleButton());
|
|
||||||
|
|
||||||
panelBuilder.build();
|
panelBuilder.build();
|
||||||
}
|
}
|
||||||
@ -229,17 +233,9 @@ public class ListUsersGUI extends CommonGUI
|
|||||||
{
|
{
|
||||||
return new ArrayList<>(Bukkit.getOnlinePlayers());
|
return new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||||
}
|
}
|
||||||
else if (mode.equals(ViewMode.OFFLINE))
|
else if (mode.equals(ViewMode.WITH_ISLAND))
|
||||||
{
|
{
|
||||||
List<Player> offlinePlayer = new ArrayList<>(Bukkit.getOfflinePlayers().length);
|
return this.addon.getChallengesManager().getPlayers(this.world);
|
||||||
|
|
||||||
for (int index = 0; index < Bukkit.getOfflinePlayers().length; index++)
|
|
||||||
{
|
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayers()[index];
|
|
||||||
offlinePlayer.add(player.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
return offlinePlayer;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,8 @@ public class ManageBlocksGUI extends CommonGUI
|
|||||||
int index = 10;
|
int index = 10;
|
||||||
|
|
||||||
while (entitiesIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
while (entitiesIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
||||||
entitiesIndex < this.materialList.size())
|
entitiesIndex < this.materialList.size() &&
|
||||||
|
index < 36)
|
||||||
{
|
{
|
||||||
if (!panelBuilder.slotOccupied(index))
|
if (!panelBuilder.slotOccupied(index))
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,8 @@ public class ManageEntitiesGUI extends CommonGUI
|
|||||||
int index = 10;
|
int index = 10;
|
||||||
|
|
||||||
while (entitiesIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
while (entitiesIndex < ((this.pageIndex + 1) * MAX_ELEMENTS) &&
|
||||||
entitiesIndex < this.entityList.size())
|
entitiesIndex < this.entityList.size() &&
|
||||||
|
index < 26)
|
||||||
{
|
{
|
||||||
if (!panelBuilder.slotOccupied(index))
|
if (!panelBuilder.slotOccupied(index))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user