1.0.0-SNAPSHOT-U46

+ Adjusted a few things mechanic wise
+ Added and completed the minion skill
This commit is contained in:
AMinecraftDev 2018-11-13 21:50:58 +08:00
parent 1d4dc9b6ad
commit 165d991496
28 changed files with 512 additions and 64 deletions

View File

@ -139,7 +139,7 @@
},
"minions": {
"amount": 5,
"bosses": [
"minionsToSpawn": [
"Minion1"
]
}

View File

@ -275,17 +275,16 @@ public class BossAPI {
* bossEntity, under the activebossholder.
*
* @param activeBossHolder - targeted active boss
* @param minionEntity - MinionEntity to spawn
* @param minions - Minion skill class
* @return ActiveBossHolder class with stored information
* @return boolean if the spawning of the minions succeeded or failed
*/
public static ActiveBossHolder spawnNewMinion(ActiveBossHolder activeBossHolder, MinionEntity minionEntity, Minions minions) {
public static boolean spawnNewMinion(ActiveBossHolder activeBossHolder, Minions minions) {
// if(minionEntity.isEditing()) {
// Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
// return null;
// }
return PLUGIN.getBossEntityManager().spawnMinionsOnBossHolder(activeBossHolder, minionEntity, minions);
return PLUGIN.getBossEntityManager().spawnMinionsOnBossHolder(activeBossHolder, minions);
}
/**

View File

@ -21,9 +21,8 @@ public class ActiveBossHolder {
@Getter private final Location location;
@Getter private final String name;
@Getter private Map<Integer, LivingEntity> livingEntityMap = new HashMap<>();
@Getter private Map<Integer, LivingEntity> livingEntityMap = new HashMap<>(), minionEntityMap = new HashMap<>();
@Getter private Map<UUID, Double> mapOfDamagingUsers = new HashMap<>();
@Getter private List<LivingEntity> minionList = new ArrayList<>();
@Getter @Setter private TargetHandler targetHandler = null;
@Getter @Setter private boolean isDead = false;

View File

@ -13,6 +13,7 @@ import com.songoda.epicbosses.holder.DeadBossHolder;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.managers.files.DropTableFileManager;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.managers.files.MinionsFileManager;
import com.songoda.epicbosses.skills.custom.Minions;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.RandomUtils;
@ -39,6 +40,7 @@ public class BossEntityManager {
private DropTableFileManager dropTableFileManager;
private BossDropTableManager bossDropTableManager;
private BossMechanicManager bossMechanicManager;
private MinionsFileManager minionsFileManager;
private ItemsFileManager bossItemFileManager;
private BossesFileManager bossesFileManager;
@ -47,6 +49,7 @@ public class BossEntityManager {
this.dropTableFileManager = customBosses.getDropTableFileManager();
this.bossDropTableManager = customBosses.getBossDropTableManager();
this.bossMechanicManager = customBosses.getBossMechanicManager();
this.minionsFileManager = customBosses.getMinionsFileManager();
this.bossItemFileManager = customBosses.getItemStackManager();
this.bossesFileManager = customBosses.getBossesFileManager();
}
@ -174,16 +177,36 @@ public class BossEntityManager {
return activeBossHolder;
}
public ActiveBossHolder spawnMinionsOnBossHolder(ActiveBossHolder activeBossHolder, MinionEntity minionEntity, Minions minions) {
//TODO: Add Minions json class
//TODO: Finish minions spawn method
public boolean spawnMinionsOnBossHolder(ActiveBossHolder activeBossHolder, Minions minions) {
List<String> minionsToSpawn = minions.getMinions().getMinionsToSpawn();
Integer amount = minions.getMinions().getAmount();
if(!this.minionMechanicManager.handleMechanicApplication(minionEntity, activeBossHolder)) {
Debug.FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER.debug();
return null;
if(minionsToSpawn == null || minionsToSpawn.isEmpty()) {
Debug.FAILED_TO_SPAWN_MINIONS_FROM_SKILL.debug(minions.getDisplayName());
return false;
}
return activeBossHolder;
if(amount == null) amount = 1;
int finalAmount = amount;
minionsToSpawn.forEach(string -> {
MinionEntity minionEntity = this.minionsFileManager.getMinionEntity(string);
if(minionEntity == null) {
Debug.FAILED_TO_FIND_MINION.debug(minions.getDisplayName(), string);
return;
}
for(int i = 1; i <= finalAmount; i++) {
if(!this.minionMechanicManager.handleMechanicApplication(minionEntity, activeBossHolder)) {
Debug.FAILED_TO_SPAWN_MINION.debug(minions.getDisplayName(), string);
return;
}
}
});
return true;
}
public ActiveBossHolder getActiveBossHolder(LivingEntity livingEntity) {

View File

@ -4,9 +4,8 @@ import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.managers.interfaces.IMechanicManager;
import com.songoda.epicbosses.mechanics.*;
import com.songoda.epicbosses.mechanics.boss.*;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.ILoadable;
import com.songoda.epicbosses.utils.IMechanic;
import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
@ -23,8 +22,8 @@ import java.util.Queue;
public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveBossHolder> {
private final CustomBosses customBosses;
private Queue<IOptionalMechanic> optionalMechanics;
private Queue<IPrimaryMechanic> primaryMechanics;
private Queue<IOptionalMechanic<BossEntity>> optionalMechanics;
private Queue<IPrimaryMechanic<BossEntity>> primaryMechanics;
public BossMechanicManager(CustomBosses customBosses) {
this.customBosses = customBosses;
@ -45,11 +44,11 @@ public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveB
}
@Override
public void registerMechanic(IMechanic mechanic) {
public void registerMechanic(IMechanic<BossEntity> mechanic) {
if(mechanic instanceof IPrimaryMechanic) {
this.primaryMechanics.add((IPrimaryMechanic) mechanic);
this.primaryMechanics.add((IPrimaryMechanic<BossEntity>) mechanic);
} else if(mechanic instanceof IOptionalMechanic) {
this.optionalMechanics.add((IOptionalMechanic) mechanic);
this.optionalMechanics.add((IOptionalMechanic<BossEntity>) mechanic);
} else {
Debug.MECHANIC_TYPE_NOT_STORED.debug();
}
@ -63,10 +62,10 @@ public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveB
// return false;
// }
Queue<IMechanic> queue = new LinkedList<>(this.primaryMechanics);
Queue<IMechanic<BossEntity>> queue = new LinkedList<>(this.primaryMechanics);
while(!queue.isEmpty()) {
IMechanic mechanic = queue.poll();
IMechanic<BossEntity> mechanic = queue.poll();
if(mechanic == null) continue;
@ -78,7 +77,7 @@ public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveB
queue = new LinkedList<>(this.optionalMechanics);
while(!queue.isEmpty()) {
IMechanic mechanic = queue.poll();
IMechanic<BossEntity> mechanic = queue.poll();
if(mechanic == null) continue;
if(didMechanicApplicationFail(mechanic, bossEntity, activeBossHolder)) continue;
@ -88,7 +87,7 @@ public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveB
return true;
}
private boolean didMechanicApplicationFail(IMechanic mechanic, BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
private boolean didMechanicApplicationFail(IMechanic<BossEntity> mechanic, BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
if(mechanic == null) return true;
if(!mechanic.applyMechanic(bossEntity, activeBossHolder)) {

View File

@ -4,7 +4,7 @@ import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.managers.interfaces.IMechanicManager;
import com.songoda.epicbosses.mechanics.*;
import com.songoda.epicbosses.mechanics.minions.*;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.IMechanic;
import com.songoda.epicbosses.utils.ServerUtils;
@ -22,8 +22,8 @@ import java.util.Queue;
public class MinionMechanicManager implements IMechanicManager<MinionEntity, ActiveBossHolder> {
private final CustomBosses customBosses;
private Queue<IOptionalMechanic> optionalMechanics;
private Queue<IPrimaryMechanic> primaryMechanics;
private Queue<IOptionalMechanic<MinionEntity>> optionalMechanics;
private Queue<IPrimaryMechanic<MinionEntity>> primaryMechanics;
public MinionMechanicManager(CustomBosses customBosses) {
this.customBosses = customBosses;
@ -32,6 +32,7 @@ public class MinionMechanicManager implements IMechanicManager<MinionEntity, Act
@Override
public void load() {
this.primaryMechanics = new LinkedList<>();
this.optionalMechanics = new LinkedList<>();
registerMechanic(new EntityTypeMechanic());
registerMechanic(new NameMechanic());
@ -43,11 +44,11 @@ public class MinionMechanicManager implements IMechanicManager<MinionEntity, Act
}
@Override
public void registerMechanic(IMechanic mechanic) {
public void registerMechanic(IMechanic<MinionEntity> mechanic) {
if(mechanic instanceof IPrimaryMechanic) {
this.primaryMechanics.add((IPrimaryMechanic) mechanic);
this.primaryMechanics.add((IPrimaryMechanic<MinionEntity>) mechanic);
} else if(mechanic instanceof IOptionalMechanic) {
this.optionalMechanics.add((IOptionalMechanic) mechanic);
this.optionalMechanics.add((IOptionalMechanic<MinionEntity>) mechanic);
} else {
Debug.MECHANIC_TYPE_NOT_STORED.debug();
}
@ -56,15 +57,15 @@ public class MinionMechanicManager implements IMechanicManager<MinionEntity, Act
@Override
public boolean handleMechanicApplication(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(minionEntity != null && activeBossHolder != null) {
// if(bossEntity.isEditing()) {
// if(minionEntity.isEditing()) {
// Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
// return false;
// }
Queue<IMechanic> queue = new LinkedList<>(this.primaryMechanics);
Queue<IMechanic<MinionEntity>> queue = new LinkedList<>(this.primaryMechanics);
while(!queue.isEmpty()) {
IMechanic mechanic = queue.poll();
IMechanic<MinionEntity> mechanic = queue.poll();
if(mechanic == null) continue;
@ -76,7 +77,7 @@ public class MinionMechanicManager implements IMechanicManager<MinionEntity, Act
queue = new LinkedList<>(this.optionalMechanics);
while(!queue.isEmpty()) {
IMechanic mechanic = queue.poll();
IMechanic<MinionEntity> mechanic = queue.poll();
if(mechanic == null) continue;
if(didMechanicApplicationFail(mechanic, minionEntity, activeBossHolder)) continue;
@ -86,7 +87,7 @@ public class MinionMechanicManager implements IMechanicManager<MinionEntity, Act
return true;
}
private boolean didMechanicApplicationFail(IMechanic mechanic, MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
private boolean didMechanicApplicationFail(IMechanic<MinionEntity> mechanic, MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(mechanic == null) return true;
if(!mechanic.applyMechanic(minionEntity, activeBossHolder)) {

View File

@ -10,7 +10,7 @@ import com.songoda.epicbosses.utils.IMechanic;
*/
public interface IMechanicManager<T, J> extends ILoadable {
void registerMechanic(IMechanic mechanic);
void registerMechanic(IMechanic<T> mechanic);
boolean handleMechanicApplication(T t, J j);

View File

@ -1,7 +1,8 @@
package com.songoda.epicbosses.mechanics;
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
@ -15,17 +16,13 @@ import org.bukkit.entity.LivingEntity;
* @version 1.0.0
* @since 01-Jun-18
*/
public class EntityTypeMechanic implements IPrimaryMechanic {
public class EntityTypeMechanic implements IPrimaryMechanic<BossEntity> {
@Override
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
for(EntityStatsElement entityStatsElement : bossEntity.getEntityStats()) {
System.out.println(entityStatsElement);
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
System.out.println(mainStatsElement);
String bossEntityType = mainStatsElement.getEntityType();
String input = bossEntityType.split(":")[0];
EntityFinder entityFinder = EntityFinder.get(input);

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.mechanics;
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
@ -17,7 +17,7 @@ import org.bukkit.inventory.ItemStack;
* @version 1.0.0
* @since 03-Jun-18
*/
public class EquipmentMechanic implements IOptionalMechanic {
public class EquipmentMechanic implements IOptionalMechanic<BossEntity> {
private ItemsFileManager itemStackManager;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.mechanics;
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
@ -16,7 +16,7 @@ import org.bukkit.entity.LivingEntity;
* @version 1.0.0
* @since 27-Jun-18
*/
public class HealthMechanic implements IPrimaryMechanic {
public class HealthMechanic implements IPrimaryMechanic<BossEntity> {
@Override
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.mechanics;
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
@ -17,7 +17,7 @@ import org.bukkit.entity.LivingEntity;
*
* TODO: Make a hologram above name instead of using default CustomName
*/
public class NameMechanic implements IOptionalMechanic {
public class NameMechanic implements IOptionalMechanic<BossEntity> {
@Override
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.mechanics;
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
@ -18,7 +18,7 @@ import java.util.List;
* @version 1.0.0
* @since 27-Jun-18
*/
public class PotionMechanic implements IOptionalMechanic {
public class PotionMechanic implements IOptionalMechanic<BossEntity> {
private PotionEffectConverter potionEffectConverter;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.mechanics;
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
@ -18,7 +18,7 @@ import org.bukkit.inventory.EntityEquipment;
* @version 1.0.0
* @since 02-Jun-18
*/
public class SettingsMechanic implements IPrimaryMechanic {
public class SettingsMechanic implements IPrimaryMechanic<BossEntity> {
private VersionHandler versionHandler;

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.mechanics;
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack;
* @version 1.0.0
* @since 27-Jun-18
*/
public class WeaponMechanic implements IOptionalMechanic {
public class WeaponMechanic implements IOptionalMechanic<BossEntity> {
private ItemsFileManager itemStackManager;
private VersionHandler versionHandler;

View File

@ -0,0 +1,54 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.EntityFinder;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 01-Jun-18
*/
public class EntityTypeMechanic implements IPrimaryMechanic<MinionEntity> {
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
String bossEntityType = mainStatsElement.getEntityType();
String input = bossEntityType.split(":")[0];
EntityFinder entityFinder = EntityFinder.get(input);
Integer position = mainStatsElement.getPosition();
if(position == null) position = 1;
if(entityFinder == null) return false;
LivingEntity livingEntity = entityFinder.spawnNewLivingEntity(bossEntityType, activeBossHolder.getLivingEntity().getLocation());
if(livingEntity == null) return false;
activeBossHolder.getMinionEntityMap().put(position, livingEntity);
if(position > 1) {
int lowerPosition = position - 1;
LivingEntity lowerLivingEntity = activeBossHolder.getLivingEntityMap().getOrDefault(lowerPosition, null);
if(lowerLivingEntity == null) {
Debug.FAILED_ATTEMPT_TO_STACK_BOSSES.debug(BossAPI.getMinionEntityName(minionEntity));
return false;
}
lowerLivingEntity.setPassenger(livingEntity);
}
}
return true;
}
}

View File

@ -0,0 +1,88 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.EquipmentElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 03-Jun-18
*/
public class EquipmentMechanic implements IOptionalMechanic<MinionEntity> {
private ItemsFileManager itemStackManager;
public EquipmentMechanic(ItemsFileManager itemStackManager) {
this.itemStackManager = itemStackManager;
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
if(livingEntity == null) return false;
EquipmentElement equipmentElement = entityStatsElement.getEquipment();
EntityEquipment entityEquipment = livingEntity.getEquipment();
String helmet = equipmentElement.getHelmet();
String chestplate = equipmentElement.getChestplate();
String leggings = equipmentElement.getLeggings();
String boots = equipmentElement.getBoots();
if(helmet != null) {
ItemStackHolder itemStackHolder = this.itemStackManager.getItemStackHolder(helmet);
if(itemStackHolder != null) {
ItemStack itemStack = this.itemStackManager.getItemStackConverter().from(itemStackHolder);
entityEquipment.setHelmet(itemStack);
}
}
if(chestplate != null) {
ItemStackHolder itemStackHolder = this.itemStackManager.getItemStackHolder(chestplate);
if(itemStackHolder != null) {
ItemStack itemStack = this.itemStackManager.getItemStackConverter().from(itemStackHolder);
entityEquipment.setChestplate(itemStack);
}
}
if(leggings != null) {
ItemStackHolder itemStackHolder = this.itemStackManager.getItemStackHolder(leggings);
if(itemStackHolder != null) {
ItemStack itemStack = this.itemStackManager.getItemStackConverter().from(itemStackHolder);
entityEquipment.setLeggings(itemStack);
}
}
if(boots != null) {
ItemStackHolder itemStackHolder = this.itemStackManager.getItemStackHolder(boots);
if(itemStackHolder != null) {
ItemStack itemStack = this.itemStackManager.getItemStackConverter().from(itemStackHolder);
entityEquipment.setBoots(itemStack);
}
}
}
return true;
}
}

View File

@ -0,0 +1,44 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.file.reader.SpigotYmlReader;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jun-18
*/
public class HealthMechanic implements IPrimaryMechanic<MinionEntity> {
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
double maxHealthSetting = (double) SpigotYmlReader.get().getObject("settings.attribute.maxHealth.max");
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
double maxHealth = mainStatsElement.getHealth();
if(livingEntity == null) return false;
if(maxHealth > maxHealthSetting) {
Debug.MAX_HEALTH.debug(maxHealthSetting);
return false;
}
livingEntity.setMaxHealth(maxHealth);
livingEntity.setHealth(maxHealth);
}
return true;
}
}

View File

@ -0,0 +1,39 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import org.bukkit.entity.LivingEntity;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jun-18
*
* TODO: Make a hologram above name instead of using default CustomName
*/
public class NameMechanic implements IOptionalMechanic<MinionEntity> {
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
String customName = mainStatsElement.getDisplayName();
if(livingEntity == null) return false;
if(customName != null) {
livingEntity.setCustomName(StringUtils.get().translateColor(customName));
livingEntity.setCustomNameVisible(true);
}
}
return true;
}
}

View File

@ -0,0 +1,45 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import com.songoda.epicbosses.utils.potion.PotionEffectConverter;
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
import org.bukkit.entity.LivingEntity;
import java.util.List;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jun-18
*/
public class PotionMechanic implements IOptionalMechanic<MinionEntity> {
private PotionEffectConverter potionEffectConverter;
public PotionMechanic() {
this.potionEffectConverter = new PotionEffectConverter();
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getLivingEntityMap().getOrDefault(1, null) == null) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
List<PotionEffectHolder> potionElements = entityStatsElement.getPotions();
if(livingEntity == null) return false;
if(potionElements != null && !potionElements.isEmpty()) {
potionElements.forEach(potionElement -> livingEntity.addPotionEffect(this.potionEffectConverter.from(potionElement)));
}
}
return true;
}
}

View File

@ -0,0 +1,55 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 02-Jun-18
*/
public class SettingsMechanic implements IPrimaryMechanic<MinionEntity> {
private VersionHandler versionHandler;
public SettingsMechanic() {
this.versionHandler = new VersionHandler();
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
if(livingEntity == null) return false;
EntityEquipment entityEquipment = livingEntity.getEquipment();
livingEntity.setRemoveWhenFarAway(false);
livingEntity.setCanPickupItems(false);
entityEquipment.setHelmetDropChance(0.0F);
entityEquipment.setChestplateDropChance(0.0F);
entityEquipment.setLeggingsDropChance(0.0F);
entityEquipment.setBootsDropChance(0.0F);
if(this.versionHandler.canUseOffHand()) {
entityEquipment.setItemInMainHandDropChance(0.0F);
entityEquipment.setItemInOffHandDropChance(0.0F);
} else {
entityEquipment.setItemInHandDropChance(0.0F);
}
}
return true;
}
}

View File

@ -0,0 +1,74 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.HandsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jun-18
*/
public class WeaponMechanic implements IOptionalMechanic<MinionEntity> {
private ItemsFileManager itemStackManager;
private VersionHandler versionHandler;
public WeaponMechanic(ItemsFileManager itemStackManager) {
this.itemStackManager = itemStackManager;
this.versionHandler = new VersionHandler();
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
if(livingEntity == null) return false;
EntityEquipment entityEquipment = livingEntity.getEquipment();
HandsElement handsElement = entityStatsElement.getHands();
String mainHand = handsElement.getMainHand();
String offHand = handsElement.getOffHand();
if(mainHand != null) {
ItemStackHolder itemStackHolder = this.itemStackManager.getItemStackHolder(mainHand);
if(itemStackHolder != null) {
ItemStack itemStack = this.itemStackManager.getItemStackConverter().from(itemStackHolder);
if(this.versionHandler.canUseOffHand()) {
entityEquipment.setItemInMainHand(itemStack);
} else {
entityEquipment.setItemInHand(itemStack);
}
}
}
if(offHand != null && this.versionHandler.canUseOffHand()) {
ItemStackHolder itemStackHolder = this.itemStackManager.getItemStackHolder(offHand);
if(itemStackHolder != null) {
ItemStack itemStack = this.itemStackManager.getItemStackConverter().from(itemStackHolder);
entityEquipment.setItemInOffHand(itemStack);
}
}
}
return true;
}
}

View File

@ -1,8 +1,13 @@
package com.songoda.epicbosses.skills.custom;
import com.google.gson.annotations.Expose;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement;
import com.songoda.epicbosses.skills.types.CustomSkill;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.LivingEntity;
import java.util.List;
@ -11,17 +16,17 @@ import java.util.List;
* @author Charles Cullen
* @version 1.0.0
* @since 11-Nov-18
*
* TODO
*/
public class Minions extends CustomSkill {
@Expose @Getter @Setter private CustomMinionSkillElement minions;
public Minions(CustomBosses plugin) {
super(plugin);
}
@Override
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
BossAPI.spawnNewMinion(activeBossHolder, this);
}
}

View File

@ -0,0 +1,24 @@
package com.songoda.epicbosses.skills.elements;
import com.google.gson.annotations.Expose;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 13-Nov-18
*/
public class CustomMinionSkillElement {
@Expose @Getter @Setter private List<String> minionsToSpawn;
@Expose @Getter @Setter private Integer amount;
public CustomMinionSkillElement(Integer amount, List<String> minionsToSpawn) {
this.amount = amount;
this.minionsToSpawn = minionsToSpawn;
}
}

View File

@ -28,6 +28,9 @@ public enum Debug {
FAILED_ATTEMPT_TO_STACK_BOSSES("A boss has failed to stack on top of another boss under the {0} boss configuration."),
FAILED_TO_SAVE_THE_NEW_BOSS("The {0} with EntityType boss was successfully created but failed to save."),
FAILED_TO_SAVE_THE_NEW_MINION("The {0} with EntityType minion was successfully created but failed to save."),
FAILED_TO_SPAWN_MINIONS_FROM_SKILL("The skill {0} failed to spawn minions as the minionsToSpawn list was empty or null. Please make sure this has got at least one minion in it before trying to call from the skill."),
FAILED_TO_FIND_MINION("The skill {0} has failed to find the specified minion {1}."),
FAILED_TO_SPAWN_MINION("The skill {0} has failed to spawn the minion {1}."),
FAILED_TO_LOAD_BOSSCOMMANDMANAGER("The boss command manager tried to load again, but it has already loaded previously."),
FAILED_TO_LOAD_BOSSLISTENERMANAGER("The boss listener manager tried to load again, but it has already loaded previously."),
FAILED_TO_LOAD_CUSTOM_ITEM("The itemstack name that is provided ({0}) for the spawn item doesn't exist or wasn't found."),

View File

@ -1,6 +1,5 @@
package com.songoda.epicbosses.utils;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
/**
@ -8,8 +7,8 @@ import com.songoda.epicbosses.holder.ActiveBossHolder;
* @version 1.0.0
* @since 02-Jun-18
*/
public interface IMechanic {
public interface IMechanic<Entity> {
boolean applyMechanic(MinionEntity bossEntity, ActiveBossHolder activeBossHolder);
boolean applyMechanic(Entity entity, ActiveBossHolder activeBossHolder);
}

View File

@ -7,5 +7,5 @@ import com.songoda.epicbosses.utils.IMechanic;
* @version 1.0.0
* @since 02-Oct-18
*/
public interface IOptionalMechanic extends IMechanic {
public interface IOptionalMechanic<Entity> extends IMechanic<Entity> {
}

View File

@ -7,5 +7,5 @@ import com.songoda.epicbosses.utils.IMechanic;
* @version 1.0.0
* @since 02-Oct-18
*/
public interface IPrimaryMechanic extends IMechanic {
public interface IPrimaryMechanic<Entity> extends IMechanic<Entity> {
}

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>1.0.0-SNAPSHOT-U45</plugin.version>
<plugin.version>1.0.0-SNAPSHOT-U46</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>