1.0.0-SNAPSHOT-U114

+ Added/Connected the Group Skill
This commit is contained in:
Charles 2018-12-09 23:36:59 +08:00
parent ac19dbe327
commit 1eadf6a664
4 changed files with 77 additions and 46 deletions

View File

@ -96,38 +96,8 @@ public class BossSkillListener implements Listener {
}
List<LivingEntity> targettedEntities = this.bossSkillManager.getTargetedEntities(activeBossHolder, skill, activeBossHolder.getLivingEntity().getLocation(), damagingEntity);
String bossDisplayName = activeBossHolder.getName();
String skillDisplayName = skill.getDisplayName();
ISkillHandler<?> skillHandler;
if(skill.getType().equalsIgnoreCase("POTION")) {
PotionSkillElement potionSkillElement = this.bossSkillManager.getPotionSkillElement(skill);
potionSkillElement.castSkill(skill, potionSkillElement, activeBossHolder, targettedEntities);
skillHandler = potionSkillElement;
} else if(skill.getType().equalsIgnoreCase("COMMAND")) {
CommandSkillElement commandSkillElement = this.bossSkillManager.getCommandSkillElement(skill);
commandSkillElement.castSkill(skill, commandSkillElement, activeBossHolder, targettedEntities);
skillHandler = commandSkillElement;
} else if(skill.getType().equalsIgnoreCase("GROUP")) {
GroupSkillElement groupSkillElement = this.bossSkillManager.getGroupSkillElement(skill);
groupSkillElement.castSkill(skill, groupSkillElement, activeBossHolder, targettedEntities);
skillHandler = groupSkillElement;
} else if(skill.getType().equalsIgnoreCase("CUSTOM")) {
CustomSkillElement customSkillElement = this.bossSkillManager.getCustomSkillElement(skill);
skillHandler = this.bossSkillManager.handleCustomSkillCasting(skill, customSkillElement, activeBossHolder, targettedEntities);
} else {
return;
}
masterMessage.replaceAll(s -> s.replace("{boss}", bossDisplayName).replace("{skill}", skillDisplayName));
targettedEntities.forEach(livingEntity -> MessageUtils.get().sendMessage(livingEntity, masterMessage));
BossSkillEvent bossSkillEvent = new BossSkillEvent(activeBossHolder, skillHandler, skill);
ServerUtils.get().callEvent(bossSkillEvent);
this.bossSkillManager.handleSkill(masterMessage, skill, targettedEntities, activeBossHolder, true, false);
}
}

View File

