3.0.0-SNAPSHOT-U13

Fixed up some issues on the BossEntity Elements, as well as started working on a EntityFinder class which will handle every sort of mob
This commit is contained in:
AMinecraftDev 2018-06-28 21:12:36 +08:00
parent be824fe0c1
commit 5b3d99152c
26 changed files with 331 additions and 75 deletions

21
TODO
View File

@ -1,21 +0,0 @@
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)
TODO: Write particle system so u can make bosses change particles when they get hit, or use skills, etc.
TODO: Make a (sorted) drop table viewer
TODO: Method for equipment, weapons, etc. will when selecting a current one it grabs all items from the items.json if they have a valid type for the needed, otherwise it when creating it'll allow you to place an item in, and that item gets saved
TODO: Loading drop tables, it'll grab an active list (which will be the same as the droptables.json) and project that into a GUI (with pages)

View File

@ -19,15 +19,15 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
@Override
public void onEnable() {
this.itemStackManager = new BossItemFileManager(this);
this.bossMechanicManager = new BossMechanicManager(this);
reload();
this.bossMechanicManager.load();
}
@Override
public void reload() {
this.itemStackManager.reload();
this.bossMechanicManager.load();
}
}

View File

@ -0,0 +1,47 @@
package net.aminecraftdev.custombosses.api;
import net.aminecraftdev.custombosses.entity.BossEntity;
import net.aminecraftdev.custombosses.entity.elements.*;
import net.aminecraftdev.custombosses.utils.EntityTypeUtil;
import net.aminecraftdev.custombosses.utils.potion.holder.PotionEffectHolder;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Jun-18
*/
public class BossAPI {
public static BossEntity createBoss(String name, String entityTypeInput) {
MainStatsElement mainStatsElement = new MainStatsElement();
EquipmentElement equipmentElement = new EquipmentElement();
HandsElement handsElement = new HandsElement();
List<PotionEffectHolder> potionEffectHolders = new ArrayList<>();
SkillsElement skillsElement = new SkillsElement();
DropsElement dropsElement = new DropsElement();
MessagesElement messagesElement = new MessagesElement();
CommandsElement commandsElement = new CommandsElement();
EntityTypeUtil entityTypeUtil = EntityTypeUtil.get(entityTypeInput);
if(entityTypeUtil == null) {
try {
} catch (Exception ex) {
}
EntityType entityType = EntityType.valueOf(entityTypeInput.toUpperCase());
if(entityType == null) {
}
}
BossEntity bossEntity = new BossEntity(true, null, mainStatsElement, equipmentElement, handsElement, potionEffectHolders, skillsElement, dropsElement, messagesElement, commandsElement);
}
}

View File

