1.0.0-SNAPSHOT-U90

+ Fully implemented the text managers
+ Updated config.yml
+ Updated editor.yml
+ Added onSpawnTextSubEditor, onDeathTextSubEditor, onDeathTextEditor, onSpawnTextEditor
+ Added the connection in to MainBossEditPanel
This commit is contained in:
Charles 2018-11-29 23:10:01 +08:00
parent 171fb1819f
commit 0b86ef262c
12 changed files with 632 additions and 11 deletions

View File

@ -34,6 +34,13 @@ Hooks:
- 'blocked_region2'
Display:
Boss:
Text:
menuName: '&b&l{name} Editor'
selectedName: '&bMessage: &f{name} &a&l** Selected **'
name: '&bMessage: &f{name}'
lore:
- '&fStrings within this section:'
- '{message}'
Commands:
menuName: '&b&l{name} Editor'
selectedName: '&bCommand: &f{name} &a&l** Selected **'

View File

@ -289,9 +289,6 @@ DropsMainEditorPanel:
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'
DropsEditorPanel:
name: '&b&l{name} Editor'
slots: 54
@ -1095,7 +1092,7 @@ TextEditorMainPanel:
Items:
'1':
type: BOOK
name: '&c&lCommands Guide'
name: '&c&lText Guide'
lore:
- '&7Here you can configure which command set'
- '&7the boss has for specific events.'
@ -1112,6 +1109,7 @@ TextEditorMainPanel:
lore:
- '&7Here you can adjust the settings for'
- '&7the taunts of the boss.'
Button: Taunts
'6':
type: REDSTONE
name: '&e&lOn Death'
@ -1124,4 +1122,50 @@ TextEditorMainPanel:
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'
TextEditorSubPanel:
name: '&b&l{name} Editor'
slots: 9
Settings:
backButton: true
emptySpaceFiller: true
EmptySpaceFiller:
type: WHITE_STAINED_GLASS_PANE
name: '&7'
Buttons:
backButton: 5
Items:
'3':
type: TALL_GRASS
name: '&e&lSelect Message'
lore:
- '&7Here you can change the message that is'
- '&7currently selected.'
- '&7'
- '&bCurrent: &f{selected}'
Button: Select
'5':
type: PAPER
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'
'7':
type: REDSTONE
name: '&e&lRadius'
lore:
- '&7Here you can change the radius for'
- '&7this message. It is currently: &f{radius}'
- '&7blocks. Set it to &f-1&7 if you want it'
- '&7to be a server-wide broadcast.'
- '&7'
- '&bLeft Click »'
- '&7Increase the radius by &f1&7.'
- '&7'
- '&bShift Left-Click »'
- '&7Increase the radius by &f10&7.'
- '&7'
- '&bRight Click »'
- '&7Decrease the radius by &f1&7.'
- '&7'
- '&bShift Right-Click »'
- '&7Decrease the radius by &f10&7.'
Button: Radius

View File

