mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-05 06:47:48 +01:00
1.0.0-SNAPSHOT-U102
+ Fully implemented SkillTypeEditor
This commit is contained in:
parent
85959dba90
commit
737ac84c49
@ -21,7 +21,11 @@ import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.custom.Minions;
|
||||
import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement;
|
||||
import com.songoda.epicbosses.skills.elements.SubCustomSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CommandSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.GroupSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.PotionSkillElement;
|
||||
import com.songoda.epicbosses.utils.BossesGson;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.EntityFinder;
|
||||
@ -180,6 +184,33 @@ public class BossAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JsonObject createNewSkillCustomData(String type) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
String jsonString;
|
||||
|
||||
if(type.equalsIgnoreCase("COMMAND")) {
|
||||
CommandSkillElement commandSkillElement = new CommandSkillElement(new ArrayList<>());
|
||||
|
||||
jsonString = BossesGson.get().toJson(commandSkillElement);
|
||||
} else if(type.equalsIgnoreCase("POTION")) {
|
||||
PotionSkillElement potionSkillElement = new PotionSkillElement(new ArrayList<>());
|
||||
|
||||
jsonString = BossesGson.get().toJson(potionSkillElement);
|
||||
} else if(type.equalsIgnoreCase("CUSTOM")) {
|
||||
CustomSkillElement customSkillElement = new CustomSkillElement(new SubCustomSkillElement("", 0.0, null));
|
||||
|
||||
jsonString = BossesGson.get().toJson(customSkillElement);
|
||||
} else if(type.equalsIgnoreCase("GROUP")) {
|
||||
GroupSkillElement groupSkillElement = new GroupSkillElement(new ArrayList<>());
|
||||
|
||||
jsonString = BossesGson.get().toJson(groupSkillElement);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jsonParser.parse(jsonString).getAsJsonObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to create a new base drop table
|
||||
* with the specified arguments.
|
||||
|
@ -74,7 +74,7 @@ public class MainSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
counter.getSlotsWith("Mode").forEach(slot -> panel.setOnClick(slot, getModeAction(skill)));
|
||||
counter.getSlotsWith("DisplayName").forEach(slot -> panel.setOnClick(slot, getDisplayNameAction(skill)));
|
||||
counter.getSlotsWith("CustomMessage").forEach(slot -> panel.setOnClick(slot, getCustomMessageAction(skill)));
|
||||
counter.getSlotsWith("Type").forEach(slot -> {});
|
||||
counter.getSlotsWith("Type").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getSkillTypeEditMenu().openFor((Player) event.getWhoClicked(), skill)));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
@ -92,13 +92,6 @@ public class MainSkillEditorPanel extends VariablePanelHandler<Skill> {
|
||||
.addSlotCounter("Type");
|
||||
}
|
||||
|
||||
private ClickAction getTypeAction(Skill skill) {
|
||||
return event -> {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private ClickAction getDisplayNameAction(Skill skill) {
|
||||
return event -> {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
@ -1,12 +1,20 @@
|
||||
package com.songoda.epicbosses.panel.skills;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.managers.files.SkillsFileManager;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
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.InventoryClickEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
@ -15,8 +23,12 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class SkillTypeEditorPanel extends VariablePanelHandler<Skill> {
|
||||
|
||||
private SkillsFileManager skillsFileManager;
|
||||
|
||||
public SkillTypeEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
|
||||
super(bossPanelManager, panelBuilder);
|
||||
|
||||
this.skillsFileManager = plugin.getSkillsFileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,11 +38,72 @@ public class SkillTypeEditorPanel extends VariablePanelHandler<Skill> {
|
||||
|
||||
@Override
|
||||
public void openFor(Player player, Skill skill) {
|
||||
Map<String, String> replaceMap = new HashMap<>();
|
||||
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
|
||||
|
||||
replaceMap.put("{name}", BossAPI.getSkillName(skill));
|
||||
panelBuilder.addReplaceData(replaceMap);
|
||||
|
||||
Panel panel = panelBuilder.getPanel()
|
||||
.setDestroyWhenDone(true)
|
||||
.setCancelClick(true)
|
||||
.setCancelLowerClick(true)
|
||||
.setParentPanelHandler(this.bossPanelManager.getMainSkillEditMenu(), skill);
|
||||
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
|
||||
|
||||
counter.getSlotsWith("Command").forEach(slot -> panel.setOnClick(slot, getCommandAction(skill)));
|
||||
counter.getSlotsWith("Custom").forEach(slot -> panel.setOnClick(slot, getCustomAction(skill)));
|
||||
counter.getSlotsWith("Potion").forEach(slot -> panel.setOnClick(slot, getPotionAction(skill)));
|
||||
counter.getSlotsWith("Group").forEach(slot -> panel.setOnClick(slot, getGroupAction(skill)));
|
||||
|
||||
panel.openFor(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializePanel(PanelBuilder panelBuilder) {
|
||||
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
|
||||
|
||||
panelBuilderCounter
|
||||
.addSlotCounter("Command")
|
||||
.addSlotCounter("Custom")
|
||||
.addSlotCounter("Potion")
|
||||
.addSlotCounter("Group");
|
||||
}
|
||||
|
||||
private ClickAction getCommandAction(Skill skill) {
|
||||
return event -> {
|
||||
skill.setType("COMMAND");
|
||||
skill.setCustomData(BossAPI.createNewSkillCustomData(skill.getType()));
|
||||
save(skill, event);
|
||||
};
|
||||
}
|
||||
|
||||
private ClickAction getCustomAction(Skill skill) {
|
||||
return event -> {
|
||||
skill.setType("CUSTOM");
|
||||
skill.setCustomData(BossAPI.createNewSkillCustomData(skill.getType()));
|
||||
save(skill, event);
|
||||
};
|
||||
}
|
||||
|
||||
private ClickAction getGroupAction(Skill skill) {
|
||||
return event -> {
|
||||
skill.setType("GROUP");
|
||||
skill.setCustomData(BossAPI.createNewSkillCustomData(skill.getType()));
|
||||
save(skill, event);
|
||||
};
|
||||
}
|
||||
|
||||
private ClickAction getPotionAction(Skill skill) {
|
||||
return event -> {
|
||||
skill.setType("POTION");
|
||||
skill.setCustomData(BossAPI.createNewSkillCustomData(skill.getType()));
|
||||
save(skill, event);
|
||||
};
|
||||
}
|
||||
|
||||
private void save(Skill skill, InventoryClickEvent event) {
|
||||
this.skillsFileManager.save();
|
||||
this.bossPanelManager.getMainSkillEditMenu().openFor((Player) event.getWhoClicked(), skill);
|
||||
}
|
||||
}
|
||||
|
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-U101</plugin.version>
|
||||
<plugin.version>1.0.0-U102</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