diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/EntityHandler.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/EntityHandler.java deleted file mode 100644 index ec81203..0000000 --- a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/EntityHandler.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.aminecraftdev.custombosses.handlers; - -/** - * @author AMinecraftDev - * @version 1.0.0 - * @since 31-May-17 - */ -public class EntityHandler { -} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/builders/EntityHandler.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/builders/EntityHandler.java new file mode 100644 index 0000000..ac72469 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/builders/EntityHandler.java @@ -0,0 +1,129 @@ +package net.aminecraftdev.custombosses.handlers.builders; + +import net.aminecraftdev.custombosses.innerapi.reflection.ReflectionUtils; +import org.bukkit.Location; +import org.bukkit.entity.*; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public class EntityHandler extends ReflectionUtils { + + public final LivingEntity getBaseEntity(String type, Location location) { + LivingEntity livingEntity = null; + EntityType entityType = null; + + if(type.equalsIgnoreCase("WITHER_SKELETON")) livingEntity = getWitherSkeleton(location); + else if(type.equalsIgnoreCase("ELDER_GUARDIAN")) livingEntity = getElderGuardian(location); + else if(type.equalsIgnoreCase("KILLER_BUNNY")) livingEntity = getKillerBunny(location); + else if(type.equalsIgnoreCase("ZOMBIE")) livingEntity = getZombie(location); + else if(type.equalsIgnoreCase("BABY_ZOMBIE")) livingEntity = getBabyZombie(location); + else if(type.equalsIgnoreCase("PIG_ZOMBIE")) livingEntity = getPigZombie(location); + else if(type.equalsIgnoreCase("BABY_PIG_ZOMBIE")) livingEntity = getBabyPigZombie(location); + else if(type.contains(":")) { + String[] split = type.split(":"); + + if(split[0].equalsIgnoreCase("SLIME")) { + livingEntity = getSlime(location, Integer.valueOf(split[1])); + } else if(split[0].equalsIgnoreCase("MAGMA_CUBE")) { + livingEntity = getMagmaCube(location, Integer.valueOf(split[1])); + } else { + if(EntityType.valueOf(type).equals(null)) { + /* ADD A DEBUG MESSAGE HERE */ + return null; + } + } + } else { + if(EntityType.valueOf(type).equals(null)) { + /* ADD A DEBUG MESSAGE HERE */ + return null; + } + + entityType = EntityType.valueOf(type); + } + + if(livingEntity == null) { + if(entityType == EntityType.SLIME) getSlime(location, 10); + else if(entityType == EntityType.MAGMA_CUBE) getSlime(location, 10); + else { + livingEntity = (LivingEntity) location.getWorld().spawn(location, entityType.getEntityClass()); + } + } + + return livingEntity; + } + + private LivingEntity getWitherSkeleton(Location location) { + if(getAPIVersion().startsWith("v1_11_R")) { + return (LivingEntity) location.getWorld().spawn(location, EntityType.WITHER_SKELETON.getEntityClass()); + } else { + Skeleton skeleton = (Skeleton) location.getWorld().spawn(location, EntityType.SKELETON.getEntityClass()); + skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER); + + return skeleton; + } + } + + private LivingEntity getElderGuardian(Location location) { + if(getAPIVersion().startsWith("v1_11_R")) { + return (LivingEntity) location.getWorld().spawn(location, EntityType.ELDER_GUARDIAN.getEntityClass()); + } else { + Guardian guardian = (Guardian) location.getWorld().spawn(location, EntityType.GUARDIAN.getEntityClass()); + guardian.setElder(true); + + return guardian; + } + } + + private LivingEntity getKillerBunny(Location location) { + Rabbit rabbit = (Rabbit) location.getWorld().spawn(location, EntityType.RABBIT.getEntityClass()); + rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY); + + return rabbit; + } + + private LivingEntity getBabyZombie(Location location) { + Zombie zombie = (Zombie) location.getWorld().spawn(location, EntityType.ZOMBIE.getEntityClass()); + zombie.setBaby(true); + + return zombie; + } + + private LivingEntity getZombie(Location location) { + Zombie zombie = (Zombie) location.getWorld().spawn(location, EntityType.ZOMBIE.getEntityClass()); + zombie.setBaby(false); + + return zombie; + } + + private LivingEntity getBabyPigZombie(Location location) { + PigZombie pigZombie = (PigZombie) location.getWorld().spawn(location, EntityType.PIG_ZOMBIE.getEntityClass()); + pigZombie.setBaby(true); + + return pigZombie; + } + + private LivingEntity getPigZombie(Location location) { + PigZombie pigZombie = (PigZombie) location.getWorld().spawn(location, EntityType.PIG_ZOMBIE.getEntityClass()); + pigZombie.setBaby(false); + + return pigZombie; + } + + private LivingEntity getSlime(Location location, int size) { + Slime slime = (Slime) location.getWorld().spawn(location, EntityType.SLIME.getEntityClass()); + slime.setSize(size); + + return slime; + } + + private LivingEntity getMagmaCube(Location location, int size) { + MagmaCube magmaCube = (MagmaCube) location.getWorld().spawn(location, EntityType.MAGMA_CUBE.getEntityClass()); + magmaCube.setSize(size); + + return magmaCube; + } + +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/builders/EquipmentHandler.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/builders/EquipmentHandler.java new file mode 100644 index 0000000..d4f265a --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/builders/EquipmentHandler.java @@ -0,0 +1,77 @@ +package net.aminecraftdev.custombosses.handlers.builders; + +import net.aminecraftdev.custombosses.innerapi.itemstack.ItemStackUtils; +import org.bukkit.Material; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.LivingEntity; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public class EquipmentHandler { + + public void applyEquipment(LivingEntity livingEntity, ConfigurationSection configurationSection) { + Map mapOfEnchants = getMapOfEnchants(configurationSection); + String type = configurationSection.getString("type").toUpperCase(); + + if(configurationSection.getName().equalsIgnoreCase("Armor")) { + String innerType = type + "_HELMET"; + + livingEntity.getEquipment().setHelmet(getArmour(innerType, mapOfEnchants)); + innerType = type + "_CHESTPLATE"; + livingEntity.getEquipment().setChestplate(getArmour(innerType, mapOfEnchants)); + innerType = type + "_LEGGINGS"; + livingEntity.getEquipment().setLeggings(getArmour(innerType, mapOfEnchants)); + innerType = type + "_BOOTS"; + livingEntity.getEquipment().setBoots(getArmour(innerType, mapOfEnchants)); + } else { + ItemStack itemStack = new ItemStack(ItemStackUtils.getType(type)); + + itemStack.addUnsafeEnchantments(mapOfEnchants); + livingEntity.getEquipment().setItemInHand(itemStack); + } + } + + public void applySkull(LivingEntity livingEntity, ConfigurationSection configurationSection) { + String owner = configurationSection.getString("owner"); + ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); + SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta(); + + skullMeta.setOwner(owner); + itemStack.setItemMeta(skullMeta); + livingEntity.getEquipment().setHelmet(itemStack); + } + + private Map getMapOfEnchants(ConfigurationSection configurationSection) { + Map enchantmentIntegerMap = new HashMap<>(); + List enchantsList = configurationSection.getStringList("enchants"); + + for(String s : enchantsList) { + String[] spl = s.split(":"); + String ench = spl[0]; + int level = Integer.parseInt(spl[1]); + + enchantmentIntegerMap.put(Enchantment.getByName(ench), level); + } + + return enchantmentIntegerMap; + } + + private ItemStack getArmour(String type, Map enchantments) { + ItemStack itemStack = new ItemStack(ItemStackUtils.getType(type)); + + itemStack.addUnsafeEnchantments(enchantments); + + return itemStack; + } + +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/BossEntity.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/BossEntity.java new file mode 100644 index 0000000..7f73d34 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/BossEntity.java @@ -0,0 +1,140 @@ +package net.aminecraftdev.custombosses.handlers.mobs; + +import net.aminecraftdev.custombosses.handlers.mobs.interfaces.IDamageHandler; +import net.aminecraftdev.custombosses.handlers.mobs.interfaces.IKillHandler; +import net.aminecraftdev.custombosses.handlers.mobs.interfaces.IMobHandler; +import net.aminecraftdev.custombosses.handlers.mobs.interfaces.ISpawnHandler; +import net.aminecraftdev.custombosses.innerapi.message.MessageUtils; +import net.aminecraftdev.custombosses.managers.BossManager; +import org.bukkit.Location; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import java.util.UUID; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public class BossEntity implements IMobHandler, ISpawnHandler, IDamageHandler, IKillHandler { + + private boolean hasSkills, hasTaunts, hasCommands, hasMessages, isAutoBoss; + private ConfigurationSection configurationSection; + private LivingEntity livingEntity; + private BossManager bossManager; + private boolean isBossSpawned; + private double maxHealth; + private UUID uuid; + + //private Set skills = new HashSet<>(); + //private List taunts = new ArrayList<>(); + + public BossEntity(ConfigurationSection configurationSection, BossManager bossManager, boolean isAutoBoss) { + this.hasSkills = this.configurationSection.contains("Skills"); + this.hasTaunts = this.configurationSection.contains("Taunts"); + this.hasCommands = this.configurationSection.contains("Commands"); + this.hasMessages = this.configurationSection.contains("Messages"); + this.configurationSection = configurationSection; + this.bossManager = bossManager; + this.isBossSpawned = false; + this.isAutoBoss = isAutoBoss; + } + + @Override + public ConfigurationSection getConfigurationSection() { + return configurationSection; + } + + @Override + public double getMaxHealth() { + return maxHealth; + } + + @Override + public double getCurrentHealth() { + return livingEntity.getHealth(); + } + + @Override + public UUID getUniqueId() { + return uuid; + } + + @Override + public boolean isAutoBoss() { + return isAutoBoss; + } + + @Override + public void spawn(Location location) { + spawnBoss(location); + spawnMessage(location); + } + + @Override + public void spawnBoss(Location location) { + if(this.isBossSpawned) { + /* ADD DEBUG MESSAGE HERE */ + return; + } + + ConfigurationSection bossConfigurationSection = configurationSection.getConfigurationSection("Boss"); + String type = bossConfigurationSection.getString("type"); + String targetType = bossConfigurationSection.getString("targetType"); + String name = bossConfigurationSection.contains("name")? bossConfigurationSection.getString("name") : ""; + double health = bossConfigurationSection.getDouble("health"); + + this.livingEntity = this.bossManager.getEntityHandler().getBaseEntity(type, location); + + this.livingEntity.setCustomName(MessageUtils.translateString(name)); + this.livingEntity.setCustomNameVisible(true); + this.livingEntity.setMaxHealth(health); + this.livingEntity.setHealth(health); + this.livingEntity.setRemoveWhenFarAway(false); + this.livingEntity.setCanPickupItems(false); + + if(bossConfigurationSection.contains("Armor")) this.bossManager.getEquipmentHandler().applyEquipment(this.livingEntity, bossConfigurationSection.getConfigurationSection("Armor")); + if(bossConfigurationSection.contains("Weapon")) this.bossManager.getEquipmentHandler().applyEquipment(this.livingEntity, bossConfigurationSection.getConfigurationSection("Weapon")); + if(bossConfigurationSection.contains("Head")) this.bossManager.getEquipmentHandler().applySkull(this.livingEntity, bossConfigurationSection.getConfigurationSection("Head")); + if(bossConfigurationSection.contains("Potions")) this.bossManager.applyPotionEffects(this.livingEntity, bossConfigurationSection.getConfigurationSection("Potions")); + + this.maxHealth = health; + this.livingEntity.getEquipment().setHelmetDropChance(0.0F); + this.livingEntity.getEquipment().setChestplateDropChance(0.0F); + this.livingEntity.getEquipment().setLeggingsDropChance(0.0F); + this.livingEntity.getEquipment().setBootsDropChance(0.0F); + + /* HANDLE TARGET SYSTEM HERE */ + + this.uuid = this.livingEntity.getUniqueId(); + } + + @Override + public void spawnMessage(Location location) { + if(!hasMessages) return; + if(!configurationSection.contains("Messages.onSpawn")) return; + + } + + @Override + public void onDamage(Player damager, int damage) { + + } + + @Override + public void kill(Location location) { + + } + + @Override + public void killBoss(Location location) { + + } + + @Override + public void killMessage(Location location) { + + } +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/MinionEntity.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/MinionEntity.java new file mode 100644 index 0000000..989092a --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/MinionEntity.java @@ -0,0 +1,9 @@ +package net.aminecraftdev.custombosses.handlers.mobs; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public class MinionEntity { +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IDamageHandler.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IDamageHandler.java new file mode 100644 index 0000000..3ff31a0 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IDamageHandler.java @@ -0,0 +1,14 @@ +package net.aminecraftdev.custombosses.handlers.mobs.interfaces; + +import org.bukkit.entity.Player; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public interface IDamageHandler { + + void onDamage(Player damager, int damage); + +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IKillHandler.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IKillHandler.java new file mode 100644 index 0000000..b44c94f --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IKillHandler.java @@ -0,0 +1,16 @@ +package net.aminecraftdev.custombosses.handlers.mobs.interfaces; + +import org.bukkit.Location; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public interface IKillHandler { + + void killBoss(Location location); + + void killMessage(Location location); + +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IMobHandler.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IMobHandler.java new file mode 100644 index 0000000..eebecc3 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/IMobHandler.java @@ -0,0 +1,29 @@ +package net.aminecraftdev.custombosses.handlers.mobs.interfaces; + +import org.bukkit.Location; +import org.bukkit.configuration.ConfigurationSection; + +import java.util.UUID; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public interface IMobHandler { + + ConfigurationSection getConfigurationSection(); + + double getMaxHealth(); + + double getCurrentHealth(); + + UUID getUniqueId(); + + boolean isAutoBoss(); + + void spawn(Location location); + + void kill(Location location); + +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/ISpawnHandler.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/ISpawnHandler.java new file mode 100644 index 0000000..4c90fbd --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/handlers/mobs/interfaces/ISpawnHandler.java @@ -0,0 +1,16 @@ +package net.aminecraftdev.custombosses.handlers.mobs.interfaces; + +import org.bukkit.Location; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public interface ISpawnHandler { + + void spawnBoss(Location location); + + void spawnMessage(Location location); + +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/managers/BossManager.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/managers/BossManager.java index ba3447a..7e14496 100644 --- a/plugin-modules/Core/src/net/aminecraftdev/custombosses/managers/BossManager.java +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/managers/BossManager.java @@ -1,9 +1,55 @@ package net.aminecraftdev.custombosses.managers; +import net.aminecraftdev.custombosses.handlers.builders.EntityHandler; +import net.aminecraftdev.custombosses.handlers.builders.EquipmentHandler; +import net.aminecraftdev.custombosses.handlers.mobs.BossEntity; +import net.aminecraftdev.custombosses.handlers.mobs.MinionEntity; +import net.aminecraftdev.custombosses.innerapi.PotionUtils; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.entity.LivingEntity; +import org.bukkit.potion.PotionEffect; + +import java.util.HashSet; +import java.util.Set; + /** * @author AMinecraftDev * @version 1.0.0 * @since 31-May-17 */ public class BossManager { + + private static final Set BOSSES = new HashSet<>(); + private static final Set MINIONS = new HashSet<>(); + private EntityHandler entityHandler; + private EquipmentHandler equipmentHandler; + + public BossManager() { + this.entityHandler = new EntityHandler(); + this.equipmentHandler = new EquipmentHandler(); + } + + + + + public EntityHandler getEntityHandler() { + return entityHandler; + } + + public EquipmentHandler getEquipmentHandler() { + return equipmentHandler; + } + + public void applyPotionEffects(LivingEntity livingEntity, ConfigurationSection configurationSection) { + for(String s : configurationSection.getKeys(false)) { + PotionEffect potionEffect = PotionUtils.getPotionEffect(configurationSection.getConfigurationSection(s)); + + if(potionEffect == null) continue; + + livingEntity.addPotionEffect(potionEffect); + } + } + + + } diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/ITarget.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/ITarget.java new file mode 100644 index 0000000..599c207 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/ITarget.java @@ -0,0 +1,9 @@ +package net.aminecraftdev.custombosses.target; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public interface ITarget { +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/TargetTypes.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/TargetTypes.java new file mode 100644 index 0000000..500a823 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/TargetTypes.java @@ -0,0 +1,18 @@ +package net.aminecraftdev.custombosses.target; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public enum TargetTypes { + + VANILLA(), + DAMAGE(), + INTERVAL(); + + TargetTypes() { + + } + +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/types/TargetDamage.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/types/TargetDamage.java new file mode 100644 index 0000000..1b2b309 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/types/TargetDamage.java @@ -0,0 +1,9 @@ +package net.aminecraftdev.custombosses.target.types; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public class TargetDamage { +} diff --git a/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/types/TargetInterval.java b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/types/TargetInterval.java new file mode 100644 index 0000000..e419051 --- /dev/null +++ b/plugin-modules/Core/src/net/aminecraftdev/custombosses/target/types/TargetInterval.java @@ -0,0 +1,9 @@ +package net.aminecraftdev.custombosses.target.types; + +/** + * @author AMinecraftDev + * @version 1.0.0 + * @since 31-May-17 + */ +public class TargetInterval { +}