mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-22 06:41:20 +01:00
1.0.0-SNAPSHOT-U182
+ Connected the spawn rate button + Added CustomSetting to the config.yml + Updated the AutoSpawnCustomSettingsEditorPanel + Updated IntervalHandler to connect with the AutoSpawn class too + Updated AutoSpawnCustomSettingsHandler interface
This commit is contained in:
parent
dfc8f0d938
commit
f50c3ef772
@ -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}'
|
||||
|
@ -11,6 +11,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface IAutoSpawnCustomSettingsHandler {
|
||||
|
||||
List<ICustomSettingAction> getCustomSettingActions();
|
||||
List<ICustomSettingAction> getCustomSettingActions(AutoSpawn autoSpawn);
|
||||
|
||||
}
|
||||
|
@ -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<String> 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<String> 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<String> 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<String> getSpawnRateExtraInformation() {
|
||||
List<String> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<ICustomSettingAction> getCustomSettingActions() {
|
||||
public List<ICustomSettingAction> getCustomSettingActions(AutoSpawn autoSpawn) {
|
||||
List<ICustomSettingAction> 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;
|
||||
}
|
||||
|
@ -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<String> extraInformation, ItemStack displayStack, ClickAction clickAction) {
|
||||
return new CustomAutoSpawnActionCreator(name, current, extraInformation, displayStack, clickAction);
|
||||
}
|
||||
|
||||
private static class CustomAutoSpawnActionCreator implements ICustomSettingAction {
|
||||
|
||||
private final List<String> 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<String> 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<String> getExtraInformation() {
|
||||
return this.extraInformation;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -234,5 +234,10 @@ public class BossSkillManager implements ILoadable {
|
||||
public String getCurrent() {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getExtraInformation() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<AutoSpawn> {
|
||||
|
||||
|
@ -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<String> getExtraInformation();
|
||||
}
|
||||
|
@ -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."),
|
||||
|
Loading…
Reference in New Issue
Block a user