1.0.0-SNAPSHOT-U134

+ Continued the implementation of the SpecialSettingsEditor and also added a few custom panels to handle the minions and cage settings
This commit is contained in:
Charles 2018-12-22 20:41:23 +08:00
parent 9bf6fd2847
commit 50b7c82433
19 changed files with 205 additions and 38 deletions

View File

@ -1,4 +1,8 @@
{
"DefaultMinionMenuSpawnItem": {
"type": "ZOMBIE_SPAWN_EGG",
"name": "&c&lDefault Minion Menu Spawn Item"
},
"DefaultTextMenuItem": {
"type": "BOOK",
"name": "&c&lDefault Text Menu Item"

View File

@ -171,3 +171,14 @@ Display:
menuName: '&b&lSelect Material'
selectedName: '&bMaterial: &f{type} &a** Selected **'
name: '&bMaterial: &f{type}'
MinionList:
menuName: '&b&lSelect Minion For Skill'
selectedName: '&bMinion: &f{name} &a** Selected **'
name: '&bMinion: &f{name}'
lore:
- '&3Editing: &7{editing}'
- '&3Targeting: &7{targeting}'
CustomSetting:
name: '&bSetting: &f{setting}'
lore:
- '&3Currently: &7{currently}'

View File

@ -28,6 +28,7 @@ import com.songoda.epicbosses.panel.skills.custom.commands.CommandListSkillEdito
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.custom.MinionSelectEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.custom.SpecialSettingsEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.potions.CreatePotionEffectEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.potions.PotionEffectTypeEditorPanel;
@ -78,7 +79,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
@Getter private IVariablePanelHandler<Skill> mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu, potionSkillEditorPanel, commandSkillEditorPanel, groupSkillEditorPanel, customSkillEditorPanel;
@Getter private ISubVariablePanelHandler<Skill, PotionEffectHolder> createPotionEffectMenu, potionEffectTypeEditMenu;
@Getter private ISubVariablePanelHandler<Skill, SubCommandSkillElement> modifyCommandEditMenu, commandListSkillEditMenu;
@Getter private ISubVariablePanelHandler<Skill, CustomSkillElement> customSkillTypeEditorMenu, specialSettingsEditorMenu;
@Getter private ISubVariablePanelHandler<Skill, CustomSkillElement> customSkillTypeEditorMenu, specialSettingsEditorMenu, minionSelectEditorMenu;
private final CustomBosses customBosses;
@ -197,7 +198,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("ModifyCommandEditorPanel"));
PanelBuilder panelBuilder6 = new PanelBuilder(editor.getConfigurationSection("CustomSkillEditorPanel"));
PanelBuilder panelBuilder7 = new PanelBuilder(editor.getConfigurationSection("CustomSkillTypeEditorPanel"));
PanelBuilder panelBuilder8 = new PanelBuilder(editor.getConfigurationSection("CustomSkillTypeEditorPanel"));
PanelBuilder panelBuilder8 = new PanelBuilder(editor.getConfigurationSection("SpecialSettingsEditorPanel"));
this.mainSkillEditMenu = new MainSkillEditorPanel(this, panelBuilder, this.customBosses);
this.customMessageEditMenu = new SingleMessageListEditor<Skill>(this, getListMenu("Skills.MainEdit"), this.customBosses) {
@ -234,6 +235,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
this.customSkillEditorPanel = new CustomSkillEditorPanel(this, panelBuilder6, this.customBosses);
this.customSkillTypeEditorMenu = new CustomSkillTypeEditorPanel(this, panelBuilder7, this.customBosses);
this.specialSettingsEditorMenu = new SpecialSettingsEditorPanel(this, panelBuilder8, this.customBosses);
this.minionSelectEditorMenu = new MinionSelectEditorPanel(this, getListMenu("Skills.MinionList"), this.customBosses);
}
private void reloadSkillEditMenus() {
@ -246,7 +248,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("ModifyCommandEditorPanel"));
PanelBuilder panelBuilder6 = new PanelBuilder(editor.getConfigurationSection("CustomSkillEditorPanel"));
PanelBuilder panelBuilder7 = new PanelBuilder(editor.getConfigurationSection("CustomSkillTypeEditorPanel"));
PanelBuilder panelBuilder8 = new PanelBuilder(editor.getConfigurationSection("CustomSkillTypeEditorPanel"));
PanelBuilder panelBuilder8 = new PanelBuilder(editor.getConfigurationSection("SpecialSettingsEditorPanel"));
this.mainSkillEditMenu.initializePanel(panelBuilder);
this.customMessageEditMenu.initializePanel(getListMenu("Skills.MainEdit"));
@ -261,6 +263,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
this.customSkillEditorPanel.initializePanel(panelBuilder6);
this.customSkillTypeEditorMenu.initializePanel(panelBuilder7);
this.specialSettingsEditorMenu.initializePanel(panelBuilder8);
this.minionSelectEditorMenu.initializePanel(getListMenu("Skills.MinionList"));
}
//---------------------------------------------

