1.0.0-SNAPSHOT-U110

+ Started implementing ModifyCommandEditorPanel
+ Added ListCommandListEditor
+ Updated editor.yml with new fields
+ Fixed color code issue in editor.yml
+ Fixed a few things in some panel editors
This commit is contained in:
Charles 2018-12-05 22:50:48 +08:00
parent 9b268cc89e
commit 824f3e1d52
9 changed files with 215 additions and 26 deletions

View File

@ -93,11 +93,11 @@ Display:
lore:
- '&3Editing: &f{enabled}'
- '&7'
- '&3Left Click »'
- '&3Left Click &8»'
- '&7Get spawn item for custom'
- '&7boss.'
- '&7'
- '&3Right Click »'
- '&3Right Click &8»'
- '&7Edit the custom boss.'
DropTable:
menuName: '&b&lEpicBosses &3&lDropTables'
@ -140,8 +140,7 @@ Display:
Commands:
name: '&b&lCommand Section'
lore:
- '&3Left Click &8»'
- '&7Modify the assigned commands.'
- '&7'
- '&3Right Click &8»'
- '&7Modify the chance for this section.'
- '&3Chance &8» &f{chance}%'
- '&'
- '&3Commands &8»'
- '&f{commands}'

View File

@ -1608,4 +1608,43 @@ CommandSkillEditorPanel:
type: PAPER
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'
- '&7Click here to go back.'
ModifyCommandEditorPanel:
name: '&b&lCommand Editor'
slots: 9
Settings:
backButton: true
emptySpaceFiller: true
EmptySpaceFiller:
type: WHITE_STAINED_GLASS_PANE
name: '&7'
Buttons:
backButton: 5
Items:
'3':
type: BOOK
name: '&e&lCommands'
lore:
- '&7Currently selected commands:'
- '&7'
- '{commands}'
Button: Commands
'5':
type: PAPER
name: '&e&lGo Back'
lore:
- '&7Click here to go back.'
'7':
type: GUNPOWDER
name: '&e&lChance'
lore:
- '&bCurrently: &f{chance}'
- '&7'
- '&7Click here to modify the chance'
- '&7value for this boss.'
- '&7'
- '&bLeft Click &8» &f+1.0'
- '&bShift Left-Click &8» &f+0.1'
- '&7'
- '&bRight Click &8» &f-1.0'
- '&bShift Right-Click &8» &f-0.1'

View File

@ -22,10 +22,11 @@ import com.songoda.epicbosses.panel.handlers.*;
import com.songoda.epicbosses.panel.skills.MainSkillEditorPanel;
import com.songoda.epicbosses.panel.skills.SkillTypeEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.CommandSkillEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.CreatePotionEffectEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.PotionEffectTypeEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.potions.CreatePotionEffectEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.potions.PotionEffectTypeEditorPanel;
import com.songoda.epicbosses.panel.skills.custom.PotionSkillEditorPanel;
import com.songoda.epicbosses.skills.Skill;
import com.songoda.epicbosses.skills.elements.SubCommandSkillElement;
import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler;
import com.songoda.epicbosses.utils.panel.base.IVariablePanelHandler;
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
@ -67,6 +68,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
@Getter private IVariablePanelHandler<Skill> mainSkillEditMenu, customMessageEditMenu, skillTypeEditMenu, potionSkillEditorPanel, commandSkillEditorPanel;
@Getter private ISubVariablePanelHandler<Skill, PotionEffectHolder> createPotionEffectMenu, potionEffectTypeEditMenu;
@Getter private ISubVariablePanelHandler<Skill, SubCommandSkillElement> modifyCommandEditMenu;
private final CustomBosses customBosses;

View File

@ -0,0 +1,140 @@
package com.songoda.epicbosses.panel.handlers;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.CommandsFileManager;
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.IVariablePanelHandler;
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 05-Dec-18
*/
public abstract class ListCommandListEditor<T> extends VariablePanelHandler<T> {
private CommandsFileManager commandsFileManager;
private ItemStackConverter itemStackConverter;
private CustomBosses plugin;
public ListCommandListEditor(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.plugin = plugin;
this.itemStackConverter = new ItemStackConverter();
this.commandsFileManager = plugin.getBossCommandFileManager();
}
public abstract List<String> getCurrent(T object);
public abstract void updateMessage(T object, String modifiedValue);
public abstract IVariablePanelHandler<T> getParentHolder();
public abstract String getName(T object);
@Override
public void fillPanel(Panel panel, T object) {
Map<String, List<String>> currentTexts = this.commandsFileManager.getCommandsMap();
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, object);
return true;
}));
loadPage(panel, 0, currentTexts, entryList, object);
}
@Override
public void openFor(Player player, T object) {
Map<String, String> replaceMap = new HashMap<>();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
replaceMap.put("{name}", getName(object));
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(getParentHolder(), object);
fillPanel(panel, object);
panel.openFor(player);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
private void loadPage(Panel panel, int page, Map<String, List<String>> currentMessages, List<String> entryList, T object) {
List<String> current = getCurrent(object);
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.contains(name)) {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Commands.selectedName"), replaceMap);
} else {
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Boss.Command.name"), replaceMap);
}
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> presetLore = this.plugin.getConfig().getStringList("Display.Boss.Commands.lore");
List<String> newLore = new ArrayList<>();
for(String s : presetLore) {
if(s.contains("{commands}")) {
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 -> {
updateMessage(object, name);
this.plugin.getBossesFileManager().save();
loadPage(panel, page, currentMessages, entryList, object);
});
}
});
}
}

View File

@ -29,6 +29,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -104,23 +105,22 @@ public class CommandSkillEditorPanel extends VariablePanelHandler<Skill> {
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
} else {
SubCommandSkillElement subCommandSkillElement = subCommandSkillElements.get(slot);
Map<String, String> replaceMap = new HashMap<>();
Double chance = subCommandSkillElement.getChance();
List<String> commands = subCommandSkillElement.getCommands();
if(chance == null) chance = 100.0;
if(commands == null) commands = new ArrayList<>();
replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance));
replaceMap.put("{commands}", StringUtils.get().appendList(commands));
ItemStack itemStack = new ItemStack(Material.BOOK);
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.Skills.Commands.lore"));
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.Commands.name"));
ItemStackUtils.applyDisplayLore(itemStack, this.plugin.getConfig().getStringList("Display.Skills.Commands.lore"), replaceMap);
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.Commands.name"), replaceMap);
panel.setItem(realisticSlot, itemStack, event -> {
ClickType clickType = event.getClick();
if(clickType.name().contains("RIGHT")) {
//TODO: Modify Chance
} else {
//TODO: Modify commands
}
loadPage(panel, page, subCommandSkillElements, skill);
});
panel.setItem(realisticSlot, itemStack, event -> this.bossPanelManager.getModifyCommandEditMenu().openFor((Player) event.getWhoClicked(), skill, subCommandSkillElement));
}
});
}

View File

@ -0,0 +1,9 @@
package com.songoda.epicbosses.panel.skills.custom.commands;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 05-Dec-18
*/
public class ModifyCommandEditorPanel {
}

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.panel.skills.custom;
package com.songoda.epicbosses.panel.skills.custom.potions;
import com.google.gson.JsonObject;
import com.songoda.epicbosses.CustomBosses;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.panel.skills.custom;
package com.songoda.epicbosses.panel.skills.custom.potions;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.entity.BossEntity;

View File

@ -20,7 +20,7 @@
<properties>
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
<plugin.version>1.0.0-U109</plugin.version>
<plugin.version>1.0.0-U110</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>