@ -14,6 +14,10 @@ import com.songoda.epicbosses.panel.bosses.equipment.HelmetEditorPanel;
import com.songoda.epicbosses.panel.bosses.equipment.LeggingsEditorPanel;
import com.songoda.epicbosses.panel.bosses.list.BossListStatisticEditorPanel;
import com.songoda.epicbosses.panel.bosses.list.BossListWeaponEditorPanel;
import com.songoda.epicbosses.panel.bosses.text.OnDeathTextEditor;
import com.songoda.epicbosses.panel.bosses.text.OnDeathTextSubEditor;
import com.songoda.epicbosses.panel.bosses.text.OnSpawnTextEditor;
import com.songoda.epicbosses.panel.bosses.text.OnSpawnTextSubEditor;
import com.songoda.epicbosses.panel.bosses.weapons.MainHandEditorPanel;
import com.songoda.epicbosses.panel.bosses.weapons.OffHandEditorPanel;
import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler;
@ -47,7 +51,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> weaponEditMenu, offHandEditorMenu, mainHandEditorMenu;
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> statisticMainEditMenu, entityTypeEditMenu;
@Getter private IVariablePanelHandler<BossEntity> mainBossEditMenu, dropsEditMenu, targetingEditMenu, skillsBossEditMenu, skillListBossEditMenu, commandsMainEditMenu, onSpawnCommandEditMenu, onDeathCommandEditMenu;
@Getter private IVariablePanelHandler<BossEntity> mainDropsEditMenu;
@Getter private IVariablePanelHandler<BossEntity> mainDropsEditMenu, mainTextEditMenu, mainTauntEditMenu, onSpawnTextEditMenu, onSpawnSubTextEditMenu, onDeathTextEditMenu, onDeathSubTextEditMenu;
@Getter private BossListEditorPanel equipmentListEditMenu, weaponListEditMenu, statisticListEditMenu;
private final CustomBosses customBosses;
@ -75,6 +79,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
loadSkillsEditMenu();
loadStatEditMenu();
loadCommandEditMenus();
loadTextEditMenus();
loadEquipmentEditMenu();
loadWeaponEditMenu();
@ -101,6 +106,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
reloadSkillsEditMenu();
reloadStatEditMenu();
reloadCommandEditMenus();
reloadTextEditMenus();
reloadEquipmentEditMenu();
reloadWeaponEditMenu();
@ -133,6 +139,34 @@ public class BossPanelManager implements ILoadable, IReloadable {
return timesUsed;
}
//---------------------------------------------
//
// T E X T E D I T P A N E L S
//
//---------------------------------------------
private void loadTextEditMenus() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("TextEditorMainPanel"));
PanelBuilder panelBuilder1 = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("TextEditorSubPanel"));
this.mainTextEditMenu = new TextMainEditorPanel(this, panelBuilder);
this.onSpawnSubTextEditMenu = new OnSpawnTextSubEditor(this, panelBuilder1.cloneBuilder(), this.customBosses);
this.onDeathSubTextEditMenu = new OnDeathTextSubEditor(this, panelBuilder1.cloneBuilder(), this.customBosses);
this.onSpawnTextEditMenu = new OnSpawnTextEditor(this, getListMenu("Boss.Text"), this.customBosses);
this.onDeathTextEditMenu = new OnDeathTextEditor(this, getListMenu("Boss.Text"), this.customBosses);
}
private void reloadTextEditMenus() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("TextEditorMainPanel"));
PanelBuilder panelBuilder1 = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("TextEditorSubPanel"));
this.mainTextEditMenu.initializePanel(panelBuilder);
this.onSpawnSubTextEditMenu.initializePanel(panelBuilder1.cloneBuilder());
this.onDeathSubTextEditMenu.initializePanel(panelBuilder1.cloneBuilder());
this.onSpawnTextEditMenu.initializePanel(getListMenu("Boss.Text"));
this.onDeathTextEditMenu.initializePanel(getListMenu("Boss.Text"));
}
//---------------------------------------------
//
// C O M M A N D S E D I T P A N E L S

View File

@ -83,6 +83,7 @@ public class MainBossEditPanel extends VariablePanelHandler<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)));
counter.getSlotsWith("Text").forEach(slot -> panel.setOnClick(slot, e -> this.bossPanelManager.getMainTextEditMenu().openFor((Player) e.getWhoClicked(), bossEntity)));
panel.openFor(player);
}

View File

@ -1,9 +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 TextMainEditorPanel {
public class TextMainEditorPanel extends VariablePanelHandler<BossEntity> {
public TextMainEditorPanel(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));
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
counter.getSlotsWith("OnSpawn").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnSpawnSubTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
counter.getSlotsWith("OnDeath").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnDeathSubTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Taunts").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getMainTauntEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
panelBuilderCounter
.addSlotCounter("OnSpawn")
.addSlotCounter("OnDeath")
.addSlotCounter("Taunts");
}
}

View File

@ -5,8 +5,6 @@ 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;
@ -14,7 +12,6 @@ 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;

View File