View File

@ -197,35 +197,41 @@ public class BossSkillManager implements ILoadable {
return null;
}
public static ICustomSkillAction createCustomSkillAction(String name, ItemStack displayStack, ClickAction clickAction) {
return new CustomSkillActionCreator(name, displayStack, clickAction);
public static ICustomSkillAction createCustomSkillAction(String name, String current, ItemStack displayStack, ClickAction clickAction) {
return new CustomSkillActionCreator(name, current, displayStack, clickAction);
}
private static class CustomSkillActionCreator implements ICustomSkillAction {
private final ClickAction clickAction;
private final String name;
private final String name, current;
private final ItemStack itemStack;
public CustomSkillActionCreator(String name, ItemStack itemStack, ClickAction clickAction) {
public CustomSkillActionCreator(String name, String current, ItemStack itemStack, ClickAction clickAction) {
this.name = name;
this.current = current;
this.itemStack = itemStack;
this.clickAction = clickAction;
}
@Override
public ClickAction getAction() {
return null;
return this.clickAction;
}
@Override
public String getSettingName() {
return null;
return this.name;
}
@Override
public ItemStack getDisplayItemStack() {
return null;
return this.itemStack;
}
@Override
public String getCurrent() {
return this.current;
}
}
}

View File

@ -7,7 +7,6 @@ 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;

View File

@ -0,0 +1,123 @@
package com.songoda.epicbosses.panel.skills.custom.custom;
import com.google.gson.JsonObject;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.managers.files.MinionsFileManager;
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.StringUtils;
import com.songoda.epicbosses.utils.itemstack.ItemStackConverter;
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
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.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 22-Dec-18
*/
public class MinionSelectEditorPanel extends SubVariablePanelHandler<Skill, CustomSkillElement> {
private MinionsFileManager minionsFileManager;
private ItemStackConverter itemStackConverter;
private ItemsFileManager itemsFileManager;
private CustomBosses plugin;
public MinionSelectEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.itemsFileManager = plugin.getItemStackManager();
this.minionsFileManager = plugin.getMinionsFileManager();
}
@Override
public void fillPanel(Panel panel, Skill skill, CustomSkillElement customSkillElement) {
Map<String, MinionEntity> currentEntities = this.minionsFileManager.getMinionEntities();
List<String> entryList = new ArrayList<>(currentEntities.keySet());
int maxPage = panel.getMaxPage(entryList);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, currentEntities, entryList, skill, customSkillElement);
return true;
}));
loadPage(panel, 0, currentEntities, entryList, skill, customSkillElement);
}
@Override
public void openFor(Player player, Skill skill, CustomSkillElement customSkillElement) {
Panel panel = getPanelBuilder().getPanel()
.setParentPanelHandler(this.bossPanelManager.getSpecialSettingsEditorMenu(), skill, customSkillElement);
fillPanel(panel, skill, customSkillElement);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int page, Map<String, MinionEntity> currentEntities, List<String> entryList, Skill skill, CustomSkillElement customSkillElement) {
CustomMinionSkillElement customMinionSkillElement = customSkillElement.getCustom().getCustomMinionSkillData();
String current = customMinionSkillElement.getMinionToSpawn();
panel.loadPage(page, ((slot, realisticSlot) -> {
if(slot >= entryList.size()) {
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e->{});
} else {
String name = entryList.get(slot);
MinionEntity minionEntity = currentEntities.get(name);
ItemStackHolder itemStackHolder = this.itemsFileManager.getItemStackHolder("DefaultMinionMenuSpawnItem");
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{name}", StringUtils.get().formatString(name));
replaceMap.put("{editing}", ""+minionEntity.isEditing());
replaceMap.put("{targeting}", minionEntity.getTargeting());
if(current.equalsIgnoreCase(name)) {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.MinionList.selectedName"), replaceMap);
} else {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.MinionList.name"), replaceMap);
}
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.Skills.MinionList.lore"), replaceMap);
panel.setItem(realisticSlot, itemStack, event -> {
customMinionSkillElement.setMinionToSpawn(name);
JsonObject minionElement = BossAPI.convertObjectToJsonObject(customMinionSkillElement);
customSkillElement.getCustom().setOtherSkillData(minionElement);
JsonObject customElement = BossAPI.convertObjectToJsonObject(customSkillElement);
skill.setCustomData(customElement);
this.plugin.getSkillsFileManager().save();
loadPage(panel, page, currentEntities, entryList, skill, customSkillElement);
});
}
}));
}
}

