From 171fb1819f89ae8d9c569f59954cf4c9bb75f31f Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 28 Nov 2018 23:06:13 +0800 Subject: [PATCH] 1.0.0-SNAPSHOT-U89 + Started working on TextEditor + Added DropsMainEditor + Fixed few issues within config.yml --- plugin-modules/Core/resources-yml/config.yml | 1 + plugin-modules/Core/resources-yml/editor.yml | 96 +++++++++++++++++ .../epicbosses/managers/BossPanelManager.java | 13 ++- .../panel/bosses/DropsMainEditorPanel.java | 101 ++++++++++++++++++ .../panel/bosses/MainBossEditPanel.java | 2 +- .../panel/bosses/TextMainEditorPanel.java | 9 ++ pom.xml | 2 +- 7 files changed, 219 insertions(+), 5 deletions(-) create mode 100644 plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/DropsMainEditorPanel.java create mode 100644 plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/TextMainEditorPanel.java diff --git a/plugin-modules/Core/resources-yml/config.yml b/plugin-modules/Core/resources-yml/config.yml index d680f99..c40af32 100644 --- a/plugin-modules/Core/resources-yml/config.yml +++ b/plugin-modules/Core/resources-yml/config.yml @@ -44,6 +44,7 @@ Display: Taunts: menuName: '&b&l{name} Editor' Drops: + name: '&bDropTable: &f{name}' lore: - '&3Type: &7{type}' - '&7' diff --git a/plugin-modules/Core/resources-yml/editor.yml b/plugin-modules/Core/resources-yml/editor.yml index 316a558..c94b11c 100644 --- a/plugin-modules/Core/resources-yml/editor.yml +++ b/plugin-modules/Core/resources-yml/editor.yml @@ -240,6 +240,58 @@ MainEditorPanel: - '&7Click here to edit the taunts, sayings,' - '&7etc. for this boss.' Button: Text +DropsMainEditorPanel: + name: '&b&l{name} Editor' + slots: 9 + Settings: + backButton: true + emptySpaceFiller: true + EmptySpaceFiller: + type: WHITE_STAINED_GLASS_PANE + name: '&7' + Buttons: + backButton: 9 + Items: + '1': + type: BOOK + name: '&c&lDrops Guide' + lore: + - '&7Here you can configure the drop systems' + - '&7the boss has when he dies.' + '4': + type: GUN_POWDER + name: '&e&lNatural Drops' + lore: + - '&bCurrently: &f{naturalDrops}' + - '&7' + - '&7Click to toggle the natural drops' + - '&7for this boss.' + Button: NaturalDrops + '5': + type: BOOK + name: '&e&lDrop Table' + lore: + - '&bCurrently: &f{dropTable}' + - '&7Click here to change the drop table' + - '&7assigned to this boss.' + Button: DropTable + '6': + type: REDSTONE + name: '&e&lNatural EXP' + lore: + - '&bCurrently: &f{naturalExp}' + - '&7' + - '&7Click to toggle the natural drop' + - '&7of exp for this boss.' + Button: NaturalEXP + '9': + type: PAPER + name: '&e&lGo Back' + lore: + - '&7Click here to go back.' + + + DropsEditorPanel: name: '&b&l{name} Editor' slots: 54 @@ -1029,3 +1081,47 @@ CommandsEditorPanel: name: '&e&lGo Back' lore: - '&7Click here to go back.' +TextEditorMainPanel: + name: '&b&l{name} Editor' + slots: 9 + Settings: + backButton: true + emptySpaceFiller: true + EmptySpaceFiller: + type: WHITE_STAINED_GLASS_PANE + name: '&7' + Buttons: + backButton: 9 + Items: + '1': + type: BOOK + name: '&c&lCommands Guide' + lore: + - '&7Here you can configure which command set' + - '&7the boss has for specific events.' + '4': + type: TALL_GRASS + name: '&e&lOn Spawn' + lore: + - '&7Here you can change the settings for' + - '&7the spawn messages of the boss.' + Button: OnSpawn + '5': + type: REDSTONE_TORCH + name: '&e&lTaunts' + lore: + - '&7Here you can adjust the settings for' + - '&7the taunts of the boss.' + '6': + type: REDSTONE + name: '&e&lOn Death' + lore: + - '&7Here you can change the settings for' + - '&7the death messages of the boss.' + Button: OnDeath + '9': + type: PAPER + name: '&e&lGo Back' + lore: + - '&7Click here to go back.' + 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 6bce64d..2ceb2ac 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java @@ -47,6 +47,7 @@ public class BossPanelManager implements ILoadable, IReloadable { @Getter private ISubVariablePanelHandler weaponEditMenu, offHandEditorMenu, mainHandEditorMenu; @Getter private ISubVariablePanelHandler statisticMainEditMenu, entityTypeEditMenu; @Getter private IVariablePanelHandler mainBossEditMenu, dropsEditMenu, targetingEditMenu, skillsBossEditMenu, skillListBossEditMenu, commandsMainEditMenu, onSpawnCommandEditMenu, onDeathCommandEditMenu; + @Getter private IVariablePanelHandler mainDropsEditMenu; @Getter private BossListEditorPanel equipmentListEditMenu, weaponListEditMenu, statisticListEditMenu; private final CustomBosses customBosses; @@ -219,14 +220,14 @@ public class BossPanelManager implements ILoadable, IReloadable { PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("StatisticsMainEditorPanel")); this.statisticMainEditMenu = new StatisticMainEditorPanel(this, panelBuilder, this.customBosses); - this.entityTypeEditMenu = new EntityTypeEditorPanel(this, getListMenu("EntityTypeEditor"), this.customBosses); + this.entityTypeEditMenu = new EntityTypeEditorPanel(this, getListMenu("Boss.EntityType"), this.customBosses); } private void reloadStatEditMenu() { PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("StatisticsMainEditorPanel")); this.statisticMainEditMenu.initializePanel(panelBuilder); - this.entityTypeEditMenu.initializePanel(getListMenu("EntityTypeEditor")); + this.entityTypeEditMenu.initializePanel(getListMenu("Boss.EntityType")); } //--------------------------------------------- @@ -293,13 +294,17 @@ public class BossPanelManager implements ILoadable, IReloadable { private void loadDropsEditMenu() { PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("DropsEditorPanel")); + PanelBuilder panelBuilder1 = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("DropsMainEditorPanel")); + this.mainDropsEditMenu = new DropsMainEditorPanel(this, panelBuilder1, this.customBosses); this.dropsEditMenu = new DropsEditorPanel(this, panelBuilder, this.customBosses); } private void reloadDropsEditMenu() { PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("DropsEditorPanel")); + PanelBuilder panelBuilder1 = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("DropsMainEditorPanel")); + this.mainDropsEditMenu.initializePanel(panelBuilder1); this.dropsEditMenu.initializePanel(panelBuilder); } @@ -467,8 +472,10 @@ public class BossPanelManager implements ILoadable, IReloadable { private PanelBuilder getListMenu(String path) { Map replaceMap = new HashMap<>(); + String finalPath = getPath(path); + String value = this.customBosses.getConfig().getString(finalPath); - replaceMap.put("{panelName}", StringUtils.get().translateColor(this.customBosses.getConfig().getString(getPath(path)))); + replaceMap.put("{panelName}", StringUtils.get().translateColor(value)); return new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("ListPanel"), replaceMap); } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/DropsMainEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/DropsMainEditorPanel.java new file mode 100644 index 0000000..0150482 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/DropsMainEditorPanel.java @@ -0,0 +1,101 @@ +package com.songoda.epicbosses.panel.bosses; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.entity.BossEntity; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.BossesFileManager; +import com.songoda.epicbosses.utils.NumberUtils; +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 org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 28-Nov-18 + */ +public class DropsMainEditorPanel extends VariablePanelHandler { + + private BossesFileManager bossesFileManager; + + public DropsMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder); + + this.bossesFileManager = plugin.getBossesFileManager(); + } + + @Override + public void fillPanel(Panel panel, BossEntity bossEntity) { + + } + + @Override + public void openFor(Player player, BossEntity bossEntity) { + Map replaceMap = new HashMap<>(); + Boolean naturalDrops = bossEntity.getDrops().getNaturalDrops(); + Boolean naturalExp = bossEntity.getDrops().getDropExp(); + String dropTable = bossEntity.getDrops().getDropTable(); + PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); + + if(naturalDrops == null) naturalDrops = true; + if(naturalExp == null) naturalExp = true; + if(dropTable == null) dropTable = "N/A"; + + replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity)); + replaceMap.put("{naturalDrops}", ""+naturalDrops); + replaceMap.put("{naturalExp}", ""+naturalExp); + replaceMap.put("{dropTable}", dropTable); + panelBuilder.addReplaceData(replaceMap); + + Panel panel = panelBuilder.getPanel() + .setDestroyWhenDone(true) + .setCancelClick(true) + .setCancelLowerClick(true) + .setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity); + PanelBuilderCounter counter = panel.getPanelBuilderCounter(); + + Boolean finalNaturalDrops = naturalDrops; + Boolean finalNaturalEXP = naturalExp; + + counter.getSlotsWith("NaturalDrops").forEach(slot -> panel.setOnClick(slot, getNaturalDropsAction(bossEntity, finalNaturalDrops))); + counter.getSlotsWith("DropTable").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getDropsEditMenu().openFor((Player) event.getWhoClicked(), bossEntity))); + counter.getSlotsWith("NaturalEXP").forEach(slot -> panel.setOnClick(slot, getNaturalExpAction(bossEntity, finalNaturalEXP))); + + panel.openFor(player); + } + + @Override + public void initializePanel(PanelBuilder panelBuilder) { + PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter(); + + panelBuilderCounter + .addSlotCounter("NaturalDrops") + .addSlotCounter("DropTable") + .addSlotCounter("NaturalEXP"); + } + + private ClickAction getNaturalDropsAction(BossEntity bossEntity, Boolean current) { + return event -> { + bossEntity.getDrops().setNaturalDrops(!current); + this.bossesFileManager.save(); + + openFor((Player) event.getWhoClicked(), bossEntity); + }; + } + + private ClickAction getNaturalExpAction(BossEntity bossEntity, Boolean current) { + return event -> { + bossEntity.getDrops().setDropExp(!current); + this.bossesFileManager.save(); + + openFor((Player) event.getWhoClicked(), bossEntity); + }; + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/MainBossEditPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/MainBossEditPanel.java index 5ef41fc..1a0fed9 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/MainBossEditPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/MainBossEditPanel.java @@ -76,7 +76,7 @@ public class MainBossEditPanel extends VariablePanelHandler { PanelBuilderCounter counter = panel.getPanelBuilderCounter(); counter.getSlotsWith("Editing").forEach(slot -> panel.setOnClick(slot, getEditingAction(bossEntity))); - counter.getSlotsWith("Drops").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getDropsEditMenu().openFor((Player) e.getWhoClicked(), bossEntity))); + counter.getSlotsWith("Drops").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getMainDropsEditMenu().openFor((Player) e.getWhoClicked(), bossEntity))); counter.getSlotsWith("Targeting").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getTargetingEditMenu().openFor((Player) e.getWhoClicked(), bossEntity))); counter.getSlotsWith("Equipment").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getEquipmentListEditMenu().openFor((Player) e.getWhoClicked(), bossEntity))); counter.getSlotsWith("Weapon").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getWeaponListEditMenu().openFor((Player) e.getWhoClicked(), bossEntity))); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/TextMainEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/TextMainEditorPanel.java new file mode 100644 index 0000000..06ff13f --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/bosses/TextMainEditorPanel.java @@ -0,0 +1,9 @@ +package com.songoda.epicbosses.panel.bosses; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 28-Nov-18 + */ +public class TextMainEditorPanel { +} diff --git a/pom.xml b/pom.xml index 849065a..33a28af 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ - maven-version-number-SNAPSHOT-U88 + maven-version-number-SNAPSHOT-U89 EpicBosses com.songoda.epicbosses.CustomBosses AMinecraftDev