1.0.0-SNAPSHOT-U127

+ Completed the CustomSkillTypeEditorPanel
+ Added the correct item configuration to the config.yml and editor.yml
This commit is contained in:
Charles 2018-12-16 17:28:44 +08:00
parent aa1833490a
commit f727fe3588
7 changed files with 104 additions and 8 deletions

View File

@ -160,4 +160,11 @@ Display:
- '&3Type: &7{type}'
- '&3Display Name: &7{displayName}'
- '&3Custom Message: &7{customMessage}'
- '&3Radius: &7{radius}'
- '&3Radius: &7{radius}'
CustomType:
selectedName: '&bCustom Skill: &f{name} &a** Selected **'
name: '&bCustom Skill: &f{name}'
lore:
- '&3Type: &7{type}'
- '&3Multiplier: &7{multiplier}'
- '&3Has Custom Data: &7{customData}'

View File

@ -26,11 +26,14 @@ import com.songoda.epicbosses.panel.skills.custom.CustomSkillEditorPanel;
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.potions.CreatePotionEffectEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.potions.PotionEffectTypeEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.PotionSkillEditorPanel;
import com.songoda.epicbosses.skills.Skill;
import com.songoda.epicbosses.skills.elements.SubCommandSkillElement;
import com.songoda.epicbosses.skills.elements.SubCustomSkillElement;
import com.songoda.epicbosses.skills.types.CustomSkillElement;
import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler;
import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler;
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
@ -73,6 +76,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;
private final CustomBosses customBosses;
@ -175,6 +179,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("CommandSkillEditorPanel"));
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("ModifyCommandEditorPanel"));
PanelBuilder panelBuilder6 = new PanelBuilder(editor.getConfigurationSection("CustomSkillEditorPanel"));
PanelBuilder panelBuilder7 = new PanelBuilder(editor.getConfigurationSection("CustomSkillTypeEditorPanel"));
this.mainSkillEditMenu = new MainSkillEditorPanel(this, panelBuilder, this.customBosses);
this.customMessageEditMenu = new SingleMessageListEditor<Skill>(this, getListMenu("Skills.MainEdit"), this.customBosses) {
@ -209,6 +214,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
this.commandListSkillEditMenu = new CommandListSkillEditorPanel(this, getListMenu("Skills.CommandList"), this.customBosses);
this.groupSkillEditorPanel = new GroupSkillEditorPanel(this, getListMenu("Skills.Group"), this.customBosses);
this.customSkillEditorPanel = new CustomSkillEditorPanel(this, panelBuilder6, this.customBosses);
this.customSkillTypeEditorMenu = new CustomSkillTypeEditorPanel(this, panelBuilder7, this.customBosses);
}
private void reloadSkillEditMenus() {
@ -220,6 +226,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("CommandSkillEditorPanel"));
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("ModifyCommandEditorPanel"));
PanelBuilder panelBuilder6 = new PanelBuilder(editor.getConfigurationSection("CustomSkillEditorPanel"));
PanelBuilder panelBuilder7 = new PanelBuilder(editor.getConfigurationSection("CustomSkillTypeEditorPanel"));
this.mainSkillEditMenu.initializePanel(panelBuilder);
this.customMessageEditMenu.initializePanel(getListMenu("Skills.MainEdit"));
@ -232,6 +239,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
this.commandListSkillEditMenu.initializePanel(getListMenu("Skills.CommandList"));
this.groupSkillEditorPanel.initializePanel(getListMenu("Skills.Group"));
this.customSkillEditorPanel.initializePanel(panelBuilder6);
this.customSkillTypeEditorMenu.initializePanel(panelBuilder7);
}
//---------------------------------------------

View File

