mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-05 06:47:48 +01:00
1.0.0-SNAPSHOT-U103
+ Started implementing CustomData menus + Added PotionSkillEditorPanel to editor.yml
This commit is contained in:
parent
737ac84c49
commit
5bb87ab6b9
@ -1429,3 +1429,60 @@ SkillTypeEditorPanel:
|
||||
- '&7This will remove any previous'
|
||||
- '&7custom skill data.'
|
||||
Button: Group
|
||||
PotionSkillEditorPanel:
|
||||
name: '&b&l{name} Skill Editor'
|
||||
slots: 54
|
||||
Settings:
|
||||
backButton: true
|
||||
Buttons:
|
||||
backButton: 54
|
||||
Items:
|
||||
'46':
|
||||
type: BOOK
|
||||
name: '&e&lPotion Guide'
|
||||
lore:
|
||||
- '&7Here you can adjust the potion effects'
|
||||
- '&7that are applied when the skill is'
|
||||
- '&7called. If you want to remove a potion'
|
||||
- '&7effect simply click on the potion and'
|
||||
- '&7it will removed from the skill. If you'
|
||||
- '&7want to add a new potion effect click'
|
||||
- '&7on the green emerald block.'
|
||||
'47':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'48':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'49':
|
||||
type: ARROW
|
||||
name: '&e&l&m<-&e&l Previous Page'
|
||||
lore:
|
||||
- '&7Click here to go to the previous'
|
||||
- '&7page of custom drops.'
|
||||
PreviousPage: true
|
||||
'50':
|
||||
type: EMERALD_BLOCK
|
||||
name: '&e&lCreate a new Potion Effect'
|
||||
lore:
|
||||
- '&7Click here to create a new potion'
|
||||
- '&7effect.'
|
||||
Button: PotionEffect
|
||||
'51':
|
||||
type: ARROW
|
||||
name: '&e&lNext Page &e&l&m->'
|
||||
lore:
|
||||
- '&7Click here to go to the next'
|
||||
- '&7page of custom drops.'
|
||||
NextPage: true
|
||||
'52':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'53':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'54':
|
||||
type: PAPER
|
||||
name: '&e&lGo Back'
|
||||
lore:
|
||||
- '&7Click here to go back.'
|
@ -21,7 +21,9 @@ import com.songoda.epicbosses.panel.bosses.weapons.OffHandEditorPanel;
|
||||
import com.songoda.epicbosses.panel.handlers.*;
|
||||
import com.songoda.epicbosses.panel.skills.MainSkillEditorPanel;
|
||||
import com.songoda.epicbosses.panel.skills.SkillTypeEditorPanel;
|
||||
import com.songoda.epicbosses.panel.skills.custom.PotionSkillEditorPanel;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.PotionSkillElement;
|
||||
import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler;
|
||||
import lombok.Getter;
|
||||
@ -61,7 +63,8 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
onTauntTextEditMenu;
|
||||
@Getter private BossListEditorPanel equipmentListEditMenu, weaponListEditMenu, statisticListEditMenu;
|
||||
|
||||
@Getter private IVariablePanelHandler<Skill> mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu;
|
||||
@Getter private IVariablePanelHandler<Skill> mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu, potionSkillEditorPanel;
|
||||
@Getter private ISubVariablePanelHandler<Skill, PotionSkillElement> createPotionEffectMenu;
|
||||
|
||||
private final CustomBosses customBosses;
|
||||
|
||||
@ -159,6 +162,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
FileConfiguration editor = this.customBosses.getEditor();
|
||||
PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("SkillEditorPanel"));
|
||||
PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("SkillTypeEditorPanel"));
|
||||
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("PotionSkillEditorPanel"));
|
||||
|
||||
this.mainSkillEditMenu = new MainSkillEditorPanel(this, panelBuilder, this.customBosses);
|
||||
this.customMessageEditMenu = new SingleMessageListEditor<Skill>(this, getListMenu("Skills.MainEdit"), this.customBosses) {
|
||||
@ -185,16 +189,19 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
}
|
||||
};
|
||||
this.skillTypeEditMenu = new SkillTypeEditorPanel(this, panelBuilder1, this.customBosses);
|
||||
this.potionSkillEditorPanel = new PotionSkillEditorPanel(this, panelBuilder2, this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadSkillEditMenus() {
|
||||
FileConfiguration editor = this.customBosses.getEditor();
|
||||
PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("SkillEditorPanel"));
|
||||
PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("SkillTypeEditorPanel"));
|
||||
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("PotionSkillEditorPanel"));
|
||||
|
||||
this.mainSkillEditMenu.initializePanel(panelBuilder);
|
||||
this.customMessageEditMenu.initializePanel(getListMenu("Skills.MainEdit"));
|
||||
this.skillTypeEditMenu.initializePanel(panelBuilder1);
|
||||
this.potionSkillEditorPanel.initializePanel(panelBuilder2);
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.songoda.epicbosses.panel.skills.custom;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Dec-18
|
||||
*/
|
||||
public class CreatePotionEffectEditorPanel {
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
package com.songoda.epicbosses.panel.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.SkillsFileManager;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.PotionSkillElement;
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler;
|
||||
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 org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Dec-18
|
||||
*/
|
||||
public class PotionSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
|
||||
private PotionEffectConverter potionEffectConverter;
|
||||
private SkillsFileManager skillsFileManager;
|
||||
private BossSkillManager bossSkillManager;
|
||||
|
||||
public PotionSkillEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.bossSkillManager = plugin.getBossSkillManager();
|
||||
this.skillsFileManager = plugin.getSkillsFileManager();
|
||||
this.potionEffectConverter = new PotionEffectConverter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, Skill skill) {
|
||||
PotionSkillElement potionSkillElement = this.bossSkillManager.getPotionSkillElement(skill);
|
||||
List<PotionEffectHolder> potionEffectHolders = potionSkillElement.getPotions();
|
||||
int maxPage = panel.getMaxPage(potionEffectHolders);
|
||||
|
||||
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
|
||||
if(requestedPage < 0 || requestedPage > maxPage) return false;
|
||||
|
||||
loadPage(panel, requestedPage, potionEffectHolders, potionSkillElement);
|
||||
return true;
|
||||
}));
|
||||
|
||||
loadPage(panel, 0, potionEffectHolders, potionSkillElement);
|
||||
}
|
||||
|
||||
@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();
|
||||
PotionSkillElement potionSkillElement = this.bossSkillManager.getPotionSkillElement(skill);
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setDestroyWhenDone(true)
|
||||
.setCancelClick(true)
|
||||
.setCancelLowerClick(true)
|
||||
.setParentPanelHandler(this.bossPanelManager.getMainSkillEditMenu(), skill);
|
||||
|
||||
fillPanel(panel, skill);
|
||||
counter.getSlotsWith("PotionEffect").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getCreatePotionEffectMenu().openFor((Player) event.getWhoClicked(), skill, potionSkillElement)));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
|
||||
panelBuilderCounter
|
||||
.addSlotCounter("PotionEffect");
|
||||
}
|
||||
|
||||
private void loadPage(Panel panel, int page, List<PotionEffectHolder> potionEffectHolders, PotionSkillElement potionSkillElement) {
|
||||
panel.loadPage(page, (slot, realisticSlot) -> {
|
||||
if(slot >= potionEffectHolders.size()) {
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
|
||||
} else {
|
||||
PotionEffectHolder potionEffectHolder = potionEffectHolders.get(slot);
|
||||
PotionEffect potionEffect = this.potionEffectConverter.from(potionEffectHolder);
|
||||
|
||||
ItemStack itemStack = new ItemStack(Material.POTION);
|
||||
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
|
||||
potionMeta.addCustomEffect(potionEffect, true);
|
||||
itemStack.setItemMeta(potionMeta);
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, e -> {
|
||||
potionEffectHolders.remove(potionEffectHolder);
|
||||
potionSkillElement.setPotions(potionEffectHolders);
|
||||
this.skillsFileManager.save();
|
||||
|
||||
loadPage(panel, page, potionEffectHolders, potionSkillElement);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
2
pom.xml
2
pom.xml
@ -20,7 +20,7 @@
|
||||
|
||||
<properties>
|
||||
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
|
||||
<plugin.version>1.0.0-U102</plugin.version>
|
||||
<plugin.version>1.0.0-U103</plugin.version>
|
||||
<plugin.name>EpicBosses</plugin.name>
|
||||
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
|
||||
<plugin.author>AMinecraftDev</plugin.author>
|
||||
|
Loading…
Reference in New Issue
Block a user