diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/CommandSkillEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/CommandSkillEditorPanel.java index 9f200ca..af7a146 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/CommandSkillEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/CommandSkillEditorPanel.java @@ -40,6 +40,8 @@ public class CommandSkillEditorPanel extends VariablePanelHandler { @Override public void fillPanel(Panel panel, Skill skill) { CommandSkillElement commandSkillElement = this.plugin.getBossSkillManager().getCommandSkillElement(skill); + if (commandSkillElement == null) + commandSkillElement = new CommandSkillElement(new ArrayList<>()); List subCommandSkillElements = commandSkillElement.getCommands(); int maxPage = panel.getMaxPage(subCommandSkillElements); @@ -55,24 +57,22 @@ public class CommandSkillEditorPanel extends VariablePanelHandler { @Override public void openFor(Player player, Skill skill) { + Map replaceMap = new HashMap<>(); + PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); + + replaceMap.put("{name}", BossAPI.getSkillName(skill)); + panelBuilder.addReplaceData(replaceMap); + + PanelBuilderCounter counter = panelBuilder.getPanelBuilderCounter(); + Panel panel = panelBuilder.getPanel() + .setParentPanelHandler(this.bossPanelManager.getMainSkillEditMenu(), skill); + ServerUtils.get().runTaskAsync(() -> { - Map replaceMap = new HashMap<>(); - PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); - - replaceMap.put("{name}", BossAPI.getSkillName(skill)); - panelBuilder.addReplaceData(replaceMap); - - PanelBuilderCounter counter = panelBuilder.getPanelBuilderCounter(); - Panel panel = panelBuilder.getPanel() - .setParentPanelHandler(this.bossPanelManager.getMainSkillEditMenu(), skill); - - ServerUtils.get().runTaskAsync(() -> { - counter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, getAddNewAction(skill))); - fillPanel(panel, skill); - }); - - panel.openFor(player); + counter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, getAddNewAction(skill))); + fillPanel(panel, skill); }); + + panel.openFor(player); } @Override @@ -84,7 +84,9 @@ public class CommandSkillEditorPanel extends VariablePanelHandler { return event -> { SubCommandSkillElement subCommandSkillElement = new SubCommandSkillElement(UUID.randomUUID().toString(), 100.0, new ArrayList<>()); CommandSkillElement commandSkillElement = this.plugin.getBossSkillManager().getCommandSkillElement(skill); - + if (commandSkillElement == null) + commandSkillElement = new CommandSkillElement(new ArrayList<>()); + List subElements = commandSkillElement.getCommands(); subElements.add(subCommandSkillElement); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/GroupSkillEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/GroupSkillEditorPanel.java index d237077..217e399 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/GroupSkillEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/GroupSkillEditorPanel.java @@ -45,14 +45,17 @@ public class GroupSkillEditorPanel extends VariablePanelHandler { @Override public void fillPanel(Panel panel, Skill skill) { GroupSkillElement groupSkillElement = this.plugin.getBossSkillManager().getGroupSkillElement(skill); + if (groupSkillElement == null) + groupSkillElement = new GroupSkillElement(new ArrayList<>()); Map skillMap = this.plugin.getSkillsFileManager().getSkillMap(); List entryList = new ArrayList<>(skillMap.keySet()); int maxPage = panel.getMaxPage(entryList); + GroupSkillElement finalGroupSkillElement = groupSkillElement; panel.setOnPageChange(((player, currentPage, requestedPage) -> { if (requestedPage < 0 || requestedPage > maxPage) return false; - loadPage(panel, requestedPage, skill, groupSkillElement, skillMap, entryList); + loadPage(panel, requestedPage, skill, finalGroupSkillElement, skillMap, entryList); return true; })); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/PotionSkillEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/PotionSkillEditorPanel.java index fef437f..a554a5f 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/PotionSkillEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/PotionSkillEditorPanel.java @@ -19,6 +19,7 @@ import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter; import com.songoda.epicbosses.utils.potion.PotionEffectConverter; import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder; +import java.util.ArrayList; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -56,13 +57,16 @@ public class PotionSkillEditorPanel extends VariablePanelHandler { @Override public void fillPanel(Panel panel, Skill skill) { PotionSkillElement potionSkillElement = this.bossSkillManager.getPotionSkillElement(skill); + if (potionSkillElement == null) + potionSkillElement = new PotionSkillElement(new ArrayList<>()); List potionEffectHolders = potionSkillElement.getPotions(); int maxPage = panel.getMaxPage(potionEffectHolders); + PotionSkillElement finalPotionSkillElement = potionSkillElement; panel.setOnPageChange(((player, currentPage, requestedPage) -> { if (requestedPage < 0 || requestedPage > maxPage) return false; - loadPage(panel, requestedPage, potionEffectHolders, potionSkillElement, skill); + loadPage(panel, requestedPage, potionEffectHolders, finalPotionSkillElement, skill); return true; })); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/CreatePotionEffectEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/CreatePotionEffectEditorPanel.java index d9afdbb..bdf803a 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/CreatePotionEffectEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/CreatePotionEffectEditorPanel.java @@ -18,6 +18,7 @@ import com.songoda.epicbosses.utils.panel.base.handlers.SubVariablePanelHandler; import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter; import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder; +import java.util.ArrayList; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -146,6 +147,8 @@ public class CreatePotionEffectEditorPanel extends SubVariablePanelHandler()); PotionEffectFinder potionEffectFinder = PotionEffectFinder.getByName(type); if (potionEffectFinder != null) {