1.0.0-SNAPSHOT-U108

+ Started working on CommandSkillEditor
This commit is contained in:
Charles 2018-12-03 00:15:18 +08:00
parent 949465d528
commit 68b2cf0c78
6 changed files with 225 additions and 19 deletions

View File

@ -136,4 +136,12 @@ Display:
CreatePotion:
menuName: '&b&lSelect Potion Effect Type'
name: '&bEffect: &f{effect}'
selectedName: '&bEffect: &f{effect} &a&l** Selected **'
selectedName: '&bEffect: &f{effect} &a&l** Selected **'
Commands:
name: '&b&lCommand Section'
lore:
- '&3Left Click &8»'
- '&7Modify the assigned commands.'
- '&7'
- '&3Right Click &8»'
- '&7Modify the chance for this section.'

View File

@ -1550,3 +1550,62 @@ CreatePotionEffectEditorPanel:
- '&bEffect: &f{effect}'
- '&bLevel: &f{level}'
Button: Confirm
CommandSkillEditorPanel:
name: '&b&l{name} Skill Editor'
slots: 54
Settings:
backButton: true
fillTo: 45
Buttons:
backButton: 54
Items:
'46':
type: BOOK
name: '&e&lCommand Guide'
lore:
- '&7Here you can adjust the commands that'
- '&7are applied when the skill is called.'
- '&7If you want to remove a command section'
- '&7simply just shift left click the section'
- '&7and it will be deleted.'
- '&7To create a new section click the green'
- '&7emerald block at the bottom middle of the'
- '&7GUI.'
'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&lAdd a new Command Section'
lore:
- '&7Click here to add a new command section'
- '&7to the list.'
Button: AddNew
'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.'

View File