@ -27,7 +27,7 @@ public class BossEntity {
@Expose @Getter @Setter private String spawnItem;
@Expose @Getter @Setter private boolean editing;
public BossEntity(boolean editing, MainStatsElement mainStats, String spawnItem, EquipmentElement equipment, HandsElement hands, List<PotionEffectHolder> potions,
public BossEntity(boolean editing, String spawnItem, MainStatsElement mainStats, EquipmentElement equipment, HandsElement hands, List<PotionEffectHolder> potions,
SkillsElement skills, DropsElement drops, MessagesElement messages, CommandsElement commands) {
this.editing = editing;
this.mainStats = mainStats;

View File

@ -13,8 +13,4 @@ public class CommandsElement {
@Expose @Getter @Setter private String onSpawn, onDeath;
public CommandsElement(String onSpawn, String onDeath) {
this.onSpawn = onSpawn;
this.onDeath = onDeath;
}
}

View File

@ -11,12 +11,7 @@ import lombok.Setter;
*/
public class DropsElement {
@Expose @Getter @Setter private boolean naturalDrops, dropExp;
@Expose @Getter @Setter private Boolean naturalDrops, dropExp;
@Expose @Getter @Setter private String dropTable;
public DropsElement(boolean naturalDrops, boolean dropExp, String dropTable) {
this.naturalDrops = naturalDrops;
this.dropExp = dropExp;
this.dropTable = dropTable;
}
}

View File

@ -12,13 +12,5 @@ import lombok.Setter;
public class EquipmentElement {
@Expose @Getter @Setter private String helmet, chestplate, leggings, boots;
public EquipmentElement(String helmet, String chestplate, String leggings, String boots) {
this.helmet = helmet;
this.chestplate = chestplate;
this.leggings = leggings;
this.boots = boots;
}
}

View File

@ -12,7 +12,7 @@ import lombok.Setter;
public class MainStatsElement {
@Expose @Getter @Setter private String entityType;
@Expose @Getter @Setter private double health;
@Expose @Getter @Setter private Double health;
@Expose @Getter @Setter private String displayName;
}

View File

@ -13,7 +13,7 @@ import java.util.List;
*/
public class SkillsElement {
@Expose @Getter @Setter private double overallChance;
@Expose @Getter @Setter private Double overallChance;
@Expose @Getter @Setter private String masterMessage;
@Expose @Getter @Setter private List<String> skills;

View File

@ -13,7 +13,7 @@ import java.util.List;
*/
public class TauntElement {
@Expose @Getter @Setter private int delay;
@Expose @Getter @Setter private Integer delay;
@Expose @Getter @Setter private List<String> taunts;
}

View File

@ -51,7 +51,9 @@ public enum EnchantFinder {
EnchantFinder(String fancyName, Enchantment enchantment, String... names) {
this.fancyName = fancyName;
this.enchantment = enchantment;
this.names.addAll(Arrays.asList(names));
this.names.add(fancyName);
}
public Enchantment getEnchantment() {

View File

@ -0,0 +1,52 @@
package net.aminecraftdev.custombosses.utils;
import lombok.Getter;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.entity.handlers.*;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Jun-18
*/
public enum EntityFinder {
ELDER_GUARDIAN("ElderGuardian", new ElderGuardianHandler(), "elderguardian", "elder_guardian", "elder guardian"),
WITHER_SKELETON("WitherSkeleton", new WitherSkeletonHandler(), "witherskeleton", "wither_skeleton", "wither skeleton"),
STRAY("Stray", new StraySkeletonHandler(), "stray"),
HUSK("Husk", new HuskZombieHandler(), "husk"),
ZOMBIE_VILLAGER("ZombieVillager", new ZombieVillagerHandler(), "zombievillager", "zombie_villager", "zombie villager", "villagerzombie", "villager_zombie", "villager zombie"),
SKELETON_HORSE("SkeletonHorse", new SkeletonHorseHandler(), "skeletonhorse", "skeleton_horse", "skeleton horse"),
ZOMBIE_HORSE("ZombieHorse", new ZombieHorseHandler(), "zombiehorse", "zombie_horse", "zombie horse");
@Getter private ICustomEntityHandler customEntityHandler;
@Getter private List<String> names = new ArrayList<>();
@Getter private EntityType entityType;
@Getter private String fancyName;
EntityFinder(String fancyName, ICustomEntityHandler customEntityHandler, String... names) {
this.fancyName = fancyName;
this.customEntityHandler = customEntityHandler;
this.names.addAll(Arrays.asList(names));
this.names.add(fancyName);
this.entityType = null;
}
EntityFinder(String fancyName, EntityType entityType, String... names) {
this.fancyName = fancyName;
this.entityType = entityType;
this.names.addAll(Arrays.asList(names));
this.names.add(fancyName);
this.customEntityHandler = null;
}
}

View File

@ -3,6 +3,7 @@ package net.aminecraftdev.custombosses.utils;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.entity.handlers.*;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
@ -41,4 +42,11 @@ public enum EntityTypeUtil {
return null;
}
public static EntityTypeUtil get(String entityType) {
for(EntityTypeUtil entityTypeUtil : values()) {
if(entityType.toUpperCase().startsWith(entityTypeUtil.name())) return entityTypeUtil;
}
return null;
}
}

View File

@ -29,10 +29,22 @@ public enum Versions {
this.bukkitVersion = name();
}
public boolean isHigherThan(Versions input) {
public boolean isLessThan(Versions input) {
return this.weight < input.weight;
}
public boolean isLessThanOrEqualTo(Versions input) {
return this.weight <= input.weight;
}
public boolean isHigherThanOrEqualTo(Versions input) {
return this.weight >= input.weight;
}
public boolean isHigherThan(Versions input) {
return this.weight > input.weight;
}
public static Versions getVersion(String input) {
for(Versions versions : values()) {
if(versions.getBukkitVersion().equalsIgnoreCase(input)) {

View File

@ -1,6 +1,7 @@
package net.aminecraftdev.custombosses.utils.entity;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**

View File

@ -1,11 +1,10 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.ReflectionUtil;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.*;
/**
* @author Charles Cullen
@ -14,17 +13,14 @@ import org.bukkit.entity.Skeleton;
*/
public class ElderGuardianHandler implements ICustomEntityHandler {
private String version = ReflectionUtil.get().getVersion();
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.version.startsWith("v1_11_") || this.version.startsWith("v1_12_")) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.WITHER_SKELETON);
} else {
Skeleton skeleton = (Skeleton) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.SKELETON);
skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER);
return skeleton;
if(this.versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_7_R4)) {
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
}
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ELDER_GUARDIAN);
}
}

View File

@ -0,0 +1,27 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Jun-18
*/
public class HuskZombieHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_10_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HUSK);
}
throw new NullPointerException("This feature is only implemented in version 1.10 and above of Minecraft.");
}
}

View File