@ -117,8 +117,13 @@ public class BossSkillManager implements ILoadable {
return null;
}
public List<CustomSkillHandler> getSkills() {
return new ArrayList<>(SKILLS);
}
public boolean registerCustomSkill(CustomSkillHandler customSkillHandler) {
if(SKILLS.contains(customSkillHandler)) return false;
if(customSkillHandler == null) return false;
SKILLS.add(customSkillHandler);
return true;
@ -126,6 +131,7 @@ public class BossSkillManager implements ILoadable {
public void removeCustomSkill(CustomSkillHandler customSkillHandler) {
if(!SKILLS.contains(customSkillHandler)) return;
if(customSkillHandler == null) return;
SKILLS.remove(customSkillHandler);
}
@ -172,7 +178,7 @@ public class BossSkillManager implements ILoadable {
private CustomSkillHandler getCustomSkillHandler(String name) {
for(CustomSkillHandler customSkillHandler : new HashSet<>(SKILLS)) {
String skillName = customSkillHandler.getClass().getSimpleName();
String skillName = customSkillHandler.getSkillName();
if(skillName.equalsIgnoreCase(name)) return customSkillHandler;
}

View File

@ -1,16 +1,24 @@
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.managers.BossPanelManager;
import com.songoda.epicbosses.managers.BossSkillManager;
import com.songoda.epicbosses.skills.CustomSkillHandler;
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.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.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -20,8 +28,16 @@ import java.util.Map;
*/
public class CustomSkillTypeEditorPanel extends SubVariablePanelHandler<Skill, CustomSkillElement> {
public CustomSkillTypeEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
private ItemStackConverter itemStackConverter;
private BossSkillManager bossSkillManager;
private CustomBosses plugin;
public CustomSkillTypeEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.bossSkillManager = plugin.getBossSkillManager();
}
@Override
@ -32,12 +48,9 @@ public class CustomSkillTypeEditorPanel extends SubVariablePanelHandler<Skill, C
replaceMap.put("{name}", BossAPI.getSkillName(skill));
panelBuilder.addReplaceData(replaceMap);
PanelBuilderCounter counter = panelBuilder.getPanelBuilderCounter();
Panel panel = panelBuilder.getPanel()
.setParentPanelHandler(this.bossPanelManager.getCustomSkillEditorPanel(), skill);
fillPanel(panel, skill, customSkillElement);
panel.openFor(player);
@ -45,11 +58,65 @@ public class CustomSkillTypeEditorPanel extends SubVariablePanelHandler<Skill, C
@Override
public void fillPanel(Panel panel, Skill skill, CustomSkillElement customSkillElement) {
List<CustomSkillHandler> customSkillHandlers = this.bossSkillManager.getSkills();
int maxPage = panel.getMaxPage(customSkillHandlers);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, skill, customSkillElement, customSkillHandlers);
return true;
}));
loadPage(panel, 0, skill, customSkillElement, customSkillHandlers);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int page, Skill skill, CustomSkillElement customSkillElement, List<CustomSkillHandler> customSkillHandlers) {
String current = customSkillElement.getCustom().getType();
panel.loadPage(page, ((slot, realisticSlot) -> {
if(slot >= customSkillHandlers.size()) {
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
} else {
CustomSkillHandler customSkillHandler = customSkillHandlers.get(slot);
String name = customSkillHandler.getSkillName();
Map<String, String> replaceMap = new HashMap<>();
String hasCustomData = customSkillHandler.getOtherSkillData().isEmpty()? "false" : "true";
replaceMap.put("{name}", name);
replaceMap.put("{multiplier}", ""+customSkillHandler.doesUseMultiplier());
replaceMap.put("{customData}", hasCustomData);
ItemStack itemStack;
if(name.equalsIgnoreCase(current)) {
itemStack = this.itemStackConverter.from(this.plugin.getItemStackManager().getItemStackHolder("DefaultSelectedCustomSkillTypeItem"));
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.CustomType.selectedName"), replaceMap);
} else {
itemStack = this.itemStackConverter.from(this.plugin.getItemStackManager().getItemStackHolder("DefaultCustomSkillTypeItem"));
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.CustomType.name"), replaceMap);
}
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.Skills.CustomType.lore"), replaceMap);
panel.setItem(realisticSlot, itemStack, event -> {
customSkillElement.getCustom().setType(name);
JsonObject jsonObject = BossAPI.convertObjectToJsonObject(customSkillElement);
skill.setCustomData(jsonObject);
this.plugin.getSkillsFileManager().save();
loadPage(panel, page, skill, customSkillElement, customSkillHandlers);
});
}
}));
}
}

View File

@ -8,4 +8,10 @@ import com.songoda.epicbosses.skills.types.CustomSkillElement;
* @since 18-Nov-18
*/
public abstract class CustomSkillHandler implements ISkillHandler<CustomSkillElement> {
@Override
public String getSkillName() {
return getClass().getSimpleName();
}
}

View File

@ -14,6 +14,8 @@ import java.util.Map;
*/
public interface ISkillHandler<T> {
String getSkillName();
boolean doesUseMultiplier();
Map<String, Class<?>> getOtherSkillData();

View File

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