View File

@ -3,8 +3,10 @@ package com.songoda.epicbosses.panel.skills.custom.custom;
import com.google.gson.JsonObject;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.BossSkillManager;
import com.songoda.epicbosses.managers.files.MinionsFileManager;
import com.songoda.epicbosses.skills.CustomSkillHandler;
import com.songoda.epicbosses.skills.interfaces.ICustomSkillAction;
import com.songoda.epicbosses.skills.Skill;
@ -32,6 +34,7 @@ import java.util.Map;
public class SpecialSettingsEditorPanel extends SubVariablePanelHandler<Skill, CustomSkillElement> {
private ItemStackConverter itemStackConverter;
private MinionsFileManager minionsFileManager;
private BossSkillManager bossSkillManager;
private CustomBosses plugin;
@ -41,6 +44,7 @@ public class SpecialSettingsEditorPanel extends SubVariablePanelHandler<Skill, C
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.bossSkillManager = plugin.getBossSkillManager();
this.minionsFileManager = plugin.getMinionsFileManager();
}
@Override
@ -84,11 +88,8 @@ public class SpecialSettingsEditorPanel extends SubVariablePanelHandler<Skill, C
ClickAction clickAction = customSkillAction.getAction();
String name = customSkillAction.getSettingName();
ItemStack displayStack = customSkillAction.getDisplayItemStack();
Map<String, String> replaceMap = new HashMap<>();
// replaceMap.put("{name}", name);
// replaceMap.put("{multiplier}", ""+customSkillHandler.doesUseMultiplier());
// replaceMap.put("{customData}", hasCustomData);
}
}));

View File