@ -21,6 +21,7 @@ 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.CommandSkillEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.CreatePotionEffectEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.PotionEffectTypeEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.PotionSkillEditorPanel;
@ -64,7 +65,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
onTauntTextEditMenu;
@Getter private BossListEditorPanel equipmentListEditMenu, weaponListEditMenu, statisticListEditMenu;
@Getter private IVariablePanelHandler<Skill> mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu, potionSkillEditorPanel;
@Getter private IVariablePanelHandler<Skill> mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu, potionSkillEditorPanel, commandSkillEditorPanel;
@Getter private ISubVariablePanelHandler<Skill, PotionEffectHolder> createPotionEffectMenu, potionEffectTypeEditMenu;
private final CustomBosses customBosses;
@ -165,6 +166,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("SkillTypeEditorPanel"));
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("PotionSkillEditorPanel"));
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("CreatePotionEffectEditorPanel"));
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("CommandSkillEditorPanel"));
this.mainSkillEditMenu = new MainSkillEditorPanel(this, panelBuilder, this.customBosses);
this.customMessageEditMenu = new SingleMessageListEditor<Skill>(this, getListMenu("Skills.MainEdit"), this.customBosses) {
@ -194,6 +196,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
this.potionSkillEditorPanel = new PotionSkillEditorPanel(this, panelBuilder2, this.customBosses);
this.createPotionEffectMenu = new CreatePotionEffectEditorPanel(this, panelBuilder3, this.customBosses);
this.potionEffectTypeEditMenu = new PotionEffectTypeEditorPanel(this, getListMenu("Skills.CreatePotion"), this.customBosses);
this.commandSkillEditorPanel = new CommandSkillEditorPanel(this, panelBuilder4, this.customBosses);
}
private void reloadSkillEditMenus() {
@ -202,6 +205,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("SkillTypeEditorPanel"));
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("PotionSkillEditorPanel"));
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("CreatePotionEffectEditorPanel"));
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("CommandSkillEditorPanel"));
this.mainSkillEditMenu.initializePanel(panelBuilder);
this.customMessageEditMenu.initializePanel(getListMenu("Skills.MainEdit"));
@ -209,6 +213,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
this.potionSkillEditorPanel.initializePanel(panelBuilder2);
this.createPotionEffectMenu.initializePanel(panelBuilder3);
this.potionEffectTypeEditMenu.initializePanel(getListMenu("Skills.CreatePotion"));
this.commandSkillEditorPanel.initializePanel(panelBuilder4);
}
//---------------------------------------------
@ -291,7 +296,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
return BossAPI.getBossEntityName(object);
}
};
this.onTauntTextEditMenu = new ListMessageListEditor(this, getListMenu("Boss.Text"), this.customBosses) {
this.onTauntTextEditMenu = new ListMessageListEditor<BossEntity>(this, getListMenu("Boss.Text"), this.customBosses) {
@Override
public List<String> getCurrent(BossEntity bossEntity) {
return bossEntity.getMessages().getTaunts().getTaunts();
@ -314,6 +319,11 @@ public class BossPanelManager implements ILoadable, IReloadable {
public IVariablePanelHandler<BossEntity> getParentHolder() {
return getMainTauntEditMenu();
}
@Override
public String getName(BossEntity object) {
return BossAPI.getBossEntityName(object);
}
};
}

View File

@ -28,7 +28,7 @@ import java.util.Map;
* @version 1.0.0
* @since 29-Nov-18
*/
public abstract class ListMessageListEditor extends VariablePanelHandler<BossEntity> {
public abstract class ListMessageListEditor<T> extends VariablePanelHandler<T> {
private MessagesFileManager messagesFileManager;
private ItemStackConverter itemStackConverter;
@ -42,14 +42,16 @@ public abstract class ListMessageListEditor extends VariablePanelHandler<BossEnt
this.messagesFileManager = plugin.getBossMessagesFileManager();
}
public abstract List<String> getCurrent(BossEntity bossEntity);
public abstract List<String> getCurrent(T object);
public abstract void updateMessage(BossEntity bossEntity, String modifiedValue);
public abstract void updateMessage(T object, String modifiedValue);
public abstract IVariablePanelHandler<BossEntity> getParentHolder();
public abstract IVariablePanelHandler<T> getParentHolder();
public abstract String getName(T object);
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
public void fillPanel(Panel panel, T object) {
Map<String, List<String>> currentTexts = this.messagesFileManager.getMessagesMap();
List<String> entryList = new ArrayList<>(currentTexts.keySet());
int maxPage = panel.getMaxPage(entryList);
@ -57,28 +59,28 @@ public abstract class ListMessageListEditor extends VariablePanelHandler<BossEnt
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, currentTexts, entryList, bossEntity);
loadPage(panel, requestedPage, currentTexts, entryList, object);
return true;
}));
loadPage(panel, 0, currentTexts, entryList, bossEntity);
loadPage(panel, 0, currentTexts, entryList, object);
}
@Override
public void openFor(Player player, BossEntity bossEntity) {
public void openFor(Player player, T object) {
Map<String, String> replaceMap = new HashMap<>();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{name}", getName(object));
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(getParentHolder(), bossEntity);
.setParentPanelHandler(getParentHolder(), object);
fillPanel(panel, bossEntity);
fillPanel(panel, object);
panel.openFor(player);
}
@ -88,8 +90,8 @@ public abstract class ListMessageListEditor extends VariablePanelHandler<BossEnt
}
private void loadPage(Panel panel, int page, Map<String, List<String>> currentMessages, List<String> entryList, BossEntity bossEntity) {
List<String> current = getCurrent(bossEntity);
private void loadPage(Panel panel, int page, Map<String, List<String>> currentMessages, List<String> entryList, T object) {
List<String> current = getCurrent(object);
panel.loadPage(page, (slot, realisticSlot) -> {
if(slot >= entryList.size()) {
@ -128,9 +130,9 @@ public abstract class ListMessageListEditor extends VariablePanelHandler<BossEnt
itemStack.setItemMeta(itemMeta);
panel.setItem(realisticSlot, itemStack, e -> {
updateMessage(bossEntity, name);
updateMessage(object, name);
this.plugin.getBossesFileManager().save();
loadPage(panel, page, currentMessages, entryList, bossEntity);
loadPage(panel, page, currentMessages, entryList, object);
});
}
});

View File

@ -0,0 +1,127 @@
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.files.MessagesFileManager;
import com.songoda.epicbosses.skills.Skill;
import com.songoda.epicbosses.skills.elements.SubCommandSkillElement;
import com.songoda.epicbosses.skills.types.CommandSkillElement;
import com.songoda.epicbosses.skills.types.PotionSkillElement;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.command.SubCommand;
import com.songoda.epicbosses.utils.itemstack.ItemStackConverter;
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.ClickAction;
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.holder.PotionEffectHolder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
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 CommandSkillEditorPanel extends VariablePanelHandler<Skill> {
private MessagesFileManager messagesFileManager;
private ItemStackConverter itemStackConverter;
private CustomBosses plugin;
public CommandSkillEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
}
@Override
public void fillPanel(Panel panel, Skill skill) {
CommandSkillElement commandSkillElement = this.plugin.getBossSkillManager().getCommandSkillElement(skill);
List<SubCommandSkillElement> subCommandSkillElements = commandSkillElement.getCommands();
int maxPage = panel.getMaxPage(subCommandSkillElements);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, subCommandSkillElements, skill);
return true;
}));
loadPage(panel, 0, subCommandSkillElements, 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);
counter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, getAddNewAction(skill)));
fillPanel(panel, skill);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
panelBuilderCounter
.addSlotCounter("AddNew");
}
private ClickAction getAddNewAction(Skill skill) {
return event -> {
};
}
private void loadPage(Panel panel, int page, List<SubCommandSkillElement> subCommandSkillElements, Skill skill) {
panel.loadPage(page, (slot, realisticSlot) -> {
if(slot >= subCommandSkillElements.size()) {
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
} else {
SubCommandSkillElement subCommandSkillElement = subCommandSkillElements.get(slot);
ItemStack itemStack = new ItemStack(Material.BOOK);
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.Skills.Commands.lore"));
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.Commands.name"));
panel.setItem(realisticSlot, itemStack, event -> {
ClickType clickType = event.getClick();
if(clickType.name().contains("RIGHT")) {
//TODO: Modify Chance
} else {
//TODO: Modify commands
}
loadPage(panel, page, subCommandSkillElements, skill);
});
}
});
}
}

View File

@ -20,7 +20,7 @@
<properties>
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
<plugin.version>1.0.0-U107</plugin.version>
<plugin.version>1.0.0-U108</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>