aboutsummaryrefslogtreecommitdiffstats
path: root/bukkit/src/main/java
diff options
context:
space:
mode:
authorKrakenied <krakenied1@gmail.com>2025-07-22 11:02:27 +0200
committerKrakenied <46192742+Krakenied@users.noreply.github.com>2025-07-29 00:06:46 +0200
commit76f2b7436c13d50d83cb30591e4667608e875da4 (patch)
tree8f02a737f4835297e226058eb13bce1c254b084b /bukkit/src/main/java
parent95e64a7caf923b533b924d17e8f3c50488620f57 (diff)
Refactor paginated quest menu code a bit
Diffstat (limited to 'bukkit/src/main/java')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/menu/PaginatedQMenu.java50
1 files changed, 27 insertions, 23 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/menu/PaginatedQMenu.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/menu/PaginatedQMenu.java
index 39adf59a..f886c9ae 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/menu/PaginatedQMenu.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/menu/PaginatedQMenu.java
@@ -85,30 +85,34 @@ public abstract class PaginatedQMenu extends QMenu {
SpacerMenuElement spacer = new SpacerMenuElement();
// populate custom elements first
- if (customElementsPath != null) {
- if (plugin.getConfig().isConfigurationSection(customElementsPath)) {
- for (String s : plugin.getConfig().getConfigurationSection(customElementsPath).getKeys(false)) {
- if (!StringUtils.isNumeric(s)) continue;
- int slot = Integer.parseInt(s);
- int repeat = plugin.getConfig().getInt(customElementsPath + "." + s + ".repeat");
- boolean staticElement = plugin.getConfig().getBoolean(customElementsPath + "." + s + ".static", false);
- MenuElement menuElement;
- if (plugin.getConfig().contains(customElementsPath + "." + s + ".display")) {
- ItemStack is = plugin.getConfiguredItemStack(customElementsPath + "." + s + ".display", plugin.getConfig());
- List<String> commands = plugin.getQuestsConfig().getStringList(customElementsPath + "." + s + ".commands");
- menuElement = new CustomMenuElement(plugin, owner.getPlayerUUID(), player.getName(), is, commands);
- } else if (plugin.getConfig().getBoolean(customElementsPath + "." + s + ".spacer", false)) {
- menuElement = spacer;
- } else continue; // user = idiot
+ if (customElementsPath != null && plugin.getConfig().isConfigurationSection(customElementsPath)) {
+ for (String s : plugin.getConfig().getConfigurationSection(customElementsPath).getKeys(false)) {
+ if (!StringUtils.isNumeric(s)) {
+ continue;
+ }
+
+ int slot = Integer.parseInt(s);
+ int repeat = plugin.getConfig().getInt(customElementsPath + "." + s + ".repeat");
+ boolean staticElement = plugin.getConfig().getBoolean(customElementsPath + "." + s + ".static", false);
+
+ MenuElement menuElement;
+ if (plugin.getConfig().contains(customElementsPath + "." + s + ".display")) {
+ ItemStack is = plugin.getConfiguredItemStack(customElementsPath + "." + s + ".display", plugin.getConfig());
+ List<String> commands = plugin.getQuestsConfig().getStringList(customElementsPath + "." + s + ".commands");
+ menuElement = new CustomMenuElement(plugin, owner.getPlayerUUID(), player.getName(), is, commands);
+ } else if (plugin.getConfig().getBoolean(customElementsPath + "." + s + ".spacer", false)) {
+ menuElement = spacer;
+ } else {
+ continue; // user = idiot
+ }
- for (int i = 0; i <= repeat; i++) {
- if (staticElement) {
- int boundedSlot = slot + i % pageSize;
- staticMenuElements[boundedSlot] = menuElement;
- customStaticElements++;
- } else {
- menuElements.put(slot + i, menuElement);
- }
+ for (int i = 0; i <= repeat; i++) {
+ if (staticElement) {
+ int boundedSlot = slot + i % pageSize;
+ staticMenuElements[boundedSlot] = menuElement;
+ customStaticElements++;
+ } else {
+ menuElements.put(slot + i, menuElement);
}
}
}