1.0.0-SNAPSHOT-U83

+ Added and connected SkillListEditorPanel
+ Added more GUI configuration in to the config.yml
This commit is contained in:
Charles 2018-11-25 23:31:31 +08:00
parent 478183508f
commit ca0a710b7f
6 changed files with 163 additions and 14 deletions

View File

@ -88,4 +88,16 @@ Display:
- '&3Custom Message: &7{customMessage}'
- '&3Radius: &7{radius}'
- '&7'
- '&7Click to edit the custom skill.'
- '&7Click to edit the custom skill.'
BossSkills:
menuName: '&b&l{name} Editor'
selectedName: '&b&l{name} Skill &a&l** Selected **'
name: '&b&l{name} Skill'
lore:
- '&3Type: &7{type}'
- '&3Display Name: &7{displayName}'
- '&3Custom Message: &7{customMessage}'
- '&3Radius: &7{radius}'
- '&7'
- '&7Click to add/remove the skill to'
- '&7or from the boss skill list.'

View File

@ -42,7 +42,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> equipmentEditMenu, helmetEditorMenu, chestplateEditorMenu, leggingsEditorMenu, bootsEditorMenu;
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> weaponEditMenu, offHandEditorMenu, mainHandEditorMenu;
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, targetingEditMenu, skillsBossEditMenu;
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, targetingEditMenu, skillsBossEditMenu, skillListBossEditMenu;
@Getter private BossListEditorPanel equipmentListEditMenu, weaponListEditMenu;
private final CustomBosses customBosses;
@ -186,13 +186,15 @@ public class BossPanelManager implements ILoadable, IReloadable {
private void loadSkillsEditMenu() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("SkillMainEditorPanel"));
this.skillsBossEditMenu = new SkillMainEditorPanel(this, panelBuilder);
this.skillsBossEditMenu = new SkillMainEditorPanel(this, panelBuilder, this.customBosses);
this.skillListBossEditMenu = new SkillListEditorPanel(this, getListMenu("BossSkills"), this.customBosses);
}
private void reloadSkillsEditMenu() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("SkillMainEditorPanel"));
this.skillsBossEditMenu.initializePanel(panelBuilder);
this.skillListBossEditMenu.initializePanel(getListMenu("BossSkills"));
}
//---------------------------------------------

View File

@ -0,0 +1,127 @@
package com.songoda.epicbosses.panel.bosses;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.SkillsFileManager;
import com.songoda.epicbosses.skills.Skill;
import com.songoda.epicbosses.utils.NumberUtils;
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.VariablePanelHandler;
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 25-Nov-18
*/
public class SkillListEditorPanel extends VariablePanelHandler<BossEntity> {
private ItemStackConverter itemStackConverter;
private SkillsFileManager skillsFileManager;
private CustomBosses plugin;
public SkillListEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.itemStackConverter = new ItemStackConverter();
this.skillsFileManager = plugin.getSkillsFileManager();
this.plugin = plugin;
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
Map<String, Skill> currentSkills = this.skillsFileManager.getSkillMap();
List<String> entryList = new ArrayList<>(currentSkills.keySet());
int maxPage = panel.getMaxPage(entryList);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, currentSkills, entryList, bossEntity);
return true;
}));
loadPage(panel, 0, currentSkills, entryList, bossEntity);
}
@Override
public void openFor(Player player, BossEntity bossEntity) {
Map<String, String> replaceMap = new HashMap<>();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getSkillsBossEditMenu(), bossEntity);
fillPanel(panel, bossEntity);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int requestedPage, Map<String, Skill> currentSkills, List<String> entryList, BossEntity bossEntity) {
panel.loadPage(requestedPage, (slot, realisticSlot) -> {
if(slot >= currentSkills.size()) {
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
} else {
String name = entryList.get(slot);
Skill skill = currentSkills.get(name);
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultSkillMenuItem");
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{name}", name);
replaceMap.put("{type}", StringUtils.get().formatString(skill.getType()));
replaceMap.put("{displayName}", skill.getDisplayName());
replaceMap.put("{customMessage}", StringUtils.get().formatString(skill.getCustomMessage()));
replaceMap.put("{radius}", NumberUtils.get().formatDouble(skill.getRadius()));
if(bossEntity.getSkills().getSkills().contains(name)) {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.BossSkills.selectedName"), replaceMap);
} else {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.BossSkills.name"), replaceMap);
}
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.BossSkills.lore"), replaceMap);
panel.setItem(realisticSlot, itemStack, e -> {
List<String> currentSkillList = bossEntity.getSkills().getSkills();
if(currentSkillList.contains(name)) {
currentSkillList.remove(name);
} else {
currentSkillList.add(name);
}
bossEntity.getSkills().setSkills(currentSkillList);
this.plugin.getBossesFileManager().save();
loadPage(panel, requestedPage, currentSkills, entryList, bossEntity);
});
}
});
}
}

View File

@ -1,8 +1,10 @@
package com.songoda.epicbosses.panel.bosses;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.panel.Panel;
@ -23,8 +25,12 @@ import java.util.Map;
*/
public class SkillMainEditorPanel extends VariablePanelHandler<BossEntity> {
public SkillMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
private BossesFileManager bossesFileManager;
public SkillMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.bossesFileManager = plugin.getBossesFileManager();
}
@Override
@ -36,14 +42,12 @@ public class SkillMainEditorPanel extends VariablePanelHandler<BossEntity> {
public void openFor(Player player, BossEntity bossEntity) {
Map<String, String> replaceMap = new HashMap<>();
Double chance = bossEntity.getSkills().getOverallChance();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
if(chance == null) chance = 0.0;
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance));
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
@ -54,7 +58,7 @@ public class SkillMainEditorPanel extends VariablePanelHandler<BossEntity> {
fillPanel(panel, bossEntity);
counter.getSlotsWith("OverallChance").forEach(slot -> panel.setOnClick(slot, getOverallChanceAction(bossEntity)));
counter.getSlotsWith("SkillList").forEach(slot -> panel.setOnClick(slot, getSkillListAction()));
counter.getSlotsWith("SkillList").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getSkillListBossEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Message").forEach(slot -> panel.setOnClick(slot, getMessageAction()));
panel.openFor(player);
@ -101,15 +105,12 @@ public class SkillMainEditorPanel extends VariablePanelHandler<BossEntity> {
}
bossEntity.getSkills().setOverallChance(newChance);
this.bossesFileManager.save();
Message.Boss_Skill_SetChance.msg(event.getWhoClicked(), modifyValue, NumberUtils.get().formatDouble(newChance));
openFor((Player) event.getWhoClicked(), bossEntity);
};
}
private ClickAction getSkillListAction() {
return event -> {};
}
private ClickAction getMessageAction() {
return event -> {};
}

View File

@ -23,7 +23,7 @@ import java.util.Set;
*/
public class PanelBuilder {
private final Map<String, String> replaceMap = new HashMap<>();
@Getter private final Map<String, String> replaceMap = new HashMap<>();
private final Set<Integer> defaultSlots = new HashSet<>();
private final ConfigurationSection configurationSection;
private final PanelBuilderSettings panelBuilderSettings;
@ -145,6 +145,13 @@ public class PanelBuilder {
}
}
String nameKey = "{name}";
//Apply replace twice, to go over any missed replaced values, or new values that had been set in the replacement
if(replaceMap.containsKey(nameKey) && input.contains(nameKey)) {
input = input.replace(nameKey, replaceMap.get(nameKey));
}
return input;
}
}

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>maven-version-number-SNAPSHOT-U82</plugin.version>
<plugin.version>maven-version-number-SNAPSHOT-U83</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>