diff --git a/plugin-modules/Core/resources-yml/config.yml b/plugin-modules/Core/resources-yml/config.yml index e41499f..aa38887 100644 --- a/plugin-modules/Core/resources-yml/config.yml +++ b/plugin-modules/Core/resources-yml/config.yml @@ -93,11 +93,11 @@ Display: lore: - '&3Editing: &f{enabled}' - '&7' - - '&3Left Click »' + - '&3Left Click &8»' - '&7Get spawn item for custom' - '&7boss.' - '&7' - - '&3Right Click »' + - '&3Right Click &8»' - '&7Edit the custom boss.' DropTable: menuName: '&b&lEpicBosses &3&lDropTables' @@ -140,8 +140,7 @@ Display: Commands: name: '&b&lCommand Section' lore: - - '&3Left Click &8»' - - '&7Modify the assigned commands.' - - '&7' - - '&3Right Click &8»' - - '&7Modify the chance for this section.' \ No newline at end of file + - '&3Chance &8» &f{chance}%' + - '&' + - '&3Commands &8»' + - '&f{commands}' \ No newline at end of file diff --git a/plugin-modules/Core/resources-yml/editor.yml b/plugin-modules/Core/resources-yml/editor.yml index 8e3347b..4783c8b 100644 --- a/plugin-modules/Core/resources-yml/editor.yml +++ b/plugin-modules/Core/resources-yml/editor.yml @@ -1608,4 +1608,43 @@ CommandSkillEditorPanel: type: PAPER name: '&e&lGo Back' lore: - - '&7Click here to go back.' \ No newline at end of file + - '&7Click here to go back.' +ModifyCommandEditorPanel: + name: '&b&lCommand Editor' + slots: 9 + Settings: + backButton: true + emptySpaceFiller: true + EmptySpaceFiller: + type: WHITE_STAINED_GLASS_PANE + name: '&7' + Buttons: + backButton: 5 + Items: + '3': + type: BOOK + name: '&e&lCommands' + lore: + - '&7Currently selected commands:' + - '&7' + - '{commands}' + Button: Commands + '5': + type: PAPER + name: '&e&lGo Back' + lore: + - '&7Click here to go back.' + '7': + type: GUNPOWDER + name: '&e&lChance' + lore: + - '&bCurrently: &f{chance}' + - '&7' + - '&7Click here to modify the chance' + - '&7value for this boss.' + - '&7' + - '&bLeft Click &8» &f+1.0' + - '&bShift Left-Click &8» &f+0.1' + - '&7' + - '&bRight Click &8» &f-1.0' + - '&bShift Right-Click &8» &f-0.1' \ No newline at end of file diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java index f5db4f1..00e8f58 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java @@ -22,10 +22,11 @@ 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.potions.CreatePotionEffectEditorPanel; +import com.songoda.epicbosses.panel.skills.custom.potions.PotionEffectTypeEditorPanel; import com.songoda.epicbosses.panel.skills.custom.PotionSkillEditorPanel; import com.songoda.epicbosses.skills.Skill; +import com.songoda.epicbosses.skills.elements.SubCommandSkillElement; import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler; import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder; @@ -67,6 +68,7 @@ public class BossPanelManager implements ILoadable, IReloadable { @Getter private IVariablePanelHandler mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu, potionSkillEditorPanel, commandSkillEditorPanel; @Getter private ISubVariablePanelHandler createPotionEffectMenu, potionEffectTypeEditMenu; + @Getter private ISubVariablePanelHandler modifyCommandEditMenu; private final CustomBosses customBosses; diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/handlers/ListCommandListEditor.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/handlers/ListCommandListEditor.java new file mode 100644 index 0000000..1f3ffd2 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/handlers/ListCommandListEditor.java @@ -0,0 +1,140 @@ +package com.songoda.epicbosses.panel.handlers; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.CommandsFileManager; +import com.songoda.epicbosses.managers.files.MessagesFileManager; +import com.songoda.epicbosses.utils.StringUtils; +import com.songoda.epicbosses.utils.itemstack.ItemStackConverter; +import com.songoda.epicbosses.utils.itemstack.ItemStackUtils; +import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder; +import com.songoda.epicbosses.utils.panel.Panel; +import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 05-Dec-18 + */ +public abstract class ListCommandListEditor extends VariablePanelHandler { + + private CommandsFileManager commandsFileManager; + private ItemStackConverter itemStackConverter; + private CustomBosses plugin; + + public ListCommandListEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder); + + this.plugin = plugin; + this.itemStackConverter = new ItemStackConverter(); + this.commandsFileManager = plugin.getBossCommandFileManager(); + } + + public abstract List getCurrent(T object); + + public abstract void updateMessage(T object, String modifiedValue); + + public abstract IVariablePanelHandler getParentHolder(); + + public abstract String getName(T object); + + @Override + public void fillPanel(Panel panel, T object) { + Map> currentTexts = this.commandsFileManager.getCommandsMap(); + List entryList = new ArrayList<>(currentTexts.keySet()); + int maxPage = panel.getMaxPage(entryList); + + panel.setOnPageChange(((player, currentPage, requestedPage) -> { + if(requestedPage < 0 || requestedPage > maxPage) return false; + + loadPage(panel, requestedPage, currentTexts, entryList, object); + return true; + })); + + loadPage(panel, 0, currentTexts, entryList, object); + } + + @Override + public void openFor(Player player, T object) { + Map replaceMap = new HashMap<>(); + PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); + + replaceMap.put("{name}", getName(object)); + panelBuilder.addReplaceData(replaceMap); + + Panel panel = panelBuilder.getPanel() + .setDestroyWhenDone(true) + .setCancelClick(true) + .setCancelLowerClick(true) + .setParentPanelHandler(getParentHolder(), object); + + fillPanel(panel, object); + + panel.openFor(player); + } + + @Override + public void initializePanel(PanelBuilder panelBuilder) { + + } + + private void loadPage(Panel panel, int page, Map> currentMessages, List entryList, T object) { + List current = getCurrent(object); + + panel.loadPage(page, (slot, realisticSlot) -> { + if(slot >= entryList.size()) { + panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {}); + } else { + String name = entryList.get(slot); + List messages = currentMessages.get(name); + ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultTextMenuItem"); + ItemStack itemStack = this.itemStackConverter.from(itemStackHolder); + + Map replaceMap = new HashMap<>(); + + replaceMap.put("{name}", name); + + if(current.contains(name)) { + ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.selectedName"), replaceMap); + } else { + ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Command.name"), replaceMap); + } + + ItemMeta itemMeta = itemStack.getItemMeta(); + List presetLore = this.plugin.getConfig().getStringList("Display.Boss.Commands.lore"); + List newLore = new ArrayList<>(); + + for(String s : presetLore) { + if(s.contains("{commands}")) { + for(String message : messages) { + newLore.add(StringUtils.get().translateColor("&7" + message)); + } + } else { + newLore.add(StringUtils.get().translateColor(s)); + } + } + + itemMeta.setLore(newLore); + itemStack.setItemMeta(itemMeta); + + panel.setItem(realisticSlot, itemStack, e -> { + updateMessage(object, name); + this.plugin.getBossesFileManager().save(); + loadPage(panel, page, currentMessages, entryList, object); + }); + } + }); + } +} \ No newline at end of file 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 233f6f9..9b6767a 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 @@ -29,6 +29,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -104,23 +105,22 @@ public class CommandSkillEditorPanel extends VariablePanelHandler { panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {}); } else { SubCommandSkillElement subCommandSkillElement = subCommandSkillElements.get(slot); + Map replaceMap = new HashMap<>(); + Double chance = subCommandSkillElement.getChance(); + List commands = subCommandSkillElement.getCommands(); + + if(chance == null) chance = 100.0; + if(commands == null) commands = new ArrayList<>(); + + replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance)); + replaceMap.put("{commands}", StringUtils.get().appendList(commands)); 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")); + ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.Skills.Commands.lore"), replaceMap); + ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.Commands.name"), replaceMap); - 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); - }); + panel.setItem(realisticSlot, itemStack, event -> this.bossPanelManager.getModifyCommandEditMenu().openFor((Player) event.getWhoClicked(), skill, subCommandSkillElement)); } }); } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/commands/ModifyCommandEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/commands/ModifyCommandEditorPanel.java new file mode 100644 index 0000000..ecf613d --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/commands/ModifyCommandEditorPanel.java @@ -0,0 +1,9 @@ +package com.songoda.epicbosses.panel.skills.custom.commands; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 05-Dec-18 + */ +public class ModifyCommandEditorPanel { +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/CreatePotionEffectEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/CreatePotionEffectEditorPanel.java similarity index 99% rename from plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/CreatePotionEffectEditorPanel.java rename to plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/CreatePotionEffectEditorPanel.java index 0549bb6..3ea2140 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/CreatePotionEffectEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/CreatePotionEffectEditorPanel.java @@ -1,4 +1,4 @@ -package com.songoda.epicbosses.panel.skills.custom; +package com.songoda.epicbosses.panel.skills.custom.potions; import com.google.gson.JsonObject; import com.songoda.epicbosses.CustomBosses; diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/PotionEffectTypeEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/PotionEffectTypeEditorPanel.java similarity index 98% rename from plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/PotionEffectTypeEditorPanel.java rename to plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/PotionEffectTypeEditorPanel.java index fc751c2..319611f 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/PotionEffectTypeEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/potions/PotionEffectTypeEditorPanel.java @@ -1,4 +1,4 @@ -package com.songoda.epicbosses.panel.skills.custom; +package com.songoda.epicbosses.panel.skills.custom.potions; import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.entity.BossEntity; diff --git a/pom.xml b/pom.xml index 8b1d45b..3a282bc 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ - 1.0.0-U109 + 1.0.0-U110 EpicBosses com.songoda.epicbosses.CustomBosses AMinecraftDev