mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-11-05 01:30:07 +01:00
1.0.0-SNAPSHOT-U112
+ Completed the Command section of the skill GUI editing + Updated config.yml to support the new additions + Started implementing a string split for the GUIs + Added a name section to the commands for the command skills to know which section is which when saving/updating the skills
This commit is contained in:
parent
52a7910674
commit
e2894bc081
@ -24,6 +24,7 @@
|
||||
"customData": {
|
||||
"commands": [
|
||||
{
|
||||
"name": "a",
|
||||
"chance": 25,
|
||||
"commands": [
|
||||
"Guts1",
|
||||
@ -31,6 +32,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"chance": 10,
|
||||
"commands": [
|
||||
"Guts3"
|
||||
|
@ -144,3 +144,10 @@ Display:
|
||||
- '&f{commands}'
|
||||
- '&7'
|
||||
- '&7Click to edit command section.'
|
||||
CommandList:
|
||||
menuName: '&b&l{name} Skill Editor'
|
||||
selectedName: '&bCommand: &f{name} &a&l** Selected **'
|
||||
name: '&bCommand: &f{name}'
|
||||
lore:
|
||||
- '&fCommands within this section:'
|
||||
- '{commands}'
|
@ -1671,9 +1671,8 @@ ModifyCommandEditorPanel:
|
||||
type: BOOK
|
||||
name: '&e&lCommands'
|
||||
lore:
|
||||
- '&7Currently selected commands:'
|
||||
- '&7'
|
||||
- '{commands}'
|
||||
- '&fCurrently selected commands:'
|
||||
- '&7{commands}'
|
||||
Button: Commands
|
||||
'5':
|
||||
type: PAPER
|
||||
@ -1684,14 +1683,14 @@ ModifyCommandEditorPanel:
|
||||
type: GUNPOWDER
|
||||
name: '&e&lChance'
|
||||
lore:
|
||||
- '&bCurrently: &f{chance}'
|
||||
- '&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'
|
||||
- '&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'
|
||||
- '&bRight Click &8» &f-1.0%'
|
||||
- '&bShift Right-Click &8» &f-0.1%'
|
||||
Button: Chance
|
@ -211,30 +211,11 @@ public class BossAPI {
|
||||
return jsonParser.parse(jsonString).getAsJsonObject();
|
||||
}
|
||||
|
||||
public static JsonObject convertSkillElement(CommandSkillElement commandSkillElement) {
|
||||
|
||||
|
||||
public static <T> JsonObject convertObjectToJsonObject(T object) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
String jsonString = BossesGson.get().toJson(commandSkillElement);
|
||||
|
||||
return jsonParser.parse(jsonString).getAsJsonObject();
|
||||
}
|
||||
|
||||
public static JsonObject convertSkillElement(PotionSkillElement potionSkillElement) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
String jsonString = BossesGson.get().toJson(potionSkillElement);
|
||||
|
||||
return jsonParser.parse(jsonString).getAsJsonObject();
|
||||
}
|
||||
|
||||
public static JsonObject convertSkillElement(CustomSkillElement customSkillElement) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
String jsonString = BossesGson.get().toJson(customSkillElement);
|
||||
|
||||
return jsonParser.parse(jsonString).getAsJsonObject();
|
||||
}
|
||||
|
||||
public static JsonObject convertSkillElement(GroupSkillElement groupSkillElement) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
String jsonString = BossesGson.get().toJson(groupSkillElement);
|
||||
String jsonString = BossesGson.get().toJson(object);
|
||||
|
||||
return jsonParser.parse(jsonString).getAsJsonObject();
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ import org.bukkit.command.CommandSender;
|
||||
*
|
||||
* boss new droptable [name] [type]
|
||||
* boss new skill [name] [type] [mode]
|
||||
* boss new command [name] [commands]
|
||||
* boss new message [name] [message]
|
||||
*/
|
||||
public class BossNewCmd extends SubCommand {
|
||||
|
||||
|
@ -22,6 +22,8 @@ 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.commands.CommandListSkillEditorPanel;
|
||||
import com.songoda.epicbosses.panel.skills.custom.commands.ModifyCommandEditorPanel;
|
||||
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;
|
||||
@ -68,7 +70,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;
|
||||
@Getter private ISubVariablePanelHandler<Skill, SubCommandSkillElement> modifyCommandEditMenu, commandListSkillEditMenu;
|
||||
|
||||
private final CustomBosses customBosses;
|
||||
|
||||
@ -169,6 +171,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("PotionSkillEditorPanel"));
|
||||
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("CreatePotionEffectEditorPanel"));
|
||||
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("CommandSkillEditorPanel"));
|
||||
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("ModifyCommandEditorPanel"));
|
||||
|
||||
this.mainSkillEditMenu = new MainSkillEditorPanel(this, panelBuilder, this.customBosses);
|
||||
this.customMessageEditMenu = new SingleMessageListEditor<Skill>(this, getListMenu("Skills.MainEdit"), this.customBosses) {
|
||||
@ -199,6 +202,8 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
this.createPotionEffectMenu = new CreatePotionEffectEditorPanel(this, panelBuilder3, this.customBosses);
|
||||
this.potionEffectTypeEditMenu = new PotionEffectTypeEditorPanel(this, getListMenu("Skills.CreatePotion"), this.customBosses);
|
||||
this.commandSkillEditorPanel = new CommandSkillEditorPanel(this, panelBuilder4, this.customBosses);
|
||||
this.modifyCommandEditMenu = new ModifyCommandEditorPanel(this, panelBuilder5, this.customBosses);
|
||||
this.commandListSkillEditMenu = new CommandListSkillEditorPanel(this, getListMenu("Skills.CommandList"), this.customBosses);
|
||||
}
|
||||
|
||||
private void reloadSkillEditMenus() {
|
||||
@ -208,6 +213,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
PanelBuilder panelBuilder2 = new PanelBuilder(editor.getConfigurationSection("PotionSkillEditorPanel"));
|
||||
PanelBuilder panelBuilder3 = new PanelBuilder(editor.getConfigurationSection("CreatePotionEffectEditorPanel"));
|
||||
PanelBuilder panelBuilder4 = new PanelBuilder(editor.getConfigurationSection("CommandSkillEditorPanel"));
|
||||
PanelBuilder panelBuilder5 = new PanelBuilder(editor.getConfigurationSection("ModifyCommandEditorPanel"));
|
||||
|
||||
this.mainSkillEditMenu.initializePanel(panelBuilder);
|
||||
this.customMessageEditMenu.initializePanel(getListMenu("Skills.MainEdit"));
|
||||
@ -216,6 +222,8 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
||||
this.createPotionEffectMenu.initializePanel(panelBuilder3);
|
||||
this.potionEffectTypeEditMenu.initializePanel(getListMenu("Skills.CreatePotion"));
|
||||
this.commandSkillEditorPanel.initializePanel(panelBuilder4);
|
||||
this.modifyCommandEditMenu.initializePanel(panelBuilder5);
|
||||
this.commandListSkillEditMenu.initializePanel(getListMenu("Skills.CommandList"));
|
||||
}
|
||||
|
||||
//---------------------------------------------
|
||||
|
@ -81,15 +81,7 @@ public class MainSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
// PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
//
|
||||
// panelBuilderCounter
|
||||
// .addSlotCounter("CustomMessage")
|
||||
// .addSlotCounter("Radius")
|
||||
// .addSlotCounter("CustomData")
|
||||
// .addSlotCounter("Mode")
|
||||
// .addSlotCounter("DisplayName")
|
||||
// .addSlotCounter("Type");
|
||||
|
||||
}
|
||||
|
||||
private ClickAction getCustomDataAction(Skill skill) {
|
||||
@ -104,7 +96,7 @@ public class MainSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
} else if(type.equalsIgnoreCase("CUSTOM")) {
|
||||
|
||||
} else if(type.equalsIgnoreCase("COMMAND")) {
|
||||
|
||||
this.bossPanelManager.getCommandSkillEditorPanel().openFor(player, skill);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -87,10 +87,7 @@ public class CommandSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
// PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
//
|
||||
// panelBuilderCounter
|
||||
// .addSlotCounter("AddNew");
|
||||
|
||||
}
|
||||
|
||||
private ClickAction getAddNewAction(Skill skill) {
|
||||
|
@ -92,10 +92,7 @@ public class PotionSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
// PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
//
|
||||
// panelBuilderCounter
|
||||
// .addSlotCounter("PotionEffect");
|
||||
|
||||
}
|
||||
|
||||
private void loadPage(Panel panel, int page, List<PotionEffectHolder> potionEffectHolders, PotionSkillElement potionSkillElement, Skill skill) {
|
||||
@ -129,7 +126,7 @@ public class PotionSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
potionSkillElement.setPotions(potionEffectHolders);
|
||||
|
||||
|
||||
JsonObject jsonObject = BossAPI.convertSkillElement(potionSkillElement);
|
||||
JsonObject jsonObject = BossAPI.convertObjectToJsonObject(potionSkillElement);
|
||||
|
||||
skill.setCustomData(jsonObject);
|
||||
this.skillsFileManager.save();
|
||||
|
@ -0,0 +1,167 @@
|
||||
package com.songoda.epicbosses.panel.skills.custom.commands;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.CommandsFileManager;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.elements.SubCommandSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CommandSkillElement;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
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.SubVariablePanelHandler;
|
||||
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 09-Dec-18
|
||||
*/
|
||||
public class CommandListSkillEditorPanel extends SubVariablePanelHandler<Skill, SubCommandSkillElement> {
|
||||
|
||||
private CommandsFileManager commandsFileManager;
|
||||
private ItemStackConverter itemStackConverter;
|
||||
private BossSkillManager bossSkillManager;
|
||||
private CustomBosses plugin;
|
||||
|
||||
public CommandListSkillEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.plugin = plugin;
|
||||
this.itemStackConverter = new ItemStackConverter();
|
||||
this.bossSkillManager = plugin.getBossSkillManager();
|
||||
this.commandsFileManager = plugin.getBossCommandFileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPanel(Panel panel, Skill skill, SubCommandSkillElement subCommandSkillElement) {
|
||||
Map<String, List<String>> currentCommands = this.commandsFileManager.getCommandsMap();
|
||||
List<String> entryList = new ArrayList<>(currentCommands.keySet());
|
||||
List<String> commands = subCommandSkillElement.getCommands();
|
||||
int maxPage = panel.getMaxPage(entryList);
|
||||
|
||||
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
|
||||
if(requestedPage < 0 || requestedPage > maxPage) return false;
|
||||
|
||||
loadPage(panel, requestedPage, commands, currentCommands, entryList, skill, subCommandSkillElement);
|
||||
return true;
|
||||
}));
|
||||
|
||||
loadPage(panel, 0, commands, currentCommands, entryList, skill, subCommandSkillElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, Skill skill, SubCommandSkillElement subCommandSkillElement) {
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
|
||||
|
||||
replaceMap.put("{name}", BossAPI.getSkillName(skill));
|
||||
panelBuilder.addReplaceData(replaceMap);
|
||||
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setParentPanelHandler(this.bossPanelManager.getCommandSkillEditorPanel(), skill);
|
||||
|
||||
fillPanel(panel, skill, subCommandSkillElement);
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
|
||||
}
|
||||
|
||||
private void loadPage(Panel panel, int page, List<String> commands, Map<String, List<String>> allCommands, List<String> entryList, Skill skill, SubCommandSkillElement subCommandSkillElement) {
|
||||
panel.loadPage(page, (slot, realisticSlot) -> {
|
||||
if(slot >= allCommands.size()) {
|
||||
panel.setItem(realisticSlot, new ItemStack(Material.AIR), e -> {});
|
||||
} else {
|
||||
String name = entryList.get(slot);
|
||||
List<String> boundCommands = allCommands.get(name);
|
||||
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack("DefaultTextMenuItem");
|
||||
ItemStack itemStack = this.itemStackConverter.from(itemStackHolder);
|
||||
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
|
||||
replaceMap.put("{name}", name);
|
||||
|
||||
if(commands.contains(name)) {
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.CommandList.selectedName"), replaceMap);
|
||||
} else {
|
||||
ItemStackUtils.applyDisplayName(itemStack, this.plugin.getConfig().getString("Display.Skills.CommandList.name"), replaceMap);
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
List<String> presetLore = this.plugin.getConfig().getStringList("Display.Skills.CommandList.lore");
|
||||
List<String> newLore = new ArrayList<>();
|
||||
|
||||
for(String s : presetLore) {
|
||||
if(s.contains("{commands}")) {
|
||||
for(String command : boundCommands) {
|
||||
List<String> split = StringUtils.get().splitString(command, 45);
|
||||
|
||||
split.forEach(string -> newLore.add(StringUtils.get().translateColor("&7") + string));
|
||||
newLore.add(" ");
|
||||
}
|
||||
} else {
|
||||
newLore.add(StringUtils.get().translateColor(s));
|
||||
}
|
||||
}
|
||||
|
||||
itemMeta.setLore(newLore);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
panel.setItem(realisticSlot, itemStack, e -> {
|
||||
if(commands.contains(name)) {
|
||||
commands.remove(name);
|
||||
} else {
|
||||
commands.add(name);
|
||||
}
|
||||
|
||||
ServerUtils.get().runTaskAsync(() -> {
|
||||
subCommandSkillElement.setCommands(commands);
|
||||
|
||||
CommandSkillElement commandSkillElement = this.bossSkillManager.getCommandSkillElement(skill);
|
||||
List<SubCommandSkillElement> subCommandSkillElements = commandSkillElement.getCommands();
|
||||
List<SubCommandSkillElement> newElements = new ArrayList<>();
|
||||
|
||||
for(SubCommandSkillElement subElement : subCommandSkillElements) {
|
||||
if(subElement.getName().equals(subCommandSkillElement.getName())) {
|
||||
newElements.add(subCommandSkillElement);
|
||||
} else {
|
||||
newElements.add(subElement);
|
||||
}
|
||||
}
|
||||
|
||||
commandSkillElement.setCommands(newElements);
|
||||
saveSkill(skill, commandSkillElement);
|
||||
});
|
||||
|
||||
loadPage(panel, page, commands, allCommands, entryList, skill, subCommandSkillElement);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveSkill(Skill skill, CommandSkillElement commandSkillElement) {
|
||||
JsonObject jsonObject = BossAPI.convertObjectToJsonObject(commandSkillElement);
|
||||
|
||||
skill.setCustomData(jsonObject);
|
||||
this.plugin.getSkillsFileManager().save();
|
||||
}
|
||||
}
|
@ -1,13 +1,29 @@
|
||||
package com.songoda.epicbosses.panel.skills.custom.commands;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.SkillsFileManager;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.elements.SubCommandSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CommandSkillElement;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
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.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
@ -16,8 +32,14 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class ModifyCommandEditorPanel extends SubVariablePanelHandler<Skill, SubCommandSkillElement> {
|
||||
|
||||
public ModifyCommandEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
|
||||
private SkillsFileManager skillsFileManager;
|
||||
private BossSkillManager bossSkillManager;
|
||||
|
||||
public ModifyCommandEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.bossSkillManager = plugin.getBossSkillManager();
|
||||
this.skillsFileManager = plugin.getSkillsFileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,11 +49,89 @@ public class ModifyCommandEditorPanel extends SubVariablePanelHandler<Skill, Sub
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, Skill skill, SubCommandSkillElement subCommandSkillElement) {
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
List<String> commands = subCommandSkillElement.getCommands();
|
||||
Double chance = subCommandSkillElement.getChance();
|
||||
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
|
||||
|
||||
if(commands == null) commands = new ArrayList<>();
|
||||
if(chance == null) chance = 100.0;
|
||||
|
||||
replaceMap.put("{commands}", StringUtils.get().appendList(commands));
|
||||
replaceMap.put("{chance}", NumberUtils.get().formatDouble(chance));
|
||||
panelBuilder.addReplaceData(replaceMap);
|
||||
|
||||
PanelBuilderCounter counter = panelBuilder.getPanelBuilderCounter();
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setParentPanelHandler(this.bossPanelManager.getCommandSkillEditorPanel(), skill);
|
||||
|
||||
counter.getSlotsWith("Chance").forEach(slot -> panel.setOnClick(slot, getChanceAction(skill, subCommandSkillElement)));
|
||||
counter.getSlotsWith("Commands").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getCommandListSkillEditMenu().openFor((Player) event.getWhoClicked(), skill, subCommandSkillElement)));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
// PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
|
||||
}
|
||||
|
||||
private ClickAction getChanceAction(Skill skill, SubCommandSkillElement subCommandSkillElement) {
|
||||
return event -> {
|
||||
ClickType clickType = event.getClick();
|
||||
double amountToModify;
|
||||
|
||||
if(clickType == ClickType.SHIFT_LEFT) {
|
||||
amountToModify = 0.1;
|
||||
} else if(clickType == ClickType.RIGHT) {
|
||||
amountToModify = -1.0;
|
||||
} else if(clickType == ClickType.SHIFT_RIGHT) {
|
||||
amountToModify = -0.1;
|
||||
} else {
|
||||
amountToModify = 1.0;
|
||||
}
|
||||
|
||||
String modifyValue = amountToModify > 0.0? "increased" : "decreased";
|
||||
Double currentValue = subCommandSkillElement.getChance();
|
||||
|
||||
if(currentValue == null) currentValue = 100.0;
|
||||
|
||||
double newValue = currentValue + amountToModify;
|
||||
|
||||
if(newValue < 0.0) {
|
||||
newValue = 0.0;
|
||||
}
|
||||
|
||||
if(newValue > 100.0) {
|
||||
newValue = 100.0;
|
||||
}
|
||||
|
||||
subCommandSkillElement.setChance(newValue);
|
||||
|
||||
CommandSkillElement commandSkillElement = this.bossSkillManager.getCommandSkillElement(skill);
|
||||
List<SubCommandSkillElement> subCommandSkillElements = commandSkillElement.getCommands();
|
||||
List<SubCommandSkillElement> newElements = new ArrayList<>();
|
||||
|
||||
for(SubCommandSkillElement subElement : subCommandSkillElements) {
|
||||
if(subElement.getName().equals(subCommandSkillElement.getName())) {
|
||||
newElements.add(subCommandSkillElement);
|
||||
} else {
|
||||
newElements.add(subElement);
|
||||
}
|
||||
}
|
||||
|
||||
commandSkillElement.setCommands(newElements);
|
||||
saveSkill(skill, commandSkillElement);
|
||||
|
||||
openFor((Player) event.getWhoClicked(), skill, subCommandSkillElement);
|
||||
Message.Boss_Skills_SetCommandChance.msg(event.getWhoClicked(), modifyValue, NumberUtils.get().formatDouble(newValue));
|
||||
};
|
||||
}
|
||||
|
||||
private void saveSkill(Skill skill, CommandSkillElement commandSkillElement) {
|
||||
JsonObject jsonObject = BossAPI.convertObjectToJsonObject(commandSkillElement);
|
||||
|
||||
skill.setCustomData(jsonObject);
|
||||
this.skillsFileManager.save();
|
||||
}
|
||||
}
|
||||
|
@ -43,14 +43,7 @@ public class CreatePotionEffectEditorPanel extends SubVariablePanelHandler<Skill
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
// PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
//
|
||||
// panelBuilderCounter
|
||||
// .addSlotCounter("Cancel")
|
||||
// .addSlotCounter("Level")
|
||||
// .addSlotCounter("Effect")
|
||||
// .addSlotCounter("Duration")
|
||||
// .addSlotCounter("Confirm");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -160,7 +153,7 @@ public class CreatePotionEffectEditorPanel extends SubVariablePanelHandler<Skill
|
||||
currentList.add(potionEffectHolder);
|
||||
potionSkillElement.setPotions(currentList);
|
||||
|
||||
JsonObject jsonObject = BossAPI.convertSkillElement(potionSkillElement);
|
||||
JsonObject jsonObject = BossAPI.convertObjectToJsonObject(potionSkillElement);
|
||||
|
||||
skill.setCustomData(jsonObject);
|
||||
this.skillsFileManager.save();
|
||||
|
@ -13,7 +13,15 @@ import java.util.List;
|
||||
*/
|
||||
public class SubCommandSkillElement {
|
||||
|
||||
@Expose @Getter private final String name;
|
||||
|
||||
@Expose @Getter @Setter private Double chance;
|
||||
@Expose @Getter @Setter private List<String> commands;
|
||||
|
||||
public SubCommandSkillElement(String name, Double chance, List<String> commands) {
|
||||
this.name = name;
|
||||
this.chance = chance;
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ public enum Message {
|
||||
Boss_Skills_SetMode("&b&lEpicBosses &8» &7You have set the skill mode to &f{0}&7."),
|
||||
Boss_Skills_SetDisplayName("&b&lEpicBosses &8» &7Your next input in to chat will be the display name for the skill. If you enter &f-&7 it will remove/clear the display name of the skill. For color codes use the &f& &7sign."),
|
||||
Boss_Skills_NotCompleteEnough("&c&l(!) &cThe potion effect was unable to be created due to it not having enough information. Please make sure that the potion effect type is selected."),
|
||||
Boss_Skills_SetCommandChance("&b&lEpicBosses &8» &7You have {0} the chance for the command skill to &f{1}%&7."),
|
||||
|
||||
Boss_Spawn_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Spawn_InvalidArgs("&c&l(!) &cYou must use &n/boss spawn [name] (location)&c to spawn a boss."),
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
@ -18,6 +19,18 @@ public class StringUtils {
|
||||
|
||||
private static StringUtils INSTANCE = new StringUtils();
|
||||
|
||||
public List<String> splitString(String input, int splitSize) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
int index = 0;
|
||||
|
||||
while (index < input.length()) {
|
||||
messages.add(input.substring(index, Math.min(index + splitSize, input.length())));
|
||||
index += splitSize;
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
public String stripColor(String string) {
|
||||
return ChatColor.stripColor(string);
|
||||
}
|
||||
|
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-U111</plugin.version>
|
||||
<plugin.version>1.0.0-U112</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