@ -1,11 +1,10 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.ReflectionUtil;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.*;
/**
* @author Charles Cullen
@ -14,11 +13,11 @@ import org.bukkit.entity.Rabbit;
*/
public class KillerBunnyHandler implements ICustomEntityHandler {
private String version = ReflectionUtil.get().getVersion();
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.version.startsWith("v1_7_") || this.version.startsWith("v1_6_")) {
if(this.versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_7_R4)) {
throw new NullPointerException("This feature is only implemented in version 1.8 and above of Minecraft.");
}

View File

@ -0,0 +1,31 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Jun-18
*/
public class SkeletonHorseHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.SKELETON_HORSE);
}
Horse horse = (Horse) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
horse.setVariant(Horse.Variant.SKELETON_HORSE);
return horse;
}
}

View File

@ -0,0 +1,35 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Skeleton;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jun-18
*/
public class StraySkeletonHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isLessThanOrEqualTo(Versions.v1_9_R2)) {
throw new NullPointerException("This feature is only implemented in version 1.10 and above of Minecraft.");
}
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.STRAY);
}
Skeleton skeleton = (Skeleton) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.SKELETON);
skeleton.setSkeletonType(Skeleton.SkeletonType.STRAY);
return skeleton;
}
}

View File

@ -17,14 +17,20 @@ public class VillagerHandler implements ICustomEntityHandler {
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
Villager villager = (Villager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VILLAGER);
String[] split = entityType.split(":");
int size = Integer.valueOf(split[1]);
Villager.Profession profession = Villager.Profession.getProfession(size);
if(profession == null) {
throw new NullPointerException("Profession value is too high and does not represent an actual villager profession.");
if(split.length == 2) {
String type = split[1];
Villager.Profession profession;
try {
profession = Villager.Profession.valueOf(type.toUpperCase());
} catch (Exception ex) {
throw new NullPointerException("Profession value is too high and does not represent an actual villager profession.");
}
villager.setProfession(profession);
}
villager.setProfession(profession);
return villager;
}
}

View File

@ -1,7 +1,8 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.ReflectionUtil;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -14,11 +15,11 @@ import org.bukkit.entity.Skeleton;
*/
public class WitherSkeletonHandler implements ICustomEntityHandler {
private String version = ReflectionUtil.get().getVersion();
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.version.startsWith("v1_11_") || this.version.startsWith("v1_12_")) {
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.WITHER_SKELETON);
}

View File

@ -0,0 +1,31 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Jun-18
*/
public class ZombieHorseHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
return (LivingEntity) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE_HORSE);
}
Horse horse = (Horse) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.HORSE);
horse.setVariant(Horse.Variant.UNDEAD_HORSE);
return horse;
}
}

View File

@ -0,0 +1,45 @@
package net.aminecraftdev.custombosses.utils.entity.handlers;
import net.aminecraftdev.custombosses.utils.Versions;
import net.aminecraftdev.custombosses.utils.entity.ICustomEntityHandler;
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
import org.bukkit.Location;
import org.bukkit.entity.*;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 28-Jun-18
*/
public class ZombieVillagerHandler implements ICustomEntityHandler {
private VersionHandler versionHandler = new VersionHandler();
@Override
public LivingEntity getBaseEntity(String entityType, Location spawnLocation) {
if(this.versionHandler.getVersion().isHigherThanOrEqualTo(Versions.v1_11_R1)) {
ZombieVillager zombieVillager = (ZombieVillager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE_VILLAGER);
String[] split = entityType.split(":");
if(split.length == 2) {
String type = split[1];
Villager.Profession profession;
try {
profession = Villager.Profession.valueOf(type.toUpperCase());
} catch (Exception ex) {
throw new NullPointerException("Profession value is too high and does not represent an actual villager profession.");
}
zombieVillager.setVillagerProfession(profession);
return zombieVillager;
}
}
Zombie zombie = (Zombie) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.ZOMBIE);
zombie.setVillager(true);
return zombie;
}
}

View File

@ -1,5 +1,6 @@
package net.aminecraftdev.custombosses.utils.version;
import lombok.Getter;
import net.aminecraftdev.custombosses.utils.Versions;
import org.bukkit.Bukkit;
@ -10,7 +11,7 @@ import org.bukkit.Bukkit;
*/
public class VersionHandler {
private Versions version;
@Getter private Versions version;
public VersionHandler() {
String v = Bukkit.getServer().getClass().getPackage().getName();
@ -21,7 +22,7 @@ public class VersionHandler {
}
public boolean canUseOffHand() {
return this.version.isHigherThan(Versions.v1_9_R1);
return this.version.isHigherThanOrEqualTo(Versions.v1_9_R1);
}
}

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>3.0.0-SNAPSHOT-U12</plugin.version>
<plugin.version>3.0.0-SNAPSHOT-U13</plugin.version>
<plugin.name>CustomBosses</plugin.name>
<plugin.main>net.aminecraftdev.custombosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>