mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-09-27 13:03:01 +02:00
3.0.0b - Updated
This commit is contained in:
parent
b13a57d773
commit
79ebecdd77
18
TODO
Normal file
18
TODO
Normal file
@ -0,0 +1,18 @@
|
||||
TODO: Remove the need for a skill Model, make it get JSON data -> send it through the parser -> output custom skill
|
||||
TODO: Finish the Skill system
|
||||
TODO: Setup the Custom input Skill system
|
||||
TODO: Test the Skill system (without running the plugin as a whole)
|
||||
TODO: Apply CustomSkill class to BossEntity
|
||||
TODO: Add additional configurations to BossEntity/CustomEntityModel
|
||||
TODO: Make a parser to convert CustomEntityModels to CustomEntity's
|
||||
TODO: Make a parser to convert SkillModels to Skills
|
||||
TODO: Setup a items.json which can read and write items really easily
|
||||
TODO: Setup a messages.json which can allow for any message within the plugin to be referred to this section
|
||||
TODO: Make a load/save for bosses.json and skills.json
|
||||
TODO: Setup commands
|
||||
TODO: Setup drops system
|
||||
TODO: Setup API
|
||||
TODO: Setup GUI aspect to allow for in-game boss setup
|
||||
TODO: Write a documentation up about how to use the plugin
|
||||
TODO: Make the 2.x.x - 3.x.x converter (an executable jar, NOT a plugin)
|
||||
|
3
plugin-modules/Core/resources/bosses.json
Normal file
3
plugin-modules/Core/resources/bosses.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
3
plugin-modules/Core/resources/skills.json
Normal file
3
plugin-modules/Core/resources/skills.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package net.aminecraftdev.custombosses;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* @author AMinecraftDev
|
||||
* @version 1.0.0
|
||||
* @since 06-Sep-17
|
||||
*/
|
||||
public class CustomBosses {
|
||||
public class CustomBosses extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package net.aminecraftdev.custombosses.api;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*
|
||||
*/
|
||||
public class BossAPI {
|
||||
|
||||
private static BossAPI instance;
|
||||
|
||||
public BossAPI() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static BossAPI get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package net.aminecraftdev.custombosses.entities.base;
|
||||
|
||||
import net.aminecraftdev.custombosses.handlers.EntityHandler;
|
||||
import net.aminecraftdev.custombosses.handlers.IIdentifier;
|
||||
import net.aminecraftdev.custombosses.utils.IIdentifier;
|
||||
import net.aminecraftdev.custombosses.models.CustomEntityModel;
|
||||
import net.aminecraftdev.custombosses.skills.base.CustomSkill;
|
||||
import net.aminecraftdev.custombosses.skills.CustomSkill;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
@ -27,8 +27,6 @@ public class CustomEntity implements IIdentifier {
|
||||
public CustomEntity(String identifier, CustomEntityModel customEntityModel) {
|
||||
this.identifier = identifier;
|
||||
this.customEntityModel = customEntityModel;
|
||||
|
||||
// TODO: Convert customSkillModels into customSkills
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,45 @@
|
||||
package net.aminecraftdev.custombosses.entities.components;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class PotionEffectComponent {
|
||||
|
||||
@Expose private PotionEffectType potionEffectType;
|
||||
@Expose private int duration, level;
|
||||
|
||||
public PotionEffectComponent(PotionEffectType potionEffectType, int duration, int level) {
|
||||
this.potionEffectType = potionEffectType;
|
||||
this.duration = duration;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public PotionEffectType getPotionEffectType() {
|
||||
return potionEffectType;
|
||||
}
|
||||
|
||||
public void setPotionEffectType(PotionEffectType potionEffectType) {
|
||||
this.potionEffectType = potionEffectType;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package net.aminecraftdev.custombosses.entities.components.entity;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class ArmorComponent {
|
||||
|
||||
@Expose private String helmet, chestplate, leggings, boots;
|
||||
|
||||
public ArmorComponent(String helmet, String chestplate, String leggings, String boots, String mainHand, String offHand) {
|
||||
this.helmet = helmet;
|
||||
this.chestplate = chestplate;
|
||||
this.leggings = leggings;
|
||||
this.boots = boots;
|
||||
}
|
||||
|
||||
public String getHelmet() {
|
||||
return helmet;
|
||||
}
|
||||
|
||||
public void setHelmet(String helmet) {
|
||||
this.helmet = helmet;
|
||||
}
|
||||
|
||||
public String getChestplate() {
|
||||
return chestplate;
|
||||
}
|
||||
|
||||
public void setChestplate(String chestplate) {
|
||||
this.chestplate = chestplate;
|
||||
}
|
||||
|
||||
public String getLeggings() {
|
||||
return leggings;
|
||||
}
|
||||
|
||||
public void setLeggings(String leggings) {
|
||||
this.leggings = leggings;
|
||||
}
|
||||
|
||||
public String getBoots() {
|
||||
return boots;
|
||||
}
|
||||
|
||||
public void setBoots(String boots) {
|
||||
this.boots = boots;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package net.aminecraftdev.custombosses.entities.components.entity;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class HandComponent {
|
||||
|
||||
@Expose private String mainHand, offHand;
|
||||
|
||||
public HandComponent(String mainHand, String offHand) {
|
||||
this.mainHand = mainHand;
|
||||
this.offHand = offHand;
|
||||
}
|
||||
|
||||
public String getMainHand() {
|
||||
return mainHand;
|
||||
}
|
||||
|
||||
public void setMainHand(String mainHand) {
|
||||
this.mainHand = mainHand;
|
||||
}
|
||||
|
||||
public String getOffHand() {
|
||||
return offHand;
|
||||
}
|
||||
|
||||
public void setOffHand(String offHand) {
|
||||
this.offHand = offHand;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package net.aminecraftdev.custombosses.entities.components.skills;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseSkillData;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillTarget;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillType;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class SkillComponent {
|
||||
|
||||
@Expose private String name;
|
||||
@Expose private int radius;
|
||||
@Expose private SkillTarget skillTarget;
|
||||
@Expose private SkillType skillType;
|
||||
@Expose private String showName, customMessage;
|
||||
@Expose private BaseSkillData skillData;
|
||||
@Expose private SkillGroupComponent skillGroupComponent;
|
||||
|
||||
public SkillComponent(String name, int radius, SkillTarget skillTarget, SkillType skillType, String showName, String customMessage, BaseSkillData skillData, SkillGroupComponent skillGroupComponent) {
|
||||
this.name = name;
|
||||
|
||||
setRadius(radius);
|
||||
setSkillTarget(skillTarget);
|
||||
setSkillType(skillType, skillData);
|
||||
setShowName(showName);
|
||||
setCustomMessage(customMessage);
|
||||
|
||||
this.skillGroupComponent = skillGroupComponent;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SkillTarget getSkillTarget() {
|
||||
return skillTarget;
|
||||
}
|
||||
|
||||
public void setSkillTarget(SkillTarget skillTarget) {
|
||||
this.skillTarget = skillTarget;
|
||||
}
|
||||
|
||||
public SkillType getSkillType() {
|
||||
return skillType;
|
||||
}
|
||||
|
||||
public void setSkillType(SkillType skillType, BaseSkillData baseSkillData) {
|
||||
this.skillType = skillType;
|
||||
this.skillData = baseSkillData;
|
||||
}
|
||||
|
||||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public String getCustomMessage() {
|
||||
return customMessage;
|
||||
}
|
||||
|
||||
public void setCustomMessage(String customMessage) {
|
||||
this.customMessage = customMessage;
|
||||
}
|
||||
|
||||
public BaseSkillData getSkillData() {
|
||||
return skillData;
|
||||
}
|
||||
|
||||
public SkillGroupComponent getSkillGroupComponent() {
|
||||
return skillGroupComponent;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package net.aminecraftdev.custombosses.entities.components.skills;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class SkillGroupComponent {
|
||||
|
||||
@Expose private boolean isGroup;
|
||||
@Expose private List<String> connectedSkills;
|
||||
|
||||
public SkillGroupComponent(boolean isGroup, List<String> connectedSkills) {
|
||||
this.isGroup = isGroup;
|
||||
this.connectedSkills = connectedSkills;
|
||||
}
|
||||
|
||||
public boolean isGroup() {
|
||||
return this.isGroup;
|
||||
}
|
||||
|
||||
public void setGroup(boolean group) {
|
||||
isGroup = group;
|
||||
}
|
||||
|
||||
public List<String> getConnectedSkills() {
|
||||
return connectedSkills;
|
||||
}
|
||||
|
||||
public void setConnectedSkills(List<String> connectedSkills) {
|
||||
this.connectedSkills = connectedSkills;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package net.aminecraftdev.custombosses.entities.components.skills.data;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseSkillData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class CommandSkillData extends BaseSkillData {
|
||||
|
||||
@Expose private List<String> commands;
|
||||
|
||||
public CommandSkillData(List<String> commands) {
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package net.aminecraftdev.custombosses.entities.components.skills.data;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseSkillData;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class CustomSkillData extends BaseSkillData {
|
||||
|
||||
@Expose private Object customData;
|
||||
|
||||
public CustomSkillData(Object object) {
|
||||
this.customData = object;
|
||||
}
|
||||
|
||||
public Object getCustomData() {
|
||||
return customData;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package net.aminecraftdev.custombosses.entities.components.skills.data;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import net.aminecraftdev.custombosses.entities.components.PotionEffectComponent;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseSkillData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class PotionSkillData extends BaseSkillData {
|
||||
|
||||
@Expose private List<PotionEffectComponent> potionEffects;
|
||||
|
||||
public PotionSkillData(List<PotionEffectComponent> potionEffectComponents) {
|
||||
this.potionEffects = potionEffectComponents;
|
||||
}
|
||||
|
||||
public List<PotionEffectComponent> getPotionEffects() {
|
||||
return potionEffects;
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package net.aminecraftdev.custombosses.models;
|
||||
|
||||
import net.aminecraftdev.custombosses.handlers.IIdentifier;
|
||||
import net.aminecraftdev.custombosses.utils.IIdentifier;
|
||||
import net.aminecraftdev.custombosses.handlers.ValidationHandler;
|
||||
import net.aminecraftdev.custombosses.handlers.models.IEquipmentHandler;
|
||||
import net.aminecraftdev.custombosses.handlers.models.IPotionHandler;
|
||||
import net.aminecraftdev.custombosses.handlers.models.ISkillHandler;
|
||||
import net.aminecraftdev.custombosses.handlers.models.IStatsHandler;
|
||||
import net.aminecraftdev.custombosses.utils.models.IEquipmentHandler;
|
||||
import net.aminecraftdev.custombosses.utils.models.IPotionHandler;
|
||||
import net.aminecraftdev.custombosses.utils.models.ISkillHandler;
|
||||
import net.aminecraftdev.custombosses.utils.models.IStatsHandler;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -16,9 +16,6 @@ import java.util.*;
|
||||
* @author AMinecraftDev
|
||||
* @version 1.0.0
|
||||
* @since 06-Sep-17
|
||||
*
|
||||
* TODO: Make it load messages via a messages.json file
|
||||
* TODO: Make it load all custom items via. a items.json file
|
||||
*/
|
||||
public class CustomEntityModel implements IIdentifier, IStatsHandler, IEquipmentHandler, ISkillHandler, IPotionHandler {
|
||||
|
||||
|
@ -1,45 +1,9 @@
|
||||
package net.aminecraftdev.custombosses.models;
|
||||
|
||||
import net.aminecraftdev.custombosses.handlers.IIdentifier;
|
||||
import net.aminecraftdev.custombosses.skills.types.SkillTarget;
|
||||
import net.aminecraftdev.custombosses.skills.types.SkillType;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 08-Mar-18
|
||||
* @since 12-Mar-18
|
||||
*/
|
||||
public class CustomSkillModel implements IIdentifier {
|
||||
|
||||
private SkillTarget skillTarget;
|
||||
private SkillType skillType;
|
||||
private String identifier;
|
||||
|
||||
public CustomSkillModel(String identifier, SkillTarget skillTarget, SkillType skillType) {
|
||||
this.identifier = identifier;
|
||||
|
||||
setSkillTarget(skillTarget);
|
||||
setSkillType(skillType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
public SkillType getSkillType() {
|
||||
return this.skillType;
|
||||
}
|
||||
|
||||
public void setSkillType(SkillType skillType) {
|
||||
this.skillType = skillType;
|
||||
}
|
||||
|
||||
public SkillTarget getSkillTarget() {
|
||||
return this.skillTarget;
|
||||
}
|
||||
|
||||
public void setSkillTarget(SkillTarget skillTarget) {
|
||||
this.skillTarget = skillTarget;
|
||||
}
|
||||
public class CustomSkillModel {
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
package net.aminecraftdev.custombosses.skills;
|
||||
|
||||
import net.aminecraftdev.custombosses.handlers.ValidationHandler;
|
||||
import net.aminecraftdev.custombosses.models.CustomSkillModel;
|
||||
import net.aminecraftdev.custombosses.skills.base.CustomSkill;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 08-Mar-18
|
||||
*/
|
||||
public class CustomCommandSkill extends CustomSkill {
|
||||
|
||||
private List<String> commands = new ArrayList<>();
|
||||
|
||||
public CustomCommandSkill(String identifier, CustomSkillModel customSkillModel, List<String> commands) {
|
||||
super(identifier, customSkillModel);
|
||||
|
||||
if(ValidationHandler.isNull(commands)) return;
|
||||
|
||||
this.commands.addAll(commands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeSkill(LivingEntity livingEntity) {
|
||||
for(String command : this.commands) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("%player%", livingEntity.getName()));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package net.aminecraftdev.custombosses.skills;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 08-Mar-18
|
||||
*/
|
||||
public class CustomEffectSkill {
|
||||
|
||||
//TODO: Setup EffectSkill type
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package net.aminecraftdev.custombosses.skills;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 08-Mar-18
|
||||
*/
|
||||
public class CustomPotionSkill {
|
||||
|
||||
//TODO: Setup PotionSkill type
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package net.aminecraftdev.custombosses.skills;
|
||||
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.SkillComponent;
|
||||
import net.aminecraftdev.custombosses.utils.IIdentifier;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillTarget;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public abstract class CustomSkill implements IIdentifier {
|
||||
|
||||
private String name, showName, customMessage;
|
||||
private List<String> linkedSkills;
|
||||
private SkillTarget skillTarget;
|
||||
private SkillType skillType;
|
||||
private boolean isGroup;
|
||||
private int radius;
|
||||
|
||||
public CustomSkill(SkillComponent skillComponent) {
|
||||
this.name = skillComponent.getName();
|
||||
this.radius = skillComponent.getRadius();
|
||||
this.skillTarget = skillComponent.getSkillTarget();
|
||||
this.skillType = skillComponent.getSkillType();
|
||||
this.showName = skillComponent.getShowName();
|
||||
this.customMessage = skillComponent.getCustomMessage();
|
||||
this.linkedSkills = skillComponent.getSkillGroupComponent().getConnectedSkills();
|
||||
this.isGroup = skillComponent.getSkillGroupComponent().isGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SkillTarget getSkillTarget() {
|
||||
return skillTarget;
|
||||
}
|
||||
|
||||
public void setSkillTarget(SkillTarget skillTarget) {
|
||||
this.skillTarget = skillTarget;
|
||||
}
|
||||
|
||||
public SkillType getSkillType() {
|
||||
return skillType;
|
||||
}
|
||||
|
||||
public void setSkillType(SkillType skillType) {
|
||||
this.skillType = skillType;
|
||||
}
|
||||
|
||||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
public void setRadius(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public String getShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
public void setShowName(String showName) {
|
||||
this.showName = showName;
|
||||
}
|
||||
|
||||
public String getCustomMessage() {
|
||||
return customMessage;
|
||||
}
|
||||
|
||||
public void setCustomMessage(String customMessage) {
|
||||
this.customMessage = customMessage;
|
||||
}
|
||||
|
||||
public boolean isGroup() {
|
||||
return isGroup;
|
||||
}
|
||||
|
||||
public void setGroup(boolean group) {
|
||||
isGroup = group;
|
||||
}
|
||||
|
||||
public List<String> getLinkedSkills() {
|
||||
return linkedSkills;
|
||||
}
|
||||
|
||||
public void setLinkedSkills(List<String> linkedSkills) {
|
||||
this.linkedSkills = linkedSkills;
|
||||
}
|
||||
|
||||
public abstract void execute(Player player);
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package net.aminecraftdev.custombosses.skills.base;
|
||||
|
||||
import net.aminecraftdev.custombosses.handlers.IIdentifier;
|
||||
import net.aminecraftdev.custombosses.models.CustomSkillModel;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 08-Mar-18
|
||||
*/
|
||||
public abstract class CustomSkill implements IIdentifier {
|
||||
|
||||
private CustomSkillModel customSkillModel;
|
||||
private String identifier;
|
||||
|
||||
public CustomSkill(String identifier, CustomSkillModel customSkillModel) {
|
||||
this.identifier = identifier;
|
||||
this.customSkillModel = customSkillModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.identifier;
|
||||
}
|
||||
|
||||
public CustomSkillModel getCustomSkillModel() {
|
||||
return this.customSkillModel;
|
||||
}
|
||||
|
||||
public abstract void executeSkill(LivingEntity livingEntity);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.aminecraftdev.custombosses.skills.types;
|
||||
package net.aminecraftdev.custombosses.skills.enums;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
@ -1,4 +1,4 @@
|
||||
package net.aminecraftdev.custombosses.skills.types;
|
||||
package net.aminecraftdev.custombosses.skills.enums;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
@ -0,0 +1,40 @@
|
||||
package net.aminecraftdev.custombosses.skills.types;
|
||||
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.SkillComponent;
|
||||
import net.aminecraftdev.custombosses.skills.CustomSkill;
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.data.CommandSkillData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 12-Mar-18
|
||||
*/
|
||||
public class CommandSkill extends CustomSkill {
|
||||
|
||||
private List<String> commands;
|
||||
|
||||
public CommandSkill(SkillComponent skillComponent, CommandSkillData commandSkillData) {
|
||||
super(skillComponent);
|
||||
|
||||
this.commands = commandSkillData.getCommands();
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public void setCommands(List<String> commands) {
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player player) {
|
||||
for(String s : getCommands()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), s.replace("%player%", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package net.aminecraftdev.custombosses.skills.types;
|
||||
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.SkillComponent;
|
||||
import net.aminecraftdev.custombosses.skills.CustomSkill;
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.data.PotionSkillData;
|
||||
import net.aminecraftdev.custombosses.utils.parser.PotionParser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 12-Mar-18
|
||||
*/
|
||||
public class PotionSkill extends CustomSkill {
|
||||
|
||||
private List<PotionEffect> potionEffects;
|
||||
|
||||
public PotionSkill(SkillComponent skillComponent, PotionSkillData potionSkillData) {
|
||||
super(skillComponent);
|
||||
|
||||
this.potionEffects = new ArrayList<>();
|
||||
|
||||
potionSkillData.getPotionEffects().forEach(potionEffectComponent -> this.potionEffects.add(new PotionParser(potionEffectComponent).parse()));
|
||||
}
|
||||
|
||||
public void setPotionEffects(List<PotionEffect> potionEffects) {
|
||||
this.potionEffects = potionEffects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player player) {
|
||||
for(PotionEffect potionEffect : this.potionEffects) {
|
||||
player.addPotionEffect(potionEffect);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package net.aminecraftdev.custombosses.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseSkillData;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillTarget;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillType;
|
||||
import net.aminecraftdev.custombosses.utils.adapters.PotionEffectTypeAdapter;
|
||||
import net.aminecraftdev.custombosses.utils.adapters.SkillDataAdapter;
|
||||
import net.aminecraftdev.custombosses.utils.adapters.SkillTargetAdapter;
|
||||
import net.aminecraftdev.custombosses.utils.adapters.SkillTypeAdapter;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class BossesGson {
|
||||
|
||||
private static Gson gson = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.registerTypeAdapter(PotionEffectType.class, new PotionEffectTypeAdapter())
|
||||
.registerTypeAdapter(BaseSkillData.class, new SkillDataAdapter())
|
||||
.registerTypeAdapter(SkillTarget.class, new SkillTargetAdapter())
|
||||
.registerTypeAdapter(SkillType.class, new SkillTypeAdapter())
|
||||
.create();
|
||||
|
||||
public static Gson get() {
|
||||
return gson;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.aminecraftdev.custombosses.handlers;
|
||||
package net.aminecraftdev.custombosses.utils;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
@ -0,0 +1,30 @@
|
||||
package net.aminecraftdev.custombosses.utils.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseAdapter;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class PotionEffectTypeAdapter implements BaseAdapter<PotionEffectType> {
|
||||
|
||||
@Override
|
||||
public PotionEffectType deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
String effectType = jsonElement.getAsString();
|
||||
PotionEffectType potionEffectType = PotionEffectType.getByName(effectType.toUpperCase());
|
||||
|
||||
if(potionEffectType == null) return null;
|
||||
|
||||
return potionEffectType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(PotionEffectType potionEffectType, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||
return new JsonPrimitive(potionEffectType.getName().toUpperCase());
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package net.aminecraftdev.custombosses.utils.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseSkillData;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseAdapter;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class SkillDataAdapter implements BaseAdapter<BaseSkillData> {
|
||||
|
||||
@Override
|
||||
public BaseSkillData deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
final JsonObject member = (JsonObject) jsonElement;
|
||||
final JsonElement typeString = get(member, "type");
|
||||
final JsonElement data = get(member, "data");
|
||||
final Type actualType = typeForName(typeString);
|
||||
|
||||
return jsonDeserializationContext.deserialize(data, actualType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(BaseSkillData baseSkillData, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||
final JsonObject jsonObject = new JsonObject();
|
||||
|
||||
jsonObject.addProperty("type", baseSkillData.getClass().getName());
|
||||
jsonObject.add("data", jsonSerializationContext.serialize(baseSkillData));
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private Type typeForName(final JsonElement typeElem) {
|
||||
try {
|
||||
return Class.forName(typeElem.getAsString());
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new JsonParseException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private JsonElement get(final JsonObject wrapper, final String memberName) {
|
||||
final JsonElement elem = wrapper.get(memberName);
|
||||
|
||||
if (elem == null) {
|
||||
throw new JsonParseException(
|
||||
"no '" + memberName + "' member found in json file.");
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package net.aminecraftdev.custombosses.utils.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillTarget;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseAdapter;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class SkillTargetAdapter implements BaseAdapter<SkillTarget> {
|
||||
|
||||
@Override
|
||||
public SkillTarget deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
String target = jsonElement.getAsString();
|
||||
|
||||
try {
|
||||
return SkillTarget.valueOf(target);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(SkillTarget skillTarget, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||
return new JsonPrimitive(skillTarget.name().toUpperCase());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.aminecraftdev.custombosses.utils.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import net.aminecraftdev.custombosses.skills.enums.SkillType;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseAdapter;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class SkillTypeAdapter implements BaseAdapter<SkillType> {
|
||||
|
||||
@Override
|
||||
public SkillType deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
String target = jsonElement.getAsString();
|
||||
|
||||
try {
|
||||
return SkillType.valueOf(target);
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(SkillType skillTarget, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||
return new JsonPrimitive(skillTarget.name().toUpperCase());
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.aminecraftdev.custombosses.utils.base;
|
||||
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public interface BaseAdapter<T> extends JsonSerializer<T>, JsonDeserializer<T> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package net.aminecraftdev.custombosses.utils.base;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public abstract class BaseParser<Input, Output> {
|
||||
|
||||
protected Input input;
|
||||
|
||||
public BaseParser(Input input) {
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
public abstract Output parse();
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package net.aminecraftdev.custombosses.utils.base;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class BaseSkillData {}
|
@ -1,4 +1,4 @@
|
||||
package net.aminecraftdev.custombosses.handlers.models;
|
||||
package net.aminecraftdev.custombosses.utils.models;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.aminecraftdev.custombosses.handlers.models;
|
||||
package net.aminecraftdev.custombosses.utils.models;
|
||||
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.aminecraftdev.custombosses.handlers.models;
|
||||
package net.aminecraftdev.custombosses.utils.models;
|
||||
|
||||
import net.aminecraftdev.custombosses.models.CustomSkillModel;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.aminecraftdev.custombosses.handlers.models;
|
||||
package net.aminecraftdev.custombosses.utils.models;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
@ -0,0 +1,31 @@
|
||||
package net.aminecraftdev.custombosses.utils.parser;
|
||||
|
||||
import net.aminecraftdev.custombosses.entities.components.PotionEffectComponent;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseParser;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 11-Mar-18
|
||||
*/
|
||||
public class PotionParser extends BaseParser<PotionEffectComponent, PotionEffect> {
|
||||
|
||||
public PotionParser(PotionEffectComponent potionEffectComponent) {
|
||||
super(potionEffectComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffect parse() {
|
||||
int duration = this.input.getDuration();
|
||||
int level = this.input.getLevel();
|
||||
PotionEffectType potionEffectType = this.input.getPotionEffectType();
|
||||
|
||||
if(duration == -1) {
|
||||
duration = 15000;
|
||||
}
|
||||
|
||||
return new PotionEffect(potionEffectType, duration*20, level-1);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.aminecraftdev.custombosses.utils.parser.skills;
|
||||
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.SkillComponent;
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.data.CommandSkillData;
|
||||
import net.aminecraftdev.custombosses.skills.types.CommandSkill;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseParser;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 12-Mar-18
|
||||
*/
|
||||
public class CommandSkillParser extends BaseParser<SkillComponent, CommandSkill> {
|
||||
|
||||
public CommandSkillParser(SkillComponent skillComponent) {
|
||||
super(skillComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSkill parse() {
|
||||
if(this.input.getSkillData() instanceof CommandSkillData) {
|
||||
CommandSkillData commandSkillData = (CommandSkillData) this.input.getSkillData();
|
||||
|
||||
return new CommandSkill(this.input, commandSkillData);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.aminecraftdev.custombosses.utils.parser.skills;
|
||||
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.SkillComponent;
|
||||
import net.aminecraftdev.custombosses.entities.components.skills.data.PotionSkillData;
|
||||
import net.aminecraftdev.custombosses.skills.types.PotionSkill;
|
||||
import net.aminecraftdev.custombosses.utils.base.BaseParser;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 12-Mar-18
|
||||
*/
|
||||
public class PotionSkillParser extends BaseParser<SkillComponent, PotionSkill> {
|
||||
|
||||
public PotionSkillParser(SkillComponent skillComponent) {
|
||||
super(skillComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionSkill parse() {
|
||||
if(this.input.getSkillData() instanceof PotionSkillData) {
|
||||
PotionSkillData potionSkillData = (PotionSkillData) this.input.getSkillData();
|
||||
|
||||
return new PotionSkill(this.input, potionSkillData);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user