@ -16,6 +16,7 @@ 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.base.ClickAction;
import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler;
import lombok.Getter;
import org.bukkit.Location;
@ -58,12 +59,12 @@ public class Cage extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
Map<String, Class<?>> map = new HashMap<>();
public Map<String, Object> getOtherSkillData() {
Map<String, Object> map = new HashMap<>();
map.put("flatType", String.class);
map.put("wallType", String.class);
map.put("insideType", String.class);
map.put("flatType", "IRON_BLOCK");
map.put("wallType", "IRON_BARS");
map.put("insideType", "AIR");
return map;
}
@ -71,10 +72,14 @@ public class Cage extends CustomSkillHandler {
@Override
public List<ICustomSkillAction> getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) {
List<ICustomSkillAction> clickActions = new ArrayList<>();
ItemStack clickStack = new ItemStack(Material.STONE_PRESSURE_PLATE);
ClickAction flatAction = (event -> this.flatTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
ClickAction wallAction = (event -> this.wallTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
ClickAction insideAction = (event -> this.insideTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
// clickActions.add(BossSkillManager.createCustomSkillAction("Flat Type Editor", new ItemStack(Material.STONE_PRESSURE_PLATE), event -> this.flatTypeEditor.openFor((Player) event.getWhoClicked()), skill, customSkillElement));
// clickActions.add(event -> this.wallTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
// clickActions.add(event -> this.insideTypeEditor.openFor((Player) event.getWhoClicked(), skill, customSkillElement));
clickActions.add(BossSkillManager.createCustomSkillAction("Flat Type Editor", clickStack.clone(), flatAction));
clickActions.add(BossSkillManager.createCustomSkillAction("Wall Type Editor", clickStack.clone(), wallAction));
clickActions.add(BossSkillManager.createCustomSkillAction("Inside Type Editor", clickStack.clone(), insideAction));
return clickActions;
}

View File

@ -31,7 +31,7 @@ public class Disarm extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
public Map<String, Object> getOtherSkillData() {
return null;
}

View File

@ -25,7 +25,7 @@ public class Fireball extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
public Map<String, Object> getOtherSkillData() {
return null;
}

View File

@ -26,7 +26,7 @@ public class Grapple extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
public Map<String, Object> getOtherSkillData() {
return null;
}

View File

@ -26,7 +26,7 @@ public class Knockback extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
public Map<String, Object> getOtherSkillData() {
return null;
}

View File

@ -25,7 +25,7 @@ public class Launch extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
public Map<String, Object> getOtherSkillData() {
return null;
}

View File

@ -24,7 +24,7 @@ public class Lightning extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
public Map<String, Object> getOtherSkillData() {
return null;
}

View File

@ -4,6 +4,7 @@ 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.managers.BossSkillManager;
import com.songoda.epicbosses.skills.CustomSkillHandler;
import com.songoda.epicbosses.skills.Skill;
import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement;
@ -12,9 +13,11 @@ 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.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
@ -40,11 +43,11 @@ public class Minions extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
Map<String, Class<?>> map = new HashMap<>();
public Map<String, Object> getOtherSkillData() {
Map<String, Object> map = new HashMap<>();
map.put("amount", Integer.class);
map.put("minionToSpawn", String.class);
map.put("amount", 1);
map.put("minionToSpawn", "");
return map;
}
@ -53,7 +56,8 @@ public class Minions extends CustomSkillHandler {
public List<ICustomSkillAction> getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement) {
List<ICustomSkillAction> clickActions = new ArrayList<>();
// clickActions.add(getAmountAction(skill, customSkillElement));
clickActions.add(BossSkillManager.createCustomSkillAction("Amount Editor", getAmountCurrent(customSkillElement), new ItemStack(Material.REDSTONE), getAmountAction(skill, customSkillElement)));
clickActions.add(BossSkillManager.createCustomSkillAction("Minion to Spawn Editor", new ItemStack(Material.CREEPER_SPAWN_EGG), getMinionToSpawnAction(skill, customSkillElement)));
return clickActions;
}
@ -63,6 +67,16 @@ public class Minions extends CustomSkillHandler {
BossAPI.spawnNewMinion(activeBossHolder, skill);
}
private ClickAction getMinionToSpawnAction(Skill skill, CustomSkillElement customSkillElement) {
return event -> this.plugin.getBossPanelManager().getMinionSelectEditorMenu().openFor((Player) event.getWhoClicked(), skill, customSkillElement);
}
private String getAmountCurrent(CustomSkillElement customSkillElement) {
CustomMinionSkillElement customMinionSkillElement = customSkillElement.getCustom().getCustomMinionSkillData();
return ""+customMinionSkillElement.getAmount();
}
private ClickAction getAmountAction(Skill skill, CustomSkillElement customSkillElement) {
return event -> {
CustomMinionSkillElement customMinionSkillElement = customSkillElement.getCustom().getCustomMinionSkillData();

View File

@ -24,7 +24,7 @@ public class Warp extends CustomSkillHandler {
}
@Override
public Map<String, Class<?>> getOtherSkillData() {
public Map<String, Object> getOtherSkillData() {
return null;
}

View File

@ -16,4 +16,5 @@ public interface ICustomSkillAction {
ItemStack getDisplayItemStack();
String getCurrent();
}

View File

@ -15,7 +15,7 @@ public interface ICustomSkillHandler extends ISkillHandler<CustomSkillElement> {
boolean doesUseMultiplier();
Map<String, Class<?>> getOtherSkillData();
Map<String, Object> getOtherSkillData();
List<ICustomSkillAction> getOtherSkillDataActions(Skill skill, CustomSkillElement customSkillElement);

View File

@ -20,7 +20,7 @@
<properties>
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
<plugin.version>1.0.0-U133</plugin.version>
<plugin.version>1.0.0-U134</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>