mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-09-29 22:07:32 +02:00
1.0.0-SNAPSHOT-U72
+ Added BossList Panel + Updated Equipment Panel
This commit is contained in:
parent
06474b91f3
commit
ccf471b16d
77
backup.yml
77
backup.yml
@ -1,68 +1,5 @@
|
||||
EquipmentPanel:
|
||||
name: '&b&l{boss} Editor'
|
||||
slots: 9
|
||||
Settings:
|
||||
backButton: true
|
||||
emptySpaceFiller: true
|
||||
EmptySpaceFiller:
|
||||
type: '160:0'
|
||||
name: '&7'
|
||||
Buttons:
|
||||
BackButton: 9
|
||||
Items:
|
||||
'2':
|
||||
type: DIAMOND_HELMET
|
||||
name: '&c&lHelmet'
|
||||
lore:
|
||||
- '&7Click here to change the'
|
||||
- '&7helmet for the &f{boss}'
|
||||
- '&7or add one from your'
|
||||
- '&7inventory.'
|
||||
Button: Helmet
|
||||
'3':
|
||||
type: DIAMOND_CHESTPLATE
|
||||
name: '&c&lChestplate'
|
||||
lore:
|
||||
- '&7Click here to change the'
|
||||
- '&7chestplate for the &f{boss}'
|
||||
- '&7or add one from your'
|
||||
- '&7inventory.'
|
||||
Button: Chestplate
|
||||
'4':
|
||||
type: DIAMOND_LEGGINGS
|
||||
name: '&c&lLeggings'
|
||||
lore:
|
||||
- '&7Click here to change the'
|
||||
- '&7leggings for the &f{boss}'
|
||||
- '&7or add one from your'
|
||||
- '&7inventory.'
|
||||
Button: Leggings
|
||||
'5':
|
||||
type: DIAMOND_BOOTS
|
||||
name: '&c&lBoots'
|
||||
lore:
|
||||
- '&7Click here to change the'
|
||||
- '&7boots for the &f{boss}'
|
||||
- '&7or add one from your'
|
||||
- '&7inventory.'
|
||||
Button: Boots
|
||||
'8':
|
||||
type: PAPER
|
||||
name: '&e&lGo Back'
|
||||
lore:
|
||||
- '&7Click here to go back.'
|
||||
'9':
|
||||
type: BOOK
|
||||
name: '&c&lEquipment Guide'
|
||||
lore:
|
||||
- '&7here you can choose what equipment'
|
||||
- '&7this boss has. To choose simply click'
|
||||
- '&7the desired piece, then click one of'
|
||||
- '&7the preset pieces or click the diamond'
|
||||
- '&7block to add a new piece from your'
|
||||
- '&7inventory.'
|
||||
HelmetPanel:
|
||||
name: '&b&l{boss} Editor'
|
||||
name: '&b&l{name} Editor'
|
||||
slots: 54
|
||||
Settings:
|
||||
fillTo: 45
|
||||
@ -78,10 +15,10 @@ HelmetPanel:
|
||||
- '&7currently equipped helmet.'
|
||||
Button: Remove
|
||||
'47':
|
||||
type: STAINED_GLASS_PANE
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'48':
|
||||
type: STAINED_GLASS_PANE
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'49':
|
||||
type: ARROW
|
||||
@ -89,8 +26,6 @@ HelmetPanel:
|
||||
lore:
|
||||
- '&7Click here to go to the previous'
|
||||
- '&7page of helmets.'
|
||||
- '&7'
|
||||
- '&7Currently viewing page &e{currentPage}/{maxPages}&7.'
|
||||
PreviousPage: true
|
||||
'50':
|
||||
type: DIAMOND_BLOCK
|
||||
@ -106,14 +41,12 @@ HelmetPanel:
|
||||
lore:
|
||||
- '&7Click here to go to the next'
|
||||
- '&7page of helmets.'
|
||||
- '&7'
|
||||
- '&7Currently viewing page &e{currentPage}/{maxPages}&7.'
|
||||
NextPage: true
|
||||
'52':
|
||||
type: STAINED_GLASS_PANE
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'53':
|
||||
type: STAINED_GLASS_PANE
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'54':
|
||||
type: PAPER
|
||||
|
@ -15,6 +15,10 @@
|
||||
"type": "BLAZE_POWDER",
|
||||
"name": "&c&lDefault Skill Menu Item"
|
||||
},
|
||||
"DefaultBossListEditorMenuItem": {
|
||||
"type": "ZOMBIE_SPAWN_EGG",
|
||||
"name": "&c&lDefault Boss List Editor Menu Item"
|
||||
},
|
||||
"SKSpawnItem": {
|
||||
"type": "SKELETON_SPAWN_EGG",
|
||||
"name": "&6&lSkeleton King Boss Spawn Egg",
|
||||
|
@ -33,6 +33,18 @@ Hooks:
|
||||
- 'blocked_region1'
|
||||
- 'blocked_region2'
|
||||
Display:
|
||||
BossListEditor:
|
||||
name: '&3{position} Entity'
|
||||
lore:
|
||||
- '&3Left Click &8»'
|
||||
- '&7Edit the {targetType} for this'
|
||||
- '&7entity in the section.'
|
||||
- '&7'
|
||||
- '&3Right Click &8»'
|
||||
- '&7Remove this section, can be done'
|
||||
- '&7to anything above the first one.'
|
||||
EquipmentEditor:
|
||||
name: '{name} &a&l** Selected **'
|
||||
EditDrops:
|
||||
lore:
|
||||
- '&3Type: &7{type}'
|
||||
|
@ -309,6 +309,48 @@ DropsEditorPanel:
|
||||
- '&7 with an emerald which states so.'
|
||||
- '&c&l* &7Every drop table from every boss will be listed'
|
||||
- '&7 here as an available drop table.'
|
||||
BossListEditorPanel:
|
||||
name: '&b&l{name} Editor'
|
||||
slots: 54
|
||||
Settings:
|
||||
backButton: true
|
||||
fillTo: 45
|
||||
Buttons:
|
||||
backButton: 54
|
||||
Items:
|
||||
'46':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'47':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'48':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'49':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'50':
|
||||
type: DIAMOND_BLOCK
|
||||
name: '&a&lCreate a new Entity'
|
||||
lore:
|
||||
- '&7Click here to create a new entity'
|
||||
- '&7within this boss.'
|
||||
Button: CreateEntity
|
||||
'51':
|
||||
type: WHITE_STAINED_GLASS_PANE
|
||||
name: '&7'
|
||||
'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.'
|
||||
EquipmentEditorPanel:
|
||||
name: '&b&l{name} Editor'
|
||||
slots: 9
|
||||
@ -372,3 +414,58 @@ EquipmentEditorPanel:
|
||||
- '&7the preset pieces or click the diamond'
|
||||
- '&7block to add a new piece from your'
|
||||
- '&7inventory.'
|
||||
HelmetEditorPanel:
|
||||
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'
|
||||
- '&7currently equipped helmet.'
|
||||
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 helmets.'
|
||||
PreviousPage: true
|
||||
'50':
|
||||
type: DIAMOND_BLOCK
|
||||
name: '&a&lAdd New Helmet'
|
||||
lore:
|
||||
- '&7Click here to add a new'
|
||||
- '&7helmet 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 helmets.'
|
||||
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.'
|
@ -4,9 +4,13 @@ import com.songoda.epicbosses.entity.BossEntity;
|
||||
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.entity.elements.MainStatsElement;
|
||||
import com.songoda.epicbosses.panel.bosses.BossListEquipmentEditorPanel;
|
||||
import com.songoda.epicbosses.panel.bosses.DropsEditorPanel;
|
||||
import com.songoda.epicbosses.panel.bosses.EquipmentEditorPanel;
|
||||
import com.songoda.epicbosses.panel.bosses.MainBossEditPanel;
|
||||
import com.songoda.epicbosses.panel.bosses.equipment.HelmetEditorPanel;
|
||||
import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler;
|
||||
import lombok.Getter;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
@ -32,7 +36,8 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
@Getter private IPanelHandler mainMenu, customItems, bosses, autoSpawns, dropTables, customSkills, shopPanel;
|
||||
@Getter private IPanelHandler addItemsMenu;
|
||||
|
||||
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, equipmentEditMenu;
|
||||
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, equipmentListEditMenu;
|
||||
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> equipmentEditMenu, helmetEditorMenu;
|
||||
|
||||
private final CustomBosses customBosses;
|
||||
|
||||
@ -54,7 +59,10 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
loadAddItemsMenu();
|
||||
loadMainEditMenu();
|
||||
loadDropsEditMenu();
|
||||
loadEquipmentListEditMenu();
|
||||
|
||||
loadEquipmentEditMenu();
|
||||
loadHelmetEditMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +79,10 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
reloadAddItemsMenu();
|
||||
reloadMainEditMenu();
|
||||
reloadDropsEditMenu();
|
||||
reloadEquipmentListEditMenu();
|
||||
|
||||
reloadEquipmentEditMenu();
|
||||
reloadHelmetEditMenu();
|
||||
}
|
||||
|
||||
public int isItemStackUsed(String name) {
|
||||
@ -99,6 +110,42 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
return timesUsed;
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//
|
||||
// H E L ME T E D I T P A N E L
|
||||
//
|
||||
//---------------------------------------------
|
||||
|
||||
private void loadHelmetEditMenu() {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("HelmetEditorPanel"));
|
||||
|
||||
this.helmetEditorMenu = new HelmetEditorPanel(this, panelBuilder, this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadHelmetEditMenu() {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("HelmetEditorPanel"));
|
||||
|
||||
this.helmetEditorMenu.initializePanel(panelBuilder);
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//
|
||||
// E Q U I P M E N T L I S T E D I T P A N E L
|
||||
//
|
||||
//---------------------------------------------
|
||||
|
||||
private void loadEquipmentListEditMenu() {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("BossListEditorPanel"));
|
||||
|
||||
this.equipmentListEditMenu = new BossListEquipmentEditorPanel(this, panelBuilder, this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadEquipmentListEditMenu() {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("BossListEditorPanel"));
|
||||
|
||||
this.equipmentListEditMenu.initializePanel(panelBuilder);
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//
|
||||
// E Q U I P M E N T E D I T P A N E L
|
||||
|
@ -0,0 +1,124 @@
|
||||
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.entity.elements.EquipmentElement;
|
||||
import com.songoda.epicbosses.entity.elements.HandsElement;
|
||||
import com.songoda.epicbosses.entity.elements.MainStatsElement;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
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.VariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
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 19-Nov-18
|
||||
*/
|
||||
public class BossListEquipmentEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
private ItemStackConverter itemStackConverter;
|
||||
private BossesFileManager bossesFileManager;
|
||||
private CustomBosses plugin;
|
||||
|
||||
public BossListEquipmentEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.itemStackConverter = new ItemStackConverter();
|
||||
this.bossesFileManager = plugin.getBossesFileManager();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, BossEntity bossEntity) {
|
||||
List<EntityStatsElement> entityStatsElements = new ArrayList<>(bossEntity.getEntityStats());
|
||||
int slot = 0;
|
||||
|
||||
for(EntityStatsElement entityStatsElement : entityStatsElements) {
|
||||
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultBossListEditorMenuItem");
|
||||
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
|
||||
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{position}", ""+entityStatsElement.getMainStats().getPosition());
|
||||
replaceMap.put("{targetType}", "Equipment");
|
||||
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.BossListEditor.name"), replaceMap);
|
||||
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.BossListEditor.lore"), replaceMap);
|
||||
|
||||
panel.setItem(slot, itemStack, event -> {
|
||||
if(event.getClick() == ClickType.LEFT || event.getClick() == ClickType.SHIFT_LEFT) {
|
||||
this.bossPanelManager.getEquipmentEditMenu().openFor((Player) event.getWhoClicked(), bossEntity, entityStatsElement);
|
||||
} else {
|
||||
if(entityStatsElement.getMainStats().getPosition() > 1) {
|
||||
bossEntity.getEntityStats().remove(entityStatsElement);
|
||||
this.bossesFileManager.save();
|
||||
|
||||
openFor((Player) event.getWhoClicked(), bossEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, BossEntity bossEntity) {
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
|
||||
|
||||
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
|
||||
|
||||
panelBuilder.addReplaceData(replaceMap);
|
||||
|
||||
int nextNumber = bossEntity.getEntityStats().size()+1;
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setDestroyWhenDone(true)
|
||||
.setCancelClick(true)
|
||||
.setCancelLowerClick(true)
|
||||
.setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity);
|
||||
|
||||
fillPanel(panel, bossEntity);
|
||||
|
||||
panel.getPanelBuilderCounter().getSlotsWith("CreateEntity").forEach(slot -> panel.setOnClick(slot, event -> {
|
||||
MainStatsElement mainStatsElement = new MainStatsElement(nextNumber, "", 50.0, "");
|
||||
EquipmentElement equipmentElement = new EquipmentElement("", "", "", "");
|
||||
HandsElement handsElement = new HandsElement("", "");
|
||||
|
||||
EntityStatsElement entityStatsElement = new EntityStatsElement(mainStatsElement, equipmentElement, handsElement, new ArrayList<>());
|
||||
|
||||
bossEntity.getEntityStats().add(entityStatsElement);
|
||||
this.bossesFileManager.save();
|
||||
|
||||
openFor((Player) event.getWhoClicked(), bossEntity);
|
||||
}));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
|
||||
panelBuilderCounter.addSlotCounter("CreateEntity");
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
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.ItemsFileManager;
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.base.VariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.base.SubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,7 +18,7 @@ import java.util.Map;
|
||||
* @version 1.0.0
|
||||
* @since 19-Nov-18
|
||||
*/
|
||||
public class EquipmentEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
public class EquipmentEditorPanel extends SubVariablePanelHandler<BossEntity, EntityStatsElement> {
|
||||
|
||||
public EquipmentEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
@ -37,12 +36,12 @@ public class EquipmentEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, BossEntity bossEntity) {
|
||||
public void fillPanel(Panel panel, BossEntity bossEntity, EntityStatsElement entityStatsElement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, BossEntity bossEntity) {
|
||||
public void openFor(Player player, BossEntity bossEntity, EntityStatsElement entityStatsElement) {
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
|
||||
@ -55,7 +54,7 @@ public class EquipmentEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
.setDestroyWhenDone(true)
|
||||
.setCancelLowerClick(true)
|
||||
.setCancelClick(true)
|
||||
.setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity);
|
||||
.setParentPanelHandler(this.bossPanelManager.getEquipmentListEditMenu(), bossEntity);
|
||||
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class MainBossEditPanel extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
counter.getSlotsWith("Editing").forEach(slot -> panel.setOnClick(slot, getEditingAction(bossEntity)));
|
||||
counter.getSlotsWith("Drops").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getDropsEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
|
||||
counter.getSlotsWith("Equipment").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getEquipmentEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
|
||||
counter.getSlotsWith("Equipment").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getEquipmentListEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
package com.songoda.epicbosses.panel.bosses.equipment;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
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.ItemsFileManager;
|
||||
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.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 19-Nov-18
|
||||
*/
|
||||
public class HelmetEditorPanel extends SubVariablePanelHandler<BossEntity, EntityStatsElement> {
|
||||
|
||||
private ItemStackConverter itemStackConverter;
|
||||
private ItemsFileManager itemsFileManager;
|
||||
private CustomBosses plugin;
|
||||
|
||||
public HelmetEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.plugin = plugin;
|
||||
this.itemStackConverter = new ItemStackConverter();
|
||||
this.itemsFileManager = plugin.getItemStackManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, BossEntity bossEntity, EntityStatsElement entityStatsElement) {
|
||||
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, entityStatsElement);
|
||||
return true;
|
||||
}));
|
||||
|
||||
loadPage(panel, 0, itemStackHolderMap, entryList, entityStatsElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, BossEntity bossEntity, EntityStatsElement entityStatsElement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
|
||||
}
|
||||
|
||||
private void loadPage(Panel panel, int requestedPage, Map<String, ItemStackHolder> itemStackHolderMap, List<String> entryList, EntityStatsElement entityStatsElement) {
|
||||
String helmet = entityStatsElement.getEquipment().getHelmet();
|
||||
|
||||
panel.loadPage(requestedPage, (slot, realisticSlot) -> {
|
||||
if(slot >= itemStackHolderMap.size()) {
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
|
||||
} else {
|
||||
String name = entryList.get(slot);
|
||||
ItemStackHolder itemStackHolder = itemStackHolderMap.get(name);
|
||||
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
|
||||
|
||||
if(itemStack == null) {
|
||||
itemStack = new ItemStack(Material.BARRIER);
|
||||
}
|
||||
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", ItemStackUtils.getName(itemStack));
|
||||
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.EquipmentEditor.name"), replaceMap);
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, e -> {
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -220,6 +220,16 @@ public class ItemStackUtils {
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
public static String getName(ItemStack itemStack) {
|
||||
if(!itemStack.hasItemMeta() || !itemStack.getItemMeta().hasDisplayName()) {
|
||||
return StringUtils.get().formatString(itemStack.getType().name());
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
|
||||
return itemMeta.getDisplayName();
|
||||
}
|
||||
|
||||
public static Material getType(String string) {
|
||||
Material material = Material.getMaterial(string);
|
||||
|
||||
|
@ -401,14 +401,10 @@ public class Panel implements Listener, ICloneable<Panel> {
|
||||
}
|
||||
|
||||
public <T> Panel setParentPanelHandler(IVariablePanelHandler<T> variablePanelHandler, T variable) {
|
||||
System.out.println(this.panelBuilderSettings.isBackButton());
|
||||
|
||||
if(!this.panelBuilderSettings.isBackButton()) return this;
|
||||
|
||||
int slot = this.panelBuilderSettings.getBackButtonSlot() - 1;
|
||||
|
||||
System.out.println(slot);
|
||||
|
||||
setOnClick(slot, event -> variablePanelHandler.openFor((Player) event.getWhoClicked(), variable));
|
||||
return this;
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.songoda.epicbosses.utils.panel.base;
|
||||
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 19-Nov-18
|
||||
*/
|
||||
public interface ISubVariablePanelHandler<Variable, SubVariable> extends IBasicPanelHandler {
|
||||
|
||||
void fillPanel(Panel panel, Variable variable, SubVariable subVariable);
|
||||
|
||||
void openFor(Player player, Variable variable, SubVariable subVariable);
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.songoda.epicbosses.utils.panel.base;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 19-Nov-18
|
||||
*/
|
||||
public abstract class SubVariablePanelHandler<Variable, SubVariable> extends BasePanelHandler implements ISubVariablePanelHandler<Variable, SubVariable> {
|
||||
|
||||
public SubVariablePanelHandler(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
}
|
||||
}
|
2
pom.xml
2
pom.xml
@ -19,7 +19,7 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<plugin.version>maven-version-number-SNAPSHOT-U71</plugin.version>
|
||||
<plugin.version>maven-version-number-SNAPSHOT-U72</plugin.version>
|
||||
<plugin.name>EpicBosses</plugin.name>
|
||||
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
|
||||
<plugin.author>AMinecraftDev</plugin.author>
|
||||
|
Loading…
Reference in New Issue
Block a user