@ -0,0 +1,131 @@
package com.songoda.epicbosses.panel.bosses.text;
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.MessagesFileManager;
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 29-Nov-18
*/
public class OnDeathTextEditor extends VariablePanelHandler<BossEntity> {
private MessagesFileManager messagesFileManager;
private ItemStackConverter itemStackConverter;
private CustomBosses plugin;
public OnDeathTextEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.messagesFileManager = plugin.getBossMessagesFileManager();
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
Map<String, List<String>> currentTexts = this.messagesFileManager.getMessagesMap();
List<String> entryList = new ArrayList<>(currentTexts.keySet());
int maxPage = panel.getMaxPage(entryList);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, currentTexts, entryList, bossEntity);
return true;
}));
loadPage(panel, 0, currentTexts, 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.getOnDeathSubTextEditMenu(), bossEntity);
fillPanel(panel, bossEntity);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int page, Map<String, List<String>> currentMessages, List<String> entryList, BossEntity bossEntity) {
String current = bossEntity.getMessages().getOnDeath().getMessage();
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> messages = currentMessages.get(name);
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultTextMenuItem");
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{name}", name);
if(current.equalsIgnoreCase(name)) {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Text.selectedName"), replaceMap);
} else {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Text.name"), replaceMap);
}
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> presetLore = this.plugin.getConfig().getStringList("Display.Boss.Text.lore");
List<String> newLore = new ArrayList<>();
for(String s : presetLore) {
if(s.contains("{message}")) {
for(String message : messages) {
newLore.add(StringUtils.get().translateColor("&7" + message));
}
} else {
newLore.add(StringUtils.get().translateColor(s));
}
}
itemMeta.setLore(newLore);
itemStack.setItemMeta(itemMeta);
panel.setItem(realisticSlot, itemStack, e -> {
bossEntity.getMessages().getOnDeath().setMessage(name);
this.plugin.getBossesFileManager().save();
loadPage(panel, page, currentMessages, entryList, bossEntity);
});
}
});
}
}

View File

@ -0,0 +1,110 @@
package com.songoda.epicbosses.panel.bosses.text;
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.BossesFileManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.panel.Panel;
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.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.HashMap;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 29-Nov-18
*/
public class OnDeathTextSubEditor extends VariablePanelHandler<BossEntity> {
private BossesFileManager bossesFileManager;
public OnDeathTextSubEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.bossesFileManager = plugin.getBossesFileManager();
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
}
@Override
public void openFor(Player player, BossEntity bossEntity) {
Map<String, String> replaceMap = new HashMap<>();
Integer radius = bossEntity.getMessages().getOnDeath().getRadius();
String message = bossEntity.getMessages().getOnDeath().getMessage();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
if(radius == null) radius = 0;
if(message == null) message = "N/A";
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{radius}", NumberUtils.get().formatDouble(radius));
replaceMap.put("{selected}", message);
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainTextEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
counter.getSlotsWith("Select").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnDeathTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Radius").forEach(slot -> panel.setOnClick(slot, getRadiusAction(bossEntity)));
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
panelBuilderCounter
.addSlotCounter("Select")
.addSlotCounter("Radius");
}
private ClickAction getRadiusAction(BossEntity bossEntity) {
return event -> {
ClickType clickType = event.getClick();
int radiusToModifyBy = 0;
if(clickType == ClickType.LEFT) {
radiusToModifyBy = 1;
} else if(clickType == ClickType.SHIFT_LEFT) {
radiusToModifyBy = 10;
} else if(clickType == ClickType.RIGHT) {
radiusToModifyBy = -1;
} else if(clickType == ClickType.SHIFT_RIGHT) {
radiusToModifyBy = -10;
}
String modifyValue = radiusToModifyBy > 0? "increased" : "decreased";
Integer currentRadius = bossEntity.getMessages().getOnDeath().getRadius();
if(currentRadius == null) currentRadius = 0;
int newRadius = currentRadius + radiusToModifyBy;
if(newRadius < -1) {
newRadius = -1;
}
bossEntity.getMessages().getOnDeath().setRadius(newRadius);
this.bossesFileManager.save();
Message.Boss_Messages_SetRadiusOnDeath.msg(event.getWhoClicked(), modifyValue, NumberUtils.get().formatDouble(newRadius));
openFor((Player) event.getWhoClicked(), bossEntity);
};
}
}

View File

