1.0.0-SNAPSHOT-U88

+ Added Commands EditorPanel
This commit is contained in:
Charles 2018-11-28 22:33:45 +08:00
parent 0121b96788
commit 1a42d8860f
9 changed files with 403 additions and 3 deletions

View File

@ -34,6 +34,15 @@ Hooks:
- 'blocked_region2'
Display:
Boss:
Commands:
menuName: '&b&l{name} Editor'
selectedName: '&bCommand: &f{name} &a&l** Selected **'
name: '&bCommand: &f{name}'
lore:
- '&fCommands within this section:'
- '{commands}'
Taunts:
menuName: '&b&l{name} Editor'
Drops:
lore:
- '&3Type: &7{type}'

View File

@ -988,3 +988,44 @@ StatisticsMainEditorPanel:
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'
CommandsEditorPanel:
name: '&b&l{name} Editor'
slots: 9
Settings:
backButton: true
emptySpaceFiller: true
EmptySpaceFiller:
type: WHITE_STAINED_GLASS_PANE
name: '&7'
Buttons:
backButton: 9
Items:
'1':
type: BOOK
name: '&c&lCommands Guide'
lore:
- '&7Here you can configure which command set'
- '&7the boss has for specific events.'
'4':
type: TALL_GRASS
name: '&e&lOn Spawn'
lore:
- '&7Here you can change the command for'
- '&7the spawn of the boss.'
- '&7'
- '&fCurrently Selected: &7{onSpawn}'
Button: OnSpawn
'6':
type: REDSTONE
name: '&e&lOn Death'
lore:
- '&7Here you can change the command'
- '&7the death of the boss.'
- '&7'
- '&fCurrently Selected: &7{onDeath}'
Button: OnDeath
'9':
type: PAPER
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'

View File

@ -5,6 +5,8 @@ import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.EquipmentElement;
import com.songoda.epicbosses.entity.elements.HandsElement;
import com.songoda.epicbosses.panel.bosses.*;
import com.songoda.epicbosses.panel.bosses.commands.OnDeathCommandEditor;
import com.songoda.epicbosses.panel.bosses.commands.OnSpawnCommandEditor;
import com.songoda.epicbosses.panel.bosses.list.BossListEquipmentEditorPanel;
import com.songoda.epicbosses.panel.bosses.equipment.BootsEditorPanel;
import com.songoda.epicbosses.panel.bosses.equipment.ChestplateEditorPanel;
@ -44,7 +46,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 ISubVariablePanelHandler<BossEntity, EntityStatsElement> statisticMainEditMenu, entityTypeEditMenu;
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, targetingEditMenu, skillsBossEditMenu, skillListBossEditMenu;
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, targetingEditMenu, skillsBossEditMenu, skillListBossEditMenu, commandsMainEditMenu, onSpawnCommandEditMenu, onDeathCommandEditMenu;
@Getter private BossListEditorPanel equipmentListEditMenu, weaponListEditMenu, statisticListEditMenu;
private final CustomBosses customBosses;
@ -71,6 +73,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
loadTargetingEditMenu();
loadSkillsEditMenu();
loadStatEditMenu();
loadCommandEditMenus();
loadEquipmentEditMenu();
loadWeaponEditMenu();
@ -96,6 +99,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
reloadTargetingEditMenu();
reloadSkillsEditMenu();
reloadStatEditMenu();
reloadCommandEditMenus();
reloadEquipmentEditMenu();
reloadWeaponEditMenu();
@ -128,6 +132,28 @@ public class BossPanelManager implements ILoadable, IReloadable {
return timesUsed;
}
//---------------------------------------------
//
// C O M M A N D S E D I T P A N E L S
//
//---------------------------------------------
private void loadCommandEditMenus() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("CommandsEditorPanel"));
this.commandsMainEditMenu = new CommandsMainEditorPanel(this, panelBuilder);
this.onSpawnCommandEditMenu = new OnSpawnCommandEditor(this, getListMenu("Boss.Commands"), this.customBosses);
this.onDeathCommandEditMenu = new OnDeathCommandEditor(this, getListMenu("Boss.Commands"), this.customBosses);
}
private void reloadCommandEditMenus() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("CommandsEditorPanel"));
this.commandsMainEditMenu.initializePanel(panelBuilder);
this.onSpawnCommandEditMenu.initializePanel(getListMenu("Boss.Commands"));
this.onDeathCommandEditMenu.initializePanel(getListMenu("Boss.Commands"));
}
//---------------------------------------------
//
// E Q U I P M E N T E D I T P A N E L S

View File

@ -0,0 +1,62 @@
package com.songoda.epicbosses.panel.bosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
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 com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Nov-18
*/
public class CommandsMainEditorPanel extends VariablePanelHandler<BossEntity> {
public CommandsMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
}
@Override
public void fillPanel(Panel panel, BossEntity 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));
replaceMap.put("{onSpawn}", bossEntity.getCommands().getOnSpawn());
replaceMap.put("{onDeath}", bossEntity.getCommands().getOnDeath());
panelBuilder.addReplaceData(replaceMap);
PanelBuilderCounter counter = panelBuilder.getPanelBuilderCounter();
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity);
counter.getSlotsWith("OnSpawn").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnSpawnCommandEditMenu().openFor(player, bossEntity)));
counter.getSlotsWith("OnDeath").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnDeathCommandEditMenu().openFor(player, bossEntity)));
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
panelBuilderCounter
.addSlotCounter("OnSpawn")
.addSlotCounter("OnDeath");
}
}

