fix skills

This commit is contained in:
Aurora 2020-08-07 21:22:43 +02:00
parent 1621536206
commit d8ee559047
4 changed files with 31 additions and 19 deletions

View File

@ -40,6 +40,8 @@ public class CommandSkillEditorPanel extends VariablePanelHandler<Skill> {
@Override
public void fillPanel(Panel panel, Skill skill) {
CommandSkillElement commandSkillElement = this.plugin.getBossSkillManager().getCommandSkillElement(skill);
if (commandSkillElement == null)
commandSkillElement = new CommandSkillElement(new ArrayList<>());
List<SubCommandSkillElement> subCommandSkillElements = commandSkillElement.getCommands();
int maxPage = panel.getMaxPage(subCommandSkillElements);
@ -55,24 +57,22 @@ public class CommandSkillEditorPanel extends VariablePanelHandler<Skill> {
@Override
public void openFor(Player player, Skill skill) {
Map<String, String> 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<String, String> 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<Skill> {
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<SubCommandSkillElement> subElements = commandSkillElement.getCommands();
subElements.add(subCommandSkillElement);

View File

@ -45,14 +45,17 @@ public class GroupSkillEditorPanel extends VariablePanelHandler<Skill> {
@Override
public void fillPanel(Panel panel, Skill skill) {
GroupSkillElement groupSkillElement = this.plugin.getBossSkillManager().getGroupSkillElement(skill);
if (groupSkillElement == null)
groupSkillElement = new GroupSkillElement(new ArrayList<>());
Map<String, Skill> skillMap = this.plugin.getSkillsFileManager().getSkillMap();
List<String> 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;
}));

View File

@ -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<Skill> {
@Override
public void fillPanel(Panel panel, Skill skill) {
PotionSkillElement potionSkillElement = this.bossSkillManager.getPotionSkillElement(skill);
if (potionSkillElement == null)
potionSkillElement = new PotionSkillElement(new ArrayList<>());
List<PotionEffectHolder> 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;
}));

View File

@ -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<Skill
if (duration != null && level != null && type != null && !type.isEmpty()) {
PotionSkillElement potionSkillElement = this.bossSkillManager.getPotionSkillElement(skill);
if (potionSkillElement == null)
potionSkillElement = new PotionSkillElement(new ArrayList<>());
PotionEffectFinder potionEffectFinder = PotionEffectFinder.getByName(type);
if (potionEffectFinder != null) {