1.0.0-SNAPSHOT-U64

+ Remodeled Minion System
+ Remodeled targeting system
+ Begun work on the drops manager
This commit is contained in:
Brianna O'Keefe 2018-11-19 01:25:46 -05:00
parent 3babd95f34
commit 96ace06f92
45 changed files with 515 additions and 365 deletions

View File

@ -1,84 +1,3 @@
MainPanel:
name: '&b&l{boss} Editor'
slots: 45
Settings:
emptySpaceFiller: true
EmptySpaceFiller:
type: '160:0'
name: '&7'
Items:
'12':
type: DIAMOND
name: '&c&lDrops Manager'
lore:
- '&7Click here to manage the drop table'
- '&7that is attached to this boss.'
Button: Drops
'14':
type: DIAMOND_HELMET
name: '&c&lEquipment Manager'
lore:
- '&7Click here to manage the equipment'
- '&7that the boss has equipped.'
Button: Equipment
'16':
type: BONE
name: '&a&lTargeting Manager'
lore:
- '&7Click here to edit how the boss handles'
- '&7targeting of players and mobs.'
Button: Targeting
'22':
type: BOW
name: '&c&lWeapon Manager'
lore:
- '&7Click here to manage the weapon(s)'
- '&7that the boss has equipped.'
Button: Weapon
'23':
type: BARRIER
name: '&c&l!&4&l!&c&l! &4&lWARNING &c&l!&4&l!&c&l!'
lore:
- '&7While editing is enabled for this boss'
- '&7no one will be able to spawn it, nor'
- '&7will it spawn naturally.'
'24':
type: BLAZE_POWDER
name: '&c&lSkill Manager'
lore:
- '&7Click here to manage the assigned'
- '&7skill(s) the boss has and their occurrence'
- '&7chances.'
Button: Skill
'32':
type: '351:4'
name: '&a&lStatistics Manager'
lore:
- '&7Click here to edit the statistics of the'
- '&7boss, including things like: health,'
- '&7potion effects, commands on spawn, etc.'
Button: Stats
'39':
type: REDSTONE
name: '&a&lParticle Manager'
lore:
- '&7Click here to manage the particles the'
- '&7boss has equipped during certain events.'
Button: Particle
'41':
type: GRASS
name: '&a&lSpawning Manager'
lore:
- '&7Click here to edit how the boss handles'
- '&7spawning.'
Button: Spawning
'43':
type: BOOK
name: '&a&lText Manager'
lore:
- '&7Click here to edit the taunts, sayings,'
- '&7etc. for this boss.'
Button: Text
DropsPanel:
name: '&b&l{boss} Editor'
slots: 54
@ -99,11 +18,12 @@ DropsPanel:
- '&7 have one selected.'
- '&b&l* &7Click here to go straight to the'
- '&7 editing screen of the drop table.'
Button: Selected
'47':
type: STAINED_GLASS_PANE
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'48':
type: STAINED_GLASS_PANE
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'49':
type: ARROW
@ -132,10 +52,10 @@ DropsPanel:
- '&7Currently viewing page &e{currentPage}/{maxPages}&7.'
NextPage: true
'52':
type: STAINED_GLASS_PANE
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'53':
type: STAINED_GLASS_PANE
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'54':
type: BOOK

View File