View File

@ -12,6 +12,7 @@ import com.songoda.epicbosses.utils.panel.base.ClickAction;
import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler;
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 java.util.HashMap;
@ -81,6 +82,7 @@ public class MainBossEditPanel extends VariablePanelHandler<BossEntity> {
counter.getSlotsWith("Weapon").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getWeaponListEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Skill").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getSkillsBossEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Stats").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getStatisticListEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Command").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getCommandsMainEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
panel.openFor(player);
}

View File

@ -57,7 +57,6 @@ public class SkillMainEditorPanel extends VariablePanelHandler<BossEntity> {
.setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
fillPanel(panel, bossEntity);
counter.getSlotsWith("OverallChance").forEach(slot -> panel.setOnClick(slot, getOverallChanceAction(bossEntity)));
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()));

View File

@ -0,0 +1,129 @@
package com.songoda.epicbosses.panel.bosses.commands;
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.CommandsFileManager;
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 org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Nov-18
*/
public class OnDeathCommandEditor extends VariablePanelHandler<BossEntity> {
private CommandsFileManager commandsFileManager;
private ItemStackConverter itemStackConverter;
private CustomBosses plugin;
public OnDeathCommandEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.commandsFileManager = plugin.getBossCommandFileManager();
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
Map<String, List<String>> currentCommands = this.commandsFileManager.getCommandsMap();
List<String> entryList = new ArrayList<>(currentCommands.keySet());
int maxPage = panel.getMaxPage(entryList);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, currentCommands, entryList, bossEntity);
return true;
}));
loadPage(panel, 0, currentCommands, 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.getCommandsMainEditMenu(), bossEntity);
fillPanel(panel, bossEntity);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int page, Map<String, List<String>> currentCommands, List<String> entryList, BossEntity bossEntity) {
panel.loadPage(page, (slot, realisticSlot) -> {
if(slot >= entryList.size()) {
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
} else {
String name = entryList.get(slot);
List<String> commands = currentCommands.get(name);
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultTextMenuItem");
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{name}", name);
if(bossEntity.getCommands().getOnDeath().equalsIgnoreCase(name)) {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.selectedName"), replaceMap);
} else {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.name"), replaceMap);
}
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> presetLore = this.plugin.getConfig().getStringList("Display.Boss.Commands.lore");
List<String> newLore = new ArrayList<>();
for(String s : presetLore) {
if(s.contains("{commands}")) {
for(String command : commands) {
newLore.add(StringUtils.get().translateColor("&7" + command));
}
} else {
newLore.add(StringUtils.get().translateColor(s));
}
}
itemMeta.setLore(newLore);
itemStack.setItemMeta(itemMeta);
panel.setItem(realisticSlot, itemStack, e -> {
bossEntity.getCommands().setOnDeath(name);
this.plugin.getBossesFileManager().save();
loadPage(panel, page, currentCommands, entryList, bossEntity);
});
}
});
}
}

View File

@ -0,0 +1,132 @@
package com.songoda.epicbosses.panel.bosses.commands;
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.CommandsFileManager;
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 javafx.scene.layout.Pane;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Nov-18
*/
public class OnSpawnCommandEditor extends VariablePanelHandler<BossEntity> {
private CommandsFileManager commandsFileManager;
private ItemStackConverter itemStackConverter;
private CustomBosses plugin;
public OnSpawnCommandEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.commandsFileManager = plugin.getBossCommandFileManager();
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
Map<String, List<String>> currentCommands = this.commandsFileManager.getCommandsMap();
List<String> entryList = new ArrayList<>(currentCommands.keySet());
int maxPage = panel.getMaxPage(entryList);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, currentCommands, entryList, bossEntity);
return true;
}));
loadPage(panel, 0, currentCommands, 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.getCommandsMainEditMenu(), bossEntity);
fillPanel(panel, bossEntity);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int page, Map<String, List<String>> currentCommands, List<String> entryList, BossEntity bossEntity) {
panel.loadPage(page, (slot, realisticSlot) -> {
if(slot >= entryList.size()) {
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
} else {
String name = entryList.get(slot);
List<String> commands = currentCommands.get(name);
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultTextMenuItem");
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{name}", name);
if(bossEntity.getCommands().getOnSpawn().equalsIgnoreCase(name)) {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.selectedName"), replaceMap);
} else {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.name"), replaceMap);
}
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> presetLore = this.plugin.getConfig().getStringList("Display.Boss.Commands.lore");
List<String> newLore = new ArrayList<>();
for(String s : presetLore) {
if(s.contains("{commands}")) {
for(String command : commands) {
newLore.add(StringUtils.get().translateColor("&7" + command));
}
} else {
newLore.add(StringUtils.get().translateColor(s));
}
}
itemMeta.setLore(newLore);
itemStack.setItemMeta(itemMeta);
panel.setItem(realisticSlot, itemStack, e -> {
bossEntity.getCommands().setOnSpawn(name);
this.plugin.getBossesFileManager().save();
loadPage(panel, page, currentCommands, entryList, bossEntity);
});
}
});
}
}

View File

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