diff --git a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/PageConfig.java b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/PageConfig.java index 13967d9..6ae1e79 100644 --- a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/PageConfig.java +++ b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/PageConfig.java @@ -21,7 +21,7 @@ public class PageConfig implements InventoryHolder { @NotNull private final Plugin plugin; @NotNull - private final ConfigurationSection config; + private final ConfigurationSection rawConfig; @NotNull private final String title; @@ -38,12 +38,12 @@ public class PageConfig implements InventoryHolder { @NotNull private final Inventory inventory; - public PageConfig(@NotNull Plugin plugin, @NotNull ConfigurationSection config) { + public PageConfig(@NotNull Plugin plugin, @NotNull ConfigurationSection rawConfig) { this.plugin = plugin; - this.config = config; - title = config.getString("title", "").replace("&", "§"); + this.rawConfig = rawConfig; + title = rawConfig.getString("title", "").replace("&", "§"); - List graphicString = config.getStringList("graphic"); + List graphicString = rawConfig.getStringList("graphic"); if (graphicString.size() > 6) { graphicString = graphicString.subList(0, 6); } @@ -59,7 +59,7 @@ public class PageConfig implements InventoryHolder { inventory = Bukkit.createInventory(this, graphicString.size() * 9, title); buttons = new HashMap<>(); - ConfigurationSection buttonsConfig = config.getConfigurationSection("buttons"); + ConfigurationSection buttonsConfig = rawConfig.getConfigurationSection("buttons"); if (buttonsConfig != null) { for (String key : buttonsConfig.getKeys(false)) { buttons.put(key, buttonsConfig.getItemStack(key)); @@ -67,7 +67,7 @@ public class PageConfig implements InventoryHolder { } buttonGroups = new ArrayList<>(); - ConfigurationSection buttonGroupsConfig = config.getConfigurationSection("groups"); + ConfigurationSection buttonGroupsConfig = rawConfig.getConfigurationSection("groups"); if (buttonGroupsConfig != null) { for (String key : buttonGroupsConfig.getKeys(false)) { //noinspection ConstantConditions @@ -87,7 +87,7 @@ public class PageConfig implements InventoryHolder { } buttonSounds = new HashMap<>(); - ConfigurationSection buttonSoundConfig = config.getConfigurationSection("sounds"); + ConfigurationSection buttonSoundConfig = rawConfig.getConfigurationSection("sounds"); if (buttonSoundConfig != null) { for (String key : buttonSoundConfig.getKeys(false)) { try { @@ -164,8 +164,8 @@ public class PageConfig implements InventoryHolder { } @NotNull - public ConfigurationSection getConfig() { - return config; + public ConfigurationSection getRawConfig() { + return rawConfig; } @NotNull diff --git a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/FixedPageHandler.java b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/FixedPageHandler.java index f5eefd3..c932401 100644 --- a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/FixedPageHandler.java +++ b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/FixedPageHandler.java @@ -24,11 +24,11 @@ public class FixedPageHandler extends PageHandler { @Override public void initPage() { if (inventory == null) { - inventory = Bukkit.createInventory(this, getConfig().getInventory().getSize(), getTitle()); + inventory = Bukkit.createInventory(this, getPageConfig().getInventory().getSize(), getTitle()); } HumanEntity player = getPlayer(); - PageConfig config = getConfig(); + PageConfig config = getPageConfig(); ButtonGroup group = getButtonGroup(); List graphic = config.getGraphic(); diff --git a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageHandler.java b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageHandler.java index d71d27d..c01f56e 100644 --- a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageHandler.java +++ b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageHandler.java @@ -17,17 +17,17 @@ import org.jetbrains.annotations.NotNull; */ @SuppressWarnings("unused") public abstract class PageHandler implements InventoryHolder { - private final PageConfig config; + private final PageConfig pageConfig; private final HumanEntity player; protected Inventory inventory; public PageHandler(@NotNull HumanEntity player) { - config = PageManager.getPageConfig(getClass()); + pageConfig = PageManager.getPageConfig(getClass()); this.player = player; } - public PageHandler(@NotNull PageConfig config, @NotNull HumanEntity player) { - this.config = config; + public PageHandler(@NotNull PageConfig pageConfig, @NotNull HumanEntity player) { + this.pageConfig = pageConfig; this.player = player; } @@ -51,7 +51,7 @@ public abstract class PageHandler implements InventoryHolder { } public void onPlayButtonSound(@NotNull ClickType clickType, @NotNull InventoryAction action, int index) { - PageConfig config = getConfig(); + PageConfig config = getPageConfig(); Sound sound = config.getButtonSound(getButtonGroup().getButtonName(index)); sound = sound == null ? config.getButtonSound("default") : sound; if (sound == null) { @@ -81,16 +81,16 @@ public abstract class PageHandler implements InventoryHolder { if (init) { initPage(); } - Bukkit.getScheduler().runTask(config.getPlugin(), () -> player.openInventory(getInventory())); + Bukkit.getScheduler().runTask(pageConfig.getPlugin(), () -> player.openInventory(getInventory())); } public void close() { - Bukkit.getScheduler().runTask(config.getPlugin(), player::closeInventory); + Bukkit.getScheduler().runTask(pageConfig.getPlugin(), player::closeInventory); } @NotNull - public PageConfig getConfig() { - return config; + public PageConfig getPageConfig() { + return pageConfig; } @NotNull @@ -100,12 +100,12 @@ public abstract class PageHandler implements InventoryHolder { @NotNull public ButtonGroup getButtonGroup() { - return getConfig().getButtonGroup("default"); + return getPageConfig().getButtonGroup("default"); } @NotNull public String getTitle() { - return config.getTitle(); + return pageConfig.getTitle(); } @NotNull diff --git a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java index dba0249..c127edb 100644 --- a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java +++ b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java @@ -68,7 +68,7 @@ public abstract class PageableHandler extends FixedPageHandler { onClickElement(event.getClick(), event.getAction(), e); return; } - String name = getConfig().getButtonName(event.getCurrentItem()); + String name = getPageConfig().getButtonName(event.getCurrentItem()); if (name.equalsIgnoreCase(nextButtonName)) { showNextPage(); return;