@ -0,0 +1,131 @@
package com.songoda.epicbosses.panel.bosses.text;
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.MessagesFileManager;
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 29-Nov-18
*/
public class OnSpawnTextEditor extends VariablePanelHandler<BossEntity> {
private MessagesFileManager messagesFileManager;
private ItemStackConverter itemStackConverter;
private CustomBosses plugin;
public OnSpawnTextEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.messagesFileManager = plugin.getBossMessagesFileManager();
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
Map<String, List<String>> currentTexts = this.messagesFileManager.getMessagesMap();
List<String> entryList = new ArrayList<>(currentTexts.keySet());
int maxPage = panel.getMaxPage(entryList);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(panel, requestedPage, currentTexts, entryList, bossEntity);
return true;
}));
loadPage(panel, 0, currentTexts, 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.getOnSpawnSubTextEditMenu(), bossEntity);
fillPanel(panel, bossEntity);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int page, Map<String, List<String>> currentMessages, List<String> entryList, BossEntity bossEntity) {
String current = bossEntity.getMessages().getOnSpawn().getMessage();
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> messages = currentMessages.get(name);
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultTextMenuItem");
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{name}", name);
if(current.equalsIgnoreCase(name)) {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Text.selectedName"), replaceMap);
} else {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Text.name"), replaceMap);
}
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> presetLore = this.plugin.getConfig().getStringList("Display.Boss.Text.lore");
List<String> newLore = new ArrayList<>();
for(String s : presetLore) {
if(s.contains("{message}")) {
for(String message : messages) {
newLore.add(StringUtils.get().translateColor("&7" + message));
}
} else {
newLore.add(StringUtils.get().translateColor(s));
}
}
itemMeta.setLore(newLore);
itemStack.setItemMeta(itemMeta);
panel.setItem(realisticSlot, itemStack, e -> {
bossEntity.getMessages().getOnSpawn().setMessage(name);
this.plugin.getBossesFileManager().save();
loadPage(panel, page, currentMessages, entryList, bossEntity);
});
}
});
}
}

View File

@ -0,0 +1,110 @@
package com.songoda.epicbosses.panel.bosses.text;
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.BossesFileManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.panel.Panel;
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.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.HashMap;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 29-Nov-18
*/
public class OnSpawnTextSubEditor extends VariablePanelHandler<BossEntity> {
private BossesFileManager bossesFileManager;
public OnSpawnTextSubEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.bossesFileManager = plugin.getBossesFileManager();
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
}
@Override
public void openFor(Player player, BossEntity bossEntity) {
Map<String, String> replaceMap = new HashMap<>();
Integer radius = bossEntity.getMessages().getOnSpawn().getRadius();
String message = bossEntity.getMessages().getOnDeath().getMessage();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
if(radius == null) radius = 0;
if(message == null) message = "N/A";
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{radius}", NumberUtils.get().formatDouble(radius));
replaceMap.put("{selected}", message);
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainTextEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
counter.getSlotsWith("Select").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnSpawnTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Radius").forEach(slot -> panel.setOnClick(slot, getRadiusAction(bossEntity)));
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
panelBuilderCounter
.addSlotCounter("Select")
.addSlotCounter("Radius");
}
private ClickAction getRadiusAction(BossEntity bossEntity) {
return event -> {
ClickType clickType = event.getClick();
int radiusToModifyBy = 0;
if(clickType == ClickType.LEFT) {
radiusToModifyBy = 1;
} else if(clickType == ClickType.SHIFT_LEFT) {
radiusToModifyBy = 10;
} else if(clickType == ClickType.RIGHT) {
radiusToModifyBy = -1;
} else if(clickType == ClickType.SHIFT_RIGHT) {
radiusToModifyBy = -10;
}
String modifyValue = radiusToModifyBy > 0? "increased" : "decreased";
Integer currentRadius = bossEntity.getMessages().getOnSpawn().getRadius();
if(currentRadius == null) currentRadius = 0;
int newRadius = currentRadius + radiusToModifyBy;
if(newRadius < -1) {
newRadius = -1;
}
bossEntity.getMessages().getOnSpawn().setRadius(newRadius);
this.bossesFileManager.save();
Message.Boss_Messages_SetRadiusOnSpawn.msg(event.getWhoClicked(), modifyValue, NumberUtils.get().formatDouble(newRadius));
openFor((Player) event.getWhoClicked(), bossEntity);
};
}
}

View File

@ -106,6 +106,9 @@ public enum Message {
Boss_Menu_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Messages_SetRadiusOnSpawn("&b&lEpicBosses &8» &7You have just {0} the radius for the onSpawn message to &f{1}&7."),
Boss_Messages_SetRadiusOnDeath("&b&lEpicBosses &8» &7You have just {0} the radius for the onDeath message to &f{1}&7."),
Boss_Nearby_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Nearby_MaxRadius("&c&l(!) &cYou cannot check for bosses any further then &f{0}&c away from your position."),
Boss_Nearby_NoneNearby("&b&lEpicBosses &8» &7There is currently no nearby bosses."),

View File

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