diff --git a/plugin-modules/Core/resources-yml/config.yml b/plugin-modules/Core/resources-yml/config.yml index 89e466b..fb60f65 100644 --- a/plugin-modules/Core/resources-yml/config.yml +++ b/plugin-modules/Core/resources-yml/config.yml @@ -112,6 +112,11 @@ Display: - '&3Drop Table: &f{dropTable}' - '&7' - '&7Click to select or deselect this boss.' + CustomSettings: + name: '&bCustom Setting: &f{name}' + lore: + - '&3Currently: &f{currently}' + - '{extraInformation}' Bosses: menuName: '&b&lEpicBosses &3&lBosses' name: '&b&l{name}' diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/IAutoSpawnCustomSettingsHandler.java b/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/IAutoSpawnCustomSettingsHandler.java index b731f05..50e6eb2 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/IAutoSpawnCustomSettingsHandler.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/IAutoSpawnCustomSettingsHandler.java @@ -11,6 +11,6 @@ import java.util.List; */ public interface IAutoSpawnCustomSettingsHandler { - List getCustomSettingActions(); + List getCustomSettingActions(AutoSpawn autoSpawn); } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/handlers/IntervalSpawnHandler.java b/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/handlers/IntervalSpawnHandler.java index c09b551..7f143f7 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/handlers/IntervalSpawnHandler.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/handlers/IntervalSpawnHandler.java @@ -1,5 +1,7 @@ package com.songoda.epicbosses.autospawns.handlers; +import com.google.gson.JsonObject; +import com.songoda.epicbosses.CustomBosses; import com.songoda.epicbosses.api.BossAPI; import com.songoda.epicbosses.autospawns.AutoSpawn; import com.songoda.epicbosses.autospawns.settings.AutoSpawnSettings; @@ -8,17 +10,13 @@ import com.songoda.epicbosses.entity.BossEntity; import com.songoda.epicbosses.holder.ActiveBossHolder; import com.songoda.epicbosses.holder.autospawn.ActiveIntervalAutoSpawnHolder; import com.songoda.epicbosses.listeners.IBossDeathHandler; -import com.songoda.epicbosses.utils.MessageUtils; -import com.songoda.epicbosses.utils.NumberUtils; -import com.songoda.epicbosses.utils.ObjectUtils; -import com.songoda.epicbosses.utils.StringUtils; +import com.songoda.epicbosses.utils.*; import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; +import java.util.*; /** * @author Charles Cullen @@ -78,16 +76,85 @@ public class IntervalSpawnHandler { return event -> {}; } + public List getSpawnAfterLastBossIsKilledExtraInformation() { + return Arrays.asList("&7Click here to toggle the timer", "&7being enabled/reset after the last boss is killed.", "&7This will make it so only one active", "&7boss from this section can be spawned", "&7at a time."); + } + public ClickAction getLocationAction(IntervalSpawnElement intervalSpawnElement) { return event -> {}; } + public List getLocationExtraInformation() { + return Arrays.asList("&7Click here to update the location", "&7of this interval spawn section.", "&7", "&7This will ask you to put something in chat", "&7in the specific format of the new", "&7location."); + } + public ClickAction getPlaceholderAction(IntervalSpawnElement intervalSpawnElement) { return event -> {}; } - public ClickAction getSpawnRateAction(IntervalSpawnElement intervalSpawnElement) { - return event -> {}; + public List getPlaceholderExtraInformation() { + return Arrays.asList("&7Click here to modify the placeholder", "&7that is used to display the timer for this", "&7auto spawn section in a hologram or", "&7through PlaceholderAPI."); + } + + public ClickAction getSpawnRateAction(IntervalSpawnElement intervalSpawnElement, AutoSpawn autoSpawn) { + return event -> { + ClickType clickType = event.getClick(); + int amountToModifyBy; + + if(clickType == ClickType.SHIFT_LEFT) { + amountToModifyBy = 10; + } else if(clickType == ClickType.RIGHT) { + amountToModifyBy = -1; + } else if(clickType == ClickType.SHIFT_RIGHT) { + amountToModifyBy = -10; + } else { + amountToModifyBy = 1; + } + + int currentAmount = ObjectUtils.getValue(intervalSpawnElement.getSpawnRate(), 30); + String modifyValue; + int newAmount; + + if(amountToModifyBy > 0) { + modifyValue = "increased"; + newAmount = currentAmount + amountToModifyBy; + } else { + modifyValue = "decreased"; + newAmount = currentAmount + amountToModifyBy; + } + + if(newAmount <= 0) { + newAmount = 0; + } + + intervalSpawnElement.setSpawnRate(newAmount); + + JsonObject jsonObject = BossAPI.convertObjectToJsonObject(intervalSpawnElement); + + autoSpawn.setCustomData(jsonObject); + CustomBosses.get().getAutoSpawnFileManager().save(); + Message.Boss_AutoSpawn_SpawnRate.msg(event.getWhoClicked(), modifyValue, NumberUtils.get().formatDouble(newAmount)); + }; + } + + public List getSpawnRateExtraInformation() { + List extraInformation = new ArrayList<>(); + + extraInformation.add("&7Click here to modify the spawn rate of"); + extraInformation.add("&7this interval section. The rate is calculated"); + extraInformation.add("&7by a minute."); + extraInformation.add("&7"); + extraInformation.add("&31 Hour is &f60"); + extraInformation.add("&35 Hours is &f300"); + extraInformation.add("&312 Hours is &f720"); + extraInformation.add("&7"); + extraInformation.add("&bLeft Click &8» &f+1"); + extraInformation.add("&bShift Left-Click &8» &f+10"); + extraInformation.add("&7"); + extraInformation.add("&bRight Click &8» &f-1"); + extraInformation.add("&bShift Right-Click &8» &f-10"); + + return extraInformation; } } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/types/IntervalSpawnElement.java b/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/types/IntervalSpawnElement.java index ea53f66..1ab3bb5 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/types/IntervalSpawnElement.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/autospawns/types/IntervalSpawnElement.java @@ -1,6 +1,7 @@ package com.songoda.epicbosses.autospawns.types; import com.google.gson.annotations.Expose; +import com.songoda.epicbosses.autospawns.AutoSpawn; import com.songoda.epicbosses.autospawns.IAutoSpawnCustomSettingsHandler; import com.songoda.epicbosses.autospawns.handlers.IntervalSpawnHandler; import com.songoda.epicbosses.holder.autospawn.ActiveIntervalAutoSpawnHolder; @@ -37,18 +38,18 @@ public class IntervalSpawnElement implements IAutoSpawnCustomSettingsHandler { } @Override - public List getCustomSettingActions() { + public List getCustomSettingActions(AutoSpawn autoSpawn) { List clickActions = new ArrayList<>(); ItemStack clickStack = new ItemStack(Material.IRON_BLOCK); ClickAction lastBossKilledAction = this.intervalSpawnHandler.getSpawnAfterLastBossIsKilledAction(this); ClickAction locationAction = this.intervalSpawnHandler.getLocationAction(this); ClickAction placeholderAction = this.intervalSpawnHandler.getPlaceholderAction(this); - ClickAction spawnRateAction = this.intervalSpawnHandler.getSpawnRateAction(this); + ClickAction spawnRateAction = this.intervalSpawnHandler.getSpawnRateAction(this, autoSpawn); - clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn After Last Boss Is Killed", getSpawnAfterLastBossIsKilled()+"", clickStack.clone(), lastBossKilledAction)); - clickActions.add(AutoSpawnManager.createAutoSpawnAction("Location", getLocation(), clickStack.clone(), locationAction)); - clickActions.add(AutoSpawnManager.createAutoSpawnAction("Placeholder", getPlaceholder(), clickStack.clone(), placeholderAction)); - clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn Rate", getSpawnRate()+"", clickStack.clone(), spawnRateAction)); + clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn After Last Boss Is Killed", getSpawnAfterLastBossIsKilled()+"", this.intervalSpawnHandler.getSpawnAfterLastBossIsKilledExtraInformation(), clickStack.clone(), lastBossKilledAction)); + clickActions.add(AutoSpawnManager.createAutoSpawnAction("Location", getLocation(), this.intervalSpawnHandler.getLocationExtraInformation(), clickStack.clone(), locationAction)); + clickActions.add(AutoSpawnManager.createAutoSpawnAction("Placeholder", getPlaceholder(), this.intervalSpawnHandler.getPlaceholderExtraInformation(), clickStack.clone(), placeholderAction)); + clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn Rate", getSpawnRate()+"", this.intervalSpawnHandler.getSpawnRateExtraInformation(), clickStack.clone(), spawnRateAction)); return clickActions; } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/managers/AutoSpawnManager.java b/plugin-modules/Core/src/com/songoda/epicbosses/managers/AutoSpawnManager.java index b165303..d1a1ea9 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/AutoSpawnManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/AutoSpawnManager.java @@ -136,21 +136,23 @@ public class AutoSpawnManager { } } - public static ICustomSettingAction createAutoSpawnAction(String name, String current, ItemStack displayStack, ClickAction clickAction) { - return new CustomAutoSpawnActionCreator(name, current, displayStack, clickAction); + public static ICustomSettingAction createAutoSpawnAction(String name, String current, List extraInformation, ItemStack displayStack, ClickAction clickAction) { + return new CustomAutoSpawnActionCreator(name, current, extraInformation, displayStack, clickAction); } private static class CustomAutoSpawnActionCreator implements ICustomSettingAction { + private final List extraInformation; private final ClickAction clickAction; private final String name, current; private final ItemStack itemStack; - public CustomAutoSpawnActionCreator(String name, String current, ItemStack itemStack, ClickAction clickAction) { + public CustomAutoSpawnActionCreator(String name, String current, List extraInformation, ItemStack itemStack, ClickAction clickAction) { this.name = name; this.current = current; this.itemStack = itemStack; this.clickAction = clickAction; + this.extraInformation = extraInformation; } @Override @@ -172,6 +174,11 @@ public class AutoSpawnManager { public String getCurrent() { return this.current; } + + @Override + public List getExtraInformation() { + return this.extraInformation; + } } } 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 676dc97..72528ff 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossSkillManager.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/managers/BossSkillManager.java @@ -234,5 +234,10 @@ public class BossSkillManager implements ILoadable { public String getCurrent() { return this.current; } + + @Override + public List getExtraInformation() { + return null; + } } } diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/panel/autospawns/AutoSpawnCustomSettingsEditorPanel.java b/plugin-modules/Core/src/com/songoda/epicbosses/panel/autospawns/AutoSpawnCustomSettingsEditorPanel.java index 4262d09..5b2d42f 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/panel/autospawns/AutoSpawnCustomSettingsEditorPanel.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/panel/autospawns/AutoSpawnCustomSettingsEditorPanel.java @@ -18,6 +18,8 @@ import java.util.Map; * @author Charles Cullen * @version 1.0.0 * @since 07-Jan-19 + * + * TODO Handle Extra Information */ public class AutoSpawnCustomSettingsEditorPanel extends VariablePanelHandler { diff --git a/plugin-modules/Core/src/com/songoda/epicbosses/skills/interfaces/ICustomSettingAction.java b/plugin-modules/Core/src/com/songoda/epicbosses/skills/interfaces/ICustomSettingAction.java index df0cb6f..d88cb7a 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/skills/interfaces/ICustomSettingAction.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/skills/interfaces/ICustomSettingAction.java @@ -3,6 +3,8 @@ package com.songoda.epicbosses.skills.interfaces; import com.songoda.epicbosses.utils.panel.base.ClickAction; import org.bukkit.inventory.ItemStack; +import java.util.List; + /** * @author Charles Cullen * @version 1.0.0 @@ -17,4 +19,6 @@ public interface ICustomSettingAction { ItemStack getDisplayItemStack(); String getCurrent(); + + List getExtraInformation(); } 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 fa9a2c9..b66455c 100644 --- a/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java +++ b/plugin-modules/Core/src/com/songoda/epicbosses/utils/Message.java @@ -26,6 +26,7 @@ public enum Message { Boss_AutoSpawn_ToggleEditing("&b&lEpicBosses &8» &7You have toggled the editing mode for the &f{0}&7 auto spawn to &f{1}&7."), Boss_AutoSpawn_NotCompleteEnough("&c&l(!) &cThe auto spawn is not set up enough to be enabled. Please make sure it has: &fA Spawn Entity(s) and Type&c before you try and enable the auto spawn."), + Boss_AutoSpawn_SpawnRate("&b&lEpicBosses &8» &7You have {0} the spawn rate of the auto spawn to &f{1}&7."), Boss_Create_EntityTypeNotFound("&c&l(!) &cThe specified entity type {0} was not found. If you think this is an error please contact &fAMinecraftDev&c."), Boss_Create_InvalidArgs("&c&l(!) &cYou must use &n/boss create [name] [entity] &c to create a boss."), diff --git a/pom.xml b/pom.xml index 1af93ca..a5e9015 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ - 1.0.0-U181 + 1.0.0-U182 EpicBosses com.songoda.epicbosses.CustomBosses AMinecraftDev