@ -1,17 +1,16 @@
package com.songoda.epicbosses.managers;
import com.songoda.epicbosses.events.BossSkillEvent;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.skills.CustomSkillHandler;
import com.songoda.epicbosses.skills.ISkillHandler;
import com.songoda.epicbosses.skills.Skill;
import com.songoda.epicbosses.skills.custom.*;
import com.songoda.epicbosses.skills.types.CommandSkillElement;
import com.songoda.epicbosses.skills.types.CustomSkillElement;
import com.songoda.epicbosses.skills.types.GroupSkillElement;
import com.songoda.epicbosses.skills.types.PotionSkillElement;
import com.songoda.epicbosses.utils.BossesGson;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.ILoadable;
import com.songoda.epicbosses.utils.RandomUtils;
import com.songoda.epicbosses.utils.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
@ -42,17 +41,48 @@ public class BossSkillManager implements ILoadable {
registerCustomSkill(new Warp());
}
public CustomSkillHandler handleCustomSkillCasting(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
String type = customSkillElement.getCustom().getType();
CustomSkillHandler customSkillHandler = getCustomSkillHandler(type);
if(customSkillHandler == null) {
Debug.FAILED_TO_OBTAIN_THE_SKILL_HANDLER.debug(type);
return null;
public void handleSkill(List<String> masterMessage, Skill skill, List<LivingEntity> targetedEntities, ActiveBossHolder activeBossHolder, boolean message, boolean subSkill) {
if(skill == null) {
Debug.SKILL_NOT_FOUND.debug();
return;
}
customSkillHandler.castSkill(skill, customSkillElement, activeBossHolder, nearbyEntities);
return customSkillHandler;
ISkillHandler<?> skillHandler;
String bossDisplayName = activeBossHolder.getName();
String skillDisplayName = skill.getDisplayName();
if(skill.getType().equalsIgnoreCase("POTION")) {
PotionSkillElement potionSkillElement = getPotionSkillElement(skill);
potionSkillElement.castSkill(skill, potionSkillElement, activeBossHolder, targetedEntities);
skillHandler = potionSkillElement;
} else if(skill.getType().equalsIgnoreCase("COMMAND")) {
CommandSkillElement commandSkillElement = getCommandSkillElement(skill);
commandSkillElement.castSkill(skill, commandSkillElement, activeBossHolder, targetedEntities);
skillHandler = commandSkillElement;
} else if(skill.getType().equalsIgnoreCase("GROUP")) {
if(subSkill) return;
GroupSkillElement groupSkillElement = getGroupSkillElement(skill);
groupSkillElement.castSkill(skill, groupSkillElement, activeBossHolder, targetedEntities);
skillHandler = groupSkillElement;
} else if(skill.getType().equalsIgnoreCase("CUSTOM")) {
CustomSkillElement customSkillElement = getCustomSkillElement(skill);
skillHandler = handleCustomSkillCasting(skill, customSkillElement, activeBossHolder, targetedEntities);
} else {
return;
}
if(message && masterMessage != null) {
masterMessage.replaceAll(s -> s.replace("{boss}", bossDisplayName).replace("{skill}", skillDisplayName));
targetedEntities.forEach(livingEntity -> MessageUtils.get().sendMessage(livingEntity, masterMessage));
}
BossSkillEvent bossSkillEvent = new BossSkillEvent(activeBossHolder, skillHandler, skill);
ServerUtils.get().callEvent(bossSkillEvent);
}
public PotionSkillElement getPotionSkillElement(Skill skill) {
@ -127,6 +157,19 @@ public class BossSkillManager implements ILoadable {
return targetedList;
}
private CustomSkillHandler handleCustomSkillCasting(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
String type = customSkillElement.getCustom().getType();
CustomSkillHandler customSkillHandler = getCustomSkillHandler(type);
if(customSkillHandler == null) {
Debug.FAILED_TO_OBTAIN_THE_SKILL_HANDLER.debug(type);
return null;
}
customSkillHandler.castSkill(skill, customSkillElement, activeBossHolder, nearbyEntities);
return customSkillHandler;
}
private CustomSkillHandler getCustomSkillHandler(String name) {
for(CustomSkillHandler customSkillHandler : new HashSet<>(SKILLS)) {
String skillName = customSkillHandler.getClass().getSimpleName();

View File

@ -1,9 +1,13 @@
package com.songoda.epicbosses.skills.types;
import com.google.gson.annotations.Expose;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.managers.BossSkillManager;
import com.songoda.epicbosses.managers.files.SkillsFileManager;
import com.songoda.epicbosses.skills.ISkillHandler;
import com.songoda.epicbosses.skills.Skill;
import com.songoda.epicbosses.utils.Debug;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.LivingEntity;
@ -25,6 +29,20 @@ public class GroupSkillElement implements ISkillHandler<GroupSkillElement> {
@Override
public void castSkill(Skill skill, GroupSkillElement groupSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
//TODO
List<String> currentGroupedSkills = getGroupedSkills();
CustomBosses plugin = CustomBosses.get();
SkillsFileManager skillsFileManager = plugin.getSkillsFileManager();
BossSkillManager bossSkillManager = plugin.getBossSkillManager();
currentGroupedSkills.forEach(string -> {
Skill innerSkill = skillsFileManager.getSkill(string);
if(innerSkill == null) {
Debug.SKILL_NOT_FOUND.debug();
return;
}
bossSkillManager.handleSkill(null, skill, nearbyEntities, activeBossHolder, false, true);
});
}
}

View File

@ -20,7 +20,7 @@
<properties>
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
<plugin.version>1.0.0-U113</plugin.version>
<plugin.version>1.0.0-U114</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>