diff --git a/plugin-modules/Core/resources-yml/editor.yml b/plugin-modules/Core/resources-yml/editor.yml index 244f383..955eee3 100644 --- a/plugin-modules/Core/resources-yml/editor.yml +++ b/plugin-modules/Core/resources-yml/editor.yml @@ -2066,179 +2066,6 @@ SprayDropTableMainEditMenu: - '&bRight Click &8» &f-1' - '&bShift Right-Click &8» &f-10' Button: MaxDrops -SprayRewardsListEditMenu: - name: '&b&l{name} DropTable' - slots: 54 - Settings: - backButton: true - fillTo: 45 - Buttons: - backButton: 54 - Items: - '46': - type: BOOK - name: '&c&lSpray Rewards Guide' - lore: - - '&7Here you can adjust the rewards for' - - '&7the skill with the spray layout. To' - - '&7adjust the chance of a section or to' - - '&7remove a section, then all you have' - - '&7to do is click on the section you''d' - - '&7like to modify and then click the' - - '&7corresponding button.' - - '&7To add a new section click on the' - - '&7emerald block in the bottom middle of' - - '&7the menu in between the page buttons.' - '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 rewards.' - PreviousPage: true - '50': - type: EMERALD_BLOCK - name: '&b&lAdd a New Reward Section' - lore: - - '&7Click here if you would like to add' - - '&7a new reward section to this drop' - - '&7table.' - Button: NewReward - '51': - type: ARROW - name: '&e&lNext Page &e&l&m->' - lore: - - '&7Click here to go to the next' - - '&7page of rewards.' - NextPage: true - '52': - type: GLASS_PANE - name: '&7' - '53': - type: GLASS_PANE - name: '&7' - '54': - type: REDSTONE - name: '&cClick here to go back' - lore: - - '&7Click this button to go back to' - - '&7the drop table main edit menu.' -SprayNewRewardEditMenu: - name: '&b&lNew Reward for DropTable' - slots: 54 - Settings: - backButton: true - fillTo: 45 - Buttons: - backButton: 54 - Items: - '46': - type: BOOK - name: '&c&lNew Spray Reward Guide' - lore: - - '&7Once you click an item within this' - - '&7menu it will create a new reward' - - '&7section with that selected item' - - '&7to the drop table you were working' - - '&7on. From there you can adjust the' - - '&7chance for it to be sprayed.' - - '&7' - - '&c&lWARNING' - - '&7At this moment you cannot have' - - '&7two sections for the same item,' - - '&7an easy way to bypass this is to' - - '&7add a new Item with the same' - - '&7itemstack, therefore giving it' - - '&7a new name, and allowing for' - - '&7another new section of the same' - - '&7item.' - '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 itemstacks.' - PreviousPage: true - '50': - type: GLASS_PANE - name: '&7' - '51': - type: ARROW - name: '&e&lNext Page &e&l&m->' - lore: - - '&7Click here to go to the next' - - '&7page of itemstacks.' - NextPage: true - '52': - type: GLASS_PANE - name: '&7' - '53': - type: GLASS_PANE - name: '&7' - '54': - type: REDSTONE - name: '&cClick here to go back' - lore: - - '&7Click this button to go back to' - - '&7the drop table reward list menu.' -SprayRewardMainEditMenu: - name: '&b&l{name} DropTable' - slots: 9 - Settings: - backButton: true - emptySpaceFiller: true - EmptySpaceFiller: - type: WHITE_STAINED_GLASS_PANE - name: '&7' - Buttons: - backButton: 9 - Items: - '3': - type: GUNPOWDER - name: '&e&lSelected ItemStack' - lore: - - '&bCurrently: &f{itemStack}' - - '&7This is the selected itemStack for this' - - '&7reward section.' - '4': - type: EMERALD - name: '&e&lChance' - lore: - - '&bCurrently: &f{chance}' - - '&7Click here to modify the chance of this' - - '&7reward ' - - '&7' - - '&bLeft Click &8» &f+1%' - - '&bShift Left-Click &8» &f+0.1%' - - '&7' - - '&bRight Click &8» &f-1%' - - '&bShift Right-Click &8» &f-0.1%' - Button: Chance - '5': - type: BARRIER - name: '&e&lClick here to remove' - lore: - - '&7Click here to remove this rewards section.' - - '&7You can always re-create this section if' - - '&7was a mistake.' - Button: Remove - '9': - type: REDSTONE - name: '&e&lGo Back' - lore: - - '&7Click here to go back.' DropDropTableMainEditMenu: name: '&b&l{name} Editor' slots: 9 @@ -2295,179 +2122,6 @@ DropDropTableMainEditMenu: name: '&e&lGo Back' lore: - '&7Click here to go back.' -DropRewardsListEditMenu: - name: '&b&l{name} DropTable' - slots: 54 - Settings: - backButton: true - fillTo: 45 - Buttons: - backButton: 54 - Items: - '46': - type: BOOK - name: '&c&lDrop Rewards Guide' - lore: - - '&7Here you can adjust the rewards for' - - '&7the skill with the drop layout. To' - - '&7adjust the chance of a section or to' - - '&7remove a section, then all you have' - - '&7to do is click on the section you''d' - - '&7like to modify and then click the' - - '&7corresponding button.' - - '&7To add a new section click on the' - - '&7emerald block in the bottom middle of' - - '&7the menu in between the page buttons.' - '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 rewards.' - PreviousPage: true - '50': - type: EMERALD_BLOCK - name: '&b&lAdd a New Reward Section' - lore: - - '&7Click here if you would like to add' - - '&7a new reward section to this drop' - - '&7table.' - Button: NewReward - '51': - type: ARROW - name: '&e&lNext Page &e&l&m->' - lore: - - '&7Click here to go to the next' - - '&7page of rewards.' - NextPage: true - '52': - type: GLASS_PANE - name: '&7' - '53': - type: GLASS_PANE - name: '&7' - '54': - type: REDSTONE - name: '&cClick here to go back' - lore: - - '&7Click this button to go back to' - - '&7the drop table main edit menu.' -DropNewRewardEditMenu: - name: '&b&lNew Reward for DropTable' - slots: 54 - Settings: - backButton: true - fillTo: 45 - Buttons: - backButton: 54 - Items: - '46': - type: BOOK - name: '&c&lNew Drop Reward Guide' - lore: - - '&7Once you click an item within this' - - '&7menu it will create a new reward' - - '&7section with that selected item' - - '&7to the drop table you were working' - - '&7on. From there you can adjust the' - - '&7chance for it to be sprayed.' - - '&7' - - '&c&lWARNING' - - '&7At this moment you cannot have' - - '&7two sections for the same item,' - - '&7an easy way to bypass this is to' - - '&7add a new Item with the same' - - '&7itemstack, therefore giving it' - - '&7a new name, and allowing for' - - '&7another new section of the same' - - '&7item.' - '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 itemstacks.' - PreviousPage: true - '50': - type: GLASS_PANE - name: '&7' - '51': - type: ARROW - name: '&e&lNext Page &e&l&m->' - lore: - - '&7Click here to go to the next' - - '&7page of itemstacks.' - NextPage: true - '52': - type: GLASS_PANE - name: '&7' - '53': - type: GLASS_PANE - name: '&7' - '54': - type: REDSTONE - name: '&cClick here to go back' - lore: - - '&7Click this button to go back to' - - '&7the drop table reward list menu.' -DropRewardMainEditMenu: - name: '&b&l{name} DropTable' - slots: 9 - Settings: - backButton: true - emptySpaceFiller: true - EmptySpaceFiller: - type: WHITE_STAINED_GLASS_PANE - name: '&7' - Buttons: - backButton: 9 - Items: - '3': - type: GUNPOWDER - name: '&e&lSelected ItemStack' - lore: - - '&bCurrently: &f{itemStack}' - - '&7This is the selected itemStack for this' - - '&7reward section.' - '4': - type: EMERALD - name: '&e&lChance' - lore: - - '&bCurrently: &f{chance}' - - '&7Click here to modify the chance of this' - - '&7reward ' - - '&7' - - '&bLeft Click &8» &f+1%' - - '&bShift Left-Click &8» &f+0.1%' - - '&7' - - '&bRight Click &8» &f-1%' - - '&bShift Right-Click &8» &f-0.1%' - Button: Chance - '5': - type: BARRIER - name: '&e&lClick here to remove' - lore: - - '&7Click here to remove this rewards section.' - - '&7You can always re-create this section if' - - '&7was a mistake.' - Button: Remove - '9': - type: REDSTONE - name: '&e&lGo Back' - lore: - - '&7Click here to go back.' GiveRewardPositionListMenu: name: '&b&l{name} DropTable' slots: 54 @@ -2706,4 +2360,177 @@ GiveRewardMainEditMenu: name: '&cClick here to go back' lore: - '&7Click this button to go back to' - - '&7the reward drop section list menu.' \ No newline at end of file + - '&7the reward drop section list menu.' +DropTableRewardsListEditMenu: + name: '&b&l{name} DropTable' + slots: 54 + Settings: + backButton: true + fillTo: 45 + Buttons: + backButton: 54 + Items: + '46': + type: BOOK + name: '&c&lDrop Rewards Guide' + lore: + - '&7Here you can adjust the rewards for' + - '&7the skill with the drop layout. To' + - '&7adjust the chance of a section or to' + - '&7remove a section, then all you have' + - '&7to do is click on the section you''d' + - '&7like to modify and then click the' + - '&7corresponding button.' + - '&7To add a new section click on the' + - '&7emerald block in the bottom middle of' + - '&7the menu in between the page buttons.' + '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 rewards.' + PreviousPage: true + '50': + type: EMERALD_BLOCK + name: '&b&lAdd a New Reward Section' + lore: + - '&7Click here if you would like to add' + - '&7a new reward section to this drop' + - '&7table.' + Button: NewReward + '51': + type: ARROW + name: '&e&lNext Page &e&l&m->' + lore: + - '&7Click here to go to the next' + - '&7page of rewards.' + NextPage: true + '52': + type: GLASS_PANE + name: '&7' + '53': + type: GLASS_PANE + name: '&7' + '54': + type: REDSTONE + name: '&cClick here to go back' + lore: + - '&7Click this button to go back to' + - '&7the drop table main edit menu.' +DropTableNewRewardEditMenu: + name: '&b&lNew Reward for DropTable' + slots: 54 + Settings: + backButton: true + fillTo: 45 + Buttons: + backButton: 54 + Items: + '46': + type: BOOK + name: '&c&lNew Drop Reward Guide' + lore: + - '&7Once you click an item within this' + - '&7menu it will create a new reward' + - '&7section with that selected item' + - '&7to the drop table you were working' + - '&7on. From there you can adjust the' + - '&7chance for it to be sprayed.' + - '&7' + - '&c&lWARNING' + - '&7At this moment you cannot have' + - '&7two sections for the same item,' + - '&7an easy way to bypass this is to' + - '&7add a new Item with the same' + - '&7itemstack, therefore giving it' + - '&7a new name, and allowing for' + - '&7another new section of the same' + - '&7item.' + '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 itemstacks.' + PreviousPage: true + '50': + type: GLASS_PANE + name: '&7' + '51': + type: ARROW + name: '&e&lNext Page &e&l&m->' + lore: + - '&7Click here to go to the next' + - '&7page of itemstacks.' + NextPage: true + '52': + type: GLASS_PANE + name: '&7' + '53': + type: GLASS_PANE + name: '&7' + '54': + type: REDSTONE + name: '&cClick here to go back' + lore: + - '&7Click this button to go back to' + - '&7the drop table reward list menu.' +DropTableRewardMainEditMenu: + name: '&b&l{name} DropTable' + slots: 9 + Settings: + backButton: true + emptySpaceFiller: true + EmptySpaceFiller: + type: WHITE_STAINED_GLASS_PANE + name: '&7' + Buttons: + backButton: 9 + Items: + '3': + type: GUNPOWDER + name: '&e&lSelected ItemStack' + lore: + - '&bCurrently: &f{itemStack}' + - '&7This is the selected itemStack for this' + - '&7reward section.' + '4': + type: EMERALD + name: '&e&lChance' + lore: + - '&bCurrently: &f{chance}' + - '&7Click here to modify the chance of this' + - '&7reward ' + - '&7' + - '&bLeft Click &8» &f+1%' + - '&bShift Left-Click &8» &f+0.1%' + - '&7' + - '&bRight Click &8» &f-1%' + - '&bShift Right-Click &8» &f-0.1%' + Button: Chance + '5': + type: BARRIER + name: '&e&lClick here to remove' + lore: + - '&7Click here to remove this rewards section.' + - '&7You can always re-create this section if' + - '&7was a mistake.' + Button: Remove + '9': + type: REDSTONE + name: '&e&lGo Back' + lore: + - '&7Click here to go back.' \ 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 076ac60..0ffee1c 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java @@ -24,18 +24,21 @@ import com.songoda.epicbosses.panel.bosses.weapons.MainHandEditorPanel; import com.songoda.epicbosses.panel.bosses.weapons.OffHandEditorPanel; import com.songoda.epicbosses.panel.droptables.DropTableTypeEditorPanel; import com.songoda.epicbosses.panel.droptables.MainDropTableEditorPanel; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableNewRewardEditorPanel; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardMainEditorPanel; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardsListEditorPanel; +import com.songoda.epicbosses.panel.droptables.types.drop.DropDropNewRewardPanel; +import com.songoda.epicbosses.panel.droptables.types.drop.DropDropRewardListPanel; +import com.songoda.epicbosses.panel.droptables.types.drop.DropDropRewardMainEditPanel; import com.songoda.epicbosses.panel.droptables.types.drop.DropDropTableMainEditorPanel; -import com.songoda.epicbosses.panel.droptables.types.drop.DropNewRewardEditorPanel; -import com.songoda.epicbosses.panel.droptables.types.drop.DropRewardMainEditorPanel; -import com.songoda.epicbosses.panel.droptables.types.drop.DropRewardsListEditorPanel; import com.songoda.epicbosses.panel.droptables.types.give.GiveRewardMainEditPanel; import com.songoda.epicbosses.panel.droptables.types.give.GiveRewardPositionListPanel; import com.songoda.epicbosses.panel.droptables.types.give.GiveRewardRewardsListPanel; import com.songoda.epicbosses.panel.droptables.types.give.handlers.GiveRewardEditHandler; +import com.songoda.epicbosses.panel.droptables.types.spray.SprayDropNewRewardPanel; +import com.songoda.epicbosses.panel.droptables.types.spray.SprayDropRewardListPanel; +import com.songoda.epicbosses.panel.droptables.types.spray.SprayDropRewardMainEditPanel; import com.songoda.epicbosses.panel.droptables.types.spray.SprayDropTableMainEditorPanel; -import com.songoda.epicbosses.panel.droptables.types.spray.SprayNewRewardEditorPanel; -import com.songoda.epicbosses.panel.droptables.types.spray.SprayRewardMainEditorPanel; -import com.songoda.epicbosses.panel.droptables.types.spray.SprayRewardsListEditorPanel; import com.songoda.epicbosses.panel.handlers.*; import com.songoda.epicbosses.panel.skills.MainSkillEditorPanel; import com.songoda.epicbosses.panel.skills.SkillTypeEditorPanel; @@ -99,15 +102,23 @@ public class BossPanelManager implements ILoadable, IReloadable { @Getter private ISubVariablePanelHandler customSkillTypeEditorMenu, specialSettingsEditorMenu, minionSelectEditorMenu; @Getter private IVariablePanelHandler mainDropTableEditMenu, dropTableTypeEditMenu; - @Getter private ISubVariablePanelHandler sprayDropTableMainEditMenu, sprayRewardListEditMenu, sprayNewRewardEditMenu; - @Getter private ISubSubVariablePanelHandler sprayRewardMainEditMenu; + + @Getter private ISubVariablePanelHandler sprayDropTableMainEditMenu; + @Getter private DropTableRewardMainEditorPanel sprayDropRewardMainEditPanel; + @Getter private DropTableNewRewardEditorPanel sprayDropNewRewardEditPanel; + @Getter private DropTableRewardsListEditorPanel sprayDropRewardListPanel; @Getter private ISubSubVariablePanelHandler giveRewardRewardsListMenu; @Getter private ISubVariablePanelHandler giveRewardPositionListMenu; @Getter private ISubVariablePanelHandler giveRewardMainEditMenu; + @Getter private DropTableRewardMainEditorPanel giveDropRewardMainEditPanel; + @Getter private DropTableNewRewardEditorPanel giveDropNewRewardEditPanel; + @Getter private DropTableRewardsListEditorPanel giveDropRewardListPanel; - @Getter private ISubVariablePanelHandler dropDropTableMainEditMenu, dropRewardListEditMenu, dropNewRewardEditMenu; - @Getter private ISubSubVariablePanelHandler dropRewardMainEditMenu; + @Getter private ISubVariablePanelHandler dropDropTableMainEditMenu; + @Getter private DropTableRewardMainEditorPanel dropDropRewardMainEditPanel; + @Getter private DropTableNewRewardEditorPanel dropDropNewRewardEditPanel; + @Getter private DropTableRewardsListEditorPanel dropDropRewardListPanel; private final CustomBosses customBosses; @@ -223,14 +234,12 @@ public class BossPanelManager implements ILoadable, IReloadable { PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("DropTableMainEditorPanel")); PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("DropTableTypeEditorPanel")); PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); - PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("SprayRewardsListEditMenu")); - PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); - PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("SprayNewRewardEditMenu")); + + PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("DropTableRewardsListEditMenu")); + PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("DropTableNewRewardEditMenu")); + PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("DropTableRewardMainEditMenu")); PanelBuilder panelBuilder6 = new PanelBuilder(editor.getConfigurationSection("DropDropTableMainEditMenu")); - PanelBuilder panelBuilder7 = new PanelBuilder(editor.getConfigurationSection("DropRewardsListEditMenu")); - PanelBuilder panelBuilder8 = new PanelBuilder(editor.getConfigurationSection("DropDropTableMainEditMenu")); - PanelBuilder panelBuilder9 = new PanelBuilder(editor.getConfigurationSection("DropNewRewardEditMenu")); PanelBuilder panelBuilder10 = new PanelBuilder(editor.getConfigurationSection("GiveRewardPositionListMenu")); PanelBuilder panelBuilder11 = new PanelBuilder(editor.getConfigurationSection("GiveRewardRewardsListMenu")); @@ -240,14 +249,14 @@ public class BossPanelManager implements ILoadable, IReloadable { this.dropTableTypeEditMenu = new DropTableTypeEditorPanel(this, panelBuilder1, this.customBosses); this.sprayDropTableMainEditMenu = new SprayDropTableMainEditorPanel(this, panelBuilder2, this.customBosses); - this.sprayRewardListEditMenu = new SprayRewardsListEditorPanel(this, panelBuilder3, this.customBosses); - this.sprayRewardMainEditMenu = new SprayRewardMainEditorPanel(this, panelBuilder4, this.customBosses); - this.sprayNewRewardEditMenu = new SprayNewRewardEditorPanel(this, panelBuilder5, this.customBosses); + this.sprayDropNewRewardEditPanel = new SprayDropNewRewardPanel(this, panelBuilder4, this.customBosses); + this.sprayDropRewardListPanel = new SprayDropRewardListPanel(this, panelBuilder3, this.customBosses); + this.sprayDropRewardMainEditPanel = new SprayDropRewardMainEditPanel(this, panelBuilder5, this.customBosses); this.dropDropTableMainEditMenu = new DropDropTableMainEditorPanel(this, panelBuilder6, this.customBosses); - this.dropRewardListEditMenu = new DropRewardsListEditorPanel(this, panelBuilder7, this.customBosses); - this.dropRewardMainEditMenu = new DropRewardMainEditorPanel(this, panelBuilder8, this.customBosses); - this.dropNewRewardEditMenu = new DropNewRewardEditorPanel(this, panelBuilder9, this.customBosses); + this.dropDropNewRewardEditPanel = new DropDropNewRewardPanel(this, panelBuilder4, this.customBosses); + this.dropDropRewardListPanel = new DropDropRewardListPanel(this, panelBuilder3, this.customBosses); + this.dropDropRewardMainEditPanel = new DropDropRewardMainEditPanel(this, panelBuilder5, this.customBosses); this.giveRewardPositionListMenu = new GiveRewardPositionListPanel(this, panelBuilder10, this.customBosses); this.giveRewardRewardsListMenu = new GiveRewardRewardsListPanel(this, panelBuilder11, this.customBosses); @@ -259,14 +268,12 @@ public class BossPanelManager implements ILoadable, IReloadable { PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("DropTableMainEditorPanel")); PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("DropTableTypeEditorPanel")); PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); - PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("SprayRewardsListEditMenu")); - PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); - PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("SprayNewRewardEditMenu")); + + PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("DropTableRewardsListEditMenu")); + PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("DropTableNewRewardEditMenu")); + PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("DropTableRewardMainEditMenu")); PanelBuilder panelBuilder6 = new PanelBuilder(editor.getConfigurationSection("DropDropTableMainEditMenu")); - PanelBuilder panelBuilder7 = new PanelBuilder(editor.getConfigurationSection("DropRewardsListEditMenu")); - PanelBuilder panelBuilder8 = new PanelBuilder(editor.getConfigurationSection("DropDropTableMainEditMenu")); - PanelBuilder panelBuilder9 = new PanelBuilder(editor.getConfigurationSection("DropNewRewardEditMenu")); PanelBuilder panelBuilder10 = new PanelBuilder(editor.getConfigurationSection("GiveRewardPositionListMenu")); PanelBuilder panelBuilder11 = new PanelBuilder(editor.getConfigurationSection("GiveRewardRewardsListMenu")); @@ -276,14 +283,14 @@ public class BossPanelManager implements ILoadable, IReloadable { this.dropTableTypeEditMenu.initializePanel(panelBuilder1); this.sprayDropTableMainEditMenu.initializePanel(panelBuilder2); - this.sprayRewardListEditMenu.initializePanel(panelBuilder3); - this.sprayRewardMainEditMenu.initializePanel(panelBuilder4); - this.sprayNewRewardEditMenu.initializePanel(panelBuilder5); + this.sprayDropNewRewardEditPanel.initializePanel(panelBuilder4); + this.sprayDropRewardListPanel.initializePanel(panelBuilder5); + this.sprayDropRewardMainEditPanel.initializePanel(panelBuilder3); this.dropDropTableMainEditMenu.initializePanel(panelBuilder6); - this.dropRewardListEditMenu.initializePanel(panelBuilder7); - this.dropRewardMainEditMenu.initializePanel(panelBuilder8); - this.dropNewRewardEditMenu.initializePanel(panelBuilder9); + this.dropDropNewRewardEditPanel.initializePanel(panelBuilder4); + this.dropDropRewardListPanel.initializePanel(panelBuilder5); + this.dropDropRewardMainEditPanel.initializePanel(panelBuilder3); this.giveRewardPositionListMenu.initializePanel(panelBuilder10); this.giveRewardPositionListMenu.initializePanel(panelBuilder11); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropNewRewardEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableNewRewardEditorPanel.java similarity index 61% rename from plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropNewRewardEditorPanel.java rename to plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableNewRewardEditorPanel.java index 7d09fa7..680e47d 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropNewRewardEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableNewRewardEditorPanel.java @@ -1,11 +1,11 @@ -package com.songoda.epicbosses.panel.droptables.types.drop; +package com.songoda.epicbosses.panel.droptables.rewards; import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.api.BossAPI; import com.songoda.epicbosses.droptable.DropTable; -import com.songoda.epicbosses.droptable.elements.DropTableElement; import com.songoda.epicbosses.managers.BossPanelManager; import com.songoda.epicbosses.managers.files.ItemsFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.interfaces.IDropTableNewRewardEditor; import com.songoda.epicbosses.utils.Message; import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder; import com.songoda.epicbosses.utils.panel.Panel; @@ -22,14 +22,14 @@ import java.util.Map; /** * @author Charles Cullen * @version 1.0.0 - * @since 29-Dec-18 + * @since 02-Jan-19 */ -public class DropNewRewardEditorPanel extends SubVariablePanelHandler { +public abstract class DropTableNewRewardEditorPanel extends SubVariablePanelHandler implements IDropTableNewRewardEditor { private ItemsFileManager itemsFileManager; private CustomBosses plugin; - public DropNewRewardEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + public DropTableNewRewardEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { super(bossPanelManager, panelBuilder); this.itemsFileManager = plugin.getItemStackManager(); @@ -37,28 +37,28 @@ public class DropNewRewardEditorPanel extends SubVariablePanelHandler itemStacks = this.itemsFileManager.getItemStackHolders(); - List currentKeys = new ArrayList<>(dropTableElement.getDropRewards().keySet()); + List currentKeys = getCurrentKeys(subVariable); List filteredKeys = getFilteredKeys(itemStacks, currentKeys); int maxPage = panel.getMaxPage(filteredKeys); panel.setOnPageChange(((player, currentPage, requestedPage) -> { if(requestedPage < 0 || requestedPage > maxPage) return false; - loadPage(panel, requestedPage, dropTable, dropTableElement, filteredKeys, itemStacks); + loadPage(panel, requestedPage, dropTable, subVariable, filteredKeys, itemStacks); return true; })); - loadPage(panel, 0, dropTable, dropTableElement, filteredKeys, itemStacks); + loadPage(panel, 0, dropTable, subVariable, filteredKeys, itemStacks); } @Override - public void openFor(Player player, DropTable dropTable, DropTableElement dropTableElement) { + public void openFor(Player player, DropTable dropTable, SubVariable subVariable) { Panel panel = getPanelBuilder().getPanel() - .setParentPanelHandler(this.bossPanelManager.getDropRewardListEditMenu(), dropTable, dropTableElement); + .setParentPanelHandler(getParentPanelHandler(), dropTable, subVariable); - fillPanel(panel, dropTable, dropTableElement); + fillPanel(panel, dropTable, subVariable); panel.openFor(player); } @@ -67,7 +67,7 @@ public class DropNewRewardEditorPanel extends SubVariablePanelHandler filteredKeys, Map itemStacks) { + private void loadPage(Panel panel, int page, DropTable dropTable, SubVariable subVariable, List filteredKeys, Map itemStacks) { panel.loadPage(page, (slot, realisticSlot) -> { if(slot >= filteredKeys.size()) { panel.setItem(realisticSlot, new ItemStack(Material.AIR), e->{}); @@ -77,14 +77,13 @@ public class DropNewRewardEditorPanel extends SubVariablePanelHandler { - Map currentRewards = dropTableElement.getDropRewards(); + Map currentRewards = getRewards(subVariable); currentRewards.put(name, 50.0); - dropTable.setRewards(BossAPI.convertObjectToJsonObject(dropTableElement)); - this.plugin.getDropTableFileManager().save(); + saveDropTable(this.plugin.getDropTableFileManager(), dropTable, subVariable); - this.bossPanelManager.getDropRewardMainEditMenu().openFor((Player) event.getWhoClicked(), dropTable, dropTableElement, name); - Message.Boss_DropTable_DropAddedNewReward.msg(event.getWhoClicked(), BossAPI.getDropTableName(dropTable)); + getRewardMainEditMenu().openFor((Player) event.getWhoClicked(), dropTable, subVariable, name); + Message.Boss_DropTable_AddedNewReward.msg(event.getWhoClicked(), BossAPI.getDropTableName(dropTable)); }); } }); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayRewardMainEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardMainEditorPanel.java similarity index 54% rename from plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayRewardMainEditorPanel.java rename to plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardMainEditorPanel.java index a3c2f97..fcff0b5 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayRewardMainEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardMainEditorPanel.java @@ -1,14 +1,14 @@ -package com.songoda.epicbosses.panel.droptables.types.spray; +package com.songoda.epicbosses.panel.droptables.rewards; import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.api.BossAPI; import com.songoda.epicbosses.droptable.DropTable; -import com.songoda.epicbosses.droptable.elements.SprayTableElement; import com.songoda.epicbosses.managers.BossPanelManager; import com.songoda.epicbosses.managers.files.DropTableFileManager; -import com.songoda.epicbosses.skills.Skill; +import com.songoda.epicbosses.panel.droptables.rewards.interfaces.IDropTableRewardMainEditor; import com.songoda.epicbosses.utils.Message; import com.songoda.epicbosses.utils.NumberUtils; +import com.songoda.epicbosses.utils.ObjectUtils; import com.songoda.epicbosses.utils.panel.Panel; import com.songoda.epicbosses.utils.panel.base.ClickAction; import com.songoda.epicbosses.utils.panel.base.handlers.SubSubVariablePanelHandler; @@ -23,36 +23,34 @@ import java.util.Map; /** * @author Charles Cullen * @version 1.0.0 - * @since 28-Dec-18 + * @since 02-Jan-19 */ -public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler { +public abstract class DropTableRewardMainEditorPanel extends SubSubVariablePanelHandler implements IDropTableRewardMainEditor { private DropTableFileManager dropTableFileManager; - public SprayRewardMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + public DropTableRewardMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { super(bossPanelManager, panelBuilder); this.dropTableFileManager = plugin.getDropTableFileManager(); } @Override - public void openFor(Player player, DropTable dropTable, SprayTableElement sprayTableElement, String string) { + public void openFor(Player player, DropTable dropTable, SubVariable subVariable, String s) { PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); Map replaceMap = new HashMap<>(); - Double chance = sprayTableElement.getSprayRewards().get(string); - - if(chance == null) chance = 50.0; + double chance = ObjectUtils.getValue(getChance(subVariable, s), 50.0); replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance)); - replaceMap.put("{itemStack}", string); + replaceMap.put("{itemStack}", s); panelBuilder.addReplaceData(replaceMap); PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter(); Panel panel = panelBuilder.getPanel() - .setParentPanelHandler(this.bossPanelManager.getSprayRewardListEditMenu(), dropTable, sprayTableElement); + .setParentPanelHandler(getParentPanelHandler(), dropTable, subVariable); - panelBuilderCounter.getSlotsWith("Chance").forEach(slot -> panel.setOnClick(slot, getChanceAction(dropTable, sprayTableElement, string))); - panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, getRemoveAction(dropTable, sprayTableElement, string))); + panelBuilderCounter.getSlotsWith("Chance").forEach(slot -> panel.setOnClick(slot, getChanceAction(dropTable, subVariable, s))); + panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, getRemoveAction(dropTable, subVariable, s))); panel.openFor(player); } @@ -62,7 +60,7 @@ public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler { ClickType clickType = event.getClick(); double amountToModifyBy; @@ -78,7 +76,7 @@ public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler 0? "increased" : "decreased"; - Map rewards = sprayTableElement.getSprayRewards(); + Map rewards = getRewards(subVariable); double currentValue = rewards.getOrDefault(name, 50.0); double newValue = currentValue + amountToModifyBy; @@ -91,29 +89,24 @@ public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler { - Map current = sprayTableElement.getSprayRewards(); + Map rewards = getRewards(subVariable); - current.remove(name); - sprayTableElement.setSprayRewards(current); - save(dropTable, sprayTableElement); + rewards.remove(name); + setRewards(subVariable, rewards); + saveDropTable(this.dropTableFileManager, dropTable, subVariable); - Message.Boss_DropTable_SprayRewardRemoved.msg(event.getWhoClicked()); - this.bossPanelManager.getSprayRewardListEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement); + Message.Boss_DropTable_RewardRemoved.msg(event.getWhoClicked()); + getParentPanelHandler().openFor((Player) event.getWhoClicked(), dropTable, subVariable); }; } - - private void save(DropTable dropTable, SprayTableElement sprayTableElement) { - dropTable.setRewards(BossAPI.convertObjectToJsonObject(sprayTableElement)); - this.dropTableFileManager.save(); - } } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropRewardsListEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardsListEditorPanel.java similarity index 67% rename from plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropRewardsListEditorPanel.java rename to plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardsListEditorPanel.java index 61d3e36..c236a21 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropRewardsListEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/DropTableRewardsListEditorPanel.java @@ -1,11 +1,11 @@ -package com.songoda.epicbosses.panel.droptables.types.drop; +package com.songoda.epicbosses.panel.droptables.rewards; import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.api.BossAPI; import com.songoda.epicbosses.droptable.DropTable; -import com.songoda.epicbosses.droptable.elements.DropTableElement; import com.songoda.epicbosses.managers.BossPanelManager; import com.songoda.epicbosses.managers.files.ItemsFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.interfaces.IDropTableRewardsListEditor; import com.songoda.epicbosses.utils.NumberUtils; import com.songoda.epicbosses.utils.itemstack.ItemStackUtils; import com.songoda.epicbosses.utils.panel.Panel; @@ -24,14 +24,14 @@ import java.util.Map; /** * @author Charles Cullen * @version 1.0.0 - * @since 29-Dec-18 + * @since 02-Jan-19 */ -public class DropRewardsListEditorPanel extends SubVariablePanelHandler { +public abstract class DropTableRewardsListEditorPanel extends SubVariablePanelHandler implements IDropTableRewardsListEditor { private ItemsFileManager itemsFileManager; private CustomBosses plugin; - public DropRewardsListEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + public DropTableRewardsListEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { super(bossPanelManager, panelBuilder); this.plugin = plugin; @@ -39,23 +39,23 @@ public class DropRewardsListEditorPanel extends SubVariablePanelHandler rewardMap = dropTableElement.getDropRewards(); + public void fillPanel(Panel panel, DropTable dropTable, SubVariable subVariable) { + Map rewardMap = getRewards(subVariable); List keyList = new ArrayList<>(rewardMap.keySet()); int maxPage = panel.getMaxPage(keyList); - panel.setOnPageChange(((player, currentPage, requestedPage) -> { + panel.setOnPageChange((player, currentPage, requestedPage) -> { if(requestedPage < 0 || requestedPage > maxPage) return false; - loadPage(panel, requestedPage, dropTable, dropTableElement, rewardMap, keyList); + loadPage(panel, requestedPage, dropTable, subVariable, rewardMap, keyList); return true; - })); + }); - loadPage(panel, 0, dropTable, dropTableElement, rewardMap, keyList); + loadPage(panel, 0, dropTable, subVariable, rewardMap, keyList); } @Override - public void openFor(Player player, DropTable dropTable, DropTableElement dropTableElement) { + public void openFor(Player player, DropTable dropTable, SubVariable subVariable) { PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); Map replaceMap = new HashMap<>(); @@ -64,10 +64,10 @@ public class DropRewardsListEditorPanel extends SubVariablePanelHandler panel.setOnClick(slot, event -> this.bossPanelManager.getDropNewRewardEditMenu().openFor((Player) event.getWhoClicked(), dropTable, dropTableElement))); - fillPanel(panel, dropTable, dropTableElement); + panelBuilderCounter.getSlotsWith("NewReward").forEach(slot -> panel.setOnClick(slot, event -> getNewRewardPanelHandler().openFor((Player) event.getWhoClicked(), dropTable, subVariable))); + fillPanel(panel, dropTable, subVariable); panel.openFor(player); } @@ -77,7 +77,7 @@ public class DropRewardsListEditorPanel extends SubVariablePanelHandler rewardMap, List keyList) { + private void loadPage(Panel panel, int page, DropTable dropTable, SubVariable subVariable, Map rewardMap, List keyList) { panel.loadPage(page, (slot, realisticSlot) -> { if(slot >= keyList.size()) { panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {}); @@ -96,8 +96,8 @@ public class DropRewardsListEditorPanel extends SubVariablePanelHandler this.bossPanelManager.getDropRewardMainEditMenu().openFor((Player) event.getWhoClicked(), dropTable, dropTableElement, name)); + panel.setItem(realisticSlot, itemStack, event -> getRewardMainEditPanel().openFor((Player) event.getWhoClicked(), dropTable, subVariable, name)); } }); } -} \ No newline at end of file +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableNewRewardEditor.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableNewRewardEditor.java new file mode 100644 index 0000000..883513b --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableNewRewardEditor.java @@ -0,0 +1,28 @@ +package com.songoda.epicbosses.panel.droptables.rewards.interfaces; + +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; + +import java.util.List; +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public interface IDropTableNewRewardEditor { + + List getCurrentKeys(SubVariable subVariable); + + ISubVariablePanelHandler getParentPanelHandler(); + + Map getRewards(SubVariable subVariable); + + void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, SubVariable subVariable); + + ISubSubVariablePanelHandler getRewardMainEditMenu(); + +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableRewardMainEditor.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableRewardMainEditor.java new file mode 100644 index 0000000..8819474 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableRewardMainEditor.java @@ -0,0 +1,26 @@ +package com.songoda.epicbosses.panel.droptables.rewards.interfaces; + +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public interface IDropTableRewardMainEditor { + + double getChance(SubVariable subVariable, String name); + + ISubVariablePanelHandler getParentPanelHandler(); + + Map getRewards(SubVariable subVariable); + + void setRewards(SubVariable subVariable, Map rewards); + + void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, SubVariable subVariable); + +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableRewardsListEditor.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableRewardsListEditor.java new file mode 100644 index 0000000..8a7b809 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/rewards/interfaces/IDropTableRewardsListEditor.java @@ -0,0 +1,24 @@ +package com.songoda.epicbosses.panel.droptables.rewards.interfaces; + +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public interface IDropTableRewardsListEditor { + + Map getRewards(SubVariable subVariable); + + ISubVariablePanelHandler getParentPanelHandler(); + + ISubVariablePanelHandler getNewRewardPanelHandler(); + + ISubSubVariablePanelHandler getRewardMainEditPanel(); + +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropNewRewardPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropNewRewardPanel.java new file mode 100644 index 0000000..c18b1e7 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropNewRewardPanel.java @@ -0,0 +1,54 @@ +package com.songoda.epicbosses.panel.droptables.types.drop; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.DropTableElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableNewRewardEditorPanel; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class DropDropNewRewardPanel extends DropTableNewRewardEditorPanel { + + public DropDropNewRewardPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public List getCurrentKeys(DropTableElement dropTableElement) { + return new ArrayList<>(dropTableElement.getDropRewards().keySet()); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getDropDropRewardListPanel(); + } + + @Override + public Map getRewards(DropTableElement dropTableElement) { + return dropTableElement.getDropRewards(); + } + + @Override + public void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, DropTableElement dropTableElement) { + dropTable.setRewards(BossAPI.convertObjectToJsonObject(dropTableElement)); + dropTableFileManager.save(); + } + + @Override + public ISubSubVariablePanelHandler getRewardMainEditMenu() { + return this.bossPanelManager.getDropDropRewardMainEditPanel(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropRewardListPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropRewardListPanel.java new file mode 100644 index 0000000..6586443 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropRewardListPanel.java @@ -0,0 +1,44 @@ +package com.songoda.epicbosses.panel.droptables.types.drop; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.DropTableElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardsListEditorPanel; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class DropDropRewardListPanel extends DropTableRewardsListEditorPanel { + + public DropDropRewardListPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public Map getRewards(DropTableElement dropTableElement) { + return dropTableElement.getDropRewards(); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getDropDropTableMainEditMenu(); + } + + @Override + public ISubVariablePanelHandler getNewRewardPanelHandler() { + return this.bossPanelManager.getDropDropNewRewardEditPanel(); + } + + @Override + public ISubSubVariablePanelHandler getRewardMainEditPanel() { + return this.bossPanelManager.getDropDropRewardMainEditPanel(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropRewardMainEditPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropRewardMainEditPanel.java new file mode 100644 index 0000000..98c29c5 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropRewardMainEditPanel.java @@ -0,0 +1,53 @@ +package com.songoda.epicbosses.panel.droptables.types.drop; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.DropTableElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardMainEditorPanel; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class DropDropRewardMainEditPanel extends DropTableRewardMainEditorPanel { + + public DropDropRewardMainEditPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public double getChance(DropTableElement dropTableElement, String name) { + Map dropMap = dropTableElement.getDropRewards(); + + return dropMap.getOrDefault(name, 50.0); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getDropDropRewardListPanel(); + } + + @Override + public Map getRewards(DropTableElement dropTableElement) { + return dropTableElement.getDropRewards(); + } + + @Override + public void setRewards(DropTableElement dropTableElement, Map rewards) { + dropTableElement.setDropRewards(rewards); + } + + @Override + public void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, DropTableElement dropTableElement) { + dropTable.setRewards(BossAPI.convertObjectToJsonObject(dropTableElement)); + dropTableFileManager.save(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropTableMainEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropTableMainEditorPanel.java index 1ce90a2..cf87d34 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropTableMainEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropDropTableMainEditorPanel.java @@ -59,7 +59,7 @@ public class DropDropTableMainEditorPanel extends SubVariablePanelHandler panel.setOnClick(slot, event -> this.bossPanelManager.getDropRewardListEditMenu().openFor((Player) event.getWhoClicked(), dropTable, dropTableElement))); + panelBuilderCounter.getSlotsWith("Rewards").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getDropDropRewardListPanel().openFor((Player) event.getWhoClicked(), dropTable, dropTableElement))); panelBuilderCounter.getSlotsWith("RandomDrops").forEach(slot -> panel.setOnClick(slot, getRandomDropsAction(dropTable, dropTableElement))); panelBuilderCounter.getSlotsWith("MaxDrops").forEach(slot -> panel.setOnClick(slot, getMaxDropsAction(dropTable, dropTableElement))); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropRewardMainEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropRewardMainEditorPanel.java deleted file mode 100644 index 3b0ff3a..0000000 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/drop/DropRewardMainEditorPanel.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.songoda.epicbosses.panel.droptables.types.drop; - -import com.songoda.epicbosses.CustomBosses; -import com.songoda.epicbosses.api.BossAPI; -import com.songoda.epicbosses.droptable.DropTable; -import com.songoda.epicbosses.droptable.elements.DropTableElement; -import com.songoda.epicbosses.droptable.elements.SprayTableElement; -import com.songoda.epicbosses.managers.BossPanelManager; -import com.songoda.epicbosses.managers.files.DropTableFileManager; -import com.songoda.epicbosses.utils.Message; -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.SubSubVariablePanelHandler; -import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; -import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Charles Cullen - * @version 1.0.0 - * @since 29-Dec-18 - */ -public class DropRewardMainEditorPanel extends SubSubVariablePanelHandler { - - private DropTableFileManager dropTableFileManager; - - public DropRewardMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { - super(bossPanelManager, panelBuilder); - - this.dropTableFileManager = plugin.getDropTableFileManager(); - } - - @Override - public void openFor(Player player, DropTable dropTable, DropTableElement dropTableElement, String s) { - PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder(); - Map replaceMap = new HashMap<>(); - Double chance = dropTableElement.getDropRewards().get(s); - - if(chance == null) chance = 50.0; - - replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance)); - replaceMap.put("{itemStack}", s); - panelBuilder.addReplaceData(replaceMap); - - PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter(); - Panel panel = panelBuilder.getPanel() - .setParentPanelHandler(this.bossPanelManager.getDropRewardListEditMenu(), dropTable, dropTableElement); - - panelBuilderCounter.getSlotsWith("Chance").forEach(slot -> panel.setOnClick(slot, getChanceAction(dropTable, dropTableElement, s))); - panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, getRemoveAction(dropTable, dropTableElement, s))); - - panel.openFor(player); - } - - @Override - public void initializePanel(PanelBuilder panelBuilder) { - - } - - private ClickAction getChanceAction(DropTable dropTable, DropTableElement dropTableElement, String name) { - return event -> { - ClickType clickType = event.getClick(); - double amountToModifyBy; - - if(clickType == ClickType.SHIFT_LEFT) { - amountToModifyBy = 0.1; - } else if(clickType == ClickType.RIGHT) { - amountToModifyBy = -1.0; - } else if(clickType == ClickType.SHIFT_RIGHT) { - amountToModifyBy = -0.1; - } else { - amountToModifyBy = 1.0; - } - - String modifyValue = amountToModifyBy > 0? "increased" : "decreased"; - Map rewards = dropTableElement.getDropRewards(); - double currentValue = rewards.getOrDefault(name, 50.0); - double newValue = currentValue + amountToModifyBy; - - if(newValue < 0) { - newValue = 0; - } - - if(newValue > 100) { - newValue = 100; - } - - rewards.put(name, newValue); - dropTableElement.setDropRewards(rewards); - save(dropTable, dropTableElement); - openFor((Player) event.getWhoClicked(), dropTable, dropTableElement, name); - - Message.Boss_DropTable_DropRewardChance.msg(event.getWhoClicked(), modifyValue, BossAPI.getDropTableName(dropTable), NumberUtils.get().formatDouble(newValue)); - }; - } - - private ClickAction getRemoveAction(DropTable dropTable, DropTableElement dropTableElement, String name) { - return event -> { - Map current = dropTableElement.getDropRewards(); - - current.remove(name); - dropTableElement.setDropRewards(current); - save(dropTable, dropTableElement); - - Message.Boss_DropTable_DropRewardRemoved.msg(event.getWhoClicked()); - this.bossPanelManager.getDropRewardListEditMenu().openFor((Player) event.getWhoClicked(), dropTable, dropTableElement); - }; - } - - private void save(DropTable dropTable, DropTableElement dropTableElement) { - dropTable.setRewards(BossAPI.convertObjectToJsonObject(dropTableElement)); - this.dropTableFileManager.save(); - } -} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropNewRewardPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropNewRewardPanel.java new file mode 100644 index 0000000..0cdc56b --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropNewRewardPanel.java @@ -0,0 +1,64 @@ +package com.songoda.epicbosses.panel.droptables.types.give.drops; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.GiveTableElement; +import com.songoda.epicbosses.droptable.elements.GiveTableSubElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableNewRewardEditorPanel; +import com.songoda.epicbosses.panel.droptables.types.give.handlers.GiveRewardEditHandler; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class GiveDropNewRewardPanel extends DropTableNewRewardEditorPanel { + + public GiveDropNewRewardPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public List getCurrentKeys(GiveRewardEditHandler giveRewardEditHandler) { + return new ArrayList<>(giveRewardEditHandler.getGiveTableSubElement().getItems().keySet()); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getGiveDropRewardListPanel(); + } + + @Override + public Map getRewards(GiveRewardEditHandler giveRewardEditHandler) { + return giveRewardEditHandler.getGiveTableSubElement().getItems(); + } + + @Override + public void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, GiveRewardEditHandler giveRewardEditHandler) { + GiveTableSubElement giveTableSubElement = giveRewardEditHandler.getGiveTableSubElement(); + GiveTableElement giveTableElement = giveRewardEditHandler.getGiveTableElement(); + Map> positionMap = giveTableElement.getGiveRewards(); + Map rewardMap = positionMap.get(giveRewardEditHandler.getDamagePosition()); + + rewardMap.put(giveRewardEditHandler.getDropSection(), giveTableSubElement); + positionMap.put(giveRewardEditHandler.getDamagePosition(), rewardMap); + giveTableElement.setGiveRewards(positionMap); + dropTable.setRewards(BossAPI.convertObjectToJsonObject(giveTableElement)); + dropTableFileManager.save(); + } + + @Override + public ISubSubVariablePanelHandler getRewardMainEditMenu() { + return this.bossPanelManager.getGiveDropRewardMainEditPanel(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropRewardListPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropRewardListPanel.java new file mode 100644 index 0000000..5d0087b --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropRewardListPanel.java @@ -0,0 +1,44 @@ +package com.songoda.epicbosses.panel.droptables.types.give.drops; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardsListEditorPanel; +import com.songoda.epicbosses.panel.droptables.types.give.handlers.GiveRewardEditHandler; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class GiveDropRewardListPanel extends DropTableRewardsListEditorPanel { + + public GiveDropRewardListPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public Map getRewards(GiveRewardEditHandler giveRewardEditHandler) { + return giveRewardEditHandler.getGiveTableSubElement().getItems(); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getGiveRewardMainEditMenu(); + } + + @Override + public ISubVariablePanelHandler getNewRewardPanelHandler() { + return this.bossPanelManager.getGiveDropNewRewardEditPanel(); + } + + @Override + public ISubSubVariablePanelHandler getRewardMainEditPanel() { + return this.bossPanelManager.getGiveDropRewardMainEditPanel(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropRewardMainEditPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropRewardMainEditPanel.java new file mode 100644 index 0000000..d848b40 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveDropRewardMainEditPanel.java @@ -0,0 +1,63 @@ +package com.songoda.epicbosses.panel.droptables.types.give.drops; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.GiveTableElement; +import com.songoda.epicbosses.droptable.elements.GiveTableSubElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardMainEditorPanel; +import com.songoda.epicbosses.panel.droptables.types.give.handlers.GiveRewardEditHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class GiveDropRewardMainEditPanel extends DropTableRewardMainEditorPanel { + + public GiveDropRewardMainEditPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public double getChance(GiveRewardEditHandler giveRewardEditHandler, String name) { + Map dropMap = giveRewardEditHandler.getGiveTableSubElement().getItems(); + + return dropMap.getOrDefault(name, 50.0); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getGiveDropRewardListPanel(); + } + + @Override + public Map getRewards(GiveRewardEditHandler giveRewardEditHandler) { + return giveRewardEditHandler.getGiveTableSubElement().getItems(); + } + + @Override + public void setRewards(GiveRewardEditHandler giveRewardEditHandler, Map rewards) { + giveRewardEditHandler.getGiveTableSubElement().setItems(rewards); + } + + @Override + public void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, GiveRewardEditHandler giveRewardEditHandler) { + GiveTableSubElement giveTableSubElement = giveRewardEditHandler.getGiveTableSubElement(); + GiveTableElement giveTableElement = giveRewardEditHandler.getGiveTableElement(); + Map> positionMap = giveTableElement.getGiveRewards(); + Map rewardMap = positionMap.get(giveRewardEditHandler.getDamagePosition()); + + rewardMap.put(giveRewardEditHandler.getDropSection(), giveTableSubElement); + positionMap.put(giveRewardEditHandler.getDamagePosition(), rewardMap); + giveTableElement.setGiveRewards(positionMap); + dropTable.setRewards(BossAPI.convertObjectToJsonObject(giveTableElement)); + dropTableFileManager.save(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsListEditPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsListEditPanel.java deleted file mode 100644 index 5d19f8b..0000000 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsListEditPanel.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.songoda.epicbosses.panel.droptables.types.give.drops; - -import com.songoda.epicbosses.CustomBosses; -import com.songoda.epicbosses.api.BossAPI; -import com.songoda.epicbosses.droptable.DropTable; -import com.songoda.epicbosses.droptable.elements.GiveTableSubElement; -import com.songoda.epicbosses.droptable.elements.SprayTableElement; -import com.songoda.epicbosses.managers.BossPanelManager; -import com.songoda.epicbosses.managers.files.ItemsFileManager; -import com.songoda.epicbosses.panel.droptables.types.give.handlers.GiveRewardEditHandler; -import com.songoda.epicbosses.utils.NumberUtils; -import com.songoda.epicbosses.utils.itemstack.ItemStackUtils; -import com.songoda.epicbosses.utils.panel.Panel; -import com.songoda.epicbosses.utils.panel.base.handlers.SubVariablePanelHandler; -import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; -import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Charles Cullen - * @version 1.0.0 - * @since 02-Jan-19 - */ -public class GiveRewardDropsListEditPanel extends SubVariablePanelHandler { - - private ItemsFileManager itemsFileManager; - private CustomBosses plugin; - - public GiveRewardDropsListEditPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { - super(bossPanelManager, panelBuilder); - - this.itemsFileManager = plugin.getItemStackManager(); - this.plugin = plugin; - } - - @Override - public void fillPanel(Panel panel, DropTable dropTable, GiveRewardEditHandler giveRewardEditHandler) { - GiveTableSubElement giveTableSubElement = giveRewardEditHandler.getGiveTableSubElement(); - Map rewardMap = giveTableSubElement.getItems(); - List keyList = new ArrayList<>(); - int maxPage = panel.getMaxPage(keyList); - - panel.setOnPageChange((player, currentPage, requestedPage) -> { - if(requestedPage < 0 || requestedPage > maxPage) return false; - - loadPage(panel, requestedPage, dropTable, giveRewardEditHandler, rewardMap, keyList); - return true; - }); - - loadPage(panel, 0, dropTable, giveRewardEditHandler, rewardMap, keyList); - } - - @Override - public void openFor(Player player, DropTable dropTable, GiveRewardEditHandler giveRewardEditHandler) { - 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.getGiveRewardMainEditMenu(), dropTable, giveRewardEditHandler); - -// panelBuilderCounter.getSlotsWith("NewReward").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getSprayNewRewardEditMenu().openFor((Player) event.getWhoClicked(), dropTable, giveRewardEditHandler))); - fillPanel(panel, dropTable, giveRewardEditHandler); - - panel.openFor(player); - } - - @Override - public void initializePanel(PanelBuilder panelBuilder) { - - } - - private void loadPage(Panel panel, int page, DropTable dropTable, GiveRewardEditHandler giveRewardEditHandler, Map rewardMap, List keyList) { - panel.loadPage(page, (slot, realisticSlot) -> { - if(slot >= keyList.size()) { - panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {}); - } else { - String name = keyList.get(slot); - Double chance = rewardMap.get(name); - Map replaceMap = new HashMap<>(); - - if(chance == null) chance = 100.0; - - replaceMap.put("{itemName}", name); - replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance)); - - ItemStack itemStack = this.itemsFileManager.getItemStackConverter().from(this.itemsFileManager.getItemStackHolder(name)); - - ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.DropTable.RewardList.name"), replaceMap); - ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.DropTable.RewardList.lore"), replaceMap); - -// panel.setItem(realisticSlot, itemStack, event -> this.bossPanelManager.getSprayRewardMainEditMenu().openFor((Player) event.getWhoClicked(), dropTable, giveRewardEditHandler, name)); - } - }); - } -} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsMainEditPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsMainEditPanel.java deleted file mode 100644 index edba557..0000000 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsMainEditPanel.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.songoda.epicbosses.panel.droptables.types.give.drops; - -/** - * @author Charles Cullen - * @version 1.0.0 - * @since 02-Jan-19 - */ -public class GiveRewardDropsMainEditPanel { -} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsNewDropEditPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsNewDropEditPanel.java deleted file mode 100644 index 421a195..0000000 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/give/drops/GiveRewardDropsNewDropEditPanel.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.songoda.epicbosses.panel.droptables.types.give.drops; - -/** - * @author Charles Cullen - * @version 1.0.0 - * @since 02-Jan-19 - */ -public class GiveRewardDropsNewDropEditPanel { -} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropNewRewardPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropNewRewardPanel.java new file mode 100644 index 0000000..138264f --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropNewRewardPanel.java @@ -0,0 +1,54 @@ +package com.songoda.epicbosses.panel.droptables.types.spray; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.SprayTableElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableNewRewardEditorPanel; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class SprayDropNewRewardPanel extends DropTableNewRewardEditorPanel { + + public SprayDropNewRewardPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public List getCurrentKeys(SprayTableElement sprayTableElement) { + return new ArrayList<>(sprayTableElement.getSprayRewards().keySet()); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getSprayDropRewardListPanel(); + } + + @Override + public Map getRewards(SprayTableElement sprayTableElement) { + return sprayTableElement.getSprayRewards(); + } + + @Override + public void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, SprayTableElement sprayTableElement) { + dropTable.setRewards(BossAPI.convertObjectToJsonObject(sprayTableElement)); + dropTableFileManager.save(); + } + + @Override + public ISubSubVariablePanelHandler getRewardMainEditMenu() { + return this.bossPanelManager.getSprayDropRewardMainEditPanel(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropRewardListPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropRewardListPanel.java new file mode 100644 index 0000000..9b4fee1 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropRewardListPanel.java @@ -0,0 +1,44 @@ +package com.songoda.epicbosses.panel.droptables.types.spray; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.SprayTableElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardsListEditorPanel; +import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class SprayDropRewardListPanel extends DropTableRewardsListEditorPanel { + + public SprayDropRewardListPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public Map getRewards(SprayTableElement sprayTableElement) { + return sprayTableElement.getSprayRewards(); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getSprayDropTableMainEditMenu(); + } + + @Override + public ISubVariablePanelHandler getNewRewardPanelHandler() { + return this.bossPanelManager.getSprayDropNewRewardEditPanel(); + } + + @Override + public ISubSubVariablePanelHandler getRewardMainEditPanel() { + return this.bossPanelManager.getSprayDropRewardMainEditPanel(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropRewardMainEditPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropRewardMainEditPanel.java new file mode 100644 index 0000000..a758edc --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropRewardMainEditPanel.java @@ -0,0 +1,53 @@ +package com.songoda.epicbosses.panel.droptables.types.spray; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; +import com.songoda.epicbosses.droptable.DropTable; +import com.songoda.epicbosses.droptable.elements.SprayTableElement; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.files.DropTableFileManager; +import com.songoda.epicbosses.panel.droptables.rewards.DropTableRewardMainEditorPanel; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; + +import java.util.Map; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 02-Jan-19 + */ +public class SprayDropRewardMainEditPanel extends DropTableRewardMainEditorPanel { + + public SprayDropRewardMainEditPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder, plugin); + } + + @Override + public double getChance(SprayTableElement sprayTableElement, String name) { + Map dropMap = sprayTableElement.getSprayRewards(); + + return dropMap.getOrDefault(name, 50.0); + } + + @Override + public ISubVariablePanelHandler getParentPanelHandler() { + return this.bossPanelManager.getSprayDropRewardListPanel(); + } + + @Override + public Map getRewards(SprayTableElement sprayTableElement) { + return sprayTableElement.getSprayRewards(); + } + + @Override + public void setRewards(SprayTableElement sprayTableElement, Map rewards) { + sprayTableElement.setSprayRewards(rewards); + } + + @Override + public void saveDropTable(DropTableFileManager dropTableFileManager, DropTable dropTable, SprayTableElement sprayTableElement) { + dropTable.setRewards(BossAPI.convertObjectToJsonObject(sprayTableElement)); + dropTableFileManager.save(); + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropTableMainEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropTableMainEditorPanel.java index dc56821..0ba6e57 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropTableMainEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayDropTableMainEditorPanel.java @@ -62,7 +62,7 @@ public class SprayDropTableMainEditorPanel extends SubVariablePanelHandler panel.setOnClick(slot, event -> this.bossPanelManager.getSprayRewardListEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement))); + panelBuilderCounter.getSlotsWith("Rewards").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getSprayDropRewardListPanel().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement))); panelBuilderCounter.getSlotsWith("RandomDrops").forEach(slot -> panel.setOnClick(slot, getRandomDropsAction(dropTable, sprayTableElement))); panelBuilderCounter.getSlotsWith("MaxDistance").forEach(slot -> panel.setOnClick(slot, getMaxDistanceAction(dropTable, sprayTableElement))); panelBuilderCounter.getSlotsWith("MaxDrops").forEach(slot -> panel.setOnClick(slot, getMaxDropsAction(dropTable, sprayTableElement))); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayNewRewardEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayNewRewardEditorPanel.java deleted file mode 100644 index f103122..0000000 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayNewRewardEditorPanel.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.songoda.epicbosses.panel.droptables.types.spray; - -import com.songoda.epicbosses.CustomBosses; -import com.songoda.epicbosses.api.BossAPI; -import com.songoda.epicbosses.droptable.DropTable; -import com.songoda.epicbosses.droptable.elements.SprayTableElement; -import com.songoda.epicbosses.managers.BossPanelManager; -import com.songoda.epicbosses.managers.files.ItemsFileManager; -import com.songoda.epicbosses.utils.Message; -import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder; -import com.songoda.epicbosses.utils.panel.Panel; -import com.songoda.epicbosses.utils.panel.base.handlers.SubVariablePanelHandler; -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; -import java.util.List; -import java.util.Map; - -/** - * @author Charles Cullen - * @version 1.0.0 - * @since 28-Dec-18 - */ -public class SprayNewRewardEditorPanel extends SubVariablePanelHandler { - - private ItemsFileManager itemsFileManager; - private CustomBosses plugin; - - public SprayNewRewardEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { - super(bossPanelManager, panelBuilder); - - this.itemsFileManager = plugin.getItemStackManager(); - this.plugin = plugin; - } - - @Override - public void fillPanel(Panel panel, DropTable dropTable, SprayTableElement sprayTableElement) { - Map itemStacks = this.itemsFileManager.getItemStackHolders(); - List currentKeys = new ArrayList<>(sprayTableElement.getSprayRewards().keySet()); - List filteredKeys = getFilteredKeys(itemStacks, currentKeys); - int maxPage = panel.getMaxPage(filteredKeys); - - panel.setOnPageChange(((player, currentPage, requestedPage) -> { - if(requestedPage < 0 || requestedPage > maxPage) return false; - - loadPage(panel, requestedPage, dropTable, sprayTableElement, filteredKeys, itemStacks); - return true; - })); - - loadPage(panel, 0, dropTable, sprayTableElement, filteredKeys, itemStacks); - } - - @Override - public void openFor(Player player, DropTable dropTable, SprayTableElement sprayTableElement) { - Panel panel = getPanelBuilder().getPanel() - .setParentPanelHandler(this.bossPanelManager.getSprayRewardListEditMenu(), dropTable, sprayTableElement); - - fillPanel(panel, dropTable, sprayTableElement); - panel.openFor(player); - } - - @Override - public void initializePanel(PanelBuilder panelBuilder) { - - } - - private void loadPage(Panel panel, int page, DropTable dropTable, SprayTableElement sprayTableElement, List filteredKeys, Map itemStacks) { - panel.loadPage(page, (slot, realisticSlot) -> { - if(slot >= filteredKeys.size()) { - panel.setItem(realisticSlot, new ItemStack(Material.AIR), e->{}); - } else { - String name = filteredKeys.get(slot); - ItemStackHolder itemStackHolder = itemStacks.get(name); - ItemStack itemStack = this.itemsFileManager.getItemStackConverter().from(itemStackHolder); - - panel.setItem(realisticSlot, itemStack, event -> { - Map currentRewards = sprayTableElement.getSprayRewards(); - - currentRewards.put(name, 50.0); - dropTable.setRewards(BossAPI.convertObjectToJsonObject(sprayTableElement)); - this.plugin.getDropTableFileManager().save(); - - this.bossPanelManager.getSprayRewardMainEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement, name); - Message.Boss_DropTable_SprayAddedNewReward.msg(event.getWhoClicked(), BossAPI.getDropTableName(dropTable)); - }); - } - }); - } - - private List getFilteredKeys(Map itemStacks, List currentKeys) { - List filteredList = new ArrayList<>(); - - itemStacks.keySet().forEach(string -> { - if(currentKeys.contains(string)) return; - - filteredList.add(string); - }); - - return filteredList; - } -} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayRewardsListEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayRewardsListEditorPanel.java deleted file mode 100644 index 4fd1e07..0000000 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/droptables/types/spray/SprayRewardsListEditorPanel.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.songoda.epicbosses.panel.droptables.types.spray; - -import com.songoda.epicbosses.CustomBosses; -import com.songoda.epicbosses.api.BossAPI; -import com.songoda.epicbosses.droptable.DropTable; -import com.songoda.epicbosses.droptable.elements.SprayTableElement; -import com.songoda.epicbosses.managers.BossPanelManager; -import com.songoda.epicbosses.managers.files.ItemsFileManager; -import com.songoda.epicbosses.utils.NumberUtils; -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.SubVariablePanelHandler; -import com.songoda.epicbosses.utils.panel.builder.PanelBuilder; -import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Charles Cullen - * @version 1.0.0 - * @since 28-Dec-18 - */ -public class SprayRewardsListEditorPanel extends SubVariablePanelHandler { - - private ItemsFileManager itemsFileManager; - private CustomBosses plugin; - - public SprayRewardsListEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { - super(bossPanelManager, panelBuilder); - - this.plugin = plugin; - this.itemsFileManager = plugin.getItemStackManager(); - } - - @Override - public void fillPanel(Panel panel, DropTable dropTable, SprayTableElement sprayTableElement) { - Map rewardMap = sprayTableElement.getSprayRewards(); - List keyList = new ArrayList<>(rewardMap.keySet()); - int maxPage = panel.getMaxPage(keyList); - - panel.setOnPageChange(((player, currentPage, requestedPage) -> { - if(requestedPage < 0 || requestedPage > maxPage) return false; - - loadPage(panel, requestedPage, dropTable, sprayTableElement, rewardMap, keyList); - return true; - })); - - loadPage(panel, 0, dropTable, sprayTableElement, rewardMap, keyList); - } - - @Override - public void openFor(Player player, DropTable dropTable, SprayTableElement sprayTableElement) { - 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.getSprayDropTableMainEditMenu(), dropTable, sprayTableElement); - - panelBuilderCounter.getSlotsWith("NewReward").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getSprayNewRewardEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement))); - fillPanel(panel, dropTable, sprayTableElement); - - panel.openFor(player); - } - - @Override - public void initializePanel(PanelBuilder panelBuilder) { - - } - - private void loadPage(Panel panel, int page, DropTable dropTable, SprayTableElement sprayTableElement, Map rewardMap, List keyList) { - panel.loadPage(page, (slot, realisticSlot) -> { - if(slot >= keyList.size()) { - panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {}); - } else { - String name = keyList.get(slot); - Double chance = rewardMap.get(name); - Map replaceMap = new HashMap<>(); - - if(chance == null) chance = 100.0; - - replaceMap.put("{itemName}", name); - replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance)); - - ItemStack itemStack = this.itemsFileManager.getItemStackConverter().from(this.itemsFileManager.getItemStackHolder(name)); - - ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.DropTable.RewardList.name"), replaceMap); - ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.DropTable.RewardList.lore"), replaceMap); - - panel.setItem(realisticSlot, itemStack, event -> this.bossPanelManager.getSprayRewardMainEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement, name)); - } - }); - } -} 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 85d7490..e42018e 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java @@ -35,12 +35,12 @@ public enum Message { Boss_Debug_Toggled("&b&lEpicBosses &8» &7You have toggled debug mode for &fEpicBosses &7to {0}."), Boss_DropTable_NoPermission("&c&l(!) &cYou do not have access to this command."), + Boss_DropTable_AddedNewReward("&b&lEpicBosses &8» &7You have added a new reward to the drop table &f{0}&7. Now opening the editing panel for the new reward."), + Boss_DropTable_RewardChance("&b&lEpicBosses &8» &7You have {0} the chance for the reward section for &f{1}&7 to &f{2}%&7."), + Boss_DropTable_RewardRemoved("&b&lEpicBosses &8» &7You have removed the reward section from the drop table."), Boss_DropTable_SetMaxDrops("&b&lEpicBosses &8» &7You have {0} the max drops for the drop table to &f{1}&7."), Boss_DropTable_SetMaxDistance("&b&lEpicBosses &8» &7You have {0} the max distance for the drop table to &f{1}&7."), Boss_DropTable_SetRandomDrops("&b&lEpicBosses &8» &7You have set the random drops mode for the drop table to &f{0}&7."), - Boss_DropTable_SprayAddedNewReward("&b&lEpicBosses &8» &7You have added a new reward to the drop table &f{0}&7. Now opening the editing panel for the new reward."), - Boss_DropTable_SprayRewardRemoved("&b&lEpicBosses &8» &7You have removed the reward section from the spray drop table."), - Boss_DropTable_SprayRewardChance("&b&lEpicBosses &8» &7You have {0} the chance for the reward section for &f{1}&7 to &f{2}%&7."), Boss_DropTable_DropAddedNewReward("&b&lEpicBosses &8» &7You have added a new reward to the drop table &f{0}&7. Now opening the editing panel for the new reward."), Boss_DropTable_DropRewardChance("&b&lEpicBosses &8» &7You have {0} the chance for the reward section for &f{1}&7 to &f{2}%&7."), Boss_DropTable_DropRewardRemoved("&b&lEpicBosses &8» &7You have removed the reward section from the drop drop table."), diff --git a/pom.xml b/pom.xml index 6f9c051..6c203e0 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ - 1.0.0-U161 + 1.0.0-U162 EpicBosses com.songoda.epicbosses.CustomBosses AMinecraftDev