mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-12-23 08:27:49 +01:00
1.0.0-SNAPSHOT-U144
+ Added a feature to the CustomItemsPanel to clone a custom Item + Updated the DropTablePanel config path + Added a Guide to the CustomItemsPanel + Started working on the SprayReward Menus + Added the SubSubVariablePanelHandler interface and abstract class + Added Panels in the BossPanelManager + Updated config.yml and editor.yml with new methods
This commit is contained in:
parent
85fcf2a2c7
commit
ca3f6c83af
@ -100,12 +100,20 @@ Display:
|
||||
- '&3Right Click &8»'
|
||||
- '&7Edit the custom boss.'
|
||||
DropTable:
|
||||
menuName: '&b&lEpicBosses &3&lDropTables'
|
||||
name: '&b&l{name} Drop Table'
|
||||
lore:
|
||||
- '&3Type: &7{type}'
|
||||
- '&7'
|
||||
- '&7Click to edit the drop table.'
|
||||
Main:
|
||||
menuName: '&b&lEpicBosses &3&lDropTables'
|
||||
name: '&b&l{name} Drop Table'
|
||||
lore:
|
||||
- '&3Type: &7{type}'
|
||||
- '&7'
|
||||
- '&7Click to edit the drop table.'
|
||||
RewardList:
|
||||
name: '&bReward Section'
|
||||
lore:
|
||||
- '&bSelected Item: &f{itemName}'
|
||||
- '&3Chance: &f{chance}%'
|
||||
- '&7'
|
||||
- '&7Click to modify this reward.'
|
||||
Shop:
|
||||
menuName: '&b&lEpicBosses &3&lShop'
|
||||
name: '&b&lBuy {name}''s Egg'
|
||||
|
@ -134,8 +134,21 @@ CustomItemsMenu:
|
||||
fillTo: 45
|
||||
Items:
|
||||
'46':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
type: BOOK
|
||||
name: '&c&lCustom Items Guide'
|
||||
lore:
|
||||
- '&7In this menu you can view all the'
|
||||
- '&7custom items for the plugin, as well'
|
||||
- '&7as manipulate them to your liking.'
|
||||
- '&7'
|
||||
- '&3Left Click &8»'
|
||||
- '&7Obtain ItemStack in your inventory.'
|
||||
- '&7'
|
||||
- '&3Middle Click &8» '
|
||||
- '&7Clone ItemStack section to a new section.'
|
||||
- '&7'
|
||||
- '&3Right Click &8» '
|
||||
- '&7Remove section from list if not bound.'
|
||||
'47':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
@ -2053,3 +2066,130 @@ SprayDropTableMainEditMenu:
|
||||
- '&bRight Click &8» &f-1'
|
||||
- '&bShift Right-Click &8» &f-10'
|
||||
Button: MaxDrops
|
||||
SprayRewardsListEditMenu:
|
||||
name: '&b&l{name} DropTable'
|
||||
slots: 54
|
||||
Settings:
|
||||
backButton: true
|
||||
fillTo: 45
|
||||
Buttons:
|
||||
backButton: 54
|
||||
Items:
|
||||
'46':
|
||||
type: BOOK
|
||||
name: '&c&lSpray Rewards Guide'
|
||||
lore:
|
||||
- '&7Here you can adjust the rewards for'
|
||||
- '&7the skill with the spray layout. To'
|
||||
- '&7adjust the chance of a section or to'
|
||||
- '&7remove a section, then all you have'
|
||||
- '&7to do is click on the section you''d'
|
||||
- '&7like to modify and then click the'
|
||||
- '&7corresponding button.'
|
||||
- '&7To add a new section click on the'
|
||||
- '&7emerald block in the bottom middle of'
|
||||
- '&7the menu in between the page buttons.'
|
||||
'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 of special settings.'
|
||||
PreviousPage: true
|
||||
'50':
|
||||
type: EMERALD_BLOCK
|
||||
name: '&b&lAdd a New Reward Section'
|
||||
lore:
|
||||
- '&7Click here if you would like to add'
|
||||
- '&7a new reward section to this drop'
|
||||
- '&7table.'
|
||||
Button: NewReward
|
||||
'51':
|
||||
type: ARROW
|
||||
name: '&e&lNext Page &e&l&m->'
|
||||
lore:
|
||||
- '&7Click here to go to the next'
|
||||
- '&7page of special settings.'
|
||||
NextPage: true
|
||||
'52':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'53':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'54':
|
||||
type: REDSTONE
|
||||
name: '&cClick here to go back'
|
||||
lore:
|
||||
- '&7Click this button to go back to'
|
||||
- '&7the drop table main edit menu.'
|
||||
SprayNewRewardEditMenu:
|
||||
name: '&b&lNew Reward for DropTable'
|
||||
slots: 54
|
||||
Settings:
|
||||
backButton: true
|
||||
fillTo: 45
|
||||
Buttons:
|
||||
backButton: 54
|
||||
Items:
|
||||
'46':
|
||||
type: BOOK
|
||||
name: '&c&lNew Spray Reward Guide'
|
||||
lore:
|
||||
- '&7Once u click an item within this'
|
||||
- '&7menu it will create a new reward'
|
||||
- '&7section with that selected item'
|
||||
- '&7to the drop table you were working'
|
||||
- '&7on. From there you can adjust the'
|
||||
- '&7chance for it to be sprayed.'
|
||||
- '&7'
|
||||
- '&c&lWARNING'
|
||||
- '&7At this moment you cannot have'
|
||||
- '&7two sections for the same item,'
|
||||
- '&7an easy way to bypass this is to'
|
||||
- '&7add a new Item with the same'
|
||||
- '&7itemstack, therefore giving it'
|
||||
- '&7a new name, and allowing for'
|
||||
- '&7another new section of the same'
|
||||
- '&7item.'
|
||||
'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 of special settings.'
|
||||
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 of special settings.'
|
||||
NextPage: true
|
||||
'52':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'53':
|
||||
type: GLASS_PANE
|
||||
name: '&7'
|
||||
'54':
|
||||
type: REDSTONE
|
||||
name: '&cClick here to go back'
|
||||
lore:
|
||||
- '&7Click this button to go back to'
|
||||
- '&7the drop table reward list menu.'
|
||||
|
@ -27,6 +27,9 @@ import com.songoda.epicbosses.panel.droptables.MainDropTableEditorPanel;
|
||||
import com.songoda.epicbosses.panel.droptables.types.drop.DropDropTableMainEditorPanel;
|
||||
import com.songoda.epicbosses.panel.droptables.types.give.GiveDropTableMainEditorPanel;
|
||||
import com.songoda.epicbosses.panel.droptables.types.spray.SprayDropTableMainEditorPanel;
|
||||
import com.songoda.epicbosses.panel.droptables.types.spray.SprayNewRewardEditorPanel;
|
||||
import com.songoda.epicbosses.panel.droptables.types.spray.SprayRewardMainEditorPanel;
|
||||
import com.songoda.epicbosses.panel.droptables.types.spray.SprayRewardsListEditorPanel;
|
||||
import com.songoda.epicbosses.panel.handlers.*;
|
||||
import com.songoda.epicbosses.panel.skills.MainSkillEditorPanel;
|
||||
import com.songoda.epicbosses.panel.skills.SkillTypeEditorPanel;
|
||||
@ -46,6 +49,7 @@ import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.elements.SubCommandSkillElement;
|
||||
import com.songoda.epicbosses.skills.elements.SubCustomSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
|
||||
@ -91,7 +95,8 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
@Getter private ISubVariablePanelHandler<Skill, CustomSkillElement> customSkillTypeEditorMenu, specialSettingsEditorMenu, minionSelectEditorMenu;
|
||||
|
||||
@Getter private IVariablePanelHandler<DropTable> mainDropTableEditMenu, dropTableTypeEditMenu;
|
||||
@Getter private ISubVariablePanelHandler<DropTable, SprayTableElement> sprayDropTableMainEditMenu;
|
||||
@Getter private ISubVariablePanelHandler<DropTable, SprayTableElement> sprayDropTableMainEditMenu, sprayRewardListEditMenu, sprayNewRewardEditMenu;
|
||||
@Getter private ISubSubVariablePanelHandler<DropTable, SprayTableElement, String> sprayRewardMainEditMenu;
|
||||
@Getter private ISubVariablePanelHandler<DropTable, GiveTableElement> giveDropTableMainEditMenu;
|
||||
@Getter private ISubVariablePanelHandler<DropTable, DropTableElement> dropDropTableMainEditMenu;
|
||||
|
||||
@ -209,14 +214,16 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("DropTableMainEditorPanel"));
|
||||
PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("DropTableTypeEditorPanel"));
|
||||
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu"));
|
||||
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu"));
|
||||
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu"));
|
||||
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("SprayRewardsListEditMenu"));
|
||||
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); //TODO
|
||||
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); //TODO
|
||||
|
||||
this.mainDropTableEditMenu = new MainDropTableEditorPanel(this, panelBuilder);
|
||||
this.dropTableTypeEditMenu = new DropTableTypeEditorPanel(this, panelBuilder1, this.customBosses);
|
||||
this.sprayDropTableMainEditMenu = new SprayDropTableMainEditorPanel(this, panelBuilder2, this.customBosses);
|
||||
this.giveDropTableMainEditMenu = new GiveDropTableMainEditorPanel(this, panelBuilder3, this.customBosses);
|
||||
this.dropDropTableMainEditMenu = new DropDropTableMainEditorPanel(this, panelBuilder4, this.customBosses);
|
||||
this.sprayRewardListEditMenu = new SprayRewardsListEditorPanel(this, panelBuilder3, this.customBosses);
|
||||
this.sprayRewardMainEditMenu = new SprayRewardMainEditorPanel(this, panelBuilder4, this.customBosses);
|
||||
this.sprayNewRewardEditMenu = new SprayNewRewardEditorPanel(this, panelBuilder5, this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadDropTableEditMenus() {
|
||||
@ -224,14 +231,16 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
PanelBuilder panelBuilder = new PanelBuilder(editor.getConfigurationSection("DropTableMainEditorPanel"));
|
||||
PanelBuilder panelBuilder1 = new PanelBuilder(editor.getConfigurationSection("DropTableTypeEditorPanel"));
|
||||
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu"));
|
||||
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu"));
|
||||
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu"));
|
||||
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("SprayRewardsListEditMenu"));
|
||||
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); //TODO
|
||||
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("SprayDropTableMainEditMenu")); //TODO
|
||||
|
||||
this.mainDropTableEditMenu.initializePanel(panelBuilder);
|
||||
this.dropTableTypeEditMenu.initializePanel(panelBuilder1);
|
||||
this.sprayDropTableMainEditMenu.initializePanel(panelBuilder2);
|
||||
this.giveDropTableMainEditMenu.initializePanel(panelBuilder3);
|
||||
this.dropDropTableMainEditMenu.initializePanel(panelBuilder4);
|
||||
this.sprayRewardListEditMenu.initializePanel(panelBuilder3);
|
||||
this.sprayRewardMainEditMenu.initializePanel(panelBuilder4);
|
||||
this.sprayNewRewardEditMenu.initializePanel(panelBuilder5);
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
@ -753,7 +762,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
//---------------------------------------------
|
||||
|
||||
private void loadDropTableMenu() {
|
||||
this.dropTables = new DropTablePanel(this, getListMenu("DropTable"), this.customBosses);
|
||||
this.dropTables = new DropTablePanel(this, getListMenu("DropTable.Main"), this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadDropTable() {
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
@ -58,10 +59,11 @@ public class CustomItemsPanel extends MainListPanelHandler {
|
||||
String name = entryList.get(slot);
|
||||
ItemStackHolder itemStackHolder = currentItemStacks.get(name);
|
||||
ItemStack itemStack = this.itemsFileManager.getItemStackConverter().from(itemStackHolder);
|
||||
ItemStack cloneStack = itemStack.clone();
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, e -> {
|
||||
if(e.getClick() == ClickType.RIGHT || e.getClick() == ClickType.SHIFT_RIGHT) {
|
||||
panel.setItem(realisticSlot, itemStack.clone(), e -> {
|
||||
ClickType clickType = e.getClick();
|
||||
|
||||
if(clickType == ClickType.RIGHT || clickType == ClickType.SHIFT_RIGHT) {
|
||||
int timesUsed = this.bossPanelManager.isItemStackUsed(name);
|
||||
|
||||
if(timesUsed > 0) {
|
||||
@ -76,13 +78,15 @@ public class CustomItemsPanel extends MainListPanelHandler {
|
||||
loadPage(panel, requestedPage, currentItemStacks, entryList);
|
||||
Message.Boss_Items_Removed.msg(e.getWhoClicked());
|
||||
}
|
||||
} else if(e.getClick() == ClickType.LEFT || e.getClick() == ClickType.SHIFT_LEFT) {
|
||||
if(cloneStack == null) {
|
||||
Debug.FAILED_TO_GIVE_CUSTOM_ITEM.debug(e.getWhoClicked().getName());
|
||||
return;
|
||||
}
|
||||
} else if(clickType == ClickType.LEFT || clickType == ClickType.SHIFT_LEFT) {
|
||||
e.getWhoClicked().getInventory().addItem(itemStack.clone());
|
||||
} else if(clickType == ClickType.MIDDLE) {
|
||||
String newName = UUID.randomUUID().toString();
|
||||
ItemStack newItemStack = itemStack.clone();
|
||||
|
||||
e.getWhoClicked().getInventory().addItem(cloneStack);
|
||||
Message.Boss_Items_Cloned.msg(e.getWhoClicked(), newName);
|
||||
this.itemsFileManager.addItemStack(newName, newItemStack);
|
||||
fillPanel(panel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ public class DropTablePanel extends MainListPanelHandler {
|
||||
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);
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.DropTable.Main.name"), replaceMap);
|
||||
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.DropTable.Main.lore"), replaceMap);
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, e -> this.bossPanelManager.getMainDropTableEditMenu().openFor((Player) e.getWhoClicked(), dropTable));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class SprayDropTableMainEditorPanel extends SubVariablePanelHandler<DropT
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setParentPanelHandler(this.bossPanelManager.getMainDropTableEditMenu(), dropTable);
|
||||
|
||||
panelBuilderCounter.getSlotsWith("Rewards").forEach(slot -> panel.setOnClick(slot, event -> {}));
|
||||
panelBuilderCounter.getSlotsWith("Rewards").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getSprayRewardListEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement)));
|
||||
panelBuilderCounter.getSlotsWith("RandomDrops").forEach(slot -> panel.setOnClick(slot, getRandomDropsAction(dropTable, sprayTableElement)));
|
||||
panelBuilderCounter.getSlotsWith("MaxDistance").forEach(slot -> panel.setOnClick(slot, getMaxDistanceAction(dropTable, sprayTableElement)));
|
||||
panelBuilderCounter.getSlotsWith("MaxDrops").forEach(slot -> panel.setOnClick(slot, getMaxDropsAction(dropTable, sprayTableElement)));
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.songoda.epicbosses.panel.droptables.types.spray;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.droptable.elements.SprayTableElement;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.base.handlers.SubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Dec-18
|
||||
*/
|
||||
public class SprayNewRewardEditorPanel extends SubVariablePanelHandler<DropTable, SprayTableElement> {
|
||||
|
||||
public SprayNewRewardEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, DropTable dropTable, SprayTableElement sprayTableElement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, DropTable dropTable, SprayTableElement sprayTableElement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.songoda.epicbosses.panel.droptables.types.spray;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.droptable.elements.SprayTableElement;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.panel.base.handlers.SubSubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Dec-18
|
||||
*/
|
||||
public class SprayRewardMainEditorPanel extends SubSubVariablePanelHandler<DropTable, SprayTableElement, String> {
|
||||
|
||||
public SprayRewardMainEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, DropTable dropTable, SprayTableElement sprayTableElement, String string) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.songoda.epicbosses.panel.droptables.types.spray;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.droptable.elements.SprayTableElement;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.files.ItemsFileManager;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
|
||||
import com.songoda.epicbosses.utils.panel.Panel;
|
||||
import com.songoda.epicbosses.utils.panel.base.ClickAction;
|
||||
import com.songoda.epicbosses.utils.panel.base.handlers.SubVariablePanelHandler;
|
||||
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 28-Dec-18
|
||||
*/
|
||||
public class SprayRewardsListEditorPanel extends SubVariablePanelHandler<DropTable, SprayTableElement> {
|
||||
|
||||
private ItemsFileManager itemsFileManager;
|
||||
private CustomBosses plugin;
|
||||
|
||||
public SprayRewardsListEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.plugin = plugin;
|
||||
this.itemsFileManager = plugin.getItemStackManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, DropTable dropTable, SprayTableElement sprayTableElement) {
|
||||
Map<String, Double> rewardMap = sprayTableElement.getSprayRewards();
|
||||
List<String> keyList = new ArrayList<>(rewardMap.keySet());
|
||||
int maxPage = panel.getMaxPage(keyList);
|
||||
|
||||
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
|
||||
if(requestedPage < 0 || requestedPage > maxPage) return false;
|
||||
|
||||
loadPage(panel, requestedPage, dropTable, sprayTableElement, rewardMap, keyList);
|
||||
return true;
|
||||
}));
|
||||
|
||||
loadPage(panel, 0, dropTable, sprayTableElement, rewardMap, keyList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, DropTable dropTable, SprayTableElement sprayTableElement) {
|
||||
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", BossAPI.getDropTableName(dropTable));
|
||||
panelBuilder.addReplaceData(replaceMap);
|
||||
|
||||
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setParentPanelHandler(this.bossPanelManager.getSprayDropTableMainEditMenu(), dropTable, sprayTableElement);
|
||||
|
||||
panelBuilderCounter.getSlotsWith("NewReward").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getSprayNewRewardEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement)));
|
||||
fillPanel(panel, dropTable, sprayTableElement);
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
|
||||
}
|
||||
|
||||
private void loadPage(Panel panel, int page, DropTable dropTable, SprayTableElement sprayTableElement, Map<String, Double> rewardMap, List<String> keyList) {
|
||||
panel.loadPage(page, (slot, realisticSlot) -> {
|
||||
if(slot >= keyList.size()) {
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
|
||||
} else {
|
||||
String name = keyList.get(slot);
|
||||
Double chance = rewardMap.get(name);
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
if(chance == null) chance = 100.0;
|
||||
|
||||
replaceMap.put("{itemName}", name);
|
||||
replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance));
|
||||
|
||||
ItemStack itemStack = this.itemsFileManager.getItemStackConverter().from(this.itemsFileManager.getItemStackHolder(name));
|
||||
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.DropTable.RewardList.name"), replaceMap);
|
||||
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.DropTable.RewardList.lore"), replaceMap);
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, event -> this.bossPanelManager.getSprayRewardMainEditMenu().openFor((Player) event.getWhoClicked(), dropTable, sprayTableElement, name));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -116,6 +116,7 @@ public enum Message {
|
||||
Boss_Items_DefaultCannotBeRemoved("&c&l(!) &cThe selected item cannot be removed because it is the default item for something in one of the boss menu's."),
|
||||
Boss_Items_Removed("&b&lEpicBosses &8» &7The selected item has been removed from the EpicBosses custom items database."),
|
||||
Boss_Items_Added("&b&lEpicBosses &8» &7You have added an item to the EpicBosses custom items database."),
|
||||
Boss_Items_Cloned("&b&lEpicBosses &8» &7You have cloned an item in the EpicBosses custom items database and the clone item now has the name of &f{0}&7."),
|
||||
Boss_Items_AlreadySet("&c&l(!) &cYou must take out the item you have set to add before you can add another."),
|
||||
|
||||
Boss_KillAll_WorldNotFound("&c&l(!) &cThe specified world was not found. If you'd like to kill every boss/minion just use &f/boss killall&c without any arguments."),
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.songoda.epicbosses.utils.panel.base;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Dec-18
|
||||
*/
|
||||
public interface ISubSubVariablePanelHandler<Variable, SubVariable, SubSubVariable> extends IBasicPanelHandler {
|
||||
|
||||
void openFor(Player player, Variable variable, SubVariable subVariable, SubSubVariable subSubVariable);
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.songoda.epicbosses.utils.panel.base.handlers;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.panel.base.ISubSubVariablePanelHandler;
|
||||
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Dec-18
|
||||
*/
|
||||
public abstract class SubSubVariablePanelHandler<Variable, SubVariable, SubSubVariable> extends BasePanelHandler implements ISubSubVariablePanelHandler<Variable, SubVariable, SubSubVariable> {
|
||||
|
||||
public SubSubVariablePanelHandler(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
}
|
||||
|
||||
public SubSubVariablePanelHandler(BossPanelManager bossPanelManager, ConfigurationSection configurationSection) {
|
||||
super(bossPanelManager, configurationSection);
|
||||
}
|
||||
|
||||
}
|
2
pom.xml
2
pom.xml
@ -20,7 +20,7 @@
|
||||
|
||||
<properties>
|
||||
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
|
||||
<plugin.version>1.0.0-U143</plugin.version>
|
||||
<plugin.version>1.0.0-U144</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