@ -41,7 +41,7 @@
"overallChance": 35.5,
"masterMessage": "SKMainSkillMessage",
"skills": [
"Lightning1"
"Minions1"
]
},
"drops": {

View File

@ -1,6 +1,6 @@
{
"SkeletonKingMinion": {
"editing": true,
"editing": false,
"targeting": "RandomNearby",
"entityStats": [
{
@ -8,7 +8,7 @@
"position": 1,
"entityType": "SKELETON",
"health": 500,
"displayName": "&6&lSkeleton King Boss"
"displayName": "&6&lSkeleton King Boss Minion"
},
"equipment": {
"helmet": "SKHelmet",

View File

@ -159,9 +159,7 @@
"multiplier": null,
"otherSkillData": {
"amount": 5,
"minionsToSpawn": [
"Minion1"
]
"minionToSpawn": "SkeletonKingMinion"
}
}
}

View File

@ -240,3 +240,72 @@ MainEditorPanel:
- '&7Click here to edit the taunts, sayings,'
- '&7etc. for this boss.'
Button: Text
DropsEditorPanel:
name: '&b&l{boss} Editor'
slots: 54
Settings:
fillTo: 45
Items:
'46':
type: DIAMOND
name: '&b&lSelected Drop Table'
lore:
- '&7The current selected drop'
- '&7table is: &b{dropTable}&7.'
- '&7'
- '&b&lHints'
- '&b&l* &7If this shows N/A it means'
- '&7 there was an issue loading the'
- '&7 previous table, or it doesn''t'
- '&7 have one selected.'
- '&b&l* &7Click here to go straight to the'
- '&7 editing screen of the drop table.'
Button: Selected
'47':
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'48':
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'49':
type: ARROW
name: '&e&l&m<-&e&l Previous Page'
lore:
- '&7Click here to go to the previous'
- '&7page of drop tables.'
PreviousPage: true
'50':
type: DIAMOND_BLOCK
name: '&a&lCreate a new Drop Table'
lore:
- '&7Click here to create a new drop'
- '&7table. It will automatically be'
- '&7assigned to this boss when created.'
Button: CreateDropTable
'51':
type: ARROW
name: '&e&lNext Page &e&l&m->'
lore:
- '&7Click here to go to the next'
- '&7page of drop tables.'
NextPage: true
'52':
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'53':
type: WHITE_STAINED_GLASS_PANE
name: '&7'
'54':
type: BOOK
name: '&c&lDrops Guide'
lore:
- '&7When selecting the drop table for this custom boss'
- '&7you can either choose from one of the above listed'
- '&7pre-configured drop tables or you can make a'
- '&7new one for this boss.'
- '&7'
- '&c&lHints'
- '&c&l* &7The currently selected drop table will be shown'
- '&7 with an emerald which states so.'
- '&c&l* &7Every drop table from every boss will be listed'
- '&7 here as an available drop table.'

View File

@ -7,6 +7,7 @@ import com.songoda.epicbosses.entity.elements.*;
import com.songoda.epicbosses.events.PreBossSpawnEvent;
import com.songoda.epicbosses.events.PreBossSpawnItemEvent;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.ActiveMinionHolder;
import com.songoda.epicbosses.managers.files.CommandsFileManager;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.managers.files.MessagesFileManager;
@ -275,9 +276,7 @@ public class BossAPI {
preBossSpawnEvent = new PreBossSpawnEvent(activeBossHolder);
}
System.out.println("SPAWNING EVENT " + preBossSpawnEvent);
PLUGIN.getBossTargetManager().initializeTargetHandler(activeBossHolder);
PLUGIN.getBossTargetManager().handleBossTargeting(activeBossHolder);
ServerUtils.get().callEvent(preBossSpawnEvent);
return activeBossHolder;
@ -289,9 +288,8 @@ public class BossAPI {
*
* @param activeBossHolder - targeted active boss
* @param skill - the skill from the skills.json
* @return boolean if the spawning of the minions succeeded or failed
*/
public static boolean spawnNewMinion(ActiveBossHolder activeBossHolder, Skill skill) {
public static void spawnNewMinion(ActiveBossHolder activeBossHolder, Skill skill) {
// if(minionEntity.isEditing()) {
// Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
// return null;
@ -300,15 +298,12 @@ public class BossAPI {
if(skill.getType().equalsIgnoreCase("CUSTOM")) {
CustomSkillElement customSkillElement = PLUGIN.getBossSkillManager().getCustomSkillElement(skill);
if(customSkillElement.getCustom().getType().equalsIgnoreCase("MINION")) {
if(customSkillElement.getCustom().getType().equalsIgnoreCase("MINIONS")) {
CustomMinionSkillElement customMinionSkillElement = customSkillElement.getCustom().getCustomMinionSkillData();
PLUGIN.getBossEntityManager().spawnMinionsOnBossHolder(activeBossHolder, skill, customMinionSkillElement);
}
}
return false;
}
/**

View File

@ -16,16 +16,17 @@ import java.util.*;
* @version 1.0.0
* @since 03-Jun-18
*/
public class ActiveBossHolder {
public class ActiveBossHolder implements IActiveHolder {
@Getter private final BossEntity bossEntity;
@Getter private final Location location;
@Getter private final String name;
@Getter private Map<Integer, LivingEntity> livingEntityMap = new HashMap<>(), minionEntityMap = new HashMap<>();
@Getter private Map<Integer, ActiveMinionHolder> activeMinionHolderMap = new HashMap<>();
@Getter private Map<Integer, LivingEntity> livingEntityMap = new HashMap<>();
@Getter private Map<UUID, Double> mapOfDamagingUsers = new HashMap<>();
@Getter @Setter private TargetHandler targetHandler = null;
@Getter @Setter private TargetHandler<ActiveBossHolder> targetHandler = null;
@Getter @Setter private boolean isDead = false;
public ActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name) {
@ -42,6 +43,11 @@ public class ActiveBossHolder {
}
}
@Override
public void killAll() {
killAllSubBosses(null);
}
public LivingEntity getLivingEntity() {
for(LivingEntity livingEntity : getLivingEntityMap().values()) {
if(livingEntity != null) return livingEntity;
@ -50,31 +56,21 @@ public class ActiveBossHolder {
return null;
}
public LivingEntity getMinionEntity() {
for(LivingEntity livingEntity : getMinionEntityMap().values()) {
if(livingEntity != null) return livingEntity;
}
return null;
}
public boolean hasAttacked(UUID uuid) {
return this.mapOfDamagingUsers.containsKey(uuid);
}
public void killAllMinions() {
this.minionEntityMap.values().forEach(LivingEntity::remove);
this.minionEntityMap.clear();
this.activeMinionHolderMap.values().forEach(IActiveHolder::killAll);
}
public void killAllMinions(World world) {
LivingEntity livingEntity = getMinionEntity();
LivingEntity livingEntity = getLivingEntity();
if(livingEntity == null) return;
if(world != null && !livingEntity.getWorld().equals(world)) return;
this.minionEntityMap.values().forEach(LivingEntity::remove);
this.minionEntityMap.clear();
this.activeMinionHolderMap.values().forEach(IActiveHolder::killAll);
}
public boolean killAllSubBosses(World world) {

View File

@ -0,0 +1,75 @@
package com.songoda.epicbosses.holder;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.targeting.TargetHandler;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 19-Nov-18
*/
public class ActiveMinionHolder implements IActiveHolder {
@Getter @Setter private TargetHandler<ActiveMinionHolder> targetHandler = null;
@Getter private Map<Integer, LivingEntity> livingEntityMap = new HashMap<>();
@Getter private ActiveBossHolder activeBossHolder;
@Getter private final MinionEntity minionEntity;
@Getter private final Location location;
@Getter private final String name;
public ActiveMinionHolder(ActiveBossHolder activeBossHolder, MinionEntity minionEntity, Location spawnLocation, String name) {
this.activeBossHolder = activeBossHolder;
this.name = name;
this.location = spawnLocation;
this.minionEntity = minionEntity;
}
@Override
public Map<UUID, Double> getMapOfDamagingUsers() {
return getActiveBossHolder().getMapOfDamagingUsers();
}
@Override
public void setLivingEntity(int position, LivingEntity livingEntity) {
if(getLivingEntityMap().containsKey(position)) {
this.livingEntityMap.get(position).remove();
this.livingEntityMap.remove(position);
}
this.livingEntityMap.put(position, livingEntity);
}
@Override
public void killAll() {
this.livingEntityMap.values().forEach(LivingEntity::remove);
this.livingEntityMap.clear();
}
@Override
public boolean isDead() {
if(this.livingEntityMap.isEmpty()) return true;
for(LivingEntity livingEntity : this.livingEntityMap.values()) {
if(livingEntity == null || livingEntity.isDead()) return true;
}
return false;
}
@Override
public boolean hasAttacked(UUID uuid) {
return getActiveBossHolder().hasAttacked(uuid);
}
}

View File

@ -0,0 +1,35 @@
package com.songoda.epicbosses.holder;
import com.songoda.epicbosses.targeting.TargetHandler;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import java.util.Map;
import java.util.UUID;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 19-Nov-18
*/
public interface IActiveHolder {
Location getLocation();
String getName();
Map<Integer, LivingEntity> getLivingEntityMap();
Map<UUID, Double> getMapOfDamagingUsers();
TargetHandler getTargetHandler();
void setLivingEntity(int position, LivingEntity livingEntity);
void killAll();
boolean isDead();
boolean hasAttacked(UUID uuid);
}

View File

@ -75,11 +75,11 @@ public class BossSpawnListener implements Listener {
if(bossEntity == null) return;
// if(bossEntity.isEditing()) {
// Message.Boss_Edit_CannotSpawn.msg(player);
// event.setCancelled(true);
// return;
// }
if(bossEntity.isEditing()) {
Message.Boss_Edit_CannotSpawn.msg(player);
event.setCancelled(true);
return;
}
Location location = block.getLocation().clone();
@ -139,8 +139,6 @@ public class BossSpawnListener implements Listener {
if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName()));
messages.replaceAll(s -> s.replace("{location}", StringUtils.get().translateLocation(location)));
System.out.println("MESSAGE SYSTEM");
MessageUtils.get().sendMessage(location, NumberUtils.get().getSquared(messageRadius), messages);
}

View File

@ -10,6 +10,7 @@ import com.songoda.epicbosses.droptable.elements.SprayTableElement;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.ActiveMinionHolder;
import com.songoda.epicbosses.holder.DeadBossHolder;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.managers.files.DropTableFileManager;
@ -49,6 +50,7 @@ public class BossEntityManager {
private MinionsFileManager minionsFileManager;
private ItemsFileManager bossItemFileManager;
private BossesFileManager bossesFileManager;
private BossTargetManager bossTargetManager;
public BossEntityManager(CustomBosses customBosses) {
this.minionMechanicManager = customBosses.getMinionMechanicManager();
@ -58,6 +60,7 @@ public class BossEntityManager {
this.minionsFileManager = customBosses.getMinionsFileManager();
this.bossItemFileManager = customBosses.getItemStackManager();
this.bossesFileManager = customBosses.getBossesFileManager();
this.bossTargetManager = customBosses.getBossTargetManager();
}
public double getRadius(ActiveBossHolder activeBossHolder, Location centerLocation) {
@ -253,45 +256,43 @@ public class BossEntityManager {
public ActiveBossHolder createActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name) {
ActiveBossHolder activeBossHolder = new ActiveBossHolder(bossEntity, spawnLocation, name);
if(!this.bossMechanicManager.handleMechanicApplication(bossEntity, activeBossHolder)) {
Debug.FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER.debug();
return null;
}
this.bossMechanicManager.handleMechanicApplication(bossEntity, activeBossHolder);
ACTIVE_BOSS_HOLDERS.add(activeBossHolder);
return activeBossHolder;
}
public boolean spawnMinionsOnBossHolder(ActiveBossHolder activeBossHolder, Skill skill, CustomMinionSkillElement minionSkillElement) {
List<String> minionsToSpawn = minionSkillElement.getMinionsToSpawn();
public void spawnMinionsOnBossHolder(ActiveBossHolder activeBossHolder, Skill skill, CustomMinionSkillElement minionSkillElement) {
String minionToSpawn = minionSkillElement.getMinionToSpawn();
Integer amount = minionSkillElement.getAmount();
if(minionsToSpawn == null || minionsToSpawn.isEmpty()) {
if(minionToSpawn == null || minionToSpawn.isEmpty()) {
Debug.FAILED_TO_SPAWN_MINIONS_FROM_SKILL.debug(skill.getDisplayName());
return false;
return;
}
if(amount == null) amount = 1;
int finalAmount = amount;
minionsToSpawn.forEach(string -> {
MinionEntity minionEntity = this.minionsFileManager.getMinionEntity(string);
MinionEntity minionEntity = this.minionsFileManager.getMinionEntity(minionToSpawn);
Location location = activeBossHolder.getLivingEntity().getLocation();
if(minionEntity == null) {
Debug.FAILED_TO_FIND_MINION.debug(skill.getDisplayName(), string);
Debug.FAILED_TO_FIND_MINION.debug(skill.getDisplayName(), minionToSpawn);
return;
}
for(int i = 1; i <= finalAmount; i++) {
if(!this.minionMechanicManager.handleMechanicApplication(minionEntity, activeBossHolder)) {
Debug.FAILED_TO_SPAWN_MINION.debug(skill.getDisplayName(), string);
return;
}
}
});
activeBossHolder.killAllMinions();
return true;
for(int i = 1; i <= amount; i++) {
ActiveMinionHolder activeMinionHolder = new ActiveMinionHolder(activeBossHolder, minionEntity, location, minionToSpawn);
this.minionMechanicManager.handleMechanicApplication(minionEntity, activeMinionHolder);
this.bossTargetManager.handleMinionTargeting(activeMinionHolder);
activeBossHolder.getActiveMinionHolderMap().put(i, activeMinionHolder);
}
activeBossHolder.getActiveMinionHolderMap().values().forEach(activeMinionHolder -> activeMinionHolder.getTargetHandler().runTargetCycle());
}
public ActiveBossHolder getActiveBossHolder(LivingEntity livingEntity) {

View File

@ -4,12 +4,11 @@ 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.IBossMechanic;
import com.songoda.epicbosses.mechanics.boss.*;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.IMechanic;
import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import java.util.LinkedList;
import java.util.Queue;
@ -19,11 +18,10 @@ import java.util.Queue;
* @version 1.0.0
* @since 27-Jun-18
*/
public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveBossHolder> {
public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveBossHolder, IBossMechanic> {
private Queue<IBossMechanic> mechanics;
private final CustomBosses customBosses;
private Queue<IOptionalMechanic<BossEntity>> optionalMechanics;
private Queue<IPrimaryMechanic<BossEntity>> primaryMechanics;
public BossMechanicManager(CustomBosses customBosses) {
this.customBosses = customBosses;
@ -31,8 +29,7 @@ public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveB
@Override
public void load() {
this.primaryMechanics = new LinkedList<>();
this.optionalMechanics = new LinkedList<>();
this.mechanics = new LinkedList<>();
registerMechanic(new EntityTypeMechanic());
registerMechanic(new NameMechanic());
@ -44,53 +41,35 @@ public class BossMechanicManager implements IMechanicManager<BossEntity, ActiveB
}
@Override
public void registerMechanic(IMechanic<BossEntity> mechanic) {
if(mechanic instanceof IPrimaryMechanic) {
this.primaryMechanics.add((IPrimaryMechanic<BossEntity>) mechanic);
} else if(mechanic instanceof IOptionalMechanic) {
this.optionalMechanics.add((IOptionalMechanic<BossEntity>) mechanic);
} else {
Debug.MECHANIC_TYPE_NOT_STORED.debug();
}
public void registerMechanic(IBossMechanic mechanic) {
this.mechanics.add(mechanic);
}
@Override
public boolean handleMechanicApplication(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
public void handleMechanicApplication(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
if(bossEntity != null && activeBossHolder != null) {
// if(bossEntity.isEditing()) {
// Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
// return false;
// }
if(bossEntity.isEditing()) {
Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
return;
}
Queue<IMechanic<BossEntity>> queue = new LinkedList<>(this.primaryMechanics);
Queue<IBossMechanic> queue = new LinkedList<>(this.mechanics);
while(!queue.isEmpty()) {
IMechanic<BossEntity> mechanic = queue.poll();
IBossMechanic mechanic = queue.poll();
if(mechanic == null) continue;
ServerUtils.get().logDebug("Applying " + mechanic.getClass().getSimpleName());
if(didMechanicApplicationFail(mechanic, bossEntity, activeBossHolder)) return false;
if(!didMechanicApplicationFail(mechanic, bossEntity, activeBossHolder)) {
Debug.FAILED_TO_APPLY_MECHANIC.debug(mechanic.getClass().getSimpleName());
}
}
queue = new LinkedList<>(this.optionalMechanics);
while(!queue.isEmpty()) {
IMechanic<BossEntity> mechanic = queue.poll();
if(mechanic == null) continue;
ServerUtils.get().logDebug("Applying " + mechanic.getClass().getSimpleName());
if(didMechanicApplicationFail(mechanic, bossEntity, activeBossHolder)) continue;
}
}
return true;
}
private boolean didMechanicApplicationFail(IMechanic<BossEntity> mechanic, BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
private boolean didMechanicApplicationFail(IBossMechanic mechanic, BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
if(mechanic == null) return true;
if(!mechanic.applyMechanic(bossEntity, activeBossHolder)) {

View File

@ -2,7 +2,10 @@ package com.songoda.epicbosses.managers;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.ActiveMinionHolder;
import com.songoda.epicbosses.holder.IActiveHolder;
import com.songoda.epicbosses.targeting.TargetHandler;
import com.songoda.epicbosses.targeting.types.ClosestTargetHandler;
import com.songoda.epicbosses.targeting.types.NotDamagedNearbyTargetHandler;
@ -27,10 +30,10 @@ public class BossTargetManager {
return this.plugin.getConfig().getDouble("Settings.bossTargetRange", 50.0);
}
public void initializeTargetHandler(ActiveBossHolder activeBossHolder) {
public void handleBossTargeting(ActiveBossHolder activeBossHolder) {
BossEntity bossEntity = activeBossHolder.getBossEntity();
String targeting = bossEntity.getTargeting();
TargetHandler targetHandler;
TargetHandler<ActiveBossHolder> targetHandler;
if(targeting.equalsIgnoreCase("RandomNearby")) {
targetHandler = getRandomNearbyTargetHandler(activeBossHolder);
@ -45,20 +48,38 @@ public class BossTargetManager {
activeBossHolder.setTargetHandler(targetHandler);
}
private TargetHandler getClosestTargetHandler(ActiveBossHolder activeBossHolder) {
return new ClosestTargetHandler(activeBossHolder, this);
public void handleMinionTargeting(ActiveMinionHolder activeMinionHolder) {
MinionEntity minionEntity = activeMinionHolder.getMinionEntity();
String targeting = minionEntity.getTargeting();
TargetHandler<ActiveMinionHolder> targetHandler;
if(targeting.equalsIgnoreCase("RandomNearby")) {
targetHandler = getRandomNearbyTargetHandler(activeMinionHolder);
} else if(targeting.equalsIgnoreCase("TopDamager")) {
targetHandler = getTopDamagerTargetHandler(activeMinionHolder);
} else if(targeting.equalsIgnoreCase("NotDamagedNearby")) {
targetHandler = getNotDamagedNearbyTargetHandler(activeMinionHolder);
} else {
targetHandler = getClosestTargetHandler(activeMinionHolder);
}
private TargetHandler getNotDamagedNearbyTargetHandler(ActiveBossHolder activeBossHolder) {
return new NotDamagedNearbyTargetHandler(activeBossHolder, this);
activeMinionHolder.setTargetHandler(targetHandler);
}
private TargetHandler getRandomNearbyTargetHandler(ActiveBossHolder activeBossHolder) {
return new RandomNearbyTargetHandler(activeBossHolder, this);
private <T extends IActiveHolder> TargetHandler<T> getClosestTargetHandler(T holder) {
return new ClosestTargetHandler<>(holder, this);
}
private TargetHandler getTopDamagerTargetHandler(ActiveBossHolder activeBossHolder) {
return new TopDamagerTargetHandler(activeBossHolder, this);
private <T extends IActiveHolder> TargetHandler<T> getNotDamagedNearbyTargetHandler(T holder) {
return new NotDamagedNearbyTargetHandler<>(holder, this);
}
private <T extends IActiveHolder> TargetHandler<T> getRandomNearbyTargetHandler(T holder) {
return new RandomNearbyTargetHandler<>(holder, this);
}
private <T extends IActiveHolder> TargetHandler<T> getTopDamagerTargetHandler(T holder) {
return new TopDamagerTargetHandler<>(holder, this);
}
}

View File

@ -2,14 +2,12 @@ package com.songoda.epicbosses.managers;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.ActiveMinionHolder;
import com.songoda.epicbosses.managers.interfaces.IMechanicManager;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
import com.songoda.epicbosses.mechanics.minions.*;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.IMechanic;
import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import java.util.LinkedList;
import java.util.Queue;
@ -19,11 +17,10 @@ import java.util.Queue;
* @version 1.0.0
* @since 12-Nov-18
*/
public class MinionMechanicManager implements IMechanicManager<MinionEntity, ActiveBossHolder> {
public class MinionMechanicManager implements IMechanicManager<MinionEntity, ActiveMinionHolder, IMinionMechanic> {
private Queue<IMinionMechanic> mechanics;
private final CustomBosses customBosses;
private Queue<IOptionalMechanic<MinionEntity>> optionalMechanics;
private Queue<IPrimaryMechanic<MinionEntity>> primaryMechanics;
public MinionMechanicManager(CustomBosses customBosses) {
this.customBosses = customBosses;
@ -31,8 +28,7 @@ public class MinionMechanicManager implements IMechanicManager<MinionEntity, Act
@Override
public void load() {
this.primaryMechanics = new LinkedList<>();
this.optionalMechanics = new LinkedList<>();
this.mechanics = new LinkedList<>();
registerMechanic(new EntityTypeMechanic());
registerMechanic(new NameMechanic());
@ -44,50 +40,35 @@ public class MinionMechanicManager implements IMechanicManager<MinionEntity, Act
}
@Override
public void registerMechanic(IMechanic<MinionEntity> mechanic) {
if(mechanic instanceof IPrimaryMechanic) {
this.primaryMechanics.add((IPrimaryMechanic<MinionEntity>) mechanic);
} else if(mechanic instanceof IOptionalMechanic) {
this.optionalMechanics.add((IOptionalMechanic<MinionEntity>) mechanic);
} else {
Debug.MECHANIC_TYPE_NOT_STORED.debug();
}
public void registerMechanic(IMinionMechanic mechanic) {
this.mechanics.add(mechanic);
}
@Override
public boolean handleMechanicApplication(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(minionEntity != null && activeBossHolder != null) {
// if(minionEntity.isEditing()) {
// Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
// return false;
// }
public void handleMechanicApplication(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
if(minionEntity != null && activeMinionHolder != null) {
if(minionEntity.isEditing()) {
Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
return;
}
Queue<IMechanic<MinionEntity>> queue = new LinkedList<>(this.primaryMechanics);
Queue<IMinionMechanic> queue = new LinkedList<>(this.mechanics);
while(!queue.isEmpty()) {
IMechanic<MinionEntity> mechanic = queue.poll();
IMinionMechanic mechanic = queue.poll();
if(mechanic == null) continue;
ServerUtils.get().logDebug("Applying " + mechanic.getClass().getSimpleName());
if(didMechanicApplicationFail(mechanic, minionEntity, activeBossHolder)) return false;
if(didMechanicApplicationFail(mechanic, minionEntity, activeMinionHolder)) {
Debug.FAILED_TO_APPLY_MECHANIC.debug(mechanic.getClass().getSimpleName());
}
}
queue = new LinkedList<>(this.optionalMechanics);
while(!queue.isEmpty()) {
IMechanic<MinionEntity> mechanic = queue.poll();
if(mechanic == null) continue;
if(didMechanicApplicationFail(mechanic, minionEntity, activeBossHolder)) continue;
}
}
return true;
}
private boolean didMechanicApplicationFail(IMechanic<MinionEntity> mechanic, MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
private boolean didMechanicApplicationFail(IMinionMechanic mechanic, MinionEntity minionEntity, ActiveMinionHolder activeBossHolder) {
if(mechanic == null) return true;
if(!mechanic.applyMechanic(minionEntity, activeBossHolder)) {

View File

@ -8,10 +8,10 @@ import com.songoda.epicbosses.utils.IMechanic;
* @version 1.0.0
* @since 12-Nov-18
*/
public interface IMechanicManager<T, J> extends ILoadable {
public interface IMechanicManager<T, J, M> extends ILoadable {
void registerMechanic(IMechanic<T> mechanic);
void registerMechanic(M mechanic);
boolean handleMechanicApplication(T t, J j);
void handleMechanicApplication(T t, J j);
}

View File

@ -0,0 +1,13 @@
package com.songoda.epicbosses.mechanics;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.utils.IMechanic;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 19-Nov-18
*/
public interface IBossMechanic extends IMechanic<BossEntity, ActiveBossHolder> {
}

View File

@ -0,0 +1,14 @@
package com.songoda.epicbosses.mechanics;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.holder.ActiveMinionHolder;
import com.songoda.epicbosses.utils.IMechanic;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 19-Nov-18
*/
public interface IMinionMechanic extends IMechanic<MinionEntity, ActiveMinionHolder> {
}

View File

@ -2,13 +2,12 @@ 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;
import com.songoda.epicbosses.mechanics.IBossMechanic;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.EntityFinder;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import org.bukkit.entity.LivingEntity;
/**
@ -16,7 +15,7 @@ import org.bukkit.entity.LivingEntity;
* @version 1.0.0
* @since 01-Jun-18
*/
public class EntityTypeMechanic implements IPrimaryMechanic<BossEntity> {
public class EntityTypeMechanic implements IBossMechanic {
@Override
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {

View File

@ -6,8 +6,8 @@ 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.mechanics.IBossMechanic;
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;
@ -17,7 +17,7 @@ import org.bukkit.inventory.ItemStack;
* @version 1.0.0
* @since 03-Jun-18
*/
public class EquipmentMechanic implements IOptionalMechanic<BossEntity> {
public class EquipmentMechanic implements IBossMechanic {
private ItemsFileManager itemStackManager;

View File

@ -4,11 +4,9 @@ import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.mechanics.IBossMechanic;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.IMechanic;
import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.file.reader.SpigotYmlReader;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import org.bukkit.entity.LivingEntity;
/**
@ -16,7 +14,7 @@ import org.bukkit.entity.LivingEntity;
* @version 1.0.0
* @since 27-Jun-18
*/
public class HealthMechanic implements IPrimaryMechanic<BossEntity> {
public class HealthMechanic implements IBossMechanic {
@Override
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {

View File

@ -4,10 +4,8 @@ import com.songoda.epicbosses.entity.BossEntity;
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.IMechanic;
import com.songoda.epicbosses.mechanics.IBossMechanic;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import org.bukkit.entity.LivingEntity;
/**
@ -17,7 +15,7 @@ import org.bukkit.entity.LivingEntity;
*
* TODO: Make a hologram above name instead of using default CustomName
*/
public class NameMechanic implements IOptionalMechanic<BossEntity> {
public class NameMechanic implements IBossMechanic {
@Override
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {

View File

@ -4,9 +4,7 @@ import com.songoda.epicbosses.entity.BossEntity;
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.IMechanic;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import com.songoda.epicbosses.mechanics.IBossMechanic;
import com.songoda.epicbosses.utils.potion.PotionEffectConverter;
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
import org.bukkit.entity.LivingEntity;
@ -19,7 +17,7 @@ import java.util.List;
* @version 1.0.0
* @since 27-Jun-18
*/
public class PotionMechanic implements IOptionalMechanic<BossEntity> {
public class PotionMechanic implements IBossMechanic {
private PotionEffectConverter potionEffectConverter;

View File

@ -4,11 +4,7 @@ import com.songoda.epicbosses.entity.BossEntity;
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.IMechanic;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.file.reader.SpigotYmlReader;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import com.songoda.epicbosses.mechanics.IBossMechanic;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
@ -18,7 +14,7 @@ import org.bukkit.inventory.EntityEquipment;
* @version 1.0.0
* @since 02-Jun-18
*/
public class SettingsMechanic implements IPrimaryMechanic<BossEntity> {
public class SettingsMechanic implements IBossMechanic {
private VersionHandler versionHandler;

View File

@ -6,7 +6,7 @@ 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.mechanics.IOptionalMechanic;
import com.songoda.epicbosses.mechanics.IBossMechanic;
import com.songoda.epicbosses.utils.version.VersionHandler;
import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder;
import org.bukkit.entity.LivingEntity;
@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack;
* @version 1.0.0
* @since 27-Jun-18
*/
public class WeaponMechanic implements IOptionalMechanic<BossEntity> {
public class WeaponMechanic implements IBossMechanic {
private ItemsFileManager itemStackManager;
private VersionHandler versionHandler;

View File

@ -4,10 +4,10 @@ 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.holder.ActiveMinionHolder;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.EntityFinder;
import com.songoda.epicbosses.utils.mechanics.IPrimaryMechanic;
import org.bukkit.entity.LivingEntity;
/**
@ -15,10 +15,10 @@ import org.bukkit.entity.LivingEntity;
* @version 1.0.0
* @since 01-Jun-18
*/
public class EntityTypeMechanic implements IPrimaryMechanic<MinionEntity> {
public class EntityTypeMechanic implements IMinionMechanic {
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
@ -30,16 +30,16 @@ public class EntityTypeMechanic implements IPrimaryMechanic<MinionEntity> {
if(position == null) position = 1;
if(entityFinder == null) return false;
LivingEntity livingEntity = entityFinder.spawnNewLivingEntity(bossEntityType, activeBossHolder.getLivingEntity().getLocation());
LivingEntity livingEntity = entityFinder.spawnNewLivingEntity(bossEntityType, activeMinionHolder.getLocation());
if(livingEntity == null) return false;
if(!activeBossHolder.getMinionEntityMap().isEmpty()) activeBossHolder.killAllMinions(null);
if(!activeMinionHolder.getLivingEntityMap().isEmpty()) activeMinionHolder.killAll();
activeBossHolder.getMinionEntityMap().put(position, livingEntity);
activeMinionHolder.getLivingEntityMap().put(position, livingEntity);
if(position > 1) {
int lowerPosition = position - 1;
LivingEntity lowerLivingEntity = activeBossHolder.getLivingEntityMap().getOrDefault(lowerPosition, null);
LivingEntity lowerLivingEntity = activeMinionHolder.getLivingEntityMap().getOrDefault(lowerPosition, null);
if(lowerLivingEntity == null) {
Debug.FAILED_ATTEMPT_TO_STACK_BOSSES.debug(BossAPI.getMinionEntityName(minionEntity));

View File

@ -4,10 +4,10 @@ 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.holder.ActiveMinionHolder;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
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;
@ -17,7 +17,7 @@ import org.bukkit.inventory.ItemStack;
* @version 1.0.0
* @since 03-Jun-18
*/
public class EquipmentMechanic implements IOptionalMechanic<MinionEntity> {
public class EquipmentMechanic implements IMinionMechanic {
private ItemsFileManager itemStackManager;
@ -26,12 +26,12 @@ public class EquipmentMechanic implements IOptionalMechanic<MinionEntity> {
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeBossHolder) {
if(activeBossHolder.getLivingEntityMap() == null || activeBossHolder.getLivingEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
LivingEntity livingEntity = activeBossHolder.getLivingEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
if(livingEntity == null) return false;

View File

@ -3,10 +3,10 @@ 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.holder.ActiveMinionHolder;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
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;
/**
@ -14,17 +14,17 @@ import org.bukkit.entity.LivingEntity;
* @version 1.0.0
* @since 27-Jun-18
*/
public class HealthMechanic implements IPrimaryMechanic<MinionEntity> {
public class HealthMechanic implements IMinionMechanic {
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
if(activeMinionHolder.getLivingEntityMap() == null || activeMinionHolder.getLivingEntityMap().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);
LivingEntity livingEntity = activeMinionHolder.getLivingEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
double maxHealth = mainStatsElement.getHealth();
if(livingEntity == null) return false;

View File

@ -3,9 +3,9 @@ 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.holder.ActiveMinionHolder;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.mechanics.IOptionalMechanic;
import org.bukkit.entity.LivingEntity;
/**
@ -15,15 +15,15 @@ import org.bukkit.entity.LivingEntity;
*
* TODO: Make a hologram above name instead of using default CustomName
*/
public class NameMechanic implements IOptionalMechanic<MinionEntity> {
public class NameMechanic implements IMinionMechanic {
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
if(activeMinionHolder.getLivingEntityMap() == null || activeMinionHolder.getLivingEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
LivingEntity livingEntity = activeMinionHolder.getLivingEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
String customName = mainStatsElement.getDisplayName();
if(livingEntity == null) return false;

View File

@ -3,8 +3,8 @@ 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.holder.ActiveMinionHolder;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
import com.songoda.epicbosses.utils.potion.PotionEffectConverter;
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
import org.bukkit.entity.LivingEntity;
@ -16,7 +16,7 @@ import java.util.List;
* @version 1.0.0
* @since 27-Jun-18
*/
public class PotionMechanic implements IOptionalMechanic<MinionEntity> {
public class PotionMechanic implements IMinionMechanic {
private PotionEffectConverter potionEffectConverter;
@ -25,12 +25,12 @@ public class PotionMechanic implements IOptionalMechanic<MinionEntity> {
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getLivingEntityMap().getOrDefault(1, null) == null) return false;
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
if(activeMinionHolder.getLivingEntityMap().getOrDefault(1, null) == null) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
LivingEntity livingEntity = activeMinionHolder.getLivingEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
List<PotionEffectHolder> potionElements = entityStatsElement.getPotions();
if(livingEntity == null) return false;

View File

@ -1,11 +1,10 @@
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.holder.ActiveMinionHolder;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
import com.songoda.epicbosses.utils.version.VersionHandler;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
@ -15,7 +14,7 @@ import org.bukkit.inventory.EntityEquipment;
* @version 1.0.0
* @since 02-Jun-18
*/
public class SettingsMechanic implements IPrimaryMechanic<MinionEntity> {
public class SettingsMechanic implements IMinionMechanic {
private VersionHandler versionHandler;
@ -24,12 +23,12 @@ public class SettingsMechanic implements IPrimaryMechanic<MinionEntity> {
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
if(activeMinionHolder.getLivingEntityMap() == null || activeMinionHolder.getLivingEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
LivingEntity livingEntity = activeMinionHolder.getLivingEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
if(livingEntity == null) return false;

View File

@ -1,14 +1,13 @@
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.holder.ActiveMinionHolder;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.mechanics.IMinionMechanic;
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;
@ -19,7 +18,7 @@ import org.bukkit.inventory.ItemStack;
* @version 1.0.0
* @since 27-Jun-18
*/
public class WeaponMechanic implements IOptionalMechanic<MinionEntity> {
public class WeaponMechanic implements IMinionMechanic {
private ItemsFileManager itemStackManager;
private VersionHandler versionHandler;
@ -30,12 +29,12 @@ public class WeaponMechanic implements IOptionalMechanic<MinionEntity> {
}
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getMinionEntityMap() == null || activeBossHolder.getMinionEntityMap().isEmpty()) return false;
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
if(activeMinionHolder.getLivingEntityMap() == null || activeMinionHolder.getLivingEntityMap().isEmpty()) return false;
for(EntityStatsElement entityStatsElement : minionEntity.getEntityStats()) {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
LivingEntity livingEntity = activeBossHolder.getMinionEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
LivingEntity livingEntity = activeMinionHolder.getLivingEntityMap().getOrDefault(mainStatsElement.getPosition(), null);
if(livingEntity == null) return false;

View File

@ -0,0 +1,85 @@
package com.songoda.epicbosses.panel.bosses;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.ClickAction;
import com.songoda.epicbosses.utils.panel.base.VariablePanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilderCounter;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 19-Nov-18
*/
public class DropsEditorPanel extends VariablePanelHandler<BossEntity> {
private BossesFileManager bossesFileManager;
public DropsEditorPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
super(bossPanelManager, panelBuilder);
this.bossesFileManager = plugin.getBossesFileManager();
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
panelBuilderCounter
.addSlotCounter("Selected")
.addSlotCounter("CreateDropTable");
}
@Override
public void fillPanel(Panel panel, BossEntity bossEntity) {
}
@Override
public void openFor(Player player, BossEntity bossEntity) {
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{mode}", bossEntity.getEditingValue());
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
counter.getSlotsWith("Editing").forEach(slot -> panel.setOnClick(slot, getEditingAction(bossEntity)));
panel.openFor(player);
}
private ClickAction getEditingAction(BossEntity bossEntity) {
return event -> {
Player player = (Player) event.getWhoClicked();
if(bossEntity.isCompleteEnoughToSpawn()) {
bossEntity.setEditing(!bossEntity.isEditing());
this.bossesFileManager.save();
Message.Boss_Edit_Toggled.msg(player, BossAPI.getBossEntityName(bossEntity), bossEntity.getEditingValue());
player.closeInventory();
} else {
Message.Boss_Edit_NotCompleteEnough.msg(player);
}
};
}
}

View File

@ -81,7 +81,7 @@ public class MainBossEditPanel extends VariablePanelHandler<BossEntity> {
Player player = (Player) event.getWhoClicked();
if(bossEntity.isCompleteEnoughToSpawn()) {
bossEntity.setEditing(false);
bossEntity.setEditing(!bossEntity.isEditing());
this.bossesFileManager.save();
Message.Boss_Edit_Toggled.msg(player, BossAPI.getBossEntityName(bossEntity), bossEntity.getEditingValue());
player.closeInventory();

View File

@ -13,12 +13,12 @@ import java.util.List;
*/
public class CustomMinionSkillElement {
@Expose @Getter @Setter private List<String> minionsToSpawn;
@Expose @Getter @Setter private String minionToSpawn;
@Expose @Getter @Setter private Integer amount;
public CustomMinionSkillElement(Integer amount, List<String> minionsToSpawn) {
public CustomMinionSkillElement(Integer amount, String minionToSpawn) {
this.amount = amount;
this.minionsToSpawn = minionsToSpawn;
this.minionToSpawn = minionToSpawn;
}
}

View File

@ -32,7 +32,7 @@ public class SubCustomSkillElement {
}
public CustomMinionSkillElement getCustomMinionSkillData() {
if(getType().equalsIgnoreCase("MINION")) {
if(getType().equalsIgnoreCase("MINIONS")) {
return BossesGson.get().fromJson(this.otherSkillData, CustomMinionSkillElement.class);
}

View File

@ -1,6 +1,6 @@
package com.songoda.epicbosses.targeting;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.IActiveHolder;
import com.songoda.epicbosses.managers.BossTargetManager;
import com.songoda.epicbosses.utils.ServerUtils;
import lombok.Getter;
@ -17,13 +17,13 @@ import java.util.List;
* @version 1.0.0
* @since 30-Oct-18
*/
public abstract class TargetHandler implements ITarget {
public abstract class TargetHandler<Holder extends IActiveHolder> implements ITarget {
@Getter protected final BossTargetManager bossTargetManager;
@Getter protected final ActiveBossHolder activeBossHolder;
@Getter protected final Holder holder;
public TargetHandler(ActiveBossHolder activeBossHolder, BossTargetManager bossTargetManager) {
this.activeBossHolder = activeBossHolder;
public TargetHandler(Holder holder, BossTargetManager bossTargetManager) {
this.holder = holder;
this.bossTargetManager = bossTargetManager;
}
@ -31,12 +31,12 @@ public abstract class TargetHandler implements ITarget {
ServerUtils.get().runLaterAsync(10L, () -> {
updateTarget();
if(!getActiveBossHolder().isDead()) runTargetCycle();
if(!getHolder().isDead()) runTargetCycle();
});
}
protected LivingEntity getBossEntity() {
for(LivingEntity livingEntity : this.activeBossHolder.getLivingEntityMap().values()) {
for(LivingEntity livingEntity : getHolder().getLivingEntityMap().values()) {
if(livingEntity != null && !livingEntity.isDead()) return livingEntity;
}
@ -56,6 +56,12 @@ public abstract class TargetHandler implements ITarget {
LivingEntity livingEntity = (LivingEntity) entity;
if(livingEntity instanceof Player) {
Player player = (Player) livingEntity;
}
nearbyEntities.add(livingEntity);
}
@ -63,7 +69,7 @@ public abstract class TargetHandler implements ITarget {
}
private void updateBoss(LivingEntity newTarget) {
this.activeBossHolder.getLivingEntityMap().values().forEach(livingEntity -> {
getHolder().getLivingEntityMap().values().forEach(livingEntity -> {
if(livingEntity != null && !livingEntity.isDead()) {
((Creature) livingEntity).setTarget(newTarget);
}

View File

@ -1,6 +1,6 @@
package com.songoda.epicbosses.targeting.types;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.IActiveHolder;
import com.songoda.epicbosses.managers.BossTargetManager;
import com.songoda.epicbosses.targeting.TargetHandler;
import org.bukkit.entity.LivingEntity;
@ -12,10 +12,10 @@ import java.util.List;
* @version 1.0.0
* @since 30-Oct-18
*/
public class ClosestTargetHandler extends TargetHandler {
public class ClosestTargetHandler<T extends IActiveHolder> extends TargetHandler<T> {
public ClosestTargetHandler(ActiveBossHolder activeBossHolder, BossTargetManager bossTargetManager) {
super(activeBossHolder, bossTargetManager);
public ClosestTargetHandler(T holder, BossTargetManager bossTargetManager) {
super(holder, bossTargetManager);
}
@Override

View File

@ -1,6 +1,6 @@
package com.songoda.epicbosses.targeting.types;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.IActiveHolder;
import com.songoda.epicbosses.managers.BossTargetManager;
import com.songoda.epicbosses.targeting.TargetHandler;
import org.bukkit.entity.LivingEntity;
@ -12,16 +12,16 @@ import java.util.List;
* @version 1.0.0
* @since 02-Nov-18
*/
public class NotDamagedNearbyTargetHandler extends TargetHandler {
public class NotDamagedNearbyTargetHandler<T extends IActiveHolder> extends TargetHandler<T> {
public NotDamagedNearbyTargetHandler(ActiveBossHolder activeBossHolder, BossTargetManager bossTargetManager) {
super(activeBossHolder, bossTargetManager);
public NotDamagedNearbyTargetHandler(T holder, BossTargetManager bossTargetManager) {
super(holder, bossTargetManager);
}
@Override
public LivingEntity selectTarget(List<LivingEntity> nearbyEntities) {
for(LivingEntity livingEntity : nearbyEntities) {
if(getActiveBossHolder().hasAttacked(livingEntity.getUniqueId())) continue;
if(getHolder().hasAttacked(livingEntity.getUniqueId())) continue;
return livingEntity;
}

View File

@ -1,6 +1,6 @@
package com.songoda.epicbosses.targeting.types;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.IActiveHolder;
import com.songoda.epicbosses.managers.BossTargetManager;
import com.songoda.epicbosses.targeting.TargetHandler;
import org.bukkit.entity.LivingEntity;
@ -13,10 +13,10 @@ import java.util.List;
* @version 1.0.0
* @since 30-Oct-18
*/
public class RandomNearbyTargetHandler extends TargetHandler {
public class RandomNearbyTargetHandler<T extends IActiveHolder> extends TargetHandler<T> {
public RandomNearbyTargetHandler(ActiveBossHolder activeBossHolder, BossTargetManager bossTargetManager) {
super(activeBossHolder, bossTargetManager);
public RandomNearbyTargetHandler(T holder, BossTargetManager bossTargetManager) {
super(holder, bossTargetManager);
}
@Override

View File

@ -1,6 +1,6 @@
package com.songoda.epicbosses.targeting.types;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.IActiveHolder;
import com.songoda.epicbosses.managers.BossTargetManager;
import com.songoda.epicbosses.targeting.TargetHandler;
import com.songoda.epicbosses.utils.MapUtils;
@ -13,16 +13,16 @@ import java.util.*;
* @version 1.0.0
* @since 30-Oct-18
*/
public class TopDamagerTargetHandler extends TargetHandler {
public class TopDamagerTargetHandler<T extends IActiveHolder> extends TargetHandler<T> {
public TopDamagerTargetHandler(ActiveBossHolder activeBossHolder, BossTargetManager bossTargetManager) {
super(activeBossHolder, bossTargetManager);
public TopDamagerTargetHandler(T holder, BossTargetManager bossTargetManager) {
super(holder, bossTargetManager);
}
@Override
public LivingEntity selectTarget(List<LivingEntity> nearbyEntities) {
Map<LivingEntity, Double> nearbyDamages = new HashMap<>();
Map<UUID, Double> mapOfDamages = getActiveBossHolder().getMapOfDamagingUsers();
Map<UUID, Double> mapOfDamages = getHolder().getMapOfDamagingUsers();
nearbyEntities.forEach(livingEntity -> {
UUID uuid = livingEntity.getUniqueId();

View File

@ -22,6 +22,7 @@ public enum Debug {
ATTEMPTED_TO_UPDATE_PLUGIN("Something has attempted to update the PLUGIN variable in the BossAPI class while it is already initialized."),
ATTEMPTED_TO_SPAWN_WHILE_DISABLED("A boss/minion attempted to spawn while editing is enabled."),
FAILED_TO_APPLY_MECHANIC("The {0} mechanic failed to be applied to the entity."),
FAILED_TO_FIND_DROP_TABLE("The {0} boss has been killed however the specified drop table {1} wasn't found."),
FAILED_TO_FIND_DROP_TABLE_TYPE("The {0} drop table type was not a valid drop table. Valid types are 'SPRAY', 'DROP', 'GIVE'."),
FAILED_ATTEMPT_TO_SPAWN_BOSS("A boss has attempted to spawn but cannot spawn for the following reason: \n{0}"),

View File

@ -1,14 +1,12 @@
package com.songoda.epicbosses.utils;
import com.songoda.epicbosses.holder.ActiveBossHolder;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 02-Jun-18
*/
public interface IMechanic<Entity> {
public interface IMechanic<Entity, Holder> {
boolean applyMechanic(Entity entity, ActiveBossHolder activeBossHolder);
boolean applyMechanic(Entity entity, Holder activeBossHolder);
}

View File

@ -1,11 +0,0 @@
package com.songoda.epicbosses.utils.mechanics;
import com.songoda.epicbosses.utils.IMechanic;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 02-Oct-18
*/
public interface IOptionalMechanic<Entity> extends IMechanic<Entity> {
}

View File

@ -1,11 +0,0 @@
package com.songoda.epicbosses.utils.mechanics;
import com.songoda.epicbosses.utils.IMechanic;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 02-Oct-18
*/
public interface IPrimaryMechanic<Entity> extends IMechanic<Entity> {
}

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>maven-version-number-SNAPSHOT-U63</plugin.version>
<plugin.version>maven-version-number-SNAPSHOT-U64</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>