From 5aba97b5c0adc7077d05d90c181ba342c3994486 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 23 Dec 2018 19:11:54 +0800 Subject: [PATCH] 1.0.0-SNAPSHOT-U138 + Implemented MainDropTableEditor + Started implementing the further DropTable editing menu's --- TODO | 6 +-- plugin-modules/Core/resources-yml/editor.yml | 47 +++++++++++++++- .../com/songoda/epicbosses/api/BossAPI.java | 23 ++++++-- .../epicbosses/managers/BossPanelManager.java | 26 +++++++++ .../epicbosses/panel/DropTablePanel.java | 5 +- .../epicbosses/panel/MainMenuPanel.java | 2 +- .../droptables/DropTableTypeEditorPanel.java | 35 ++++++++++++ .../droptables/MainDropTableEditorPanel.java | 53 +++++++++++++++++++ .../com/songoda/epicbosses/utils/Message.java | 1 + pom.xml | 2 +- 10 files changed, 185 insertions(+), 15 deletions(-) create mode 100644 plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/DropTableTypeEditorPanel.java create mode 100644 plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/MainDropTableEditorPanel.java diff --git a/TODO b/TODO index 52210e7..f4e1ae5 100644 --- a/TODO +++ b/TODO @@ -17,10 +17,6 @@ 01:00 -> Wilderness - Button to change max coords, boss that autospawn applies to, maxActiveBosses, spawnChance 01:00 -> Spawner - Button to change max coords, boss that autospawn applies to, maxActiveBosses, spawnChance -00:30 -> Complete the /boss new skill command 00:30 -> Connect the /boss time [section] to the AutoSpawns timer (can only be applied to Interval AutoSpawns) 00:30 -> Add support for HolographicDisplays placeholder as the entityName for bosses and minions -01:00 -> Add a new branch for the plugin and add support for Legacy version - ------- -28.15hrs \ No newline at end of file +01:00 -> Add a new branch for the plugin and add support for Legacy version \ 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 ecf6b60..c31e5ae 100644 --- a/plugin-modules/Core/resources-yml/editor.yml +++ b/plugin-modules/Core/resources-yml/editor.yml @@ -1880,4 +1880,49 @@ SpecialSettingsEditorPanel: lore: - '&7Click this button to go back to' - '&7the skill editor panel to configure' - - '&7the general skill options.' \ No newline at end of file + - '&7the general skill options.' +DropTableMainEditorPanel: + name: '&b&l{name} Editor' + slots: 9 + Settings: + emptySpaceFiller: true + backButton: true + Buttons: + backButton: 9 + EmptySpaceFiller: + type: WHITE_STAINED_GLASS_PANE + name: '&7' + Items: + '1': + type: BOOK + name: '&c&lDrop Table Guide' + lore: + - '&7Here you are able to configure' + - '&7each aspect of the drop table to' + - '&7your liking. Remember that the moment' + - '&7something changes then it will also' + - '&7change for any live bosses.' + '4': + type: GUNPOWDER + name: '&e&lType' + lore: + - '&bCurrently: &f{type}' + - '&7Click this to change the skill type. Keep' + - '&7in mind that when you change your skill' + - '&7type the previous custom data will be erased' + - '&7to make room for the new custom data.' + Button: Type + '6': + type: DIAMOND + name: '&e&lRewards' + lore: + - '&7Click here to edit the rewards related to' + - '&7this drop table. The menu that appears will' + - '&7be relevant to the drop table type.' + Button: Rewards + '9': + type: REDSTONE + name: '&cClick here to go back' + lore: + - '&7Click this button to go back to' + - '&7the drop table list page.' \ No newline at end of file diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java b/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java index 0d53584..be1bf7a 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/api/BossAPI.java @@ -167,6 +167,21 @@ public class BossAPI { return null; } + /** + * Used to get the DropTable configuration section + * name from a DropTable instance. + * + * @param dropTable - the dropTable instance + * @return name of the dropTable from the DropTableFileManager or null if not found. + */ + public static String getDropTableName(DropTable dropTable) { + for(Map.Entry entry : PLUGIN.getDropTableFileManager().getDropTables().entrySet()) { + if(entry.getValue().equals(dropTable)) return entry.getKey(); + } + + return null; + } + /** * Used to get the Minion configuration section name * from a MinionEntity instance. @@ -384,10 +399,10 @@ public class BossAPI { * @return ActiveBossHolder class with stored information */ public static ActiveBossHolder spawnNewBoss(BossEntity bossEntity, Location location, Player player, ItemStack itemStack) { -// if(bossEntity.isEditing()) { -// Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug(); -// return null; -// } + if(bossEntity.isEditing()) { + Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug(); + return null; + } String name = PLUGIN.getBossEntityContainer().getName(bossEntity); 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 372bdea..78e7a7d 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java @@ -1,6 +1,7 @@ package com.songoda.epicbosses.managers; import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; import com.songoda.epicbosses.entity.BossEntity; import com.songoda.epicbosses.entity.elements.EntityStatsElement; import com.songoda.epicbosses.entity.elements.EquipmentElement; @@ -18,6 +19,7 @@ import com.songoda.epicbosses.panel.bosses.list.BossListWeaponEditorPanel; import com.songoda.epicbosses.panel.bosses.text.*; import com.songoda.epicbosses.panel.bosses.weapons.MainHandEditorPanel; import com.songoda.epicbosses.panel.bosses.weapons.OffHandEditorPanel; +import com.songoda.epicbosses.panel.droptables.MainDropTableEditorPanel; import com.songoda.epicbosses.panel.handlers.*; import com.songoda.epicbosses.panel.skills.MainSkillEditorPanel; import com.songoda.epicbosses.panel.skills.SkillTypeEditorPanel; @@ -81,6 +83,8 @@ public class BossPanelManager implements ILoadable, IReloadable { @Getter private ISubVariablePanelHandler modifyCommandEditMenu, commandListSkillEditMenu; @Getter private ISubVariablePanelHandler customSkillTypeEditorMenu, specialSettingsEditorMenu, minionSelectEditorMenu; + @Getter private IVariablePanelHandler mainDropTableEditMenu; + private final CustomBosses customBosses; public BossPanelManager(CustomBosses customBosses) { @@ -112,6 +116,7 @@ public class BossPanelManager implements ILoadable, IReloadable { loadEquipmentEditMenus(); loadSkillEditMenus(); + loadDropTableEditMenus(); } @Override @@ -139,6 +144,7 @@ public class BossPanelManager implements ILoadable, IReloadable { reloadEquipmentEditMenus(); reloadSkillEditMenus(); + reloadDropTableEditMenus(); } public int isItemStackUsed(String name) { @@ -182,6 +188,26 @@ public class BossPanelManager implements ILoadable, IReloadable { return new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("ListPanel"), replaceMap); } + //--------------------------------------------- + // + // D R O P T A B L E E D I T P A N E L S + // + //--------------------------------------------- + + private void loadDropTableEditMenus() { + FileConfiguration editor = this.customBosses.getEditor(); + PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("DropTableMainEditorPanel")); + + this.mainDropTableEditMenu = new MainDropTableEditorPanel(this, panelBuilder); + } + + private void reloadDropTableEditMenus() { + FileConfiguration editor = this.customBosses.getEditor(); + PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("DropTableMainEditorPanel")); + + this.mainDropTableEditMenu.initializePanel(panelBuilder); + } + //--------------------------------------------- // // S K I L L E D I T P A N E L S diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/DropTablePanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/DropTablePanel.java index f9aa7ef..59338ba 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/DropTablePanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/DropTablePanel.java @@ -13,6 +13,7 @@ import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder; import com.songoda.epicbosses.utils.panel.Panel; import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.ArrayList; @@ -77,9 +78,7 @@ public class DropTablePanel extends MainListPanelHandler { ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.DropTable.name"), replaceMap); ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.DropTable.lore"), replaceMap); - panel.setItem(realisticSlot, itemStack, e -> { - //TODO: Add Drop Table editing - }); + panel.setItem(realisticSlot, itemStack, e -> this.bossPanelManager.getMainDropTableEditMenu().openFor((Player) e.getWhoClicked(), dropTable)); } }); } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/MainMenuPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/MainMenuPanel.java index 4a48f27..62f9cab 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/MainMenuPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/MainMenuPanel.java @@ -107,7 +107,7 @@ public class MainMenuPanel extends PanelHandler { if(event.getClick() == ClickType.LEFT || event.getClick() == ClickType.SHIFT_LEFT) { this.bossPanelManager.getCustomSkills().openFor(player); } else if(event.getClick() == ClickType.RIGHT || event.getClick() == ClickType.SHIFT_RIGHT) { - //TODO: Set up create skills command + Message.Boss_New_CreateArgumentsSkill.msg(player); player.closeInventory(); } }; diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/DropTableTypeEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/DropTableTypeEditorPanel.java new file mode 100644 index 0000000..22c48c9 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/DropTableTypeEditorPanel.java @@ -0,0 +1,35 @@ +package com.songoda.epicbosses.panel.droptables; + +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.managers.BossPanelManager; +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 org.bukkit.entity.Player; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 23-Dec-18 + */ +public class DropTableTypeEditorPanel extends VariablePanelHandler { + + public DropTableTypeEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) { + super(bossPanelManager, panelBuilder); + } + + @Override + public void fillPanel(Panel panel, DropTable dropTable) { + + } + + @Override + public void openFor(Player player, DropTable dropTable) { + + } + + @Override + public void initializePanel(PanelBuilder panelBuilder) { + + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/MainDropTableEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/MainDropTableEditorPanel.java new file mode 100644 index 0000000..0b1a03a --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/MainDropTableEditorPanel.java @@ -0,0 +1,53 @@ +package com.songoda.epicbosses.panel.droptables; + +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.managers.BossPanelManager; +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 org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 23-Dec-18 + */ +public class MainDropTableEditorPanel extends VariablePanelHandler { + + public MainDropTableEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) { + super(bossPanelManager, panelBuilder); + } + + @Override + public void fillPanel(Panel panel, DropTable dropTable) { + + } + + @Override + public void openFor(Player player, DropTable dropTable) { + PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); + Map replaceMap = new HashMap<>(); + + replaceMap.put("{name}", BossAPI.getDropTableName(dropTable)); + panelBuilder.addReplaceData(replaceMap); + + PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter(); + Panel panel = panelBuilder.getPanel() + .setParentPanelHandler(this.bossPanelManager.getDropTables()); + + panelBuilderCounter.getSlotsWith("Type").forEach(slot -> panel.setOnClick(slot, event -> {})); + panelBuilderCounter.getSlotsWith("Rewards").forEach(slot -> panel.setOnClick(slot, event -> {})); + + panel.openFor(player); + } + + @Override + public void initializePanel(PanelBuilder panelBuilder) { + + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java b/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java index 80c22de..96b34a8 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java @@ -138,6 +138,7 @@ public enum Message { Boss_New_NoPermission("&c&l(!) &cYou do not have access to this command."), Boss_New_InvalidArgs("&c&l(!) &cInvalid arguments! You must use &n/boss new droptable [name] (type)&c or &n/boss new skill [name]&c!"), Boss_New_CreateArgumentsDropTable("&b&lEpicBosses &8» &7Create a new droptable with the command &f/boss new droptable [name] [type]&7."), + Boss_New_CreateArgumentsSkill("&b&lEpicBosses &8» &7Create a new skill with the command &f/boss new skill [name] [type] [mode]&7."), Boss_New_CreateArgumentsMessage("&b&lEpicBosses &8» &7Create a new message with the command &f/boss new message [name] [message(s)]. \n&7&oUse &f|| &7&oto reference a new line."), Boss_New_CreateArgumentsCommand("&b&lEpicBosses &8» &7Create a new command with the command &f/boss new command [name] [command(s)]. \n&7&oUse &f|| &7&oto reference a new line."), Boss_New_AlreadyExists("&c&l(!) &cThe specified {0} name already exists. Please try another name."), diff --git a/pom.xml b/pom.xml index b6433c0..5cd7ab5 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ - 1.0.0-U137 + 1.0.0-U138 EpicBosses com.songoda.epicbosses.CustomBosses AMinecraftDev