mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-22 06:41:20 +01:00
1.0.0-SNAPSHOT-U196
+ Added SpawnItem button to the MainBossEditMenu + Fixed issue with Bosses still taunting even after death + Fixed boss reload error + Fixed boss shop not displaying anything + Fixed boss shop not displaying a back button, and taking u back to the main menu for boss editing
This commit is contained in:
parent
cd5caeb091
commit
449d7e7003
@ -183,7 +183,6 @@ Display:
|
||||
- '&7Shift Right-Click to remove.'
|
||||
- '&7Left-Click to edit.'
|
||||
Shop:
|
||||
menuName: '&b&lEpicBosses &3&lShop'
|
||||
name: '&b&lBuy {name}''s Egg'
|
||||
lore:
|
||||
- '&3Cost: &a$&f{price}'
|
||||
|
@ -81,6 +81,50 @@ MainMenu:
|
||||
- '&7Create a new custom skill from'
|
||||
- '&7scratch.'
|
||||
Button: CustomSkills
|
||||
ShopListPanel:
|
||||
name: '&b&lEpicBosses &3&lShop'
|
||||
slots: 54
|
||||
Settings:
|
||||
backButton: true
|
||||
fillTo: 45
|
||||
Buttons:
|
||||
backButton: 50
|
||||
Items:
|
||||
'46':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'47':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'48':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'49':
|
||||
type: ARROW
|
||||
name: '&e&l&m<-&e&l Previous Page'
|
||||
lore:
|
||||
- '&7Click here to go to the previous'
|
||||
- '&7page.'
|
||||
PreviousPage: true
|
||||
'50':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'51':
|
||||
type: ARROW
|
||||
name: '&e&lNext Page &e&l&m->'
|
||||
lore:
|
||||
- '&7Click here to go to the next'
|
||||
- '&7page.'
|
||||
NextPage: true
|
||||
'52':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'53':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'54':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
ListPanel:
|
||||
name: '{panelName}'
|
||||
slots: 54
|
||||
@ -266,6 +310,16 @@ MainEditorPanel:
|
||||
- '&7skill(s) the boss has and their occurrence'
|
||||
- '&7chances.'
|
||||
Button: Skill
|
||||
'30':
|
||||
type: STICK
|
||||
name: '&a&lSpawn Item Manager'
|
||||
lore:
|
||||
- '&bCurrently: &f{spawnItem}'
|
||||
- '&7'
|
||||
- '&7Click here to select a spawn item for this'
|
||||
- '&7boss section from all the current items saved'
|
||||
- '&7in the plugin.'
|
||||
Button: SpawnItem
|
||||
'32':
|
||||
type: LAPIS_LAZULI
|
||||
name: '&a&lStatistics Manager'
|
||||
@ -274,6 +328,13 @@ MainEditorPanel:
|
||||
- '&7boss, including things like: health,'
|
||||
- '&7potion effects, commands on spawn, etc.'
|
||||
Button: Stats
|
||||
'34':
|
||||
type: GOLD_BLOCK
|
||||
name: '&a&lShop Manager'
|
||||
lore:
|
||||
- '&7Click here to modify the shop settings for'
|
||||
- '&7this boss.'
|
||||
Button: Shop
|
||||
'39':
|
||||
type: BOOK
|
||||
name: '&a&lCommand Manager'
|
||||
@ -297,6 +358,61 @@ MainEditorPanel:
|
||||
- '&7Click here to edit the taunts, sayings,'
|
||||
- '&7etc. for this boss.'
|
||||
Button: Text
|
||||
SpawnItemEditorPanel:
|
||||
name: '&b&l{name} Editor'
|
||||
slots: 54
|
||||
Settings:
|
||||
fillTo: 45
|
||||
backButton: true
|
||||
Buttons:
|
||||
backButton: 54
|
||||
Items:
|
||||
'46':
|
||||
type: DIAMOND
|
||||
name: '&c&lRemove'
|
||||
lore:
|
||||
- '&7click here to remove the currently'
|
||||
- '&7equipped spawn item.'
|
||||
Button: Remove
|
||||
'47':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'48':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'49':
|
||||
type: ARROW
|
||||
name: '&e&l&m<-&e&l Previous Page'
|
||||
lore:
|
||||
- '&7Click here to go to the previous'
|
||||
- '&7page of spawn item.'
|
||||
PreviousPage: true
|
||||
'50':
|
||||
type: DIAMOND_BLOCK
|
||||
name: '&a&lAdd New Spawn Item'
|
||||
lore:
|
||||
- '&7Click here to add a new spawn'
|
||||
- '&7item which you have in your'
|
||||
- '&7inventory.'
|
||||
Button: AddNew
|
||||
'51':
|
||||
type: ARROW
|
||||
name: '&e&lNext Page &e&l&m->'
|
||||
lore:
|
||||
- '&7Click here to go to the next'
|
||||
- '&7page of spawn item.'
|
||||
NextPage: true
|
||||
'52':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'53':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'54':
|
||||
type: PAPER
|
||||
name: '&e&lGo Back'
|
||||
lore:
|
||||
- '&7Click here to go back.'
|
||||
DropsMainEditorPanel:
|
||||
name: '&b&l{name} Editor'
|
||||
slots: 9
|
||||
|
@ -151,12 +151,12 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
this.bossMessagesFileManager.reload();
|
||||
this.bossCommandFileManager.reload();
|
||||
this.minionsFileManager.reload();
|
||||
this.bossesFileManager.reload();
|
||||
this.skillsFileManager.reload();
|
||||
this.itemStackManager.reload();
|
||||
this.bossesFileManager.reload();
|
||||
this.minionsFileManager.reload();
|
||||
this.skillsFileManager.reload();
|
||||
this.bossCommandFileManager.reload();
|
||||
this.bossMessagesFileManager.reload();
|
||||
this.dropTableFileManager.reload();
|
||||
this.autoSpawnFileManager.reload();
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> statisticMainEditMenu, entityTypeEditMenu;
|
||||
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, targetingEditMenu, skillsBossEditMenu, skillListBossEditMenu, commandsMainEditMenu, onSpawnCommandEditMenu,
|
||||
onDeathCommandEditMenu, mainDropsEditMenu, mainTextEditMenu, mainTauntEditMenu, onSpawnTextEditMenu, onSpawnSubTextEditMenu, onDeathTextEditMenu, onDeathSubTextEditMenu, onDeathPositionTextEditMenu,
|
||||
onTauntTextEditMenu;
|
||||
onTauntTextEditMenu, spawnItemEditMenu;
|
||||
@Getter private BossListEditorPanel equipmentListEditMenu, weaponListEditMenu, statisticListEditMenu;
|
||||
|
||||
@Getter private IVariablePanelHandler<Skill> mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu, potionSkillEditorPanel, commandSkillEditorPanel, groupSkillEditorPanel, customSkillEditorPanel;
|
||||
@ -606,6 +606,8 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
private void loadEquipmentEditMenus() {
|
||||
FileConfiguration editor = this.customBosses.getEditor();
|
||||
|
||||
this.spawnItemEditMenu = new SpawnItemEditorPanel(this, new PanelBuilder(editor.getConfigurationSection("SpawnItemEditorPanel")), this.customBosses);
|
||||
|
||||
this.helmetEditorMenu = new HelmetEditorPanel(this, editor.getConfigurationSection(HELMET_EDITOR_PATH), this.customBosses);
|
||||
this.chestplateEditorMenu = new ChestplateEditorPanel(this, editor.getConfigurationSection(CHESTPLATE_EDITOR_PATH), this.customBosses);
|
||||
this.leggingsEditorMenu = new LeggingsEditorPanel(this, editor.getConfigurationSection(LEGGINGS_EDITOR_PATH), this.customBosses);
|
||||
@ -618,6 +620,8 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
private void reloadEquipmentEditMenus() {
|
||||
FileConfiguration editor = this.customBosses.getEditor();
|
||||
|
||||
this.spawnItemEditMenu.initializePanel(new PanelBuilder(editor.getConfigurationSection("SpawnItemEditorPanel")));
|
||||
|
||||
this.helmetEditorMenu.initializePanel(new PanelBuilder(editor.getConfigurationSection(HELMET_EDITOR_PATH)));
|
||||
this.chestplateEditorMenu.initializePanel(new PanelBuilder(editor.getConfigurationSection(CHESTPLATE_EDITOR_PATH)));
|
||||
this.leggingsEditorMenu.initializePanel(new PanelBuilder(editor.getConfigurationSection(LEGGINGS_EDITOR_PATH)));
|
||||
@ -808,11 +812,11 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
//---------------------------------------------
|
||||
|
||||
private void loadShopMenu() {
|
||||
this.shopPanel = new ShopPanel(this, getListMenu("Shop"), this.customBosses);
|
||||
this.shopPanel = new ShopPanel(this, new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("ShopListPanel")), this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadShopMenu() {
|
||||
this.shopPanel.initializePanel(getListMenu("Shop"));
|
||||
this.shopPanel.initializePanel(new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("ShopListPanel")));
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
|
@ -53,7 +53,7 @@ public class BossTauntManager {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(activeBossHolder.isDead()) {
|
||||
if(activeBossHolder.isDead() || BossTauntManager.this.plugin.getBossEntityManager().isAllEntitiesDead(activeBossHolder)) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -9,15 +9,19 @@ import com.songoda.epicbosses.panel.handlers.MainListPanelHandler;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.dependencies.VaultHelper;
|
||||
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.PanelHandler;
|
||||
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.*;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -25,7 +29,7 @@ import java.util.stream.Collectors;
|
||||
* @version 1.0.0
|
||||
* @since 17-Nov-18
|
||||
*/
|
||||
public class ShopPanel extends MainListPanelHandler {
|
||||
public class ShopPanel extends PanelHandler {
|
||||
|
||||
private BossEntityManager bossEntityManager;
|
||||
private BossesFileManager bossesFileManager;
|
||||
@ -44,9 +48,7 @@ public class ShopPanel extends MainListPanelHandler {
|
||||
@Override
|
||||
public void fillPanel(Panel panel) {
|
||||
Map<String, BossEntity> currentEntities = this.bossesFileManager.getBossEntitiesMap();
|
||||
Map<String, BossEntity> filteredMap = currentEntities.entrySet().stream()
|
||||
.filter(entry -> entry.getValue().canBeBought())
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
Map<String, BossEntity> filteredMap = getFilteredMap(currentEntities);
|
||||
List<String> entryList = new ArrayList<>(filteredMap.keySet());
|
||||
int maxPage = panel.getMaxPage(filteredMap);
|
||||
|
||||
@ -60,6 +62,14 @@ public class ShopPanel extends MainListPanelHandler {
|
||||
loadPage(panel, 0, entryList, filteredMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player) {
|
||||
Panel panel = getPanelBuilder().getPanel();
|
||||
|
||||
ServerUtils.get().runTaskAsync(() -> fillPanel(panel));
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
private void loadPage(Panel panel, int page, List<String> entryList, Map<String, BossEntity> filteredMap) {
|
||||
panel.loadPage(page, ((slot, realisticSlot) -> {
|
||||
if(slot >= filteredMap.size()) {
|
||||
@ -105,4 +115,21 @@ public class ShopPanel extends MainListPanelHandler {
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private Map<String, BossEntity> getFilteredMap(Map<String, BossEntity> originalMap) {
|
||||
Map<String, BossEntity> newMap = new HashMap<>();
|
||||
|
||||
originalMap.forEach((s, bossEntity) -> {
|
||||
if(bossEntity.canBeBought()) {
|
||||
newMap.put(s, bossEntity);
|
||||
}
|
||||
});
|
||||
|
||||
return newMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.songoda.epicbosses.managers.BossEntityManager;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.ObjectUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.base.ClickAction;
|
||||
@ -52,6 +53,7 @@ public class MainBossEditPanel extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
|
||||
replaceMap.put("{mode}", bossEntity.getEditingValue());
|
||||
replaceMap.put("{spawnItem}", ObjectUtils.getValue(bossEntity.getSpawnItem(), "N/A"));
|
||||
|
||||
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
|
||||
|
||||
@ -73,6 +75,7 @@ public class MainBossEditPanel extends VariablePanelHandler<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)));
|
||||
counter.getSlotsWith("Text").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getMainTextEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
|
||||
counter.getSlotsWith("SpawnItem").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getSpawnItemEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
|
||||
});
|
||||
|
||||
panel.openFor(player);
|
||||
|
@ -0,0 +1,126 @@
|
||||
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.entity.elements.EntityStatsElement;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.managers.files.ItemsFileManager;
|
||||
import com.songoda.epicbosses.utils.ObjectUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
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 com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
|
||||
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 10-Jan-19
|
||||
*/
|
||||
public class SpawnItemEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
private BossesFileManager bossesFileManager;
|
||||
private ItemsFileManager itemsFileManager;
|
||||
private CustomBosses plugin;
|
||||
|
||||
public SpawnItemEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.bossesFileManager = plugin.getBossesFileManager();
|
||||
this.itemsFileManager = plugin.getItemStackManager();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, BossEntity bossEntity) {
|
||||
Map<String, ItemStackHolder> itemStackHolderMap = this.itemsFileManager.getItemStackHolders();
|
||||
List<String> entryList = new ArrayList<>(itemStackHolderMap.keySet());
|
||||
int maxPage = panel.getMaxPage(entryList);
|
||||
|
||||
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
|
||||
if(requestedPage < 0 || requestedPage > maxPage) return false;
|
||||
|
||||
loadPage(panel, requestedPage, itemStackHolderMap, entryList, bossEntity);
|
||||
return true;
|
||||
}));
|
||||
|
||||
loadPage(panel, 0, itemStackHolderMap, 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);
|
||||
|
||||
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity);
|
||||
|
||||
ServerUtils.get().runTaskAsync(() -> {
|
||||
panelBuilderCounter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getAddItemsMenu().openFor(player)));
|
||||
panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, event -> {
|
||||
bossEntity.setSpawnItem("");
|
||||
this.bossesFileManager.save();
|
||||
|
||||
openFor((Player) event.getWhoClicked(), bossEntity);
|
||||
}));
|
||||
|
||||
fillPanel(panel, bossEntity);
|
||||
});
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
|
||||
}
|
||||
|
||||
private void loadPage(Panel panel, int requestedPage, Map<String, ItemStackHolder> filteredMap, List<String> entryList, BossEntity bossEntity) {
|
||||
String current = ObjectUtils.getValue(bossEntity.getSpawnItem(), "");
|
||||
|
||||
panel.loadPage(requestedPage, (slot, realisticSlot) -> {
|
||||
if(slot >= filteredMap.size()) {
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
|
||||
} else {
|
||||
String name = entryList.get(slot);
|
||||
ItemStackHolder itemStackHolder = filteredMap.get(name);
|
||||
ItemStack itemStack = this.itemsFileManager.getItemStackConverter().from(itemStackHolder);
|
||||
|
||||
if(itemStack == null) {
|
||||
itemStack = new ItemStack(Material.BARRIER);
|
||||
}
|
||||
|
||||
if(name.equalsIgnoreCase(current)) {
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", ItemStackUtils.getName(itemStack));
|
||||
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Equipment.name"), replaceMap);
|
||||
}
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, e -> {
|
||||
bossEntity.setSpawnItem(name);
|
||||
this.bossesFileManager.save();
|
||||
|
||||
loadPage(panel, requestedPage, filteredMap, entryList, bossEntity);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user