diff --git a/plugin-modules/Core/resources-yml/config.yml b/plugin-modules/Core/resources-yml/config.yml index ccbe161..4c2a256 100644 --- a/plugin-modules/Core/resources-yml/config.yml +++ b/plugin-modules/Core/resources-yml/config.yml @@ -166,4 +166,8 @@ Display: name: '&bCustom Skill: &f{name}' lore: - '&3Uses Multiplier: &7{multiplier}' - - '&3Has Custom Data: &7{customData}' \ No newline at end of file + - '&3Has Custom Data: &7{customData}' + Material: + menuName: '&b&lSelect Material' + selectedName: '&bMaterial: &f{type} &a** Selected **' + name: '&bMaterial: &f{type}' \ 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 0101a29..81a05ae 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossPanelManager.java @@ -27,6 +27,7 @@ import com.songoda.epicbosses.panel.skills.custom.GroupSkillEditorPanel; import com.songoda.epicbosses.panel.skills.custom.commands.CommandListSkillEditorPanel; import com.songoda.epicbosses.panel.skills.custom.commands.ModifyCommandEditorPanel; import com.songoda.epicbosses.panel.skills.custom.custom.CustomSkillTypeEditorPanel; +import com.songoda.epicbosses.panel.skills.custom.custom.MaterialTypeEditorPanel; import com.songoda.epicbosses.panel.skills.custom.potions.CreatePotionEffectEditorPanel; import com.songoda.epicbosses.panel.skills.custom.potions.PotionEffectTypeEditorPanel; import com.songoda.epicbosses.panel.skills.custom.PotionSkillEditorPanel; @@ -163,6 +164,21 @@ public class BossPanelManager implements ILoadable, IReloadable { return timesUsed; } + //--------------------------------------------- + // + // G E N E R A L L I S T P A N E L + // + //--------------------------------------------- + + public 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(value)); + + return new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("ListPanel"), replaceMap); + } //--------------------------------------------- // @@ -702,22 +718,6 @@ public class BossPanelManager implements ILoadable, IReloadable { this.customItems.initializePanel(panelBuilder); } - //--------------------------------------------- - // - // G E N E R A L L I S T P A N E L - // - //--------------------------------------------- - - 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(value)); - - return new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("ListPanel"), replaceMap); - } - private String getPath(String key) { return "Display." + key + ".menuName"; } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossSkillManager.java b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossSkillManager.java index 3601ccc..6c58b04 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossSkillManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossSkillManager.java @@ -1,5 +1,6 @@ package com.songoda.epicbosses.managers; +import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.events.BossSkillEvent; import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; @@ -27,9 +28,15 @@ public class BossSkillManager implements ILoadable { private static final Set SKILLS = new HashSet<>(); + private CustomBosses plugin; + + public BossSkillManager(CustomBosses plugin) { + this.plugin = plugin; + } + @Override public void load() { - registerCustomSkill(new Cage()); + registerCustomSkill(new Cage(this.plugin)); registerCustomSkill(new Disarm()); registerCustomSkill(new Fireball()); registerCustomSkill(new Grapple()); @@ -37,7 +44,7 @@ public class BossSkillManager implements ILoadable { registerCustomSkill(new Knockback()); registerCustomSkill(new Launch()); registerCustomSkill(new Lightning()); - registerCustomSkill(new Minions()); + registerCustomSkill(new Minions(this.plugin)); registerCustomSkill(new Warp()); } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/CustomMinionSkillListEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/CustomMinionSkillListEditorPanel.java new file mode 100644 index 0000000..58274fa --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/CustomMinionSkillListEditorPanel.java @@ -0,0 +1,9 @@ +package com.songoda.epicbosses.panel.skills.custom.custom; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 16-Dec-18 + */ +public class CustomMinionSkillListEditorPanel { +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/MaterialTypeEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/MaterialTypeEditorPanel.java new file mode 100644 index 0000000..e326fb3 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/MaterialTypeEditorPanel.java @@ -0,0 +1,110 @@ +package com.songoda.epicbosses.panel.skills.custom.custom; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.skills.Skill; +import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.StringUtils; +import com.songoda.epicbosses.utils.itemstack.ItemStackUtils; +import com.songoda.epicbosses.utils.panel.Panel; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler; +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.*; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 16-Dec-18 + */ +public abstract class MaterialTypeEditorPanel extends SubVariablePanelHandler { + + private CustomBosses plugin; + + public MaterialTypeEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder); + + this.plugin = plugin; + } + + public abstract void saveSetting(Skill skill, CustomSkillElement customSkillElement, String newValue); + + public abstract String getCurrentSetting(CustomSkillElement customSkillElement); + + public abstract IVariablePanelHandler getParentHolder(Skill skill); + + @Override + public void fillPanel(Panel panel, Skill skill, CustomSkillElement customSkillElement) { + List materials = Arrays.asList(Material.values()); + List filteredList = getFilteredList(materials); + int maxPage = panel.getMaxPage(filteredList); + + panel.setOnPageChange((player, currentPage, requestedPage) -> { + if(requestedPage < 0 || requestedPage > maxPage) return false; + + loadPage(panel, requestedPage, materials, skill, customSkillElement); + return true; + }); + + loadPage(panel, 0, materials, skill, customSkillElement); + } + + @Override + public void openFor(Player player, Skill skill, CustomSkillElement customSkillElement) { + Panel panel = getPanelBuilder().getPanel() + .setParentPanelHandler(getParentHolder(skill), skill); + + fillPanel(panel, skill, customSkillElement); + panel.openFor(player); + } + + @Override + public void initializePanel(PanelBuilder panelBuilder) { + + } + + private void loadPage(Panel panel, int page, List filteredList, Skill skill, CustomSkillElement customSkillElement) { + String current = getCurrentSetting(customSkillElement); + + panel.loadPage(page, (slot, realisticSlot) -> { + if(slot >= filteredList.size()) { + panel.setItem(realisticSlot, new ItemStack(Material.AIR), e->{}); + } else { + Material material = filteredList.get(slot); + ItemStack itemStack = new ItemStack(material); + Map replaceMap = new HashMap<>(); + String name = material.name(); + + replaceMap.put("{type}", StringUtils.get().formatString(name)); + + if(current.equalsIgnoreCase(name)) { + ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.Material.selectedName"), replaceMap); + } else { + ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.Material.name"), replaceMap); + } + + panel.setItem(realisticSlot, itemStack, event -> { + saveSetting(skill, customSkillElement, name); + loadPage(panel, page, filteredList, skill, customSkillElement); + }); + } + }); + } + + private List getFilteredList(List masterList) { + List materials = new ArrayList<>(); + + masterList.forEach(material -> { + if(material.isItem()) { + materials.add(material); + } + }); + + return materials; + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/SpecialSettingsEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/SpecialSettingsEditorPanel.java new file mode 100644 index 0000000..8d96304 --- /dev/null +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/skills/custom/custom/SpecialSettingsEditorPanel.java @@ -0,0 +1,52 @@ +package com.songoda.epicbosses.panel.skills.custom.custom; + +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.managers.BossSkillManager; +import com.songoda.epicbosses.skills.Skill; +import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.itemstack.ItemStackConverter; +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.entity.Player; + +/** + * @author Charles Cullen + * @version 1.0.0 + * @since 16-Dec-18 + */ +public class SpecialSettingsEditorPanel extends SubVariablePanelHandler { + + private ItemStackConverter itemStackConverter; + private BossSkillManager bossSkillManager; + private CustomBosses plugin; + + public SpecialSettingsEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) { + super(bossPanelManager, panelBuilder); + + this.plugin = plugin; + this.itemStackConverter = new ItemStackConverter(); + this.bossSkillManager = plugin.getBossSkillManager(); + } + + @Override + public void openFor(Player player, Skill skill, CustomSkillElement customSkillElement) { + Panel panel = getPanelBuilder().getPanel() + .setParentPanelHandler(this.bossPanelManager.getCustomSkillEditorPanel(), skill); + + fillPanel(panel, skill, customSkillElement); + + panel.openFor(player); + } + + @Override + public void fillPanel(Panel panel, Skill skill, CustomSkillElement customSkillElement) { + + } + + @Override + public void initializePanel(PanelBuilder panelBuilder) { + + } +} diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/ICustomSkillHandler.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/ICustomSkillHandler.java index 59c5871..b6f055d 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/ICustomSkillHandler.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/ICustomSkillHandler.java @@ -1,6 +1,9 @@ package com.songoda.epicbosses.skills; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; + +import java.util.Map; /** * @author Charles Cullen @@ -9,6 +12,12 @@ import com.songoda.epicbosses.skills.types.CustomSkillElement; */ public interface ICustomSkillHandler extends ISkillHandler { + boolean doesUseMultiplier(); + + Map> getOtherSkillData(); + + Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement); + String getSkillName(); } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/ISkillHandler.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/ISkillHandler.java index 93186eb..09564ba 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/ISkillHandler.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/ISkillHandler.java @@ -14,10 +14,6 @@ import java.util.Map; */ public interface ISkillHandler { - boolean doesUseMultiplier(); - - Map> getOtherSkillData(); - void castSkill(Skill skill, T t, ActiveBossHolder activeBossHolder, List nearbyEntities); } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Cage.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Cage.java index 56d129e..accdd6c 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Cage.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Cage.java @@ -1,6 +1,10 @@ package com.songoda.epicbosses.skills.custom; +import com.songoda.epicbosses.CustomBosses; +import com.songoda.epicbosses.api.BossAPI; import com.songoda.epicbosses.holder.ActiveBossHolder; +import com.songoda.epicbosses.managers.BossPanelManager; +import com.songoda.epicbosses.panel.skills.custom.custom.MaterialTypeEditorPanel; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.custom.cage.CageLocationData; @@ -10,11 +14,16 @@ import com.songoda.epicbosses.skills.types.CustomSkillElement; import com.songoda.epicbosses.utils.Debug; import com.songoda.epicbosses.utils.ServerUtils; import com.songoda.epicbosses.utils.itemstack.converters.MaterialConverter; +import com.songoda.epicbosses.utils.panel.Panel; +import com.songoda.epicbosses.utils.panel.base.ClickAction; +import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler; +import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler; import lombok.Getter; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import java.util.*; @@ -30,6 +39,19 @@ public class Cage extends CustomSkillHandler { @Getter private static final Map cageLocationDataMap = new HashMap<>(); @Getter private static final List playersInCage = new ArrayList<>(); + private final MaterialTypeEditorPanel flatTypeEditor, wallTypeEditor, insideTypeEditor; + private BossPanelManager bossPanelManager; + private CustomBosses plugin; + + public Cage(CustomBosses plugin) { + this.plugin = plugin; + this.bossPanelManager = plugin.getBossPanelManager(); + + this.flatTypeEditor = getFlatTypeEditor(); + this.wallTypeEditor = getWallTypeEditor(); + this.insideTypeEditor = getInsideTypeEditor(); + } + @Override public boolean doesUseMultiplier() { return false; @@ -46,6 +68,17 @@ public class Cage extends CustomSkillHandler { return map; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + Map clickActionMap = new HashMap<>(); + + clickActionMap.put(1, event -> this.flatTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement)); + clickActionMap.put(2, event -> this.wallTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement)); + clickActionMap.put(3, event -> this.insideTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement)); + + return clickActionMap; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { nearbyEntities.forEach(livingEntity -> { @@ -137,4 +170,77 @@ public class Cage extends CustomSkillHandler { return currentLocation.clone().add(0.5, 0, 0.5); } + + private MaterialTypeEditorPanel getFlatTypeEditor() { + return new MaterialTypeEditorPanel(this.bossPanelManager, this.bossPanelManager.getListMenu("Skills.Material"), this.plugin) { + @Override + public void saveSetting(Skill skill, CustomSkillElement customSkillElement, String newValue) { + CustomCageSkillElement customCageSkillElement = customSkillElement.getCustom().getCustomCageSkillData(); + + customCageSkillElement.setFlatType(newValue); + customSkillElement.getCustom().setOtherSkillData(BossAPI.convertObjectToJsonObject(customCageSkillElement)); + skill.setCustomData(BossAPI.convertObjectToJsonObject(customSkillElement)); + Cage.this.plugin.getSkillsFileManager().save(); + } + + @Override + public String getCurrentSetting(CustomSkillElement customSkillElement) { + return customSkillElement.getCustom().getCustomCageSkillData().getFlatType(); + } + + @Override + public IVariablePanelHandler getParentHolder(Skill skill) { + return this.bossPanelManager.getCustomSkillEditorPanel(); + } + }; + } + + private MaterialTypeEditorPanel getWallTypeEditor() { + return new MaterialTypeEditorPanel(this.bossPanelManager, this.bossPanelManager.getListMenu("Skills.Material"), this.plugin) { + @Override + public void saveSetting(Skill skill, CustomSkillElement customSkillElement, String newValue) { + CustomCageSkillElement customCageSkillElement = customSkillElement.getCustom().getCustomCageSkillData(); + + customCageSkillElement.setWallType(newValue); + customSkillElement.getCustom().setOtherSkillData(BossAPI.convertObjectToJsonObject(customCageSkillElement)); + skill.setCustomData(BossAPI.convertObjectToJsonObject(customSkillElement)); + Cage.this.plugin.getSkillsFileManager().save(); + } + + @Override + public String getCurrentSetting(CustomSkillElement customSkillElement) { + return customSkillElement.getCustom().getCustomCageSkillData().getWallType(); + } + + @Override + public IVariablePanelHandler getParentHolder(Skill skill) { + return this.bossPanelManager.getCustomSkillEditorPanel(); + } + }; + } + + private MaterialTypeEditorPanel getInsideTypeEditor() { + return new MaterialTypeEditorPanel(this.bossPanelManager, this.bossPanelManager.getListMenu("Skills.Material"), this.plugin) { + @Override + public void saveSetting(Skill skill, CustomSkillElement customSkillElement, String newValue) { + CustomCageSkillElement customCageSkillElement = customSkillElement.getCustom().getCustomCageSkillData(); + + customCageSkillElement.setInsideType(newValue); + customSkillElement.getCustom().setOtherSkillData(BossAPI.convertObjectToJsonObject(customCageSkillElement)); + skill.setCustomData(BossAPI.convertObjectToJsonObject(customSkillElement)); + Cage.this.plugin.getSkillsFileManager().save(); + } + + @Override + public String getCurrentSetting(CustomSkillElement customSkillElement) { + return customSkillElement.getCustom().getCustomCageSkillData().getInsideType(); + } + + @Override + public IVariablePanelHandler getParentHolder(Skill skill) { + return this.bossPanelManager.getCustomSkillEditorPanel(); + } + }; + } + } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Disarm.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Disarm.java index e9822fd..4df98e5 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Disarm.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Disarm.java @@ -7,6 +7,7 @@ import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; import com.songoda.epicbosses.utils.Message; import com.songoda.epicbosses.utils.RandomUtils; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.LivingEntity; @@ -33,6 +34,11 @@ public class Disarm extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { nearbyEntities.forEach(livingEntity -> { diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Fireball.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Fireball.java index 024f617..693350d 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Fireball.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Fireball.java @@ -4,6 +4,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.entity.LivingEntity; import org.bukkit.util.Vector; @@ -27,6 +28,11 @@ public class Fireball extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { LivingEntity boss = activeBossHolder.getLivingEntity(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Grapple.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Grapple.java index bf9e1b1..2a06194 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Grapple.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Grapple.java @@ -4,6 +4,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.util.Vector; @@ -28,6 +29,11 @@ public class Grapple extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { Location bossLocation = activeBossHolder.getLocation(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Insidious.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Insidious.java index beda651..bfc6d90 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Insidious.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Insidious.java @@ -4,6 +4,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.entity.LivingEntity; import java.util.List; @@ -26,6 +27,11 @@ public class Insidious extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { Double multiplier = customSkillElement.getCustom().getMultiplier(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Knockback.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Knockback.java index 69ef672..49f3543 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Knockback.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Knockback.java @@ -4,6 +4,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.util.Vector; @@ -28,6 +29,11 @@ public class Knockback extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { Double multiplier = customSkillElement.getCustom().getMultiplier(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Launch.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Launch.java index 38e6b3b..d5404ef 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Launch.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Launch.java @@ -4,6 +4,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -27,6 +28,11 @@ public class Launch extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { Location bossLocation = activeBossHolder.getLocation(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Lightning.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Lightning.java index b6ec21c..ded168b 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Lightning.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Lightning.java @@ -4,6 +4,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.entity.LivingEntity; import java.util.List; @@ -26,6 +27,11 @@ public class Lightning extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { nearbyEntities.forEach(livingEntity -> livingEntity.getWorld().strikeLightningEffect(livingEntity.getEyeLocation())); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Minions.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Minions.java index 50bcf0a..c6093fb 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Minions.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Minions.java @@ -1,11 +1,19 @@ package com.songoda.epicbosses.skills.custom; +import com.google.gson.JsonObject; +import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.api.BossAPI; import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; +import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.Message; +import com.songoda.epicbosses.utils.NumberUtils; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import java.util.HashMap; import java.util.List; @@ -18,6 +26,12 @@ import java.util.Map; */ public class Minions extends CustomSkillHandler { + private CustomBosses plugin; + + public Minions(CustomBosses plugin) { + this.plugin = plugin; + } + @Override public boolean doesUseMultiplier() { return false; @@ -33,8 +47,57 @@ public class Minions extends CustomSkillHandler { return map; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + Map clickActionMap = new HashMap<>(); + + clickActionMap.put(1, getAmountAction(skill, customSkillElement)); + + + return clickActionMap; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { BossAPI.spawnNewMinion(activeBossHolder, skill); } + + private ClickAction getAmountAction(Skill skill, CustomSkillElement customSkillElement) { + return event -> { + CustomMinionSkillElement customMinionSkillElement = customSkillElement.getCustom().getCustomMinionSkillData(); + ClickType clickType = event.getClick(); + Integer amountToModifyBy; + + if(clickType.name().contains("RIGHT")) { + amountToModifyBy = -1; + } else { + amountToModifyBy = 1; + } + + Integer currentAmount = customMinionSkillElement.getAmount(); + String modifyValue; + Integer newAmount; + + if(currentAmount == null) currentAmount = 0; + + if(amountToModifyBy > 0.0) { + modifyValue = "increased"; + newAmount = currentAmount + amountToModifyBy; + } else { + modifyValue = "decreased"; + newAmount = currentAmount + amountToModifyBy; + } + + if(newAmount <= 0) { + newAmount = 0; + } + + customMinionSkillElement.setAmount(newAmount); + customSkillElement.getCustom().setOtherSkillData(BossAPI.convertObjectToJsonObject(customMinionSkillElement)); + skill.setCustomData(BossAPI.convertObjectToJsonObject(customSkillElement)); + + this.plugin.getSkillsFileManager().save(); + Message.Boss_Skills_SetMinionAmount.msg(event.getWhoClicked(), modifyValue, NumberUtils.get().formatDouble(newAmount)); + }; + } } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Warp.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Warp.java index 98be392..87733ba 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Warp.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/custom/Warp.java @@ -4,6 +4,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.skills.CustomSkillHandler; import com.songoda.epicbosses.skills.Skill; import com.songoda.epicbosses.skills.types.CustomSkillElement; +import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.entity.LivingEntity; import java.util.List; @@ -26,6 +27,11 @@ public class Warp extends CustomSkillHandler { return null; } + @Override + public Map getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) { + return null; + } + @Override public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { LivingEntity target = nearbyEntities.get(0); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/CommandSkillElement.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/CommandSkillElement.java index ecd2bad..5800a56 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/CommandSkillElement.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/CommandSkillElement.java @@ -28,16 +28,6 @@ public class CommandSkillElement implements ISkillHandler { this.commands = commandSkillElements; } - @Override - public boolean doesUseMultiplier() { - return false; - } - - @Override - public Map> getOtherSkillData() { - return null; - } - @Override public void castSkill(Skill skill, CommandSkillElement commandSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { List commandSkillElements = getCommands(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/GroupSkillElement.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/GroupSkillElement.java index 4c1aa4b..717a97a 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/GroupSkillElement.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/GroupSkillElement.java @@ -28,16 +28,6 @@ public class GroupSkillElement implements ISkillHandler { this.groupedSkills = groupedSkills; } - @Override - public boolean doesUseMultiplier() { - return false; - } - - @Override - public Map> getOtherSkillData() { - return null; - } - @Override public void castSkill(Skill skill, GroupSkillElement groupSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { List currentGroupedSkills = getGroupedSkills(); diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/PotionSkillElement.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/PotionSkillElement.java index 713ee7c..634fa65 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/PotionSkillElement.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/types/PotionSkillElement.java @@ -30,16 +30,6 @@ public class PotionSkillElement implements ISkillHandler { this.potionEffectConverter = new PotionEffectConverter(); } - @Override - public boolean doesUseMultiplier() { - return false; - } - - @Override - public Map> getOtherSkillData() { - return null; - } - @Override public void castSkill(Skill skill, PotionSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List nearbyEntities) { List potionElements = getPotions(); 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 53f249d..0c7f2a6 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java @@ -163,6 +163,7 @@ public enum Message { Boss_Skills_SetDisplayName("&b&lEpicBosses &8» &7Your next input in to chat will be the display name for the skill. If you enter &f-&7 it will remove/clear the display name of the skill. For color codes use the &f& &7sign."), Boss_Skills_NotCompleteEnough("&c&l(!) &cThe potion effect was unable to be created due to it not having enough information. Please make sure that the potion effect type is selected."), Boss_Skills_SetCommandChance("&b&lEpicBosses &8» &7You have {0} the chance for the command skill to &f{1}%&7."), + Boss_Skills_SetMinionAmount("&b&lEpicBosses &8» &&You have {0} the amount of minions to spawn from this skill to &f{1}&7."), Boss_Spawn_NoPermission("&c&l(!) &cYou do not have access to this command."), Boss_Spawn_InvalidArgs("&c&l(!) &cYou must use &n/boss spawn [name] (location)&c to spawn a boss."), diff --git a/pom.xml b/pom.xml index 5fa7eef..2781159 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ - 1.0.0-U129 + 1.0.0-U130 EpicBosses com.songoda.epicbosses.CustomBosses AMinecraftDev