mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-02-22 21:51:19 +01:00
1.0.0-SNAPSHOT-U67
+ Worked the DropsEditorPanel
This commit is contained in:
parent
1b72b14ddd
commit
fd2bf33856
@ -7,6 +7,10 @@
|
||||
"type": "OAK_PRESSURE_PLATE",
|
||||
"name": "&c&lDefault Drop Table Menu Item"
|
||||
},
|
||||
"SelectedDropTableItem": {
|
||||
"type": "LIGHT_WEIGHTED_PRESSURE_PLATE",
|
||||
"name": "&c&lSelected Defauult Drop Table Menu Item"
|
||||
},
|
||||
"DefaultSkillMenuItem": {
|
||||
"type": "BLAZE_POWDER",
|
||||
"name": "&c&lDefault Skill Menu Item"
|
||||
|
@ -241,7 +241,7 @@ MainEditorPanel:
|
||||
- '&7etc. for this boss.'
|
||||
Button: Text
|
||||
DropsEditorPanel:
|
||||
name: '&b&l{boss} Editor'
|
||||
name: '&b&l{name} Editor'
|
||||
slots: 54
|
||||
Settings:
|
||||
fillTo: 45
|
||||
|
@ -4,7 +4,6 @@ import lombok.Getter;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.utils.IReloadable;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -4,6 +4,7 @@ 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.panel.bosses.DropsEditorPanel;
|
||||
import com.songoda.epicbosses.panel.bosses.MainBossEditPanel;
|
||||
import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler;
|
||||
import lombok.Getter;
|
||||
@ -30,7 +31,7 @@ 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;
|
||||
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu;
|
||||
|
||||
private final CustomBosses customBosses;
|
||||
|
||||
@ -51,6 +52,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
|
||||
loadAddItemsMenu();
|
||||
loadMainEditMenu();
|
||||
loadDropsEditMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,6 +68,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
|
||||
reloadAddItemsMenu();
|
||||
reloadMainEditMenu();
|
||||
reloadDropsEditMenu();
|
||||
}
|
||||
|
||||
public int isItemStackUsed(String name) {
|
||||
@ -93,6 +96,24 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
return timesUsed;
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//
|
||||
// D R O P S E D I T P A N E L
|
||||
//
|
||||
//---------------------------------------------
|
||||
|
||||
private void loadDropsEditMenu() {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("DropsEditorPanel"));
|
||||
|
||||
this.dropsEditMenu = new DropsEditorPanel(this, panelBuilder, this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadDropsEditMenu() {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("DropsEditorPanel"));
|
||||
|
||||
this.dropsEditMenu.initializePanel(panelBuilder);
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
//
|
||||
// M A I N E D I T P A N E L
|
||||
|
@ -2,18 +2,28 @@ package com.songoda.epicbosses.panel.bosses;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.managers.files.DropTableFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
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.ClickAction;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
@ -23,12 +33,16 @@ import java.util.Map;
|
||||
*/
|
||||
public class DropsEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
private BossesFileManager bossesFileManager;
|
||||
private DropTableFileManager dropTableFileManager;
|
||||
private ItemStackConverter itemStackConverter;
|
||||
private CustomBosses plugin;
|
||||
|
||||
public DropsEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.bossesFileManager = plugin.getBossesFileManager();
|
||||
this.dropTableFileManager = plugin.getDropTableFileManager();
|
||||
this.itemStackConverter = new ItemStackConverter();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,7 +56,18 @@ public class DropsEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, BossEntity bossEntity) {
|
||||
Map<String, DropTable> dropTableMap = this.dropTableFileManager.getDropTables();
|
||||
List<String> entryList = new ArrayList<>(dropTableMap.keySet());
|
||||
int maxPage = panel.getMaxPage(entryList);
|
||||
|
||||
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
|
||||
if(requestedPage < 0 || requestedPage > maxPage) return false;
|
||||
|
||||
loadPage(panel, requestedPage, dropTableMap, entryList, bossEntity);
|
||||
return true;
|
||||
}));
|
||||
|
||||
loadPage(panel, 0, dropTableMap, entryList, bossEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,7 +75,7 @@ public class DropsEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
|
||||
replaceMap.put("{mode}", bossEntity.getEditingValue());
|
||||
replaceMap.put("{dropTable}", bossEntity.getDrops().getDropTable());
|
||||
|
||||
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
|
||||
|
||||
@ -62,24 +87,47 @@ public class DropsEditorPanel extends VariablePanelHandler<BossEntity> {
|
||||
.setCancelLowerClick(true);
|
||||
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
|
||||
|
||||
counter.getSlotsWith("Editing").forEach(slot -> panel.setOnClick(slot, getEditingAction(bossEntity)));
|
||||
fillPanel(panel, bossEntity);
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
private ClickAction getEditingAction(BossEntity bossEntity) {
|
||||
return event -> {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
private void loadPage(Panel panel, int requestedPage, Map<String, DropTable> dropTableMap, List<String> entryList, BossEntity bossEntity) {
|
||||
String dropTableName = bossEntity.getDrops().getDropTable();
|
||||
|
||||
if(bossEntity.isCompleteEnoughToSpawn()) {
|
||||
bossEntity.setEditing(!bossEntity.isEditing());
|
||||
this.bossesFileManager.save();
|
||||
Message.Boss_Edit_Toggled.msg(player, BossAPI.getBossEntityName(bossEntity), bossEntity.getEditingValue());
|
||||
player.closeInventory();
|
||||
panel.loadPage(requestedPage, (slot, realisticSlot) -> {
|
||||
if(slot >= dropTableMap.size()) {
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
|
||||
} else {
|
||||
Message.Boss_Edit_NotCompleteEnough.msg(player);
|
||||
String name = entryList.get(slot);
|
||||
DropTable dropTable = dropTableMap.get(name);
|
||||
ItemStackHolder itemStackHolder;
|
||||
|
||||
if(dropTableName.equalsIgnoreCase(name)) {
|
||||
itemStackHolder = BossAPI.getStoredItemStack("SelectedDropTableItem");
|
||||
} else {
|
||||
itemStackHolder = BossAPI.getStoredItemStack("DefaultDropTableMenuItem");
|
||||
}
|
||||
|
||||
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
|
||||
|
||||
if(itemStack == null) {
|
||||
itemStack = new ItemStack(Material.BARRIER);
|
||||
}
|
||||
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", name);
|
||||
replaceMap.put("{type}", StringUtils.get().formatString(dropTable.getDropType()));
|
||||
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.DropTable.name"), replaceMap);
|
||||
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.DropTable.lore"), replaceMap);
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, e -> {
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ public class MainBossEditPanel extends VariablePanelHandler<BossEntity> {
|
||||
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
|
||||
|
||||
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)));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@ -19,7 +19,7 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<plugin.version>maven-version-number-SNAPSHOT-U66</plugin.version>
|
||||
<plugin.version>maven-version-number-SNAPSHOT-U67</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